Skip to content
Edytor
Esc
↑↓navigate↵open⌘Jpreview
On this page

Arrow move

The arrow move plugin moves the caret's block with Mod+Shift and the arrow keys, as in Notion, and the selected blocks with Mod and the arrow keys.

createArrowMovePlugin() moves blocks with the keyboard. Mod + Shift + ↑/↓ moves the block holding the caret one step, as in Notion; Mod + ↑/↓ moves the selected blocks. Mod is Cmd on macOS and Ctrl elsewhere.

It is not a default plugin: list createArrowMovePlugin() in plugins to move blocks from the keyboard (see Default plugins). It takes no options.

<script lang="ts">
	import { Edytor, createArrowMovePlugin } from 'edytor';

	const plugins = [createArrowMovePlugin()];
</script>

<Edytor {plugins} />

Try it

Put the caret in a line and press Mod + Shift + ↑ or ↓ to move it. The editor is local to this page: a reload resets it.

Behavior

Keys Moves When
Mod + Shift + ↑/↓ The selected blocks; over a text range, every block it spans (as a handle drag takes them); else the caret’s block A caret, text or block selection
Mod + ↑/↓ The selected blocks A block selection

One step is:

Direction Move
Up Before the previous sibling; from a first child, before the parent
Down After the next sibling (never into its children); from a last child, after the parent

A key is claimed only when a block can take the step. Otherwise it keeps its default meaning: Mod + ↑/↓ move the caret to the start or end of the document, and with Shift extend the selection there.

  • Moving the caret’s block keeps the caret in it, at the same offset; moving a text range’s blocks keeps the range. A code block moves as one block: a caret or a range in its lines moves the code block.
  • A group of selected siblings, or of sibling blocks a text range spans, moves together, in document order (a block’s children move with it, selected or not: the block selection a grip click makes over a range holds the children it covers). Blocks that are not siblings do not move.
  • Moved selected blocks stay selected, their selected children too, so you can press the key again.
  • A move never nests a block. To nest or outdent, use Tab and Shift + Tab (with allowNesting), or a block handle’s Alt + → and Alt + ← (see Block handles).
  • Each move is one undo step, and it runs as a moveBlocks operation that plugins can refuse.

The plugin calls edytor.move({ blocks, direction }), the same command block menus use. See Commands.

Was this page helpful?