diff --git a/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/base.ts b/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/base.ts new file mode 100644 index 0000000000..3fba20f6ba --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/base.ts @@ -0,0 +1,61 @@ +import type { + ManifestTiptapExtension, + ManifestTiptapToolbarExtension, + UmbTiptapExtensionApi, + UmbTiptapExtensionArgs, + UmbTiptapToolbarElementApi, +} from './types.js'; +import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api'; +import type { Editor, Extension, Mark, Node } from '@umbraco-cms/backoffice/external/tiptap'; +import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor'; + +export abstract class UmbTiptapExtensionApiBase extends UmbControllerBase implements UmbTiptapExtensionApi { + /** + * The manifest for the extension. + */ + manifest?: ManifestTiptapExtension; + + /** + * The editor instance. + */ + protected _editor?: Editor; + + /** + * @inheritdoc + */ + setEditor(editor: Editor): void { + this._editor = editor; + } + + /** + * @inheritdoc + */ + abstract getTiptapExtensions(args?: UmbTiptapExtensionArgs): Array; +} + +export abstract class UmbTiptapToolbarElementApiBase extends UmbControllerBase implements UmbTiptapToolbarElementApi { + /** + * The manifest for the extension. + */ + manifest?: ManifestTiptapToolbarExtension; + + /** + * The data type configuration for the property editor that the editor is used for. + */ + configuration?: UmbPropertyEditorConfigCollection; + + /** + * A method to execute the toolbar element action. + */ + public abstract execute(editor: Editor): void; + + /** + * Informs the toolbar element if it is active or not. It uses the manifest meta alias to check if the toolbar element is active. + * @see {ManifestTiptapToolbarExtension} + * @param {Editor} editor The editor instance. + * @returns {boolean} Returns true if the toolbar element is active. + */ + public isActive(editor: Editor) { + return editor && this.manifest?.meta.alias ? editor?.isActive(this.manifest.meta.alias) : false; + } +} diff --git a/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/index.ts b/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/index.ts index 06c33f562f..ffd2be35b6 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/index.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/index.ts @@ -1 +1,2 @@ +export * from './base.js'; export type * from './types.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/types.ts b/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/types.ts index 49fa890922..67bdb4adfc 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/types.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/types.ts @@ -1,6 +1,5 @@ import type { ManifestTiptapExtension } from './tiptap-extension.js'; import type { ManifestTiptapToolbarExtension } from './tiptap-toolbar-extension.js'; -import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api'; import type { Editor, Extension, Mark, Node } from '@umbraco-cms/backoffice/external/tiptap'; import type { UmbApi } from '@umbraco-cms/backoffice/extension-api'; import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor'; @@ -25,30 +24,6 @@ export interface UmbTiptapExtensionApi extends UmbApi { getTiptapExtensions(args?: UmbTiptapExtensionArgs): Array; } -export abstract class UmbTiptapExtensionApiBase extends UmbControllerBase implements UmbTiptapExtensionApi { - /** - * The manifest for the extension. - */ - manifest?: ManifestTiptapExtension; - - /** - * The editor instance. - */ - protected _editor?: Editor; - - /** - * @inheritdoc - */ - setEditor(editor: Editor): void { - this._editor = editor; - } - - /** - * @inheritdoc - */ - abstract getTiptapExtensions(args?: UmbTiptapExtensionArgs): Array; -} - export interface UmbTiptapExtensionArgs { /** * The data type configuration for the property editor that the editor is used for. @@ -74,30 +49,3 @@ export interface UmbTiptapToolbarElementApi extends UmbApi, UmbTiptapExtensionAr */ isActive(editor: Editor): boolean; } - -export abstract class UmbTiptapToolbarElementApiBase extends UmbControllerBase implements UmbTiptapToolbarElementApi { - /** - * The manifest for the extension. - */ - manifest?: ManifestTiptapToolbarExtension; - - /** - * The data type configuration for the property editor that the editor is used for. - */ - configuration?: UmbPropertyEditorConfigCollection; - - /** - * A method to execute the toolbar element action. - */ - public abstract execute(editor: Editor): void; - - /** - * Informs the toolbar element if it is active or not. It uses the manifest meta alias to check if the toolbar element is active. - * @see {ManifestTiptapToolbarExtension} - * @param {Editor} editor The editor instance. - * @returns {boolean} Returns true if the toolbar element is active. - */ - public isActive(editor: Editor) { - return editor && this.manifest?.meta.alias ? editor?.isActive(this.manifest.meta.alias) : false; - } -} diff --git a/src/Umbraco.Web.UI.Client/src/packages/ufm/filters/base.filter.ts b/src/Umbraco.Web.UI.Client/src/packages/ufm/filters/base.filter.ts new file mode 100644 index 0000000000..76433cbe17 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/ufm/filters/base.filter.ts @@ -0,0 +1,6 @@ +import type { UmbUfmFilterApi } from '../ufm-filter.extension.js'; + +export abstract class UmbUfmFilterBase implements UmbUfmFilterApi { + abstract filter(...args: Array): string | undefined | null; + destroy() {} +} diff --git a/src/Umbraco.Web.UI.Client/src/packages/ufm/index.ts b/src/Umbraco.Web.UI.Client/src/packages/ufm/index.ts index 481d5818a8..4eee789e2b 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/ufm/index.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/ufm/index.ts @@ -1,6 +1,7 @@ -export * from './types.js'; export * from './components/index.js'; export * from './contexts/index.js'; +export * from './filters/base.filter.js'; export * from './plugins/index.js'; +export * from './types.js'; export * from './ufm-component.extension.js'; export * from './ufm-filter.extension.js'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/ufm/types.ts b/src/Umbraco.Web.UI.Client/src/packages/ufm/types.ts index 8b2395e4a6..5a25901cdb 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/ufm/types.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/ufm/types.ts @@ -1,7 +1 @@ -import type { UmbUfmFilterApi } from './ufm-filter.extension.js'; - -// TODO: this is not a type, in TypeScript world, as it is an actual class. So it should be moved elsewhere [NL] -export abstract class UmbUfmFilterBase implements UmbUfmFilterApi { - abstract filter(...args: Array): string | undefined | null; - destroy() {} -} +export type * from './ufm-filter.extension.js';