Skip to content

Commit

Permalink
Merge pull request #230 from eccenca/bugfix/mt-fix104and98
Browse files Browse the repository at this point in the history
Fix for template field, prevent crashing on misformatted blocks
  • Loading branch information
haschek authored Dec 16, 2024
2 parents eb4180e + d14507b commit 7c474eb
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/components/AutoSuggestion/extensions/markText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,17 @@ type marksConfig = {

export const markText = (config: marksConfig) => {
const docLength = config.view.state.doc.length;
if (!docLength) return { from: 0, to: 0 };
const strikeMark = Decoration.mark({
class: config.className,
attributes: {
title: config.title ?? "",
},
});
const stopRange = Math.min(config.to, docLength);
if (!docLength || config.from === stopRange) return { from: 0, to: 0 };
config.view.dispatch({
effects: addMarks.of([strikeMark.range(config.from, stopRange)] as any),
});

return { from: config.from, to: stopRange };
};

Expand Down

0 comments on commit 7c474eb

Please sign in to comment.