Skip to content

Commit d7d52dd

Browse files
leekelleherclaude
authored andcommitted
fix(rte): Deduplicate Tiptap extensions to prevent duplicate name warnings
When multiple Umbraco extensions (e.g., BulletList and OrderedList) include the same Tiptap extension (ListItem), duplicates were added to the extensions array, causing Tiptap to log warnings. This change uses a Map to deduplicate extensions by their name property before passing them to the Editor. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 4750101 commit d7d52dd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Editor } from '../../externals.js';
22
import { UmbTiptapRteContext } from '../../contexts/tiptap-rte.context.js';
3-
import type { Extensions } from '../../externals.js';
3+
import type { AnyExtension } from '../../externals.js';
44
import type { UmbTiptapExtensionApi } from '../../extensions/types.js';
55
import type { UmbTiptapStatusbarValue, UmbTiptapToolbarValue } from '../types.js';
66
import {
@@ -156,12 +156,16 @@ export class UmbInputTiptapElement extends UmbFormControlMixin<string, typeof Um
156156
this._toolbar = this.configuration?.getValueByAlias<UmbTiptapToolbarValue>('toolbar') ?? [[[]]];
157157
this._statusbar = this.configuration?.getValueByAlias<UmbTiptapStatusbarValue>('statusbar') ?? [];
158158

159-
const tiptapExtensions: Extensions = [];
159+
const tiptapExtensions = new Map<string, AnyExtension>();
160160

161161
this._extensions.forEach((ext) => {
162162
const tiptapExt = ext.getTiptapExtensions({ configuration: this.configuration });
163163
if (tiptapExt?.length) {
164-
tiptapExtensions.push(...tiptapExt);
164+
tiptapExt.forEach((extension) => {
165+
if (!tiptapExtensions.has(extension.name)) {
166+
tiptapExtensions.set(extension.name, extension);
167+
}
168+
});
165169
}
166170

167171
const styles = ext.getStyles();
@@ -179,7 +183,7 @@ export class UmbInputTiptapElement extends UmbFormControlMixin<string, typeof Um
179183
'aria-required': this.required ? 'true' : 'false',
180184
},
181185
},
182-
extensions: tiptapExtensions,
186+
extensions: Array.from(tiptapExtensions.values()),
183187
content: this.#value,
184188
injectCSS: false, // Prevents injecting CSS into `window.document`, as it never applies to the shadow DOM. [LK]
185189
//enableContentCheck: true,

0 commit comments

Comments
 (0)