This commit is contained in:
windingwind 2023-08-12 01:29:18 +08:00
parent 69b3d972a7
commit 026c124903

View File

@ -122,17 +122,13 @@ function getMarkRange($pos: ResolvedPos, type: MarkType, attributes = {}) {
function getMarkRangeAtCursor(state: EditorState, type: MarkType) {
const { selection } = state;
const { $from, empty } = selection;
const { $from } = selection;
if (empty) {
const start = $from.parent.childAfter($from.parentOffset);
if (start.node) {
const mark = start.node.marks.find(
(mark) => mark.type.name === type.name,
);
if (mark) {
return getMarkRange($from, type, mark.attrs);
}
const start = $from.parent.childAfter($from.parentOffset);
if (start.node) {
const mark = start.node.marks.find((mark) => mark.type.name === type.name);
if (mark) {
return getMarkRange($from, type, mark.attrs);
}
}