add commands experiment

This commit is contained in:
Philipp Kühn
2021-01-21 12:13:20 +01:00
parent 001e5b7579
commit a2d5eef6b2
8 changed files with 305 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import { Command, Range } from '../types'
/**
* Delete a given range.
*/
export const deleteRange = (range: Range): Command => ({ tr, dispatch }) => {
const { from, to } = range
if (dispatch) {
tr.delete(from, to)
}
return true
}

View File

@@ -4,6 +4,7 @@ import * as clearContent from '../commands/clearContent'
import * as clearNodes from '../commands/clearNodes'
import * as command from '../commands/command'
import * as createParagraphNear from '../commands/createParagraphNear'
import * as deleteRange from '../commands/deleteRange'
import * as deleteSelection from '../commands/deleteSelection'
import * as exitCode from '../commands/exitCode'
import * as extendMarkRange from '../commands/extendMarkRange'
@@ -52,6 +53,7 @@ export const Commands = Extension.create({
...clearNodes,
...command,
...createParagraphNear,
...deleteRange,
...deleteSelection,
...exitCode,
...extendMarkRange,