(editor: Editor, elem: SugarElement<Node>, wrapName: string, nodeName: string)
| 40 | SugarNode.isText(elem) && SugarText.get(elem) === ZWSP; |
| 41 | |
| 42 | const context = (editor: Editor, elem: SugarElement<Node>, wrapName: string, nodeName: string): ChildContext => Traverse.parentElement(elem).fold( |
| 43 | () => ChildContext.Skipping, |
| 44 | |
| 45 | (parent) => { |
| 46 | // We used to skip these, but given that they might be representing empty paragraphs, it probably |
| 47 | // makes sense to treat them just like text nodes |
| 48 | if (nodeName === 'br' || isZeroWidth(elem)) { |
| 49 | return ChildContext.Valid; |
| 50 | } else if (isAnnotation(elem)) { |
| 51 | return ChildContext.Existing; |
| 52 | } else if (isCaretNode(elem.dom)) { |
| 53 | return ChildContext.Caret; |
| 54 | } else if (Arr.exists(validBlocks, (selector) => Selectors.is(elem, selector))) { |
| 55 | return ChildContext.ValidBlock; |
| 56 | } else if (!FormatUtils.isValid(editor, wrapName, nodeName) || !FormatUtils.isValid(editor, SugarNode.name(parent), wrapName)) { |
| 57 | return ChildContext.InvalidChild; |
| 58 | } else { |
| 59 | return ChildContext.Valid; |
| 60 | } |
| 61 | } |
| 62 | ); |
| 63 | |
| 64 | export { |
| 65 | context |
no test coverage detected
searching dependent graphs…