editor: update tiptap packages to v2.0.3

This commit is contained in:
Abdullah Atta
2023-05-25 09:43:40 +05:00
committed by Abdullah Atta
parent b77711a53d
commit 3b727e6f64
5 changed files with 392 additions and 418 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -10,27 +10,27 @@
"@social-embed/lib": "^0.0.2-next.1",
"@theme-ui/components": "^0.14.7",
"@theme-ui/core": "^0.14.7",
"@tiptap/core": "^2.0.0-beta.220",
"@tiptap/extension-character-count": "^2.0.0-beta.220",
"@tiptap/extension-color": "^2.0.0-beta.220",
"@tiptap/extension-font-family": "^2.0.0-beta.220",
"@tiptap/extension-history": "^2.0.0-beta.220",
"@tiptap/extension-horizontal-rule": "^2.0.0-beta.220",
"@tiptap/extension-link": "^2.0.0-beta.220",
"@tiptap/extension-placeholder": "^2.0.0-beta.220",
"@tiptap/extension-subscript": "^2.0.0-beta.220",
"@tiptap/extension-superscript": "^2.0.0-beta.220",
"@tiptap/extension-table": "^2.0.0-beta.220",
"@tiptap/extension-table-cell": "^2.0.0-beta.220",
"@tiptap/extension-table-header": "^2.0.0-beta.220",
"@tiptap/extension-table-row": "^2.0.0-beta.220",
"@tiptap/extension-task-item": "^2.0.0-beta.220",
"@tiptap/extension-task-list": "^2.0.0-beta.220",
"@tiptap/extension-text-align": "^2.0.0-beta.220",
"@tiptap/extension-text-style": "^2.0.0-beta.220",
"@tiptap/extension-underline": "^2.0.0-beta.220",
"@tiptap/pm": "^2.0.0-beta.220",
"@tiptap/starter-kit": "^2.0.0-beta.220",
"@tiptap/core": "2.0.3",
"@tiptap/extension-character-count": "2.0.3",
"@tiptap/extension-color": "2.0.3",
"@tiptap/extension-font-family": "2.0.3",
"@tiptap/extension-history": "2.0.3",
"@tiptap/extension-horizontal-rule": "2.0.3",
"@tiptap/extension-link": "2.0.3",
"@tiptap/extension-placeholder": "2.0.3",
"@tiptap/extension-subscript": "2.0.3",
"@tiptap/extension-superscript": "2.0.3",
"@tiptap/extension-table": "2.0.3",
"@tiptap/extension-table-cell": "2.0.3",
"@tiptap/extension-table-header": "2.0.3",
"@tiptap/extension-table-row": "2.0.3",
"@tiptap/extension-task-item": "2.0.3",
"@tiptap/extension-task-list": "2.0.3",
"@tiptap/extension-text-align": "2.0.3",
"@tiptap/extension-text-style": "2.0.3",
"@tiptap/extension-underline": "2.0.3",
"@tiptap/pm": "2.0.3",
"@tiptap/starter-kit": "2.0.3",
"detect-indent": "^7.0.0",
"katex": "^0.16.2",
"nanoid": "^4.0.1",

View File

