mirror of
https://github.com/codex-team/editor.js
synced 2026-03-17 16:10:07 +01:00
up
This commit is contained in:
parent
b61fac8386
commit
550e3cec20
4 changed files with 16 additions and 5 deletions
|
|
@ -534,7 +534,7 @@ var Dom = function () {
|
|||
*
|
||||
* @param {Node} node - root Node. From this vertex we start Deep-first search {@link https://en.wikipedia.org/wiki/Depth-first_search}
|
||||
* @param {Boolean} atLast - find last text node
|
||||
* @return {Node} - it can be text Node or Element Node, so that caret will able to work with it
|
||||
* @return {Node|null} - it can be text Node or Element Node, so that caret will able to work with it
|
||||
*/
|
||||
|
||||
}, {
|
||||
|
|
@ -547,6 +547,11 @@ var Dom = function () {
|
|||
|
||||
var nodeChild = atLast ? node.lastChild : node.firstChild;
|
||||
|
||||
if (nodeChild.tagName === 'BR') {
|
||||
|
||||
nodeChild = nodeChild.nextSibling || nodeChild.parentNode.nextSibling;
|
||||
}
|
||||
|
||||
return this.getDeepestNode(nodeChild, atLast);
|
||||
}
|
||||
|
||||
|
|
@ -2535,7 +2540,7 @@ var Caret = function (_Module) {
|
|||
anchorNode = selection.anchorNode,
|
||||
firstNode = $.getDeepestNode(this.Editor.BlockManager.currentBlock.pluginsContent);
|
||||
|
||||
return anchorNode === firstNode && selection.anchorOffset === 0;
|
||||
return firstNode === null || anchorNode === firstNode && selection.anchorOffset === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -105,7 +105,7 @@ export default class Dom {
|
|||
*
|
||||
* @param {Node} node - root Node. From this vertex we start Deep-first search {@link https://en.wikipedia.org/wiki/Depth-first_search}
|
||||
* @param {Boolean} atLast - find last text node
|
||||
* @return {Node} - it can be text Node or Element Node, so that caret will able to work with it
|
||||
* @return {Node|null} - it can be text Node or Element Node, so that caret will able to work with it
|
||||
*/
|
||||
static getDeepestNode(node, atLast = false) {
|
||||
|
||||
|
|
@ -113,6 +113,12 @@ export default class Dom {
|
|||
|
||||
let nodeChild = atLast ? node.lastChild : node.firstChild;
|
||||
|
||||
if (nodeChild.tagName === 'BR') {
|
||||
|
||||
nodeChild = nodeChild.nextSibling || nodeChild.parentNode.nextSibling;
|
||||
|
||||
}
|
||||
|
||||
return this.getDeepestNode(nodeChild, atLast);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ export default class Caret extends Module {
|
|||
anchorNode = selection.anchorNode,
|
||||
firstNode = $.getDeepestNode(this.Editor.BlockManager.currentBlock.pluginsContent);
|
||||
|
||||
return anchorNode === firstNode && selection.anchorOffset === 0;
|
||||
return firstNode === null || anchorNode === firstNode && selection.anchorOffset === 0;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue