diff --git a/.changeset/smooth-rice-obey.md b/.changeset/smooth-rice-obey.md new file mode 100644 index 000000000..8a73ee788 --- /dev/null +++ b/.changeset/smooth-rice-obey.md @@ -0,0 +1,12 @@ +--- +"@tiptap/react": patch +--- + +Optimize `useEditor` and `useEditorState` to reduce number of instances created while still being performant #5432 + +The core of this change is two-fold: + - have the effect run on every render (i.e. without a dep array) + - schedule destruction of instances, but bail on the actual destruction if the instance was still mounted and a new instance had not been created yet + +It should plug a memory leak, where editor instances could be created but not cleaned up in strict mode. +As well as fixing a bug where a re-render, with deps, was not applying new options that were set on `useEditor`. diff --git a/.eslintrc.js b/.eslintrc.js index ebea8e454..18cd55d3a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,6 +8,15 @@ module.exports = { node: true, }, overrides: [ + { + files: [ + './**/*.ts', + './**/*.tsx', + './**/*.js', + './**/*.jsx', + ], + extends: ['plugin:react-hooks/recommended'], + }, { files: [ './**/*.ts', diff --git a/demos/src/Commands/Cut/React/index.jsx b/demos/src/Commands/Cut/React/index.jsx index 66a871ec2..02bea76cd 100644 --- a/demos/src/Commands/Cut/React/index.jsx +++ b/demos/src/Commands/Cut/React/index.jsx @@ -8,10 +8,6 @@ import StarterKit from '@tiptap/starter-kit' import React, { useCallback } from 'react' const MenuBar = ({ editor }) => { - if (!editor) { - return null - } - const onCutToStart = useCallback(() => { editor.chain().cut({ from: editor.state.selection.$from.pos, to: editor.state.selection.$to.pos }, 1).run() }, [editor]) @@ -20,6 +16,10 @@ const MenuBar = ({ editor }) => { editor.chain().cut({ from: editor.state.selection.$from.pos, to: editor.state.selection.$to.pos }, editor.state.doc.nodeSize - 2).run() }, [editor]) + if (!editor) { + return null + } + return (
diff --git a/package-lock.json b/package-lock.json
index 04c67060c..795aab055 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -35,6 +35,7 @@
"eslint-plugin-cypress": "^2.15.2",
"eslint-plugin-html": "^6.2.0",
"eslint-plugin-import": "^2.29.1",
+ "eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-vue": "^9.27.0",
"husky": "^8.0.3",
@@ -8942,6 +8943,18 @@
"node": ">=0.10.0"
}
},
+ "node_modules/eslint-plugin-react-hooks": {
+ "version": "4.6.2",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz",
+ "integrity": "sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==",
+ "dev": true,
+ "engines": {
+ "node": ">=10"
+ },
+ "peerDependencies": {
+ "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0"
+ }
+ },
"node_modules/eslint-plugin-simple-import-sort": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-7.0.0.tgz",
@@ -17902,159 +17915,159 @@
},
"packages/core": {
"name": "@tiptap/core",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-blockquote": {
"name": "@tiptap/extension-blockquote",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-bold": {
"name": "@tiptap/extension-bold",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-bubble-menu": {
"name": "@tiptap/extension-bubble-menu",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"dependencies": {
"tippy.js": "^6.3.7"
},
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-bullet-list": {
"name": "@tiptap/extension-bullet-list",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-character-count": {
"name": "@tiptap/extension-character-count",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-code": {
"name": "@tiptap/extension-code",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-code-block": {
"name": "@tiptap/extension-code-block",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-code-block-lowlight": {
"name": "@tiptap/extension-code-block-lowlight",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/extension-code-block": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/extension-code-block": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/extension-code-block": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/extension-code-block": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-collaboration": {
"name": "@tiptap/extension-collaboration",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7",
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8",
"y-prosemirror": "^1.2.9"
},
"funding": {
@@ -18062,17 +18075,17 @@
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7",
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8",
"y-prosemirror": "^1.2.6"
}
},
"packages/extension-collaboration-cursor": {
"name": "@tiptap/extension-collaboration-cursor",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
+ "@tiptap/core": "^2.5.8",
"y-prosemirror": "^1.2.9"
},
"funding": {
@@ -18080,607 +18093,607 @@
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
+ "@tiptap/core": "^2.5.8",
"y-prosemirror": "^1.2.6"
}
},
"packages/extension-color": {
"name": "@tiptap/extension-color",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/extension-text-style": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/extension-text-style": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/extension-text-style": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/extension-text-style": "^2.5.8"
}
},
"packages/extension-document": {
"name": "@tiptap/extension-document",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-dropcursor": {
"name": "@tiptap/extension-dropcursor",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-floating-menu": {
"name": "@tiptap/extension-floating-menu",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"dependencies": {
"tippy.js": "^6.3.7"
},
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-focus": {
"name": "@tiptap/extension-focus",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-font-family": {
"name": "@tiptap/extension-font-family",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/extension-text-style": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/extension-text-style": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/extension-text-style": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/extension-text-style": "^2.5.8"
}
},
"packages/extension-gapcursor": {
"name": "@tiptap/extension-gapcursor",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-hard-break": {
"name": "@tiptap/extension-hard-break",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-heading": {
"name": "@tiptap/extension-heading",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-highlight": {
"name": "@tiptap/extension-highlight",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-history": {
"name": "@tiptap/extension-history",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-horizontal-rule": {
"name": "@tiptap/extension-horizontal-rule",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-image": {
"name": "@tiptap/extension-image",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-italic": {
"name": "@tiptap/extension-italic",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-link": {
"name": "@tiptap/extension-link",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"dependencies": {
"linkifyjs": "^4.1.0"
},
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-list-item": {
"name": "@tiptap/extension-list-item",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-list-keymap": {
"name": "@tiptap/extension-list-keymap",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-mention": {
"name": "@tiptap/extension-mention",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7",
- "@tiptap/suggestion": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8",
+ "@tiptap/suggestion": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7",
- "@tiptap/suggestion": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8",
+ "@tiptap/suggestion": "^2.5.8"
}
},
"packages/extension-ordered-list": {
"name": "@tiptap/extension-ordered-list",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-paragraph": {
"name": "@tiptap/extension-paragraph",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-placeholder": {
"name": "@tiptap/extension-placeholder",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-strike": {
"name": "@tiptap/extension-strike",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-subscript": {
"name": "@tiptap/extension-subscript",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-superscript": {
"name": "@tiptap/extension-superscript",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-table": {
"name": "@tiptap/extension-table",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-table-cell": {
"name": "@tiptap/extension-table-cell",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-table-header": {
"name": "@tiptap/extension-table-header",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-table-row": {
"name": "@tiptap/extension-table-row",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-task-item": {
"name": "@tiptap/extension-task-item",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/extension-task-list": {
"name": "@tiptap/extension-task-list",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-text": {
"name": "@tiptap/extension-text",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-text-align": {
"name": "@tiptap/extension-text-align",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-text-style": {
"name": "@tiptap/extension-text-style",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-typography": {
"name": "@tiptap/extension-typography",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-underline": {
"name": "@tiptap/extension-underline",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/extension-youtube": {
"name": "@tiptap/extension-youtube",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7"
+ "@tiptap/core": "^2.5.8"
}
},
"packages/html": {
"name": "@tiptap/html",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"dependencies": {
"zeed-dom": "^0.10.9"
},
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/pm": {
"name": "@tiptap/pm",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"dependencies": {
"prosemirror-changeset": "^2.2.1",
@@ -18709,17 +18722,17 @@
},
"packages/react": {
"name": "@tiptap/react",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"dependencies": {
- "@tiptap/extension-bubble-menu": "^2.5.7",
- "@tiptap/extension-floating-menu": "^2.5.7",
+ "@tiptap/extension-bubble-menu": "^2.5.8",
+ "@tiptap/extension-floating-menu": "^2.5.8",
"@types/use-sync-external-store": "^0.0.6",
"use-sync-external-store": "^1.2.2"
},
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7",
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"react": "^18.0.0",
@@ -18730,36 +18743,36 @@
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7",
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8",
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0"
}
},
"packages/starter-kit": {
"name": "@tiptap/starter-kit",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"dependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/extension-blockquote": "^2.5.7",
- "@tiptap/extension-bold": "^2.5.7",
- "@tiptap/extension-bullet-list": "^2.5.7",
- "@tiptap/extension-code": "^2.5.7",
- "@tiptap/extension-code-block": "^2.5.7",
- "@tiptap/extension-document": "^2.5.7",
- "@tiptap/extension-dropcursor": "^2.5.7",
- "@tiptap/extension-gapcursor": "^2.5.7",
- "@tiptap/extension-hard-break": "^2.5.7",
- "@tiptap/extension-heading": "^2.5.7",
- "@tiptap/extension-history": "^2.5.7",
- "@tiptap/extension-horizontal-rule": "^2.5.7",
- "@tiptap/extension-italic": "^2.5.7",
- "@tiptap/extension-list-item": "^2.5.7",
- "@tiptap/extension-ordered-list": "^2.5.7",
- "@tiptap/extension-paragraph": "^2.5.7",
- "@tiptap/extension-strike": "^2.5.7",
- "@tiptap/extension-text": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/extension-blockquote": "^2.5.8",
+ "@tiptap/extension-bold": "^2.5.8",
+ "@tiptap/extension-bullet-list": "^2.5.8",
+ "@tiptap/extension-code": "^2.5.8",
+ "@tiptap/extension-code-block": "^2.5.8",
+ "@tiptap/extension-document": "^2.5.8",
+ "@tiptap/extension-dropcursor": "^2.5.8",
+ "@tiptap/extension-gapcursor": "^2.5.8",
+ "@tiptap/extension-hard-break": "^2.5.8",
+ "@tiptap/extension-heading": "^2.5.8",
+ "@tiptap/extension-history": "^2.5.8",
+ "@tiptap/extension-horizontal-rule": "^2.5.8",
+ "@tiptap/extension-italic": "^2.5.8",
+ "@tiptap/extension-list-item": "^2.5.8",
+ "@tiptap/extension-ordered-list": "^2.5.8",
+ "@tiptap/extension-paragraph": "^2.5.8",
+ "@tiptap/extension-strike": "^2.5.8",
+ "@tiptap/extension-text": "^2.5.8"
},
"funding": {
"type": "github",
@@ -18768,33 +18781,33 @@
},
"packages/suggestion": {
"name": "@tiptap/suggestion",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7"
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8"
}
},
"packages/vue-2": {
"name": "@tiptap/vue-2",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"dependencies": {
- "@tiptap/extension-bubble-menu": "^2.5.7",
- "@tiptap/extension-floating-menu": "^2.5.7",
+ "@tiptap/extension-bubble-menu": "^2.5.8",
+ "@tiptap/extension-floating-menu": "^2.5.8",
"vue-ts-types": "^1.6.0"
},
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7",
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8",
"vue": "^2.6.0"
},
"funding": {
@@ -18802,8 +18815,8 @@
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7",
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8",
"vue": "^2.6.0"
}
},
@@ -18834,15 +18847,15 @@
},
"packages/vue-3": {
"name": "@tiptap/vue-3",
- "version": "2.5.7",
+ "version": "2.5.8",
"license": "MIT",
"dependencies": {
- "@tiptap/extension-bubble-menu": "^2.5.7",
- "@tiptap/extension-floating-menu": "^2.5.7"
+ "@tiptap/extension-bubble-menu": "^2.5.8",
+ "@tiptap/extension-floating-menu": "^2.5.8"
},
"devDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7",
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8",
"vue": "^3.0.0"
},
"funding": {
@@ -18850,8 +18863,8 @@
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
- "@tiptap/core": "^2.5.7",
- "@tiptap/pm": "^2.5.7",
+ "@tiptap/core": "^2.5.8",
+ "@tiptap/pm": "^2.5.8",
"vue": "^3.0.0"
}
},
diff --git a/package.json b/package.json
index cf21df115..84132d251 100644
--- a/package.json
+++ b/package.json
@@ -58,6 +58,7 @@
"eslint-plugin-cypress": "^2.15.2",
"eslint-plugin-html": "^6.2.0",
"eslint-plugin-import": "^2.29.1",
+ "eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-vue": "^9.27.0",
"husky": "^8.0.3",
diff --git a/packages/react/src/useEditor.ts b/packages/react/src/useEditor.ts
index 2eca1f2f0..2fde5b2ce 100644
--- a/packages/react/src/useEditor.ts
+++ b/packages/react/src/useEditor.ts
@@ -1,8 +1,13 @@
import { EditorOptions } from '@tiptap/core'
import {
- DependencyList, MutableRefObject,
- useDebugValue, useEffect, useRef, useState,
+ DependencyList,
+ MutableRefObject,
+ useDebugValue,
+ useEffect,
+ useRef,
+ useState,
} from 'react'
+import { useSyncExternalStore } from 'use-sync-external-store/shim'
import { Editor } from './Editor.js'
import { useEditorState } from './useEditorState.js'
@@ -31,22 +36,241 @@ export type UseEditorOptions = Partial