Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onTapContent (evt) {
const target = evt.target();
// If the user has tapped (touchstart, touchend without movement) on an image, select it.
if (Node.name(target) === 'img') {
editor.selection.select(target.dom());
// Prevent the default behaviour from firing so that the image stays selected
evt.kill();
} else if (Node.name(target) === 'a') {
const component = realm.system().getByDom(Element.fromDom(editor.editorContainer));
component.each(function (container) {
/// view mode
if (Swapping.isAlpha(container)) {
TinyCodeDupe.openLink(target.dom());
}
});
}
}
},
(parent) => {
// We used to skip these, but given that they might be representing empty paragraphs, it probably
// makes sense to treat them just like text nodes
if (nodeName === 'br' || isZeroWidth(elem)) {
return ChildContext.Valid;
} else if (isAnnotation(elem)) {
return ChildContext.Existing;
} else if (isCaretNode(elem)) {
return ChildContext.Caret;
} else if (!FormatUtils.isValid(editor, wrapName, nodeName) || !FormatUtils.isValid(editor, Node.name(parent), wrapName)) {
return ChildContext.InvalidChild;
} else {
return ChildContext.Valid;
}
}
);
return table.map((table) => {
if (Node.name(cellOrCaption) === 'caption') {
return TableTargets.notCell(cellOrCaption);
} else {
return TableTargets.forMenu(selections, table, cellOrCaption);
}
});
});
const onSetupCellOrRow = (api) => onSetup(api, (targets) => Node.name(targets.element()) === 'caption');
const onSetupMergeable = (api) => onSetup(api, (targets) => targets.mergable().isNone());
const isTarget = (node: Element) => Arr.contains(['figcaption'], Node.name(node));
function (child) {
if (Node.name(child) === 'br') {
return Traverse.prevSibling(child).map(function (sibling) {
return [node].concat(getLastChildren(sibling));
}).getOr([]);
} else {
return [node].concat(getLastChildren(child));
}
}
);
const processElement = (elem) => {
const ctx = context(editor, elem, 'span', Node.name(elem));
switch (ctx) {
case ChildContext.InvalidChild: {
finishWrapper();
const children = Traverse.children(elem);
processElements(children);
finishWrapper();
break;
}
case ChildContext.Valid: {
const w = getOrOpenWrapper();
Insert.wrap(elem, w);
break;
}
TableLookup.table(cell).each((table) => {
const elements = Arr.filter(Elements.fromHtml(e.content), function (content) {
return Node.name(content) !== 'meta';
});
if (elements.length === 1 && Node.name(elements[0]) === 'table') {
e.preventDefault();
const doc = Element.fromDom(editor.getDoc());
const generators = TableFill.paste(doc);
const targets = TableTargets.paste(cell, elements[0], generators);
actions.pasteCells(table, targets).each(function (rng) {
editor.selection.setRng(rng);
editor.focus();
cellSelection.clear(table);
});
}
});
});
const elements = Arr.filter(Elements.fromHtml(e.content), function (content) {
return Node.name(content) !== 'meta';
});
return Traverse.parent(li).filter(Node.isElement).map((list) => {
return {
depth,
isSelected,
content: cloneItemContent(li),
itemAttributes: Attr.clone(li),
listAttributes: Attr.clone(list),
listType: Node.name(list) as ListType
};
});
};