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.
This commit is contained in:
committed by
Jacob Overgaard
parent
effa40fabb
commit
28fb7ad67e
@@ -66,23 +66,21 @@ export class UmbInputTiptapElement extends UmbFormControlMixin<string, typeof Um
|
||||
}
|
||||
|
||||
async #loadExtensions() {
|
||||
const enabledExtensions = this.configuration?.getValueByAlias<string[]>('extensions') ?? [];
|
||||
|
||||
// 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<void>((resolve) => {
|
||||
this.observe(umbExtensionsRegistry.byType('tiptapExtension'), async (manifests) => {
|
||||
let enabledExtensions = this.configuration?.getValueByAlias<string[]>('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];
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user