mirror of
https://github.com/codex-team/editor.js
synced 2026-03-16 07:35:48 +01:00
dom getdeepestnode improvements
This commit is contained in:
parent
d969f7d40d
commit
01a1b9676f
4 changed files with 28 additions and 7 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|null} - it can be text Node or Element Node, so that caret will able to work with it
|
||||
* @return {Node} - it can be text Node or Element Node, so that caret will able to work with it
|
||||
*/
|
||||
|
||||
}, {
|
||||
|
|
@ -549,7 +549,16 @@ var Dom = function () {
|
|||
|
||||
if (nodeChild.tagName === 'BR') {
|
||||
|
||||
nodeChild = nodeChild.nextSibling || nodeChild.parentNode.nextSibling;
|
||||
if (nodeChild.nextSibling) {
|
||||
|
||||
nodeChild = nodeChild.nextSibling;
|
||||
} else if (!nodeChild.nextSibling && nodeChild.parentNode.nextSibling) {
|
||||
|
||||
nodeChild = nodeChild.parentNode.nextSibling;
|
||||
} else {
|
||||
|
||||
return nodeChild.parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
return this.getDeepestNode(nodeChild, atLast);
|
||||
|
|
@ -2285,7 +2294,7 @@ var Block = function () {
|
|||
key: 'mergeable',
|
||||
get: function get() {
|
||||
|
||||
return !!(this.tool.merge && typeof this.tool.merge === 'function');
|
||||
return typeof this.tool.merge === 'function';
|
||||
}
|
||||
}, {
|
||||
key: 'isEmpty',
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -111,7 +111,7 @@ export default class Block {
|
|||
*/
|
||||
get mergeable() {
|
||||
|
||||
return !!(this.tool.merge && typeof this.tool.merge === 'function');
|
||||
return typeof this.tool.merge === 'function';
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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|null} - it can be text Node or Element Node, so that caret will able to work with it
|
||||
* @return {Node} - it can be text Node or Element Node, so that caret will able to work with it
|
||||
*/
|
||||
static getDeepestNode(node, atLast = false) {
|
||||
|
||||
|
|
@ -115,7 +115,19 @@ export default class Dom {
|
|||
|
||||
if (nodeChild.tagName === 'BR') {
|
||||
|
||||
nodeChild = nodeChild.nextSibling || nodeChild.parentNode.nextSibling;
|
||||
if (nodeChild.nextSibling) {
|
||||
|
||||
nodeChild = nodeChild.nextSibling;
|
||||
|
||||
} else if (!nodeChild.nextSibling && nodeChild.parentNode.nextSibling) {
|
||||
|
||||
nodeChild = nodeChild.parentNode.nextSibling;
|
||||
|
||||
} else {
|
||||
|
||||
return nodeChild.parentNode;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue