Skip to content
Snippets Groups Projects
Commit 1f93cd5e authored by chris's avatar chris
Browse files

fix for selection out of bounds

parent 4226e2e7
No related branches found
No related tags found
1 merge request!186add katex fonts
...@@ -38,9 +38,6 @@ const findFragmentedMark = (state, PMmark) => { ...@@ -38,9 +38,6 @@ const findFragmentedMark = (state, PMmark) => {
selection: { $from, $to }, selection: { $from, $to },
doc, doc,
} = state; } = state;
const fromPos = [$from.pos - 1, $from.pos];
const toPos = [$to.pos, $to.pos + 1];
let markFound;
// const type = state.config.schema.marks.comment; // const type = state.config.schema.marks.comment;
// const mark = empty // const mark = empty
...@@ -57,20 +54,21 @@ const findFragmentedMark = (state, PMmark) => { ...@@ -57,20 +54,21 @@ const findFragmentedMark = (state, PMmark) => {
// //
// // return undefined; // // return undefined;
for (let i = 0; i < fromPos.length; i++) { let markFound;
doc.nodesBetween(fromPos[i], toPos[i], (node, from) => {
if (node.marks) { doc.nodesBetween($from.pos - 1, $to.pos, (node, from) => {
const actualMark = node.marks.find(mark => mark.type === PMmark); if (node.marks) {
if (actualMark) { const actualMark = node.marks.find(mark => mark.type === PMmark);
markFound = { if (actualMark) {
from, markFound = {
to: from + node.nodeSize, from,
attrs: actualMark.attrs, to: from + node.nodeSize,
}; attrs: actualMark.attrs,
} };
} }
}); }
} });
return markFound; return markFound;
}; };
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment