mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-14 18:49:02 +08:00
use markRange for empty selections in removeMark and updateMark, fix #449
This commit is contained in:
parent
103d2b16a0
commit
08aa7e88bc
@ -1,6 +1,17 @@
|
||||
import { getMarkRange } from 'tiptap-utils'
|
||||
|
||||
export default function (type) {
|
||||
return (state, dispatch) => {
|
||||
const { from, to } = state.selection
|
||||
let { from, to } = state.selection
|
||||
const { $from, empty } = state.selection
|
||||
|
||||
if (empty) {
|
||||
const range = getMarkRange($from, type)
|
||||
|
||||
from = range.from
|
||||
to = range.to
|
||||
}
|
||||
|
||||
return dispatch(state.tr.removeMark(from, to, type))
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,17 @@
|
||||
import { getMarkRange } from 'tiptap-utils'
|
||||
|
||||
export default function (type, attrs) {
|
||||
return (state, dispatch) => {
|
||||
const { from, to } = state.selection
|
||||
let { from, to } = state.selection
|
||||
const { $from, empty } = state.selection
|
||||
|
||||
if (empty) {
|
||||
const range = getMarkRange($from, type)
|
||||
|
||||
from = range.from
|
||||
to = range.to
|
||||
}
|
||||
|
||||
return dispatch(state.tr.addMark(from, to, type.create(attrs)))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user