# Make a node act like input tag

**URL:** <https://discuss.prosemirror.net/t/make-a-node-act-like-input-tag/3555>\
**Category:** Show\
**Created:** [March 3, 2021, 4:01am UTC](https://discuss.prosemirror.net/t/make-a-node-act-like-input-tag/3555 "2021-03-03T04:01:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shibina](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@shibina](https://discuss.prosemirror.net/u/shibina)\
**Post date:** [March 3, 2021, 4:01am UTC](https://discuss.prosemirror.net/t/make-a-node-act-like-input-tag/3555/1 "2021-03-03T04:01:08Z")

</div>

I have node with a tag name ‘figcaption’. I need to make this act like a input tag. ie., an input tag with tagname, ‘figcaption’. Is there any way?

---

<div class="post-metadata">

**Author:** ![bhl](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/bhl/32/4074_2.png) [@bhl](https://discuss.prosemirror.net/u/bhl)\
**Post date:** [March 3, 2021, 10:06am UTC](https://discuss.prosemirror.net/t/make-a-node-act-like-input-tag/3555/2 "2021-03-03T10:06:39Z")

</div>

What do you mean by an input tag? If you mean something like a paragraph with a content hole, then

```auto
  get schema(): NodeSpec {
    return {
      content: "inline*",
      group: "figure",
      parseDOM: [{tag: "figcaption"}],
      toDOM() { return ["figcaption", 0]; },
    };
  }

```

---

<div class="post-metadata">

**Author:** ![shibina](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@shibina](https://discuss.prosemirror.net/u/shibina)\
**Post date:** [March 4, 2021, 5:38am UTC](https://discuss.prosemirror.net/t/make-a-node-act-like-input-tag/3555/3 "2021-03-04T05:38:41Z")

</div>

Thanks for the reply. Yes I need the figcaption tag, but with a placeholder. I have done the similar. content: ‘inline\*’,

```
  group: 'figure',

  draggable: true,

  attrs: {

    class: { default: '' },

    dataContent: { default: '' },

  },

  toDOM: node => {

    return ['figcaption', node.attrs, 0];

  },

  parseDOM: [

    {

      tag: 'figcaption',

      getAttrs(dom) {

        return {

          class: dom.getAttribute('class'),

          dataContent: dom.getAttribute('dataContent'),

        };

      },

    },

  ],

```

Any solution? . I insert this node inside another node figure eg: ![]()Some caption. Also, when I drag the figure, the caption doesnt gets dragged because i have set contenteditable as true. Any suggestion?

---

<div class="post-metadata">

**Author:** ![bhl](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/bhl/32/4074_2.png) [@bhl](https://discuss.prosemirror.net/u/bhl)\
**Post date:** [March 4, 2021, 7:52am UTC](https://discuss.prosemirror.net/t/make-a-node-act-like-input-tag/3555/4 "2021-03-04T07:52:39Z")

</div>

If you want a placeholder, I would recommend making an extension like [this](https://github.com/ueberdosis/tiptap/blob/main/packages/tiptap-extensions/src/extensions/Placeholder.js) which either adds a class or a decoration when the node itself is empty.

> Also, when I drag the figure, the caption doesnt gets dragged because i have set contenteditable as true.

You shouldn’t need contenteditable to be set to true cause it has a content hole. As for dragging, make sure you’re dragging the figure not the figcaption only.

---

<div class="post-metadata">

**Author:** ![shibina](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@shibina](https://discuss.prosemirror.net/u/shibina)\
**Post date:** [March 4, 2021, 9:56am UTC](https://discuss.prosemirror.net/t/make-a-node-act-like-input-tag/3555/5 "2021-03-04T09:56:12Z")

</div>

The image node ( firstchild node) gets dragged along with its parentnode( figure), leaving the figcaption ( second child node ). I have draggable: true to all the three nodes.
