add some more commands
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { Editor } from '../Editor'
|
||||
import { Command } from '../Editor'
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import getMarkType from '../utils/getMarkType'
|
||||
import getMarkRange from '../utils/getMarkRange'
|
||||
|
||||
type RemoveMarkCommand = (typeOrName: string | MarkType) => Editor
|
||||
type RemoveMarkCommand = (typeOrName: string | MarkType) => Command
|
||||
|
||||
declare module '../Editor' {
|
||||
interface Editor {
|
||||
@@ -11,10 +11,9 @@ declare module '../Editor' {
|
||||
}
|
||||
}
|
||||
|
||||
export default (next: Function, editor: Editor) => (typeOrName: string | MarkType) => {
|
||||
const { view, state, schema } = editor
|
||||
const { tr, selection } = state
|
||||
const type = getMarkType(typeOrName, schema)
|
||||
export const removeMark: RemoveMarkCommand = (typeOrName) => ({ tr, state }) => {
|
||||
const { selection } = tr
|
||||
const type = getMarkType(typeOrName, state.schema)
|
||||
let { from, to, $from, empty } = selection
|
||||
|
||||
if (empty) {
|
||||
@@ -27,6 +26,6 @@ export default (next: Function, editor: Editor) => (typeOrName: string | MarkTyp
|
||||
}
|
||||
|
||||
tr.removeMark(from, to, type)
|
||||
view.dispatch(tr)
|
||||
next()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user