Skip to content

Commit 7c474eb

Browse files
authored
Merge pull request #230 from eccenca/bugfix/mt-fix104and98
Fix for template field, prevent crashing on misformatted blocks
2 parents eb4180e + d14507b commit 7c474eb

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/components/AutoSuggestion/extensions/markText.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,17 @@ type marksConfig = {
3535

3636
export const markText = (config: marksConfig) => {
3737
const docLength = config.view.state.doc.length;
38-
if (!docLength) return { from: 0, to: 0 };
3938
const strikeMark = Decoration.mark({
4039
class: config.className,
4140
attributes: {
4241
title: config.title ?? "",
4342
},
4443
});
4544
const stopRange = Math.min(config.to, docLength);
45+
if (!docLength || config.from === stopRange) return { from: 0, to: 0 };
4646
config.view.dispatch({
4747
effects: addMarks.of([strikeMark.range(config.from, stopRange)] as any),
4848
});
49-
5049
return { from: config.from, to: stopRange };
5150
};
5251

0 commit comments

Comments
 (0)