mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 19:59:02 +08:00
improve getMarkAttrs when selection is empty
This commit is contained in:
parent
2260f3615e
commit
da1aaec025
@ -5,10 +5,13 @@ export default function getMarkAttrs(state: EditorState, type: MarkType) {
|
||||
const { from, to, empty } = state.selection
|
||||
let marks: Mark[] = []
|
||||
|
||||
// TODO: -1 only for inclusive marks?
|
||||
state.doc.nodesBetween(empty ? from - 1 : from, to, node => {
|
||||
marks = [...marks, ...node.marks]
|
||||
})
|
||||
if (empty) {
|
||||
marks = state.selection.$head.marks()
|
||||
} else {
|
||||
state.doc.nodesBetween(from, to, node => {
|
||||
marks = [...marks, ...node.marks]
|
||||
})
|
||||
}
|
||||
|
||||
const mark = marks.find(markItem => markItem.type.name === type.name)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user