editorjs-style icon indicating copy to clipboard operation
editorjs-style copied to clipboard

Add fake background

Open hata6502 opened this issue 4 years ago • 1 comments

hata6502 avatar Sep 03 '20 15:09 hata6502

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.

hata6502 avatar Sep 10 '20 13:09 hata6502