Skip to content

Commit 85f588a

Browse files
committed
Introduced UfmToken interface type
1 parent db53cfd commit 85f588a

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

src/packages/core/extension-registry/models/ufm-component.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { ManifestApi, UmbApi } from '@umbraco-cms/backoffice/extension-api';
2-
import type { Tokens } from '@umbraco-cms/backoffice/external/marked';
2+
import type { UfmToken } from '@umbraco-cms/backoffice/ufm';
33

44
export interface UmbUfmComponentApi extends UmbApi {
5-
render(token: Tokens.Generic): string | undefined;
5+
render(token: UfmToken): string | undefined;
66
}
77

88
export interface MetaUfmComponent {

src/packages/ufm/plugins/marked-ufm.plugin.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import type { MarkedExtension, Tokens } from '@umbraco-cms/backoffice/external/m
33
export interface UfmPlugin {
44
alias: string;
55
marker: string;
6-
render?: (token: Tokens.Generic) => string | undefined;
6+
render?: (token: UfmToken) => string | undefined;
7+
}
8+
9+
export interface UfmToken extends Tokens.Generic {
10+
text?: string;
711
}
812

913
export function ufm(plugins: Array<UfmPlugin> = []): MarkedExtension {

src/packages/ufm/ufm-components/label-value.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import type { UfmToken } from '../plugins/marked-ufm.plugin.js';
12
import { UmbUfmComponentBase } from './ufm-component-base.js';
2-
import type { Tokens } from '@umbraco-cms/backoffice/external/marked';
33

44
import './label-value.element.js';
55

66
export class UmbUfmLabelValueComponent extends UmbUfmComponentBase {
7-
render(token: Tokens.Generic) {
7+
render(token: UfmToken) {
8+
if (!token.text) return;
89
return `<ufm-label-value alias="${token.text}"></ufm-label-value>`;
910
}
1011
}

src/packages/ufm/ufm-components/localize.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import type { UfmToken } from '../plugins/marked-ufm.plugin.js';
12
import { UmbUfmComponentBase } from './ufm-component-base.js';
2-
import type { Tokens } from '@umbraco-cms/backoffice/external/marked';
33

44
export class UmbUfmLocalizeComponent extends UmbUfmComponentBase {
5-
render(token: Tokens.Generic) {
5+
render(token: UfmToken) {
6+
if (!token.text) return;
67
return `<umb-localize key="${token.text}"></umb-localize>`;
78
}
89
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { Tokens } from '@umbraco-cms/backoffice/external/marked';
1+
import type { UfmToken } from '../plugins/marked-ufm.plugin.js';
22
import type { UmbUfmComponentApi } from '@umbraco-cms/backoffice/extension-registry';
33

44
export abstract class UmbUfmComponentBase implements UmbUfmComponentApi {
5-
abstract render(token: Tokens.Generic): string | undefined;
5+
abstract render(token: UfmToken): string | undefined;
66
destroy() {}
77
}

0 commit comments

Comments
 (0)