Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
editor.performAutoComplete(() => {
let searcher = editor.getContentSearcherOfCursor();
let textBeforeCursor = searcher.getSubStringBefore(3);
let rangeToDelete = searcher.getRangeFromText(
textBeforeCursor,
true /*exactMatch*/
);
if (rangeToDelete) {
rangeToDelete.deleteContents();
}
// If not explicitly insert br, Chrome/Safari/IE will operate on the previous line
let tempBr = editor.getDocument().createElement('BR');
if (Browser.isChrome || Browser.isSafari || Browser.isIE11OrGreater) {
editor.insertNode(tempBr);
}
if (textBeforeCursor.indexOf('1.') == 0) {
toggleNumbering(editor);
} else {
toggleBullet(editor);
}
editor.deleteNode(tempBr);
});
});
export default function processList(editor: Editor, command: ValidProcessListDocumentCommands): Node {
let clonedNode: Node;
let relativeSelectionPath;
if (Browser.isChrome && command == DocumentCommand.Outdent) {
const parentLINode = editor.getElementAtCursor('LI');
if (parentLINode) {
let currentRange = editor.getSelectionRange();
if (
currentRange.collapsed ||
(
editor.getElementAtCursor('LI', currentRange.startContainer) == parentLINode &&
editor.getElementAtCursor('LI', currentRange.endContainer) == parentLINode
)
) {
relativeSelectionPath = getSelectionPath(parentLINode, currentRange);
// Chrome has some bad behavior when outdenting
// in order to work around this, we need to take steps to deep clone the current node
// after the outdent, we'll replace the new LI with the cloned content.
clonedNode = parentLINode.cloneNode(true);
}
export function getDefaultContentEditFeatures(): ContentEditFeatures {
return {
autoLink: true,
indentWhenTab: true,
outdentWhenShiftTab: true,
outdentWhenBackspaceOnEmptyFirstLine: true,
outdentWhenEnterOnEmptyLine: Browser.isIE,
mergeInNewLineWhenBackspaceOnFirstChar: false,
unquoteWhenBackspaceOnEmptyFirstLine: true,
unquoteWhenEnterOnEmptyLine: true,
autoBullet: true,
tabInTable: true,
upDownInTable: Browser.isChrome || Browser.isSafari,
insertLineBeforeStructuredNodeFeature: false,
defaultShortcut: true,
unlinkWhenBackspaceAfterLink: false,
noCycleCursorMove: Browser.isChrome,
smartOrderedList: false,
smartOrderedListStyles: ['lower-alpha', 'lower-roman', 'decimal'],
};
}
return {
autoLink: true,
indentWhenTab: true,
outdentWhenShiftTab: true,
outdentWhenBackspaceOnEmptyFirstLine: true,
outdentWhenEnterOnEmptyLine: Browser.isIE,
mergeInNewLineWhenBackspaceOnFirstChar: false,
unquoteWhenBackspaceOnEmptyFirstLine: true,
unquoteWhenEnterOnEmptyLine: true,
autoBullet: true,
tabInTable: true,
upDownInTable: Browser.isChrome || Browser.isSafari,
insertLineBeforeStructuredNodeFeature: false,
defaultShortcut: true,
unlinkWhenBackspaceAfterLink: false,
noCycleCursorMove: Browser.isChrome,
smartOrderedList: false,
smartOrderedListStyles: ['lower-alpha', 'lower-roman', 'decimal'],
};
}
className={
format.headerLevel == 0 && styles.inactive
}>{`Header ${format.headerLevel}`}
Undo
{this.renderSpan(format.canUndo, 'Can Undo')}
{this.renderSpan(format.canRedo, 'Can Redo')}
Browser
{this.renderSpan(Browser.isChrome, 'Chrome')}
{this.renderSpan(Browser.isEdge, 'Edge')}
{this.renderSpan(Browser.isFirefox, 'Firefox')}
{this.renderSpan(Browser.isIE11OrGreater, 'IE10/11')}
{this.renderSpan(Browser.isIE, 'IE')}
{this.renderSpan(Browser.isIEOrEdge, 'IE/Edge')}
{this.renderSpan(Browser.isSafari, 'Safari')}
{this.renderSpan(Browser.isWebKit, 'Webkit')}
OS
{this.renderSpan(Browser.isMac, 'MacOS')}
{this.renderSpan(Browser.isWin, 'Windows')}