From 963d5b736a6d056ef5cb5dc37d5a70e5ed2e4a8a Mon Sep 17 00:00:00 2001 From: kailunyao Date: Wed, 4 Sep 2024 17:27:37 +0800 Subject: [PATCH 1/3] fix(react): Fix incorrect extensionAttributes value --- .changeset/tricky-apricots-smash.md | 5 +++++ packages/react/src/ReactNodeViewRenderer.tsx | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/tricky-apricots-smash.md diff --git a/.changeset/tricky-apricots-smash.md b/.changeset/tricky-apricots-smash.md new file mode 100644 index 0000000000..89acc61c9b --- /dev/null +++ b/.changeset/tricky-apricots-smash.md @@ -0,0 +1,5 @@ +--- +"@tiptap/react": patch +--- + +Fix incorrect extensionAttributes value diff --git a/packages/react/src/ReactNodeViewRenderer.tsx b/packages/react/src/ReactNodeViewRenderer.tsx index 4f16c0c8c9..054b69130e 100644 --- a/packages/react/src/ReactNodeViewRenderer.tsx +++ b/packages/react/src/ReactNodeViewRenderer.tsx @@ -304,7 +304,9 @@ export class ReactNodeView< let attrsObj: Record = {} if (typeof this.options.attrs === 'function') { - const extensionAttributes = this.editor.extensionManager.attributes + const extensionAttributes = this.editor.extensionManager.attributes.filter( + attribute => attribute.type === this.node.type.name, + ) const HTMLAttributes = getRenderedAttributes(this.node, extensionAttributes) attrsObj = this.options.attrs({ node: this.node, HTMLAttributes }) From a091d53e332d34212d227f3e1b80068badc841a6 Mon Sep 17 00:00:00 2001 From: kailunyao Date: Mon, 23 Sep 2024 17:54:45 +0800 Subject: [PATCH 2/3] refactor(react): Moving the type filter to "getRenderedAttributes" function --- packages/core/src/helpers/getRenderedAttributes.ts | 3 +++ packages/react/src/ReactNodeViewRenderer.tsx | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/core/src/helpers/getRenderedAttributes.ts b/packages/core/src/helpers/getRenderedAttributes.ts index 5dd0855a26..fd85e699a6 100644 --- a/packages/core/src/helpers/getRenderedAttributes.ts +++ b/packages/core/src/helpers/getRenderedAttributes.ts @@ -8,6 +8,9 @@ export function getRenderedAttributes( extensionAttributes: ExtensionAttribute[], ): Record { return extensionAttributes + .filter( + attribute => attribute.type === nodeOrMark.type.name, + ) .filter(item => item.attribute.rendered) .map(item => { if (!item.attribute.renderHTML) { diff --git a/packages/react/src/ReactNodeViewRenderer.tsx b/packages/react/src/ReactNodeViewRenderer.tsx index 054b69130e..4f16c0c8c9 100644 --- a/packages/react/src/ReactNodeViewRenderer.tsx +++ b/packages/react/src/ReactNodeViewRenderer.tsx @@ -304,9 +304,7 @@ export class ReactNodeView< let attrsObj: Record = {} if (typeof this.options.attrs === 'function') { - const extensionAttributes = this.editor.extensionManager.attributes.filter( - attribute => attribute.type === this.node.type.name, - ) + const extensionAttributes = this.editor.extensionManager.attributes const HTMLAttributes = getRenderedAttributes(this.node, extensionAttributes) attrsObj = this.options.attrs({ node: this.node, HTMLAttributes }) From 9ddc31bb5753aae3dc92ab987fb5dcf251d69c7d Mon Sep 17 00:00:00 2001 From: Nick Perez Date: Tue, 24 Sep 2024 22:37:58 +0200 Subject: [PATCH 3/3] chore: update changeset --- .changeset/tricky-apricots-smash.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/tricky-apricots-smash.md b/.changeset/tricky-apricots-smash.md index 89acc61c9b..c56f556ae9 100644 --- a/.changeset/tricky-apricots-smash.md +++ b/.changeset/tricky-apricots-smash.md @@ -1,5 +1,5 @@ --- -"@tiptap/react": patch +"@tiptap/core": patch --- -Fix incorrect extensionAttributes value +filter rendered extensionAttributes (#5588)