From a343cfbd88df32f0fe88ae9eb5097f516a084987 Mon Sep 17 00:00:00 2001 From: leekelleher Date: Wed, 19 Feb 2025 10:22:48 +0000 Subject: [PATCH] Refactors loading core Tipap extension The unit test doesn't register the manifests, so we'll need to hard code loading the "Rich Text Essentials" extension. --- .../input-tiptap/input-tiptap.element.ts | 20 +++++++++---------- .../core/rich-text-essentials.tiptap-api.ts | 6 +++++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts b/src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts index 8ad71780369d..387f511eb1dc 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts @@ -66,23 +66,21 @@ export class UmbInputTiptapElement extends UmbFormControlMixin((resolve) => { - this.observe(umbExtensionsRegistry.byType('tiptapExtension'), async (manifests) => { - let enabledExtensions = this.configuration?.getValueByAlias('extensions') ?? []; + const enabledExtensions = this.configuration?.getValueByAlias('extensions') ?? []; - // Ensures that the "Rich Text Essentials" extension is always enabled. [LK] - if (!enabledExtensions.includes(TIPTAP_CORE_EXTENSION_ALIAS)) { - enabledExtensions = [TIPTAP_CORE_EXTENSION_ALIAS, ...enabledExtensions]; - } + // Ensures that the "Rich Text Essentials" extension is always enabled. [LK] + if (!enabledExtensions.includes(TIPTAP_CORE_EXTENSION_ALIAS)) { + const { api } = await import('../../extensions/core/rich-text-essentials.tiptap-api.js'); + this._extensions.push(new api(this)); + } + await new Promise((resolve) => { + this.observe(umbExtensionsRegistry.byTypeAndAliases('tiptapExtension', enabledExtensions), async (manifests) => { for (const manifest of manifests) { if (manifest.api) { const extension = await loadManifestApi(manifest.api); if (extension) { - // Check if the extension is enabled - if (enabledExtensions.includes(manifest.alias)) { - this._extensions.push(new extension(this)); - } + this._extensions.push(new extension(this)); } } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/core/rich-text-essentials.tiptap-api.ts b/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/core/rich-text-essentials.tiptap-api.ts index bee52bf76dfc..481edecdcede 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/core/rich-text-essentials.tiptap-api.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/core/rich-text-essentials.tiptap-api.ts @@ -9,7 +9,7 @@ import { TextStyle, } from '@umbraco-cms/backoffice/external/tiptap'; -export default class UmbTiptapRichTextEssentialsExtensionApi extends UmbTiptapExtensionApiBase { +export class UmbTiptapRichTextEssentialsExtensionApi extends UmbTiptapExtensionApiBase { #localize = new UmbLocalizationController(this); getTiptapExtensions = () => [ @@ -55,3 +55,7 @@ export default class UmbTiptapRichTextEssentialsExtensionApi extends UmbTiptapEx Span, ]; } + +export default UmbTiptapRichTextEssentialsExtensionApi; + +export { UmbTiptapRichTextEssentialsExtensionApi as api };