mirror of
https://github.com/codex-team/editor.js
synced 2024-06-28 02:10:31 +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",
|
"name": "codex.editor",
|
||||||
"version": "2.5.1",
|
"version": "2.5.2",
|
||||||
"description": "Codex Editor. Native JS, based on API and Open Source",
|
"description": "Codex Editor. Native JS, based on API and Open Source",
|
||||||
"main": "build/codex-editor.js",
|
"main": "build/codex-editor.js",
|
||||||
"types": "./types/index.d.ts",
|
"types": "./types/index.d.ts",
|
||||||
|
|
|
@ -331,11 +331,17 @@ export default class UI extends Module {
|
||||||
* - Block is an initial-block (Text)
|
* - Block is an initial-block (Text)
|
||||||
* - Block is empty
|
* - Block is empty
|
||||||
*/
|
*/
|
||||||
const isInitialBlock = this.Editor.Tools.isInitial(this.Editor.BlockManager.currentBlock.tool),
|
const isInitialBlock = this.Editor.Tools.isInitial(this.Editor.BlockManager.currentBlock.tool);
|
||||||
isEmptyBlock = this.Editor.BlockManager.currentBlock.isEmpty;
|
|
||||||
|
|
||||||
if (isInitialBlock && isEmptyBlock) {
|
if (isInitialBlock) {
|
||||||
this.Editor.Toolbar.plusButton.show();
|
/**
|
||||||
|
* 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 */
|
/** Clear selection */
|
||||||
|
|
Loading…
Reference in a new issue