Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const findSubLists = function (parentList) {
return Tools.grep(parentList.querySelectorAll('ol,ul,dl'), function (elm: Node) {
return NodeType.isListNode(elm);
});
};
const replace = function (editor: Editor, currentSearchState: Cell, text: string, forward?: boolean, all?: boolean) {
const searchState = currentSearchState.get();
const currentIndex = searchState.index;
let i, nodes, node, matchIndex, currentMatchIndex, nextIndex = currentIndex;
forward = forward !== false;
node = editor.getBody();
nodes = Tools.grep(Tools.toArray(node.getElementsByTagName('span')), isMatchSpan);
for (i = 0; i < nodes.length; i++) {
const nodeIndex = getElmIndex(nodes[i]);
matchIndex = currentMatchIndex = parseInt(nodeIndex, 10);
if (all || matchIndex === searchState.index) {
if (text.length) {
nodes[i].firstChild.nodeValue = text;
unwrap(nodes[i]);
} else {
removeNode(editor.dom, nodes[i]);
}
while (nodes[++i]) {
matchIndex = parseInt(getElmIndex(nodes[i]), 10);
if (matchIndex === currentMatchIndex) {
const getSelectedListItems = function (editor) {
const selectedBlocks = editor.selection.getSelectedBlocks();
return Tools.grep(findParentListItemsNodes(editor, selectedBlocks), function (block) {
return NodeType.isListItemNode(block);
});
};
const getSelectedSubLists = function (editor) {
const parentList = getParentList(editor);
const selectedBlocks = editor.selection.getSelectedBlocks();
if (isParentListSelected(parentList, selectedBlocks)) {
return findSubLists(parentList);
} else {
return Tools.grep(selectedBlocks, function (elm: Node) {
return NodeType.isListNode(elm) && parentList !== elm;
});
}
};
const getGroupsBySelector = function (groups: Group[], selector: string): Group[] {
return Tools.grep(groups, function (group) {
return !group.filter || group.filter(selector);
});
};
const hasLinks = (elements: HTMLAnchorElement[]) => {
return Tools.grep(elements, isLink).length > 0;
};