NiclasDev63 / tiptap-extension-global-drag-handle

MIT License
73 stars 13 forks source link

Not working well with the Mentions extensions #15

Closed jacquesg closed 3 months ago

jacquesg commented 3 months ago

Thank you for an awesome plugin, this is exactly what I needed. There is a weird interaction with the Mention plugin:

While dragging, it correctly shows that it will drag the block, as soon as I drop it, it only takes the actual mention element, and leaves the remaining text in the original position.

What I'm seeing is below:

image image image
NiclasDev63 commented 3 months ago

I just tested it and it seems to work. Can you provide the code to reproduce your behaviour?

jacquesg commented 3 months ago

Hi,

Well, its pretty standard stuff, the only thing that may be different could be the way we set up the Mentions plugin:

          Mention.extend({
            name: 'substitution',
          }).configure({
            HTMLAttributes: {
              class: 'mention',
            },
            suggestion: makeSuggestionOptions(makeSubstitutions(substitutions)),
            renderHTML({ node }) {
              return ['span', { class: 'mention' }, `${node.attrs.label ?? node.attrs.id}`];
            },
            renderText({ node }) {
              return `${node.attrs.label ?? node.attrs.id}`;
            },
          })
jacquesg commented 3 months ago

Also of interest maybe would be that the following node, when dragged, "drags" only the mention item, not the block:

    {
      "type": "paragraph",
      "attrs": {
        "textAlign": "left"
      },
      "content": [
        {
          "type": "text",
          "text": "My "
        },
        {
          "type": "substitution",
          "attrs": {
            "id": "country",
            "label": "country"
          }
        },
        {
          "type": "text",
          "text": " "
        }
      ]
    },
NiclasDev63 commented 3 months ago

The newest commit should fix this issue

jacquesg commented 3 months ago

@NiclasDev63 Just tested it out, fixes it for me, thank you!