move abstract classes out of types
This commit is contained in:
@@ -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<Extension | Mark | Node>;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export * from './base.js';
|
||||
export type * from './types.js';
|
||||
|
||||
@@ -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<Extension | Mark | Node>;
|
||||
}
|
||||
|
||||
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<Extension | Mark | Node>;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { UmbUfmFilterApi } from '../ufm-filter.extension.js';
|
||||
|
||||
export abstract class UmbUfmFilterBase implements UmbUfmFilterApi {
|
||||
abstract filter(...args: Array<unknown>): string | undefined | null;
|
||||
destroy() {}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
export * from './components/index.js';
|
||||
export * from './contexts/index.js';
|
||||
export * from './controllers/ufm-virtual-render.controller.js';
|
||||
export * from './filters/base.filter.js';
|
||||
export * from './plugins/index.js';
|
||||
export * from './types.js';
|
||||
export * from './ufm-component.extension.js';
|
||||
|
||||
@@ -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<unknown>): string | undefined | null;
|
||||
destroy() {}
|
||||
}
|
||||
export type * from './ufm-filter.extension.js';
|
||||
|
||||
Reference in New Issue
Block a user