A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
editor: fix crash when adding tasklist using md in heading or other nodes (#5923)
Muhammad Aliac85002dfff7
diff --git a/packages/editor/src/extensions/task-list/task-list.ts b/packages/editor/src/extensions/task-list/task-list.tsindex bc62f4aaa..73f6b862f 100644--- a/packages/editor/src/extensions/task-list/task-list.ts+++ b/packages/editor/src/extensions/task-list/task-list.ts@@ -347,9 +347,23 @@ export const TaskListNode = TaskList.extend({});const oldHandler = inputRule.handler;inputRule.handler = ({ state, range, match, chain, can, commands }) => {- oldHandler({ state, range, match, chain, can, commands });+ const tr = state.tr;+ // reset nodes before converting them to a task list.+ commands.clearNodes();++ oldHandler({+ state,+ range: {+ from: tr.mapping.map(range.from),+ to: tr.mapping.map(range.to)+ },+ match,+ chain,+ can,+ commands+ });- state.tr.setNodeMarkup(state.tr.selection.to - 2, undefined, {+ tr.setNodeMarkup(state.tr.selection.to - 2, undefined, {checked: match[match.length - 1] === "x"});};