@@ -1,29 +0,0 @@
diff --git a/node_modules/@tiptap/core/dist/index.js b/node_modules/@tiptap/core/dist/index.js
index 163e352..8cd7ec6 100644
--- a/node_modules/@tiptap/core/dist/index.js
+++ b/node_modules/@tiptap/core/dist/index.js
@@ -3129,8 +3129,7 @@ const Keymap = Extension.create({
new Plugin({
key: new PluginKey('clearDocument'),
appendTransaction: (transactions, oldState, newState) => {
- const docChanges = transactions.some(transaction => transaction.docChanged)
- && !oldState.doc.eq(newState.doc);
+ const docChanges = transactions.some(transaction => transaction.docChanged);
if (!docChanges) {
return;
}
@@ -3138,10 +3137,12 @@ const Keymap = Extension.create({
const allFrom = Selection.atStart(oldState.doc).from;
const allEnd = Selection.atEnd(oldState.doc).to;
const allWasSelected = from === allFrom && to === allEnd;
- const isEmpty = newState.doc.textBetween(0, newState.doc.content.size, ' ', ' ').length === 0;
- if (empty || !allWasSelected || !isEmpty) {
+ if (empty || !allWasSelected) {
return;
}
+ const isEmpty = newState.doc.textBetween(0, newState.doc.content.size, ' ', ' ').length === 0;
+ if (!isEmpty) return;
+
const tr = newState.tr;
const state = createChainableState({
state: newState,

View File

@@ -1,39 +0,0 @@
diff --git a/node_modules/@tiptap/extension-link/dist/index.cjs b/node_modules/@tiptap/extension-link/dist/index.cjs
index a79f326..a5f8fdd 100644
--- a/node_modules/@tiptap/extension-link/dist/index.cjs
+++ b/node_modules/@tiptap/extension-link/dist/index.cjs
@@ -101,6 +101,8 @@ function clickHandler(options) {
key: new state.PluginKey('handleClickLink'),
props: {
handleClick: (view, pos, event) => {
+ if (event.button !== 1) return;
+
var _a, _b, _c;
const attrs = core.getAttributes(view.state, options.type.name);
const link = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest('a');
diff --git a/node_modules/@tiptap/extension-link/dist/index.js b/node_modules/@tiptap/extension-link/dist/index.js
index d579117..3f6d893 100644
--- a/node_modules/@tiptap/extension-link/dist/index.js
+++ b/node_modules/@tiptap/extension-link/dist/index.js
@@ -97,6 +97,8 @@ function clickHandler(options) {
key: new PluginKey('handleClickLink'),
props: {
handleClick: (view, pos, event) => {
+ if (event.button !== 1) return;
+
var _a, _b, _c;
const attrs = getAttributes(view.state, options.type.name);
const link = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest('a');
diff --git a/node_modules/@tiptap/extension-link/dist/index.umd.js b/node_modules/@tiptap/extension-link/dist/index.umd.js
index 743ae18..643089d 100644
--- a/node_modules/@tiptap/extension-link/dist/index.umd.js
+++ b/node_modules/@tiptap/extension-link/dist/index.umd.js
@@ -99,6 +99,8 @@
key: new state.PluginKey('handleClickLink'),
props: {
handleClick: (view, pos, event) => {
+ if (event.button !== 1) return;
+
var _a, _b, _c;
const attrs = core.getAttributes(view.state, options.type.name);
const link = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest('a');

View File

@@ -0,0 +1,42 @@
diff --git a/node_modules/@tiptap/extension-link/dist/index.cjs b/node_modules/@tiptap/extension-link/dist/index.cjs
index 301cdb9..1390415 100644
--- a/node_modules/@tiptap/extension-link/dist/index.cjs
+++ b/node_modules/@tiptap/extension-link/dist/index.cjs
@@ -102,6 +102,7 @@ function clickHandler(options) {
props: {
handleClick: (view, pos, event) => {
var _a, _b, _c;
+ event.preventDefault()
if (event.button !== 0) {
return false;
}
@@ -110,7 +111,7 @@ function clickHandler(options) {
const href = (_b = link === null || link === void 0 ? void 0 : link.href) !== null && _b !== void 0 ? _b : attrs.href;
const target = (_c = link === null || link === void 0 ? void 0 : link.target) !== null && _c !== void 0 ? _c : attrs.target;
if (link && href) {
- window.open(href, target);
+ if (view.editable) window.open(href, target);
return true;
}
return false;
diff --git a/node_modules/@tiptap/extension-link/dist/index.js b/node_modules/@tiptap/extension-link/dist/index.js
index e3b8602..b75336f 100644
--- a/node_modules/@tiptap/extension-link/dist/index.js
+++ b/node_modules/@tiptap/extension-link/dist/index.js
@@ -97,6 +97,7 @@ function clickHandler(options) {
key: new PluginKey('handleClickLink'),
props: {
handleClick: (view, pos, event) => {
+ event.preventDefault()
var _a, _b, _c;
if (event.button !== 0) {
return false;
@@ -106,7 +107,7 @@ function clickHandler(options) {
const href = (_b = link === null || link === void 0 ? void 0 : link.href) !== null && _b !== void 0 ? _b : attrs.href;
const target = (_c = link === null || link === void 0 ? void 0 : link.target) !== null && _c !== void 0 ? _c : attrs.target;
if (link && href) {
- window.open(href, target);
+ if (view.editable) window.open(href, target);
return true;
}
return false;