slate-mentions
slate-mentions copied to clipboard
Switch to blocks/inlines from marks
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 span
s, 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
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.
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.
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..