Hi,
I am currently using a NodeView as an intermediate to access the current editor view and pass it down to a custom element.
Example:
export class CustomElementView implements NodeView {
dom: HTMLElement
constructor(node: Node, view: EditorView, getPos) {
const mce = document.createElement("my-custom-element") as MyCustomElement
// this way my custom element can interact with the editor
mce.nodeView = { view, node, getPos }
this.dom = mce
}
}
Is there any conceptual limitation that would prevent the same in toDOM
? For example:
toDOM(node) { return [
"my-custom-element",
// problem: I miss "view" and "getPos" on toDOM
{ "data-nodeView": { node, getPos, view} }}
] }
I’ve read about Decorations but not sure if it has anything to do with that, as it seems related mostly to plugins?