How to use the roosterjs-editor-core.cacheGetElementAtCursor function in roosterjs-editor-core

To help you get started, we’ve selected a few roosterjs-editor-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / roosterjs / packages / roosterjs-editor-api / lib / deprecated / getNodeAtCursor.ts View on Github external
export function cacheGetListElement(editor: Editor, event?: PluginEvent): Node {
    return cacheGetElementAtCursor(editor, event, 'LI');
}
github microsoft / roosterjs / packages / roosterjs-editor-plugins / lib / ContentEdit / features / listFeatures.ts View on Github external
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;
}
github microsoft / roosterjs / packages / roosterjs-editor-plugins / lib / ContentEdit / features / listFeatures.ts View on Github external
shouldHandleEvent: (event, editor) => {
        let li = cacheGetElementAtCursor(editor, event, 'LI');
        return !event.rawEvent.shiftKey && li && isNodeEmpty(li);
    },
    handleEvent: (event, editor) => {
github microsoft / roosterjs / packages / roosterjs-editor-api / lib / deprecated / cacheGetListState.ts View on Github external
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;
}
github microsoft / roosterjs / packages / roosterjs-editor-api / lib / format / getFormatState.ts View on Github external
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],
    };
}
github microsoft / roosterjs / packages / roosterjs-editor-plugins / lib / ContentEdit / features / listFeatures.ts View on Github external
shouldHandleEvent: (event, editor) => {
        let li = cacheGetElementAtCursor(editor, event, 'LI');
        return li && isNodeEmpty(li) && !li.previousSibling;
    },
    handleEvent: toggleListAndPreventDefault,
github microsoft / roosterjs / packages / roosterjs-editor-api / lib / format / getFormatState.ts View on Github external
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],
    };
}