MCPcopy Index your code
hub / github.com/resend/react-email / addKeyboardShortcuts

Function addKeyboardShortcuts

packages/editor/src/extensions/columns.tsx:440–483  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

438 },
439
440 addKeyboardShortcuts() {
441 return {
442 Backspace: ({ editor }) => {
443 const { state } = editor;
444 const { selection } = state;
445 const { empty, $from } = selection;
446
447 if (!empty) {
448 return handleNodeSelectionBackspace(editor, selection, $from, state);
449 }
450
451 if ($from.parentOffset !== 0) return false;
452
453 return handleCursorBackspace(editor, $from, state);
454 },
455 'Mod-a': ({ editor }) => {
456 const { state } = editor;
457 const { $from } = state.selection;
458
459 for (let d = $from.depth; d > 0; d--) {
460 if ($from.node(d).type.name !== 'columnsColumn') {
461 continue;
462 }
463
464 const columnStart = $from.start(d);
465 const columnEnd = $from.end(d);
466 const { from, to } = state.selection;
467
468 if (from === columnStart && to === columnEnd) {
469 return false;
470 }
471
472 editor.view.dispatch(
473 state.tr.setSelection(
474 TextSelection.create(state.doc, columnStart, columnEnd),
475 ),
476 );
477 return true;
478 }
479
480 return false;
481 },
482 };
483 },
484
485 renderToReactEmail({ children, node, style }) {
486 const inlineStyles = inlineCssToJs(node.attrs?.style);

Callers

nothing calls this directly

Calls 5

handleCursorBackspaceFunction · 0.85
dispatchMethod · 0.80
startMethod · 0.65
createMethod · 0.45

Tested by

no test coverage detected