slate-mentions icon indicating copy to clipboard operation
slate-mentions copied to clipboard

Switch to blocks/inlines from marks

Open mxstbr opened this issue 7 years ago • 3 comments

This PR switches mentions to be blocks. This is necessary to be able to position the suggestion portal right next to the mention.

The problem with this PR is that getting this to work correctly requires us to override the line and default nodes to be spans, which is obviously not optimal:tm: as it'll break a bunch of folks editors.

I tried using setInline/splitInline/... instead of setBlock/... but for some reason that didn't do anything. Maybe @ianstormtaylor has an idea why this exact change with xInline rather than xBlock doesn't work?

/cc @oyeanuj

mxstbr avatar May 07 '17 09:05 mxstbr

I feel like inline feels more natural to me, other than marks. @ianstormtaylor posted an example of how he was using both inline and the Portal here - https://github.com/ianstormtaylor/slate/issues/644#issuecomment-283847307

If that doesn't help, I'll be happy to take a look at why setInline might not be working.

oyeanuj avatar May 07 '17 17:05 oyeanuj

Please do take a look, I've unsuccessfully tried to make this work for too long! I must be missing something minor, but this feels like an Inline rather than a block for sure.

mxstbr avatar May 07 '17 17:05 mxstbr

Here is how far I reached: https://github.com/oyeanuj/slate-mentions/tree/switch-to-blocks

I see some issues with insertInline for which I have noted here: https://github.com/ianstormtaylor/slate/pull/804

It also seems like just wrapping inline, and then moving it back to start of selection is leading to an error:

If I use wrapInline.move(1), I get an error: Cannot read property 'firstChild' of null at findDeepestNode (find-deepest-node.js:15)

But, its a start..

oyeanuj avatar May 07 '17 23:05 oyeanuj