Hello. I need to get all content after current cursor position and when I press "ctrl-enter" create a new instance of tiptap editor with this content (also remove this content on the current instance).
I have created a custom plugin, using your examples, where i've track the keydown, but I can't find the method like "split" or something the same. Can you say me right way to make this feature? Thanks.
I've found a solution.
function splitBlock ({ onCtrlEnter }: { onCtrlEnter: Function }) {
return new Plugin({
key: new PluginKey('splitBlock'),
// @ts-ignore next-line
props: {
handleKeyDown ({ state, dom }, event) {
if (event.ctrlKey && event.keyCode === KeyboardKeys.ENTER) {
const pos = get(state, 'selection.$anchor.pos', true);
const { doc } = state;
const textBefore = doc.cut(0, pos).toJSON();
const textAfter = doc.cut(pos, doc.content.size).toJSON();
return onCtrlEnter({ dom, textBefore, textAfter });
}
}
}
});
}
Then in my vue component I've replace content using setContent(textBefore). And send an event with textAfter data to my Vuex.Store for creation a new editor instance.
Most helpful comment
I've found a solution.
Then in my vue component I've replace content using setContent(textBefore). And send an event with textAfter data to my Vuex.Store for creation a new editor instance.