Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*/
export const IndentWhenTab: ContentEditFeature = {
keys: [Keys.TAB],
shouldHandleEvent: (event, editor) =>
!event.rawEvent.shiftKey && cacheGetListElement(event, editor),
handleEvent: (event, editor) => {
setIndentation(editor, Indentation.Increase);
event.rawEvent.preventDefault();
},
};
/**
* OutdentWhenShiftTab edit feature, provides the ability to outdent current list when user press Shift+TAB
*/
export const OutdentWhenShiftTab: ContentEditFeature = {
keys: [Keys.TAB],
shouldHandleEvent: (event, editor) =>
event.rawEvent.shiftKey && cacheGetListElement(event, editor),
handleEvent: (event, editor) => {
setIndentation(editor, Indentation.Decrease);
event.rawEvent.preventDefault();
},
};
/**
* MergeInNewLine edit feature, provides the ability to merge current line into a new line when user press
* BACKSPACE at beginning of a list item
*/
export const MergeInNewLine: ContentEditFeature = {
keys: [Keys.BACKSPACE],
shouldHandleEvent: (event, editor) => {
let li = cacheGetElementAtCursor(editor, event, 'LI');
import { cacheGetEventData, ContentEditFeature, Editor, Keys } from 'roosterjs-editor-core';
import {
contains,
getTagOfNode,
isVoidHtmlElement,
Position,
VTable
} from 'roosterjs-editor-dom';
import { NodeType, PluginEvent, PositionType } from 'roosterjs-editor-types';
/**
* TabInTable edit feature, provides the ability to jump between cells when user press TAB in table
*/
export const TabInTable: ContentEditFeature = {
keys: [Keys.TAB],
shouldHandleEvent: cacheGetTableCell,
handleEvent: (event, editor) => {
let shift = event.rawEvent.shiftKey;
let td = cacheGetTableCell(event, editor);
for (
let vtable = new VTable(td),
step = shift ? -1 : 1,
row = vtable.row,
col = vtable.col + step;
;
col += step
) {
if (col < 0 || col >= vtable.cells[row].length) {
row += step;
if (row < 0 || row >= vtable.cells.length) {
editor.select(vtable.table, shift ? PositionType.Before : PositionType.After);