Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function cacheGetListElement(editor: Editor, event?: PluginEvent): Node {
return cacheGetElementAtCursor(editor, event, 'LI');
}
function cacheGetListElement(event: PluginKeyboardEvent, editor: Editor) {
let li = cacheGetElementAtCursor(editor, event, 'LI,TABLE');
let listElement = li && getTagOfNode(li) == 'LI' && editor.getElementAtCursor('UL,OL', li);
return listElement ? [listElement, li] : null;
}
shouldHandleEvent: (event, editor) => {
let li = cacheGetElementAtCursor(editor, event, 'LI');
return !event.rawEvent.shiftKey && li && isNodeEmpty(li);
},
handleEvent: (event, editor) => {
export default function cacheGetListState(editor: Editor, event?: PluginEvent): ListState {
let element = cacheGetElementAtCursor(editor, event, 'OL, UL');
let tag = getTagOfNode(element);
return tag == 'OL' ? ListState.Numbering : tag == 'UL' ? ListState.Bullets : ListState.None;
}
export function getElementBasedFormatState(
editor: Editor,
event?: PluginEvent
): ElementBasedFormatState {
let listTag = getTagOfNode(cacheGetElementAtCursor(editor, event, 'OL,UL'));
let headerTag = getTagOfNode(cacheGetElementAtCursor(editor, event, 'H1,H2,H3,H4,H5,H6'));
return {
isBullet: listTag == 'UL',
isNumbering: listTag == 'OL',
headerLevel: (headerTag && parseInt(headerTag[1])) || 0,
canUnlink: !!editor.queryElements('a[href]', QueryScope.OnSelection)[0],
canAddImageAltText: !!editor.queryElements('img', QueryScope.OnSelection)[0],
isBlockQuote: !!editor.queryElements('blockquote', QueryScope.OnSelection)[0],
};
}
shouldHandleEvent: (event, editor) => {
let li = cacheGetElementAtCursor(editor, event, 'LI');
return li && isNodeEmpty(li) && !li.previousSibling;
},
handleEvent: toggleListAndPreventDefault,
export function getElementBasedFormatState(
editor: Editor,
event?: PluginEvent
): ElementBasedFormatState {
let listTag = getTagOfNode(cacheGetElementAtCursor(editor, event, 'OL,UL'));
let headerTag = getTagOfNode(cacheGetElementAtCursor(editor, event, 'H1,H2,H3,H4,H5,H6'));
return {
isBullet: listTag == 'UL',
isNumbering: listTag == 'OL',
headerLevel: (headerTag && parseInt(headerTag[1])) || 0,
canUnlink: !!editor.queryElements('a[href]', QueryScope.OnSelection)[0],
canAddImageAltText: !!editor.queryElements('img', QueryScope.OnSelection)[0],
isBlockQuote: !!editor.queryElements('blockquote', QueryScope.OnSelection)[0],
};
}