mirror of
https://github.com/codex-team/editor.js
synced 2024-06-18 13:45:20 +02:00
Optimisation: dont fire isEmpty checking for not-initial Blocks (#529)
* Optimisation: dont fire isEmpty checking for not-initial Blocks Because not-initial Tools can has maaany nodes and it will be slow to walk three. * upd comment
This commit is contained in:
parent
09df079509
commit
ecfcfaa79f
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "codex.editor",
|
||||
"version": "2.5.1",
|
||||
"version": "2.5.2",
|
||||
"description": "Codex Editor. Native JS, based on API and Open Source",
|
||||
"main": "build/codex-editor.js",
|
||||
"types": "./types/index.d.ts",
|
||||
|
|
|
@ -331,11 +331,17 @@ export default class UI extends Module {
|
|||
* - Block is an initial-block (Text)
|
||||
* - Block is empty
|
||||
*/
|
||||
const isInitialBlock = this.Editor.Tools.isInitial(this.Editor.BlockManager.currentBlock.tool),
|
||||
isEmptyBlock = this.Editor.BlockManager.currentBlock.isEmpty;
|
||||
const isInitialBlock = this.Editor.Tools.isInitial(this.Editor.BlockManager.currentBlock.tool);
|
||||
|
||||
if (isInitialBlock && isEmptyBlock) {
|
||||
this.Editor.Toolbar.plusButton.show();
|
||||
if (isInitialBlock) {
|
||||
/**
|
||||
* Check isEmpty only for paragraphs to prevent unnecessary tree-walking on Tools with many nodes (for ex. Table)
|
||||
*/
|
||||
const isEmptyBlock = this.Editor.BlockManager.currentBlock.isEmpty;
|
||||
|
||||
if (isEmptyBlock) {
|
||||
this.Editor.Toolbar.plusButton.show();
|
||||
}
|
||||
}
|
||||
|
||||
/** Clear selection */
|
||||
|
|
Loading…
Reference in a new issue