Remove currentNode set and get methods (#446)

This commit is contained in:
George Berezhnoy 2018-09-04 21:32:51 +03:00 committed by GitHub
parent 45d19ab4d2
commit 2c0d747035
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 48 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -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');

View file

@ -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;
}

View file

@ -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