editorjs-style
editorjs-style copied to clipboard
Add fake background
It doesn't work:
const prevFakeBackGround = this.fakeBackground;
this.fakeBackground = document.createElement('span');
this.fakeBackground.style.backgroundColor = 'red';
const range = selection.getRangeAt(0);
this.fakeBackground.append(range.extractContents());
if (prevFakeBackGround) {
// TODO: unificate
const clonedNodes = Array.from(prevFakeBackGround.childNodes).map((node) =>
node.cloneNode(true)
);
clonedNodes.forEach((node) =>
prevFakeBackGround?.parentNode?.insertBefore(node, prevFakeBackGround)
);
prevFakeBackGround.remove();
}
range.insertNode(this.fakeBackground);
this.api.selection.expandToTag(this.fakeBackground);
Fake bacground is too complex.