Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (cursor) {
return new TextSelection(taggedDoc.resolve(cursor));
}
if (gap) {
const $pos = taggedDoc.resolve(gap);
return new GapCursor($pos, $pos);
}
if (start) {
return createTextSelection({ taggedDoc, start, end });
}
const $anchor = resolveCell(taggedDoc, anchor);
if ($anchor) {
return Cast>(
new CellSelection($anchor, resolveCell(taggedDoc, taggedDoc.tag.head) ?? undefined),
);
}
return null;
};
beforeinput: (view, ev: Event) => {
const event = Cast(ev);
if (event.inputType === 'deleteContentBackward' && isAndroidOS()) {
const pluginState = getPluginState(ctx.pluginKey, view.state);
pluginState.startDelete();
return patchDeleteContentBackward(ctx.options, view, event, pluginState);
}
return true;
},
},
const getFn = () => {
if (isNodeExtension(extension)) {
return extensionMethod.bind(extension)({
...params,
type: Cast(params.schema.nodes[extension.name]),
});
}
if (isMarkExtension(extension)) {
return extensionMethod.bind(extension)({ ...params, type: Cast(params.schema.marks[extension.name]) });
}
return extensionMethod.bind(extension)(Cast(params));
};
export const closestElement = (domNode: Node | null | undefined, selector: string): HTMLElement | null => {
if (!isElementDOMNode(domNode)) {
return null;
}
if (isNullOrUndefined(document.documentElement) || !document.documentElement.contains(domNode)) {
return null;
}
const matches = isFunction(domNode.matches) ? 'matches' : Cast<'matches'>('msMatchesSelector');
do {
if (isFunction(domNode[matches]) && domNode[matches](selector)) {
return domNode;
}
domNode = (domNode.parentElement ?? domNode.parentNode) as HTMLElement;
} while (isElementDOMNode(domNode));
return null;
};