From 2390cf20c1da7b8d6ac6951a24a9deaf81cb1955 Mon Sep 17 00:00:00 2001 From: MOHAMMAD RASIM Date: Sat, 6 Apr 2024 00:54:54 +0300 Subject: [PATCH] fix for data attributes not rendering after pr #4082 (#4980) --- docs/api/nodes/mention.md | 2 +- packages/extension-mention/src/mention.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/api/nodes/mention.md b/docs/api/nodes/mention.md index b9911dbd7..564682c8d 100644 --- a/docs/api/nodes/mention.md +++ b/docs/api/nodes/mention.md @@ -61,7 +61,7 @@ Mention.configure({ renderHTML({ options, node }) { return [ "a", - { href: '/profile/1' }, + mergeAttributes({ href: '/profile/1' }, options.HTMLAttributes), `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`, ]; } diff --git a/packages/extension-mention/src/mention.ts b/packages/extension-mention/src/mention.ts index 2938cfb02..04f426aa3 100644 --- a/packages/extension-mention/src/mention.ts +++ b/packages/extension-mention/src/mention.ts @@ -26,7 +26,7 @@ export const Mention = Node.create({ renderHTML({ options, node }) { return [ 'span', - this.HTMLAttributes, + mergeAttributes(this.HTMLAttributes, options.HTMLAttributes), `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`, ] }, @@ -131,8 +131,11 @@ export const Mention = Node.create({ }), ] } + const mergedOptions = { ...this.options } + + mergedOptions.HTMLAttributes = mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes) const html = this.options.renderHTML({ - options: this.options, + options: mergedOptions, node, })