Git Product home page Git Product logo

underline's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

underline's Issues

[Bug]: Attempting to remove the underline from the document header text

When applying underline with to a block of text that was created with "@editorjs/header". After the event of saving the document, or losing focus from the block and returning to further editing, it is impossible to remove the underline of the text. Since the tag is not removed from the currently selected text. This can be seen in the section of the attached video.

2021-04-11.21.45.44.mov

Underline doesn't have shortcut hint in inlineToolbar

can we have shortcut for underline so it'll be like bold toolbar below?
image
right now the underline toolbar is like this
image
I think we can add something like this in the class component

static get shortcut() {
    return 'CMD+U'; //or 'CTRL+U'
}

Paste detection

I'm moving an entire book into JSON, and EditorJS seems like the perfect tool for the translation process. Feel like I'm so close, the only thing I need is for it to detect underlines on paste. I'm looking into paste substitions but it's a little over my head. Any help would be appreciated!

Simpler implementation

I noticed the bold tool that comes with the core editor uses execCommand and plugins are using another method.
there is a problem with the approach that prevent user from applying the tool to a sentence then tries to remove one word of this sentence.

The issue is that it tried to get the tags around the text which will remove the whole tag and replace the sentence with just the text that was highlighted/selected.

Anyway I ended up reimplementing this tool using execCommand

class Underline {
  static get isInline() { return true; }
  static get title() { return "Underline"; }
  static get sanitize() { return { U: {} }; }

  constructor({api}) {
    this.api = api;
    this.commandName = "underline";
    this.button = null;
  }

  render() {
    this.button = document.createElement('button');
    this.button.type = 'button';
    this.button.textContent = 'U';
    this.button.classList.add(this.api.styles.inlineToolButton);
    this.button.style.textDecoration = "underline";
    return this.button;
  }

  surround(range) { document.execCommand(this.commandName); }

  checkState(selection) {
    const isActive = document.queryCommandState(this.commandName);
    this.button.classList.toggle(this.api.styles.inlineToolButtonActive, isActive);
    return isActive;
  }
}

I used the same approach to implement strikethrough too

class StrikeTool {
  static get isInline() { return true; }
  static get title() { return "Strike"; }
  static get sanitize() { return { strike: {} }; }

  constructor({api}) {
    this.api = api;
    this.commandName = "strikeThrough";
    this.button = null;
  }

  render() {
    this.button = document.createElement('button');
    this.button.type = 'button';
    this.button.textContent = 'S';
    this.button.classList.add(this.api.styles.inlineToolButton);
    this.button.style.textDecoration = "line-through";
    this.button.style.fontWeight = "bold";
    return this.button;
  }

  surround(range) { document.execCommand(this.commandName); }

  checkState(selection) {
    const isActive = document.queryCommandState(this.commandName);
    this.button.classList.toggle(this.api.styles.inlineToolButtonActive, isActive);
    return isActive;
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.