add deleteSelection command
This commit is contained in:
@@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
Clear the whole document.
|
Clear the whole document.
|
||||||
|
|
||||||
|
## .deleteSelection()
|
||||||
|
|
||||||
|
Delete the selection, if there is one.
|
||||||
|
|
||||||
## .focus()
|
## .focus()
|
||||||
|
|
||||||
Focus the editor at the given position.
|
Focus the editor at the given position.
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ export class Editor extends EventEmitter {
|
|||||||
this.createSchema()
|
this.createSchema()
|
||||||
this.createView()
|
this.createView()
|
||||||
this.registerCommand('clearContent', require('./commands/clearContent').default)
|
this.registerCommand('clearContent', require('./commands/clearContent').default)
|
||||||
|
this.registerCommand('deleteSelection', require('./commands/deleteSelection').default)
|
||||||
this.registerCommand('focus', require('./commands/focus').default)
|
this.registerCommand('focus', require('./commands/focus').default)
|
||||||
this.registerCommand('insertHTML', require('./commands/insertHTML').default)
|
this.registerCommand('insertHTML', require('./commands/insertHTML').default)
|
||||||
this.registerCommand('insertText', require('./commands/insertText').default)
|
this.registerCommand('insertText', require('./commands/insertText').default)
|
||||||
|
|||||||
15
packages/core/src/commands/deleteSelection.ts
Normal file
15
packages/core/src/commands/deleteSelection.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { Editor } from '../Editor'
|
||||||
|
import { deleteSelection } from 'prosemirror-commands'
|
||||||
|
|
||||||
|
type DeleteSelection = () => any
|
||||||
|
|
||||||
|
declare module '../Editor' {
|
||||||
|
interface Editor {
|
||||||
|
deleteSelection: DeleteSelection,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default (next: Function, { state, view }: Editor): DeleteSelection => () => {
|
||||||
|
deleteSelection(state, view.dispatch)
|
||||||
|
next()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user