Hi!
I need to replace pasted or typed emoji to some custom NodeView and don’t understand how to do it -_-
What i tryed:
create NodeView
class EmojiView { this.dom = 'some HTML' }
then declare it in nodeViews
new EditorView(htmlEl, {
state: EditorState.create(proseMirrorEditorConfig),
nodeViews: {
emoji: new EmojiView ()
},
});
In schema declare node with type ‘emoji’
new Schema({
nodes: { emoji: { ... } }
}
declare InputRule with emojiRegex
new InputRule(emojiRegex(), function emojiHandler(state, match, start, end) {
return state.tr.replaceWith(start, enf, proseMirrorSchema.nodes.emoji.createChecked());
}),
In this case, when i type emoji symbol in editor, emoji disapearse, but new node not rendered (just empty editor)
If i move node to mark in scheme (new Schema({ marks: { emoji: {} } ) and change return of InputRule to return state.tr.addMark(start, end, proseMirrorSchema.marks.emoji.create());, then my EmojiView is rendred, but inside it inserted content (emoji symbol) and i need to prevent this
Maybe someone cann help with this?