diff --git a/src/extensions/Keymap.js b/src/extensions/Keymap.js index 81883699329..e2fe7fed634 100644 --- a/src/extensions/Keymap.js +++ b/src/extensions/Keymap.js @@ -11,7 +11,13 @@ const Keymap = Extension.create({ name: 'customkeymap', addKeyboardShortcuts() { - return this.options + return { + /** + * + * Allows to undo input rules after they got automatically applied + */ + Backspace: () => this.editor.commands.undoInputRule(), + } }, addProseMirrorPlugins() { diff --git a/src/extensions/RichText.js b/src/extensions/RichText.js index e131ad9b1ab..c67b7790d37 100644 --- a/src/extensions/RichText.js +++ b/src/extensions/RichText.js @@ -118,11 +118,15 @@ export default Extension.create({ TrailingNode, TextDirection.configure({ types: [ + 'blockquote', + 'callout', + 'detailsSummary', 'heading', - 'paragraph', 'listItem', + 'paragraph', + 'tableCell', + 'tableHeader', 'taskItem', - 'blockquote', ], }), ] diff --git a/src/extensions/TextDirection.ts b/src/extensions/TextDirection.ts index 5142b171306..4be8d079042 100644 --- a/src/extensions/TextDirection.ts +++ b/src/extensions/TextDirection.ts @@ -3,8 +3,13 @@ * SPDX-License-Identifier: MIT */ -import { Extension } from '@tiptap/core' -import { Plugin, PluginKey } from '@tiptap/pm/state' +import { + Extension, + combineTransactionSteps, + findChildrenInRange, + getChangedRanges, +} from '@tiptap/core' +import { Plugin, PluginKey, Transaction } from '@tiptap/pm/state' const RTL = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC' const LTR = 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6' @@ -53,11 +58,21 @@ function TextDirectionPlugin({ types }: { types: string[] }) { } let modified = false - const tr = newState.tr + const { tr } = newState + const transform = combineTransactionSteps( + oldState.doc, + transactions as Transaction[], + ) + const changes = getChangedRanges(transform) + tr.setMeta('addToHistory', false) - newState.doc.descendants((node, pos) => { - if (types.includes(node.type.name)) { + changes.forEach(({ newRange }) => { + const nodes = findChildrenInRange(newState.doc, newRange, (node) => + types.includes(node.type.name), + ) + + nodes.forEach(({ node, pos }) => { if (node.attrs.dir !== null && node.textContent.length > 0) { return } @@ -73,7 +88,7 @@ function TextDirectionPlugin({ types }: { types: string[] }) { tr.addStoredMark(mark) } modified = true - } + }) }) return modified ? tr : null diff --git a/src/nodes/Callout.vue b/src/nodes/Callout.vue index 6bc58d2af25..0bf82b23209 100644 --- a/src/nodes/Callout.vue +++ b/src/nodes/Callout.vue @@ -6,6 +6,7 @@ @@ -41,7 +42,10 @@ export default { return ICONS_MAP[this.type] || Info }, type() { - return this.node?.attrs?.type || 'info' + return this.node.attrs.type || 'info' + }, + dir() { + return this.node.attrs.dir || '' }, }, } diff --git a/src/nodes/Table/TableCellView.vue b/src/nodes/Table/TableCellView.vue index 2293dd5d31a..87ae63fad9b 100644 --- a/src/nodes/Table/TableCellView.vue +++ b/src/nodes/Table/TableCellView.vue @@ -4,7 +4,10 @@ -->