-
Notifications
You must be signed in to change notification settings - Fork 48
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
Feature/disable tool elements #122
base: main
Are you sure you want to change the base?
Conversation
src/index.ts
Outdated
@@ -75,6 +75,10 @@ export default class EditorjsList { | |||
}, | |||
}, | |||
]; | |||
|
|||
return this.displayedEntries ? entries.filter( | |||
ele => this.displayedEntries?.includes(ele.data.style as ListDataStyle) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve naming please
src/index.ts
Outdated
/** | ||
* | ||
*/ | ||
private static displayedEntries?: ListDataStyle[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments missing
src/index.ts
Outdated
if (EditorjsList.displayedEntries){ | ||
if (this.listStyle === 'ordered') this.addAdditionalTunes(defaultTunes); | ||
} else if (this.listStyle === 'ordered') this.addAdditionalTunes(defaultTunes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to check for EditorjsList.displayedEntries
here
src/index.ts
Outdated
@@ -75,6 +75,10 @@ export default class EditorjsList { | |||
}, | |||
}, | |||
]; | |||
|
|||
return this.displayedEntries ? entries.filter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you cannot access this.displayedEntries
since it is static
src/index.ts
Outdated
tune => { | ||
if ('title' in tune) { | ||
if(tune.title === 'Start with' || tune.title === 'Counter type') return true; | ||
else return EditorjsList.displayedEntries?.includes(tune.title!.toLowerCase() as ListDataStyle); | ||
} else if (('type' in tune) && tune.type === 'separator') return true; | ||
} | ||
) : defaultTunes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can firstly filter default tunes, and then add additional ones, then you won't need to check for Start with
and Counter type
in tunes
README.md
Outdated
@@ -64,6 +64,7 @@ var editor = EditorJS({ | |||
|--------------|----------|----------------------------------------------------------------| | |||
| defaultStyle | `string` | default list style: `ordered`, `unordered` or `checklist`, default is `unordered` | | |||
| maxLevel | `number` | maximum level of the list nesting, could be set to `1` to disable nesting, unlimited by default | | |||
| displayedEntries | `listStyle[]` | List entries allowed to be displayed `ordered`, `unordered` or `checklist` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets call it styles
?
Closes #119