Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function setIndentation(editor: Editor, indentation: Indentation) {
let command: DocumentCommand.Indent | DocumentCommand.Outdent =
indentation == Indentation.Increase ? DocumentCommand.Indent : DocumentCommand.Outdent;
editor.addUndoSnapshot(() => {
editor.focus();
let listNode = editor.getElementAtCursor('OL,UL');
let newNode: Node;
if (listNode) {
// There is already list node, setIndentation() will increase/decrease the list level,
// so we need to process the list when change indentation
newNode = processList(editor, command);
} else {
// No existing list node, browser will create <blockquote> node for indentation.
// We need to set top and bottom margin to 0 to avoid unnecessary spaces
editor.getDocument().execCommand(command, false, null);
editor.queryElements('BLOCKQUOTE', QueryScope.OnSelection, node => {
newNode = newNode || node;
node.style.marginTop = '0px';
</blockquote>
onClick: editor => setIndentation(editor, Indentation.Increase),
},
handleEvent: (event, editor) => {
setIndentation(editor, Indentation.Increase);
event.rawEvent.preventDefault();
},
};
handleChange: (editor) => setIndentation(editor, Indentation.Increase)
},
document.getElementById('indentButton').addEventListener('click', function() {
setIndentation(getCurrentEditor(), Indentation.Increase);
});
handleChange: (editor: Editor, props: RoosterCommandBarProps) => (props.disableListWorkaround ? setNonCompatIndentation : setIndentation)(editor, Indentation.Increase)
},
onClick: editor => setIndentation(editor, Indentation.Increase),
};