Skip to content
Permalink
Browse files

fix: consider other style node when enter press in styled text of the…

… table
  • Loading branch information...
Sohee Lee authored and sohee-lee7 committed Mar 11, 2019
1 parent 8cf1ccd commit 445380249c1cb3073b158e2328b3e5b15ac54024
Showing with 9 additions and 5 deletions.
  1. +5 −0 src/js/domUtils.js
  2. +4 −5 src/js/wwTableManager.js
@@ -505,6 +505,10 @@ const isMDSupportInlineNode = function(node) {
return /^(A|B|BR|CODE|DEL|EM|I|IMG|S|SPAN|STRONG)$/ig.test(node.nodeName);
};

const isStyledTextNode = function(node) {
return /^(A|ABBR|ACRONYM|B|BDI|BDO|BIG|CITE|CODE|DEL|DFN|EM|I|INS|KBD|MARK|Q|S|SAMP|SMALL|SPAN|STRONG|SUB|SUP|U|VAR)$/ig.test(node.nodeName);
};

/**
* remove node from 'start' node to 'end-1' node inside parent
* if 'end' node is null, remove all child nodes after 'start' node.
@@ -590,6 +594,7 @@ export default {
getTableCellByDirection,
getSiblingRowCellByDirection,
isMDSupportInlineNode,
isStyledTextNode,
removeChildFromStartToEndNode,
removeNodesByDirection,
getLeafNode
@@ -214,16 +214,15 @@ class WwTableManager {
* @private
*/
_isInStyledText(range) {
const styleNodeNames = ['B', 'I', 'S', 'SPAN', 'CODE'];
const {startContainer} = range;
let nodeName;
let node;
if (domUtils.isTextNode(startContainer)) {
nodeName = startContainer.parentNode.nodeName;
node = startContainer.parentNode;
} else {
nodeName = startContainer.nodeName;
node = startContainer;
}

return range.collapsed && styleNodeNames.indexOf(nodeName) !== -1;
return range.collapsed && domUtils.isStyledTextNode(node);
}

/**

0 comments on commit 4453802

Please sign in to comment.
You can’t perform that action at this time.