When a nodeView is dropped, a new nodeView is created,
Is there a way to not create a new one?
class ImageView {
constructor(node, view, getPos) {
console.log('>>>>>>>>constructor');
this.node = node;
this.view = view;
this.getPos = getPos;
this.dom = document.createElement('img');
this.dom.src = node.attrs.src;
this.dom.style.border = '1px solid red';
}
update(node) {
console.log('>>>>>>>>update');
if (!node.sameMarkup(this.node)) return false;
this.node = node;
return true;
}
}
window.view = new EditorView(document.querySelector("#editor"), {
state: EditorState.create({
doc: DOMParser.fromSchema(mySchema).parse(document.querySelector("#content")),
plugins: exampleSetup({schema: mySchema})
}),
nodeViews: {
image(node, view, getPos) {
return new ImageView(node, view, getPos);
}
}
})
// console
// When ImageView is moved by dragging..
>>>>>>>>constructor
// When ImageView is moved by dragging..
>>>>>>>>constructor
I want to know how to keep the DOM without creating it every time I move it.
(The purpose is to avoid reloading the image.)
And is it possible to catch drag and drop events in ImageView?
please help me…