mirror of
https://github.com/codex-team/editor.js
synced 2024-05-29 03:52:46 +02:00
Remove currentNode set and get methods (#446)
This commit is contained in:
parent
45d19ab4d2
commit
2c0d747035
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -325,39 +325,6 @@ export default class BlockManager extends Module {
|
|||
return this._blocks[this.currentBlockIndex - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get working html element
|
||||
*
|
||||
* @return {HTMLElement}
|
||||
*/
|
||||
get currentNode() {
|
||||
return this._blocks.nodes[this.currentBlockIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set currentBlockIndex to passed block
|
||||
* @param {Node} element
|
||||
*/
|
||||
set currentNode(element) {
|
||||
if (!$.isElement(element)) {
|
||||
element = element.parentNode;
|
||||
}
|
||||
|
||||
let nodes = this._blocks.nodes,
|
||||
firstLevelBlock = element.closest(`.${Block.CSS.wrapper}`);
|
||||
|
||||
if (!firstLevelBlock) {
|
||||
throw Error('Passed element is not a Block.');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update current Block's index
|
||||
* @type {number}
|
||||
*/
|
||||
this.currentBlockIndex = nodes.indexOf(firstLevelBlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove selection from all Blocks then highlight only Current Block
|
||||
*/
|
||||
|
@ -408,7 +375,12 @@ export default class BlockManager extends Module {
|
|||
let parentFirstLevelBlock = childNode.closest(`.${Block.CSS.wrapper}`);
|
||||
|
||||
if (parentFirstLevelBlock) {
|
||||
this.currentNode = parentFirstLevelBlock;
|
||||
/**
|
||||
* Update current Block's index
|
||||
* @type {number}
|
||||
*/
|
||||
this.currentBlockIndex = this._blocks.nodes.indexOf(parentFirstLevelBlock);
|
||||
|
||||
this.Editor.Caret.setToInput(childNode);
|
||||
} else {
|
||||
throw new Error('Can not find a Block from this child Node');
|
||||
|
|
|
@ -94,7 +94,7 @@ export default class Caret extends Module {
|
|||
this.set(nodeToSet, offset);
|
||||
}, 20)();
|
||||
|
||||
BlockManager.currentNode = block.holder;
|
||||
BlockManager.setCurrentBlockByChildNode(block.holder);
|
||||
BlockManager.currentBlock.currentInput = element;
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ export default class Toolbar extends Module {
|
|||
this.Editor.BlockSettings.close();
|
||||
}
|
||||
|
||||
let currentNode = this.Editor.BlockManager.currentNode;
|
||||
let currentNode = this.Editor.BlockManager.currentBlock.holder;
|
||||
|
||||
/**
|
||||
* If no one Block selected as a Current
|
||||
|
|
Loading…
Reference in a new issue