Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execCommand marked as obsolete #741

Closed
2 tasks done
peterpeterparker opened this issue May 25, 2020 · 1 comment · Fixed by #810
Closed
2 tasks done

execCommand marked as obsolete #741

peterpeterparker opened this issue May 25, 2020 · 1 comment · Fixed by #810
Assignees
Labels
enhancement New feature or request highlight-code Highlight code web component inline-editor WYSIWYG inline edit web component studio "Studio" is the codename for the web editor
Milestone

Comments

@peterpeterparker
Copy link
Contributor

Affected part of DeckDeckGo

  • Studio
  • Web Components (inline-editor and highlight-code)

Feature Description

Document.execCommand() has been marked as obsolete. Therefore, before not supported by the browser anymore (I'm guessing that it ain't gonna be tomorrow but someday), we should replace the usages.

@peterpeterparker peterpeterparker added enhancement New feature or request highlight-code Highlight code web component studio "Studio" is the codename for the web editor inline-editor WYSIWYG inline edit web component labels May 25, 2020
@peterpeterparker peterpeterparker self-assigned this Jul 22, 2020
@peterpeterparker
Copy link
Contributor Author

peterpeterparker commented Jul 22, 2020

I'm on it. Got a small proof of concept.

if (this.selection.anchorNode.nodeType === 3) {
      const content = this.selection.anchorNode.nodeValue;

      const a = document.createTextNode(content.substring(0, this.selection.anchorOffset));
      const b = document.createTextNode(content.substring(this.selection.focusOffset));

      const span = document.createElement('span');
      span.style.backgroundColor = 'yellow';
      span.innerHTML = this.selection.toString();

      if (this.selection.focusNode.nextSibling === null) {
        this.selection.anchorNode.parentElement.appendChild(a);
        this.selection.anchorNode.parentElement.appendChild(span);
        this.selection.anchorNode.parentElement.appendChild(b);
      } else {
        this.selection.anchorNode.parentElement.insertBefore(b, this.selection.focusNode.nextSibling);
        this.selection.anchorNode.parentElement.insertBefore(span, this.selection.focusNode.nextSibling);
        this.selection.anchorNode.parentElement.insertBefore(a, this.selection.focusNode.nextSibling);
      }

      this.selection.anchorNode.parentElement.removeChild(this.selection.anchorNode);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request highlight-code Highlight code web component inline-editor WYSIWYG inline edit web component studio "Studio" is the codename for the web editor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant