editor-js / header

Header Tool for Editor.js 2.0
MIT License
99 stars 122 forks source link

No ability to provide available levels #14

Closed proArtex closed 4 years ago

proArtex commented 5 years ago

It seems like levels are hardcoded and cannot be set. What if I want to put H1 only?

Farrien commented 5 years ago

I was looking for how to prevent users from using some of the heading levels too.

talyguryn commented 5 years ago

Sorry, my bad

nynevi commented 5 years ago

ugly but works:

    .cdx-settings-button[data-level='1'],
    .cdx-settings-button[data-level='4'],
    .cdx-settings-button[data-level='5'],
    .cdx-settings-button[data-level='6'] {
      display: none;
    }

I used the same method for hiding image options but it had an explicity classname so using the above method with -settings- might break other plugin options that has levels

.image-tool__tune {
     display: none;
}
igorivaniuk commented 5 years ago

Or extend Header class

class MyHeader extends Header {
  get levels() {
    return super.levels.filter((l: any) => [2, 3, 4].includes(l.number));
  }

  get defaultLevel() {
    /**
     * Use H2 as default header
     */
    return this.levels[0];
  }
}

editorjs

zizther commented 5 years ago

Even though it is possible to extend, it would be nice to see this built in as an option.

damien-monni commented 4 years ago

I agree, it would be nice!

sandrooco commented 4 years ago

@igorivaniuk Extending like you did doesn't work for me:

Type 'typeof CustomHeading' is not assignable to type 'BaseToolConstructable'. Property 'render' is missing in type 'CustomHeading' but required in type 'BaseTool'.

If I use heading: CustomHeading as BaseToolConstructable, it will build (and work..) but still throw an error in the terminal.

neSpecc commented 4 years ago

It can be done by adding a corresponding config option. You are welcome to implement this feature and send a PR.

alexanderhorner commented 4 years ago

Extending doesn't work for me

SyntaxError: Unexpected token ':'. Expected ')' to end a compound expression.