Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: fix notes with task lists taking too long to load

Abdullah Attaad2b68c8ed82
diff --git a/packages/editor/patches/@tiptap+core+2.2.4.patch b/packages/editor/patches/@tiptap+core+2.2.4.patch
index b13604194..87f9dfe2c 100644
--- a/packages/editor/patches/@tiptap+core+2.2.4.patch
+++ b/packages/editor/patches/@tiptap+core+2.2.4.patch
@@ -1,5 +1,5 @@
diff --git a/node_modules/@tiptap/core/dist/index.cjs b/node_modules/@tiptap/core/dist/index.cjs
-index 1ea30e0..03c80e2 100644
+index 1ea30e0..2291615 100644
--- a/node_modules/@tiptap/core/dist/index.cjs
+++ b/node_modules/@tiptap/core/dist/index.cjs
@@ -383,7 +383,7 @@ function fromString(value) {
@@ -115,7 +115,7 @@ index 1ea30e0..03c80e2 100644
return;
}
const isEmpty = newState.doc.textBetween(0, newState.doc.content.size, ' ', ' ').length === 0;
-@@ -3788,23 +3792,29 @@ class Editor extends EventEmitter {
+@@ -3788,23 +3792,28 @@ class Editor extends EventEmitter {
* Creates a ProseMirror view.
*/
createView() {
@@ -133,25 +133,21 @@ index 1ea30e0..03c80e2 100644
+ doc: this.schema.topNodeType.create(),
+ })
});
-- // `editor.view` is not yet available at this time.
-- // Therefore we will add all plugins and node views directly afterwards.
++
++ const doc = createDocument(this.options.content, this.schema, this.options.parseOptions);
++ const selection = resolveFocusPosition(doc, this.options.autofocus);
+ // `editor.view` is not yet available at this time.
+ // Therefore we will add all plugins and node views directly afterwards.
- const newState = this.state.reconfigure({
-- plugins: this.extensionManager.plugins,
-+ setTimeout(() => {
-+ const doc = createDocument(this.options.content, this.schema, this.options.parseOptions);
-+ const selection = resolveFocusPosition(doc, this.options.autofocus);
-+ // `editor.view` is not yet available at this time.
-+ // Therefore we will add all plugins and node views directly afterwards.
-+ const newState = EditorState.create({
-+ plugins: this.extensionManager.plugins,
-+ doc,
-+ selection
-+ });
++ const newState = EditorState.create({
+ plugins: this.extensionManager.plugins,
++ doc,
++ selection
++ });
+
-+ this.view.setProps({
-+ state: newState,
-+ nodeViews: this.extensionManager.nodeViews
-+ })
++ this.view.setProps({
++ state: newState,
++ nodeViews: this.extensionManager.nodeViews
});
- this.view.updateState(newState);
- this.createNodeViews();
@@ -159,7 +155,7 @@ index 1ea30e0..03c80e2 100644
// Let’s store the editor instance in the DOM element.
// So we’ll have access to it for tests.
diff --git a/node_modules/@tiptap/core/dist/index.js b/node_modules/@tiptap/core/dist/index.js
-index 554e919..f1e9726 100644
+index 554e919..28fc1c1 100644
--- a/node_modules/@tiptap/core/dist/index.js
+++ b/node_modules/@tiptap/core/dist/index.js
@@ -379,9 +379,10 @@ function fromString(value) {
@@ -278,7 +274,7 @@ index 554e919..f1e9726 100644
return;
}
const isEmpty = newState.doc.textBetween(0, newState.doc.content.size, ' ', ' ').length === 0;
-@@ -3784,23 +3789,30 @@ class Editor extends EventEmitter {
+@@ -3784,23 +3789,28 @@ class Editor extends EventEmitter {
* Creates a ProseMirror view.
*/
createView() {
@@ -294,26 +290,21 @@ index 554e919..f1e9726 100644
+ doc: this.schema.topNodeType.create(),
+ })
});
-- // `editor.view` is not yet available at this time.
-- // Therefore we will add all plugins and node views directly afterwards.
++
++ const doc = createDocument(this.options.content, this.schema, this.options.parseOptions);
++ const selection = resolveFocusPosition(doc, this.options.autofocus);
+ // `editor.view` is not yet available at this time.
+ // Therefore we will add all plugins and node views directly afterwards.
- const newState = this.state.reconfigure({
-- plugins: this.extensionManager.plugins,
-+
-+ setTimeout(() => {
-+ const doc = createDocument(this.options.content, this.schema, this.options.parseOptions);
-+ const selection = resolveFocusPosition(doc, this.options.autofocus);
-+ // `editor.view` is not yet available at this time.
-+ // Therefore we will add all plugins and node views directly afterwards.
-+ const newState = EditorState.create({
-+ plugins: this.extensionManager.plugins,
-+ doc,
-+ selection
-+ });
++ const newState = EditorState.create({
+ plugins: this.extensionManager.plugins,
++ doc,
++ selection
++ });
+
-+ this.view.setProps({
-+ state: newState,
-+ nodeViews: this.extensionManager.nodeViews
-+ })
++ this.view.setProps({
++ state: newState,
++ nodeViews: this.extensionManager.nodeViews
});
- this.view.updateState(newState);
- this.createNodeViews();