Hey all,
are there any commands or functions that help with wrapping a text selection in an inline node?
wrapIn
seems to only work with block nodes.
I also need to remove the inline node again. Are there any helpers for that operation?
My Schema (simplified):
- doc => someblock*
- someblock => (text|someinline)*
- someinline => text*
So far I came up with this code for wrapping the selection in an inline node (there are some checks of selection beforehand which i omitted)
function wrapInInlineNode(state, tr, schema, type) {
const sliceJson = state.selection.content().toJSON();
sliceJson.content[0].content = [{ type, content: sliceJson.content[0].content }];
state.selection.replace(tr, Slice.fromJSON(schema, sliceJson));
}