@3kles/kles-richtext-editor 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/3kles-kles-richtext-editor-material.mjs +523 -0
- package/fesm2022/3kles-kles-richtext-editor-material.mjs.map +1 -0
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-button.component-B0aePmqW.mjs +96 -0
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-button.component-B0aePmqW.mjs.map +1 -0
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-fields.component-DZrj7frn.mjs +163 -0
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-fields.component-DZrj7frn.mjs.map +1 -0
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-menu.component-DkaxVVT8.mjs +224 -0
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-menu.component-DkaxVVT8.mjs.map +1 -0
- package/fesm2022/3kles-kles-richtext-editor.mjs +40 -22
- package/fesm2022/3kles-kles-richtext-editor.mjs.map +1 -1
- package/package.json +16 -4
- package/types/3kles-kles-richtext-editor-material.d.ts +5 -0
- package/types/3kles-kles-richtext-editor-material.d.ts.map +1 -0
- package/types/3kles-kles-richtext-editor.d.ts +82 -5
- package/types/3kles-kles-richtext-editor.d.ts.map +1 -1
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-menu.component-Dq2K0CY3.mjs +0 -183
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-menu.component-Dq2K0CY3.mjs.map +0 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { NgComponentOutlet, NgTemplateOutlet } from "@angular/common";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { ChangeDetectionStrategy, Component, InjectionToken, inject, input } from "@angular/core";
|
|
4
|
+
const RICHTEXT_TOOLBAR_APPEARANCE = new InjectionToken("RICHTEXT_TOOLBAR_APPEARANCE", {
|
|
5
|
+
providedIn: "root",
|
|
6
|
+
factory: () => ({})
|
|
7
|
+
});
|
|
8
|
+
function provideRichTextToolbarAppearance(appearance) {
|
|
9
|
+
return {
|
|
10
|
+
provide: RICHTEXT_TOOLBAR_APPEARANCE,
|
|
11
|
+
useValue: appearance
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
var RichTextToolbarButtonComponent = class RichTextToolbarButtonComponent {
|
|
15
|
+
control = input.required(...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
|
|
16
|
+
renderer = inject(RICHTEXT_TOOLBAR_APPEARANCE).button;
|
|
17
|
+
preserveSelection(event) {
|
|
18
|
+
if (event.button === 0) event.preventDefault();
|
|
19
|
+
}
|
|
20
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
21
|
+
minVersion: "12.0.0",
|
|
22
|
+
version: "22.2.6",
|
|
23
|
+
ngImport: i0,
|
|
24
|
+
type: RichTextToolbarButtonComponent,
|
|
25
|
+
deps: [],
|
|
26
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
27
|
+
});
|
|
28
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
29
|
+
minVersion: "17.0.0",
|
|
30
|
+
version: "22.2.6",
|
|
31
|
+
type: RichTextToolbarButtonComponent,
|
|
32
|
+
isStandalone: true,
|
|
33
|
+
selector: "kles-richtext-toolbar-button",
|
|
34
|
+
inputs: { control: {
|
|
35
|
+
classPropertyName: "control",
|
|
36
|
+
publicName: "control",
|
|
37
|
+
isSignal: true,
|
|
38
|
+
isRequired: true,
|
|
39
|
+
transformFunction: null
|
|
40
|
+
} },
|
|
41
|
+
ngImport: i0,
|
|
42
|
+
template: "@let button = control();\n@if (renderer) {\n <ng-container *ngComponentOutlet=\"renderer; inputs: { control: button }\" />\n} @else {\n <button\n type=\"button\"\n [class.with-icon]=\"!button.content && !!button.icon\"\n [attr.data-richtext-action]=\"button.actionId\"\n [attr.data-richtext-field]=\"button.fieldId\"\n [attr.aria-label]=\"button.ariaLabel\"\n [attr.aria-pressed]=\"button.pressed ?? null\"\n [attr.aria-haspopup]=\"button.popoverTarget ? 'dialog' : null\"\n [attr.popovertarget]=\"button.popoverTarget\"\n [attr.title]=\"button.label ? null : button.ariaLabel\"\n [attr.tabindex]=\"button.tabStop\"\n [disabled]=\"button.disabled\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"button.activate?.()\"\n >\n @if (button.content; as content) {\n <ng-container [ngTemplateOutlet]=\"content.template\" [ngTemplateOutletContext]=\"content.context\" />\n } @else {\n @if (button.iconType === 'material') {\n <span class=\"material-icon\" [attr.data-material-icon]=\"button.icon\" aria-hidden=\"true\"></span>\n } @else if (button.icon) {\n <span aria-hidden=\"true\">{{ button.icon }}</span>\n }\n {{ button.label }}\n }\n </button>\n}\n",
|
|
43
|
+
styles: [":host{display:contents}button{box-sizing:border-box;font:inherit;min-height:2.75rem;max-width:100%;padding:.5rem .7rem;border:1px solid var(--kles-richtext-toolbar-accent, var(--accent, #174f89));border-radius:var(--kles-richtext-toolbar-radius, .5rem);background:var(--kles-richtext-toolbar-background, var(--surface, #fff));color:var(--kles-richtext-toolbar-accent, var(--accent, #174f89));cursor:pointer;overflow-wrap:anywhere}button.with-icon{display:inline-flex;align-items:center;justify-content:center;gap:.35rem;min-inline-size:2.75rem}button:hover:enabled{text-decoration:underline}button[aria-pressed=true]{background:var(--kles-richtext-toolbar-accent, var(--accent, #174f89));color:var(--kles-richtext-toolbar-background, var(--surface, #fff))}button:disabled{opacity:.5;cursor:not-allowed}button:focus-visible{outline:3px solid var(--kles-richtext-toolbar-focus, var(--accent, #174f89));outline-offset:3px}.material-icon{font-family:var(--kles-richtext-toolbar-material-icon-font, \"Material Icons\");font-feature-settings:\"liga\";font-style:normal;font-weight:400;font-size:1.5rem;line-height:1;letter-spacing:normal;text-transform:none;white-space:nowrap;direction:ltr}.material-icon:before{content:attr(data-material-icon)}\n"],
|
|
44
|
+
dependencies: [{
|
|
45
|
+
kind: "directive",
|
|
46
|
+
type: NgComponentOutlet,
|
|
47
|
+
selector: "[ngComponentOutlet]",
|
|
48
|
+
inputs: [
|
|
49
|
+
"ngComponentOutlet",
|
|
50
|
+
"ngComponentOutletInputs",
|
|
51
|
+
"ngComponentOutletInjector",
|
|
52
|
+
"ngComponentOutletEnvironmentInjector",
|
|
53
|
+
"ngComponentOutletContent",
|
|
54
|
+
"ngComponentOutletNgModule"
|
|
55
|
+
],
|
|
56
|
+
exportAs: ["ngComponentOutlet"]
|
|
57
|
+
}, {
|
|
58
|
+
kind: "directive",
|
|
59
|
+
type: NgTemplateOutlet,
|
|
60
|
+
selector: "[ngTemplateOutlet]",
|
|
61
|
+
inputs: [
|
|
62
|
+
"ngTemplateOutletContext",
|
|
63
|
+
"ngTemplateOutlet",
|
|
64
|
+
"ngTemplateOutletInjector"
|
|
65
|
+
]
|
|
66
|
+
}],
|
|
67
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
71
|
+
minVersion: "12.0.0",
|
|
72
|
+
version: "22.2.6",
|
|
73
|
+
ngImport: i0,
|
|
74
|
+
type: RichTextToolbarButtonComponent,
|
|
75
|
+
decorators: [{
|
|
76
|
+
type: Component,
|
|
77
|
+
args: [{
|
|
78
|
+
selector: "kles-richtext-toolbar-button",
|
|
79
|
+
imports: [NgComponentOutlet, NgTemplateOutlet],
|
|
80
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
81
|
+
template: "@let button = control();\n@if (renderer) {\n <ng-container *ngComponentOutlet=\"renderer; inputs: { control: button }\" />\n} @else {\n <button\n type=\"button\"\n [class.with-icon]=\"!button.content && !!button.icon\"\n [attr.data-richtext-action]=\"button.actionId\"\n [attr.data-richtext-field]=\"button.fieldId\"\n [attr.aria-label]=\"button.ariaLabel\"\n [attr.aria-pressed]=\"button.pressed ?? null\"\n [attr.aria-haspopup]=\"button.popoverTarget ? 'dialog' : null\"\n [attr.popovertarget]=\"button.popoverTarget\"\n [attr.title]=\"button.label ? null : button.ariaLabel\"\n [attr.tabindex]=\"button.tabStop\"\n [disabled]=\"button.disabled\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"button.activate?.()\"\n >\n @if (button.content; as content) {\n <ng-container [ngTemplateOutlet]=\"content.template\" [ngTemplateOutletContext]=\"content.context\" />\n } @else {\n @if (button.iconType === 'material') {\n <span class=\"material-icon\" [attr.data-material-icon]=\"button.icon\" aria-hidden=\"true\"></span>\n } @else if (button.icon) {\n <span aria-hidden=\"true\">{{ button.icon }}</span>\n }\n {{ button.label }}\n }\n </button>\n}\n",
|
|
82
|
+
styles: [":host{display:contents}button{box-sizing:border-box;font:inherit;min-height:2.75rem;max-width:100%;padding:.5rem .7rem;border:1px solid var(--kles-richtext-toolbar-accent, var(--accent, #174f89));border-radius:var(--kles-richtext-toolbar-radius, .5rem);background:var(--kles-richtext-toolbar-background, var(--surface, #fff));color:var(--kles-richtext-toolbar-accent, var(--accent, #174f89));cursor:pointer;overflow-wrap:anywhere}button.with-icon{display:inline-flex;align-items:center;justify-content:center;gap:.35rem;min-inline-size:2.75rem}button:hover:enabled{text-decoration:underline}button[aria-pressed=true]{background:var(--kles-richtext-toolbar-accent, var(--accent, #174f89));color:var(--kles-richtext-toolbar-background, var(--surface, #fff))}button:disabled{opacity:.5;cursor:not-allowed}button:focus-visible{outline:3px solid var(--kles-richtext-toolbar-focus, var(--accent, #174f89));outline-offset:3px}.material-icon{font-family:var(--kles-richtext-toolbar-material-icon-font, \"Material Icons\");font-feature-settings:\"liga\";font-style:normal;font-weight:400;font-size:1.5rem;line-height:1;letter-spacing:normal;text-transform:none;white-space:nowrap;direction:ltr}.material-icon:before{content:attr(data-material-icon)}\n"]
|
|
83
|
+
}]
|
|
84
|
+
}],
|
|
85
|
+
propDecorators: { control: [{
|
|
86
|
+
type: i0.Input,
|
|
87
|
+
args: [{
|
|
88
|
+
isSignal: true,
|
|
89
|
+
alias: "control",
|
|
90
|
+
required: true
|
|
91
|
+
}]
|
|
92
|
+
}] }
|
|
93
|
+
});
|
|
94
|
+
export { RICHTEXT_TOOLBAR_APPEARANCE as n, provideRichTextToolbarAppearance as r, RichTextToolbarButtonComponent as t };
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=3kles-kles-richtext-editor-richtext-toolbar-button.component-B0aePmqW.mjs.map
|
package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-button.component-B0aePmqW.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3kles-kles-richtext-editor-richtext-toolbar-button.component-B0aePmqW.mjs","names":[],"sources":["../../../projects/kles-richtext-editor/src/lib/toolbar/toolbar-appearance.ts","../../../projects/kles-richtext-editor/src/lib/toolbar/richtext-toolbar-button.component.ts","../../../projects/kles-richtext-editor/src/lib/toolbar/richtext-toolbar-button.component.html"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport type { InputSignal, Provider, TemplateRef, Type } from '@angular/core';\nimport type {\n RichTextToolbarButtonContext,\n RichTextToolbarIconType,\n RichTextToolbarMenuCommand,\n RichTextToolbarMenuGroup,\n} from './toolbar-configuration.js';\n\nexport interface RichTextToolbarButtonControl {\n readonly label: string;\n readonly ariaLabel: string;\n readonly disabled: boolean;\n readonly pressed?: boolean | undefined;\n readonly icon?: string | undefined;\n readonly iconType?: RichTextToolbarIconType | undefined;\n readonly actionId?: string;\n readonly fieldId?: string;\n readonly tabStop?: number;\n readonly popoverTarget?: string;\n readonly content?:\n | {\n readonly template: TemplateRef<RichTextToolbarButtonContext>;\n readonly context: RichTextToolbarButtonContext;\n }\n | undefined;\n readonly activate?: () => void;\n}\n\nexport interface RichTextToolbarColorControl {\n readonly id: 'color' | 'backgroundColor';\n readonly popoverId: string;\n readonly label: string;\n readonly ariaLabel: string;\n readonly resetLabel: string;\n readonly disabled: boolean;\n /** Undefined means the default. Null means the selection contains multiple values. */\n readonly value: string | null | undefined;\n readonly fallback: string;\n readonly change: (value: string) => void;\n}\n\nexport type RichTextToolbarFieldControl = {\n readonly id: string;\n readonly label: string;\n readonly ariaLabel: string;\n readonly disabled: boolean;\n readonly value: string;\n readonly change: (value: string) => void;\n} & (\n | {\n readonly kind: 'link';\n readonly invalid: boolean;\n readonly errorId: string;\n readonly submit: (event: Event) => void;\n }\n | {\n readonly kind: 'select';\n readonly options: readonly { readonly label: string; readonly value: string; readonly disabled?: boolean }[];\n }\n);\n\nexport interface RichTextToolbarMenuControl {\n readonly label: string;\n readonly searchLabel: string;\n readonly noResults: string;\n readonly query: string;\n readonly open: boolean;\n readonly groups: readonly RichTextToolbarMenuGroup[];\n readonly search: (query: string) => void;\n readonly choose: (item: RichTextToolbarMenuCommand) => void;\n}\n\nexport interface RichTextToolbarAppearance {\n readonly button?: Type<{ readonly control: InputSignal<RichTextToolbarButtonControl> }>;\n readonly color?: Type<{ readonly control: InputSignal<RichTextToolbarColorControl> }>;\n readonly field?: Type<{ readonly control: InputSignal<RichTextToolbarFieldControl> }>;\n readonly menu?: Type<{ readonly control: InputSignal<RichTextToolbarMenuControl> }>;\n}\n\nexport const RICHTEXT_TOOLBAR_APPEARANCE = new InjectionToken<RichTextToolbarAppearance>(\n 'RICHTEXT_TOOLBAR_APPEARANCE',\n {\n providedIn: 'root',\n factory: () => ({}),\n },\n);\n\nexport function provideRichTextToolbarAppearance(appearance: RichTextToolbarAppearance): Provider {\n return { provide: RICHTEXT_TOOLBAR_APPEARANCE, useValue: appearance };\n}\n","import { NgComponentOutlet, NgTemplateOutlet } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, inject, input } from '@angular/core';\nimport { RICHTEXT_TOOLBAR_APPEARANCE } from './toolbar-appearance.js';\nimport type { RichTextToolbarButtonControl } from './toolbar-appearance.js';\n\n@Component({\n selector: 'kles-richtext-toolbar-button',\n imports: [NgComponentOutlet, NgTemplateOutlet],\n templateUrl: './richtext-toolbar-button.component.html',\n styleUrl: './richtext-toolbar-button.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class RichTextToolbarButtonComponent {\n readonly control = input.required<RichTextToolbarButtonControl>();\n protected readonly renderer = inject(RICHTEXT_TOOLBAR_APPEARANCE).button;\n\n protected preserveSelection(event: MouseEvent): void {\n if (event.button === 0) event.preventDefault();\n }\n}\n","@let button = control();\n@if (renderer) {\n <ng-container *ngComponentOutlet=\"renderer; inputs: { control: button }\" />\n} @else {\n <button\n type=\"button\"\n [class.with-icon]=\"!button.content && !!button.icon\"\n [attr.data-richtext-action]=\"button.actionId\"\n [attr.data-richtext-field]=\"button.fieldId\"\n [attr.aria-label]=\"button.ariaLabel\"\n [attr.aria-pressed]=\"button.pressed ?? null\"\n [attr.aria-haspopup]=\"button.popoverTarget ? 'dialog' : null\"\n [attr.popovertarget]=\"button.popoverTarget\"\n [attr.title]=\"button.label ? null : button.ariaLabel\"\n [attr.tabindex]=\"button.tabStop\"\n [disabled]=\"button.disabled\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"button.activate?.()\"\n >\n @if (button.content; as content) {\n <ng-container [ngTemplateOutlet]=\"content.template\" [ngTemplateOutletContext]=\"content.context\" />\n } @else {\n @if (button.iconType === 'material') {\n <span class=\"material-icon\" [attr.data-material-icon]=\"button.icon\" aria-hidden=\"true\"></span>\n } @else if (button.icon) {\n <span aria-hidden=\"true\">{{ button.icon }}</span>\n }\n {{ button.label }}\n }\n </button>\n}\n"],"mappings":";;;AAgFA,MAAa,8BAA8B,IAAI,eAC3C,+BACA;CACI,YAAY;CACZ,gBAAgB,CAAA;AACnB,CAAA;AAGL,SAAgB,iCAAiC,YAAqC;CAClF,OAAO;EAAE,SAAS;EAA6B,UAAU;CAAU;AACvE;AC9EA,IAAa,iCAAb,MAAa,+BAA8B;CAC9B,UAAU,MAAM,SAAwC,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAC9C,WAAW,OAAO,2BAA2B,CAAC,CAAC;CAExD,kBAAkB,OAAiB;EACzC,IAAI,MAAM,WAAW,GAAG,MAAM,eAAc;CAChD;CANS,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAA8B,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAA9B,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAA8B,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,SAAA;GAAA,mBAAA;GAAA,YAAA;GAAA,UAAA;GAAA,YAAA;GAAA,mBAAA;EAAA,EAAA;EAAA,UAAA;EAAA,UCZ3C;EA+BA,QAAA,CAAA,4tCAAA;EAAA,cAAA,CAAA;GAAA,MAAA;GAAA,MDxBc;GAAiB,UAAA;GAAA,QAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;GAAA;GAAA,UAAA,CAAA,mBAAA;EAAA,GAAA;GAAA,MAAA;GAAA,MAAE;GAAgB,UAAA;GAAA,QAAA;IAAA;IAAA;IAAA;GAAA;EAAA,CAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AAKpC,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAA8B,YAAA,CAAA;EAP1C,MAAA;EACa,MAAA,CAAA;GAAA,UAAA;GAA8B,SAC/B,CAAC,mBAAmB,gBAAgB;GAAC,iBAG7B,wBAAwB;GAAM,UAAA;GAAA,QAAA,CAAA,4tCAAA;EAAA,CAAA"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { n as RICHTEXT_TOOLBAR_APPEARANCE, t as RichTextToolbarButtonComponent } from "./3kles-kles-richtext-editor-richtext-toolbar-button.component-B0aePmqW.mjs";
|
|
2
|
+
import { NgComponentOutlet } from "@angular/common";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import { ChangeDetectionStrategy, Component, inject, input } from "@angular/core";
|
|
5
|
+
var RichTextToolbarFieldsComponent = class RichTextToolbarFieldsComponent {
|
|
6
|
+
toolbar = input.required(...ngDevMode ? [{ debugName: "toolbar" }] : /* istanbul ignore next */ []);
|
|
7
|
+
colorRenderer = inject(RICHTEXT_TOOLBAR_APPEARANCE).color;
|
|
8
|
+
fieldRenderer = inject(RICHTEXT_TOOLBAR_APPEARANCE).field;
|
|
9
|
+
resetColor = {
|
|
10
|
+
color: () => this.toolbar().changeStyle("color", ""),
|
|
11
|
+
backgroundColor: () => this.toolbar().changeStyle("backgroundColor", "")
|
|
12
|
+
};
|
|
13
|
+
fieldControl(field) {
|
|
14
|
+
const toolbar = this.toolbar();
|
|
15
|
+
const ariaLabel = field.ariaLabel?.trim() || field.label;
|
|
16
|
+
const shared = {
|
|
17
|
+
id: field.id,
|
|
18
|
+
label: field.label,
|
|
19
|
+
ariaLabel
|
|
20
|
+
};
|
|
21
|
+
if (field.control === "select") {
|
|
22
|
+
const options = [
|
|
23
|
+
...field.value === null ? [{
|
|
24
|
+
value: "mixed",
|
|
25
|
+
label: toolbar.text().mixedStyles,
|
|
26
|
+
disabled: true
|
|
27
|
+
}] : [],
|
|
28
|
+
{
|
|
29
|
+
value: "",
|
|
30
|
+
label: toolbar.text().defaultStyle
|
|
31
|
+
},
|
|
32
|
+
...field.options.map((value) => ({
|
|
33
|
+
label: value,
|
|
34
|
+
value
|
|
35
|
+
}))
|
|
36
|
+
];
|
|
37
|
+
return {
|
|
38
|
+
...shared,
|
|
39
|
+
kind: "select",
|
|
40
|
+
options,
|
|
41
|
+
disabled: field.disabled,
|
|
42
|
+
value: field.value === null ? "mixed" : field.value ?? "",
|
|
43
|
+
change: (value) => toolbar.changeStyle(field.id, value)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (field.id === "link") return {
|
|
47
|
+
...shared,
|
|
48
|
+
kind: "link",
|
|
49
|
+
disabled: toolbar.linksDisabled(),
|
|
50
|
+
value: toolbar.linkHref(),
|
|
51
|
+
invalid: toolbar.linkInvalid(),
|
|
52
|
+
errorId: toolbar.linkErrorId,
|
|
53
|
+
change: (value) => toolbar.changeLink(value),
|
|
54
|
+
submit: (event) => toolbar.applyLink(event)
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
...shared,
|
|
58
|
+
kind: "select",
|
|
59
|
+
disabled: toolbar.headingDisabled(),
|
|
60
|
+
value: String(toolbar.headingLevel()),
|
|
61
|
+
ariaLabel: field.ariaLabel?.trim() || toolbar.text().headingLevelLabel,
|
|
62
|
+
options: toolbar.headingLevels.map((level) => ({
|
|
63
|
+
label: String(level),
|
|
64
|
+
value: String(level)
|
|
65
|
+
})),
|
|
66
|
+
change: (value) => toolbar.setHeadingLevel(value)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
linkControl(remove) {
|
|
70
|
+
const ariaLabel = this.toolbar().text()[remove ? "removeLink" : "applyLink"];
|
|
71
|
+
const iconOnly = this.toolbar().iconOnly();
|
|
72
|
+
return {
|
|
73
|
+
label: iconOnly ? "" : ariaLabel,
|
|
74
|
+
ariaLabel,
|
|
75
|
+
disabled: remove ? this.toolbar().removeLinkDisabled() : this.toolbar().applyLinkDisabled(),
|
|
76
|
+
icon: iconOnly ? remove ? "link_off" : "link" : void 0,
|
|
77
|
+
iconType: "material",
|
|
78
|
+
fieldId: "link",
|
|
79
|
+
activate: () => remove ? this.toolbar().removeLink() : this.toolbar().applyLink()
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
colorControl(field) {
|
|
83
|
+
return {
|
|
84
|
+
...field,
|
|
85
|
+
popoverId: `${this.toolbar().linkErrorId}-${field.id}`,
|
|
86
|
+
ariaLabel: field.ariaLabel?.trim() || field.label,
|
|
87
|
+
resetLabel: this.toolbar().text()[field.id === "color" ? "resetColor" : "resetBackgroundColor"],
|
|
88
|
+
change: (value) => this.toolbar().changeStyle(field.id, value)
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
92
|
+
minVersion: "12.0.0",
|
|
93
|
+
version: "22.2.6",
|
|
94
|
+
ngImport: i0,
|
|
95
|
+
type: RichTextToolbarFieldsComponent,
|
|
96
|
+
deps: [],
|
|
97
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
98
|
+
});
|
|
99
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
100
|
+
minVersion: "17.0.0",
|
|
101
|
+
version: "22.2.6",
|
|
102
|
+
type: RichTextToolbarFieldsComponent,
|
|
103
|
+
isStandalone: true,
|
|
104
|
+
selector: "kles-richtext-toolbar-fields",
|
|
105
|
+
inputs: { toolbar: {
|
|
106
|
+
classPropertyName: "toolbar",
|
|
107
|
+
publicName: "toolbar",
|
|
108
|
+
isSignal: true,
|
|
109
|
+
isRequired: true,
|
|
110
|
+
transformFunction: null
|
|
111
|
+
} },
|
|
112
|
+
ngImport: i0,
|
|
113
|
+
template: "<div class=\"kles-richtext-toolbar__fields\" role=\"group\" [attr.aria-label]=\"toolbar().fieldsLabel()\">\n @for (field of toolbar().fields(); track field.id) {\n @if (fieldRenderer && field.control !== 'color') {\n <ng-container *ngComponentOutlet=\"fieldRenderer; inputs: { control: fieldControl(field) }\" />\n } @else if (field.id === 'headingLevel') {\n <label class=\"kles-richtext-toolbar__level\" data-richtext-field=\"headingLevel\">\n {{ field.label }}\n <select\n [attr.aria-label]=\"field.ariaLabel?.trim() || toolbar().text().headingLevelLabel\"\n [disabled]=\"toolbar().headingDisabled()\"\n (change)=\"toolbar().changeHeadingLevel($event)\"\n >\n @for (level of toolbar().headingLevels; track level) {\n <option [value]=\"level\" [selected]=\"level === toolbar().headingLevel()\">{{ level }}</option>\n }\n </select>\n </label>\n } @else if (field.id === 'link') {\n <label class=\"kles-richtext-toolbar__link\" data-richtext-field=\"link\">\n {{ field.label }}\n <input\n #linkInput\n type=\"text\"\n inputmode=\"url\"\n [disabled]=\"toolbar().linksDisabled()\"\n [value]=\"toolbar().linkHref()\"\n [attr.aria-label]=\"field.ariaLabel?.trim() || field.label\"\n [attr.aria-invalid]=\"toolbar().linkInvalid() ? 'true' : null\"\n [attr.aria-describedby]=\"toolbar().linkInvalid() ? toolbar().linkErrorId : null\"\n (input)=\"toolbar().changeLink(linkInput.value)\"\n (keydown.enter)=\"toolbar().applyLink($event)\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n </label>\n } @else if (field.control === 'color') {\n @let color = colorControl(field);\n @if (colorRenderer; as renderer) {\n <ng-container *ngComponentOutlet=\"renderer; inputs: { control: color }\" />\n } @else {\n <div class=\"kles-richtext-toolbar__color\">\n <label class=\"kles-richtext-toolbar__level\" [attr.data-richtext-field]=\"color.id\">\n {{ color.label }}\n <input\n #colorInput\n type=\"color\"\n [value]=\"color.value ?? color.fallback\"\n [disabled]=\"color.disabled\"\n [attr.aria-label]=\"color.ariaLabel\"\n (change)=\"color.change(colorInput.value)\"\n />\n </label>\n <kles-richtext-toolbar-button\n [control]=\"{\n label: '',\n icon: '×',\n ariaLabel: color.resetLabel,\n disabled: color.disabled,\n activate: resetColor[color.id],\n }\"\n />\n </div>\n }\n } @else if (field.control === 'select') {\n <label class=\"kles-richtext-toolbar__level\" [attr.data-richtext-field]=\"field.id\">\n {{ field.label }}\n <select\n #styleSelect\n [disabled]=\"field.disabled\"\n [attr.aria-label]=\"field.ariaLabel?.trim() || field.label\"\n (change)=\"toolbar().changeStyle(field.id, styleSelect.value)\"\n >\n @if (field.value === null) {\n <option disabled selected>{{ toolbar().text().mixedStyles }}</option>\n }\n <option value=\"\" [selected]=\"field.value === undefined\">\n {{ toolbar().text().defaultStyle }}\n </option>\n @for (value of field.options; track value) {\n <option [value]=\"value\" [selected]=\"field.value === value\">{{ value }}</option>\n }\n </select>\n </label>\n }\n @if (field.id === 'link') {\n <kles-richtext-toolbar-button [control]=\"linkControl(false)\" />\n <kles-richtext-toolbar-button [control]=\"linkControl(true)\" />\n }\n }\n</div>\n",
|
|
114
|
+
styles: [":host{display:contents}.kles-richtext-toolbar__fields{display:flex;align-items:flex-end;flex-wrap:wrap;gap:.5rem;margin-block-start:.75rem}.kles-richtext-toolbar__fields input,.kles-richtext-toolbar__fields select{box-sizing:border-box;font:inherit;min-height:2.75rem;max-width:100%;padding:.5rem .7rem;border:1px solid var(--kles-richtext-toolbar-accent, var(--accent, #174f89));border-radius:var(--kles-richtext-toolbar-radius, .5rem);background:var(--kles-richtext-toolbar-background, var(--surface, #fff));color:var(--kles-richtext-toolbar-accent, var(--accent, #174f89))}.kles-richtext-toolbar__fields input{min-width:0;width:100%;color:inherit}.kles-richtext-toolbar__fields input[type=color]{cursor:pointer;padding:.25rem;min-inline-size:2.75rem}.kles-richtext-toolbar__fields :is(input,select):disabled{opacity:.5;cursor:not-allowed}.kles-richtext-toolbar__fields :is(input,select):focus-visible{outline:3px solid var(--kles-richtext-toolbar-focus, var(--accent, #174f89));outline-offset:3px}.kles-richtext-toolbar__fields input[aria-invalid=true]{border-color:var(--kles-richtext-toolbar-error, var(--error, #9e2020))}.kles-richtext-toolbar__level,.kles-richtext-toolbar__link{display:flex;flex-direction:column;gap:.35rem;margin:0;font-weight:600;min-width:0}.kles-richtext-toolbar__link{flex:1 1 14rem;max-width:28rem}.kles-richtext-toolbar__color{display:flex;align-items:flex-end;gap:.25rem}\n"],
|
|
115
|
+
dependencies: [{
|
|
116
|
+
kind: "directive",
|
|
117
|
+
type: NgComponentOutlet,
|
|
118
|
+
selector: "[ngComponentOutlet]",
|
|
119
|
+
inputs: [
|
|
120
|
+
"ngComponentOutlet",
|
|
121
|
+
"ngComponentOutletInputs",
|
|
122
|
+
"ngComponentOutletInjector",
|
|
123
|
+
"ngComponentOutletEnvironmentInjector",
|
|
124
|
+
"ngComponentOutletContent",
|
|
125
|
+
"ngComponentOutletNgModule"
|
|
126
|
+
],
|
|
127
|
+
exportAs: ["ngComponentOutlet"]
|
|
128
|
+
}, {
|
|
129
|
+
kind: "component",
|
|
130
|
+
type: RichTextToolbarButtonComponent,
|
|
131
|
+
selector: "kles-richtext-toolbar-button",
|
|
132
|
+
inputs: ["control"]
|
|
133
|
+
}],
|
|
134
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
138
|
+
minVersion: "12.0.0",
|
|
139
|
+
version: "22.2.6",
|
|
140
|
+
ngImport: i0,
|
|
141
|
+
type: RichTextToolbarFieldsComponent,
|
|
142
|
+
decorators: [{
|
|
143
|
+
type: Component,
|
|
144
|
+
args: [{
|
|
145
|
+
selector: "kles-richtext-toolbar-fields",
|
|
146
|
+
imports: [NgComponentOutlet, RichTextToolbarButtonComponent],
|
|
147
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
148
|
+
template: "<div class=\"kles-richtext-toolbar__fields\" role=\"group\" [attr.aria-label]=\"toolbar().fieldsLabel()\">\n @for (field of toolbar().fields(); track field.id) {\n @if (fieldRenderer && field.control !== 'color') {\n <ng-container *ngComponentOutlet=\"fieldRenderer; inputs: { control: fieldControl(field) }\" />\n } @else if (field.id === 'headingLevel') {\n <label class=\"kles-richtext-toolbar__level\" data-richtext-field=\"headingLevel\">\n {{ field.label }}\n <select\n [attr.aria-label]=\"field.ariaLabel?.trim() || toolbar().text().headingLevelLabel\"\n [disabled]=\"toolbar().headingDisabled()\"\n (change)=\"toolbar().changeHeadingLevel($event)\"\n >\n @for (level of toolbar().headingLevels; track level) {\n <option [value]=\"level\" [selected]=\"level === toolbar().headingLevel()\">{{ level }}</option>\n }\n </select>\n </label>\n } @else if (field.id === 'link') {\n <label class=\"kles-richtext-toolbar__link\" data-richtext-field=\"link\">\n {{ field.label }}\n <input\n #linkInput\n type=\"text\"\n inputmode=\"url\"\n [disabled]=\"toolbar().linksDisabled()\"\n [value]=\"toolbar().linkHref()\"\n [attr.aria-label]=\"field.ariaLabel?.trim() || field.label\"\n [attr.aria-invalid]=\"toolbar().linkInvalid() ? 'true' : null\"\n [attr.aria-describedby]=\"toolbar().linkInvalid() ? toolbar().linkErrorId : null\"\n (input)=\"toolbar().changeLink(linkInput.value)\"\n (keydown.enter)=\"toolbar().applyLink($event)\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n </label>\n } @else if (field.control === 'color') {\n @let color = colorControl(field);\n @if (colorRenderer; as renderer) {\n <ng-container *ngComponentOutlet=\"renderer; inputs: { control: color }\" />\n } @else {\n <div class=\"kles-richtext-toolbar__color\">\n <label class=\"kles-richtext-toolbar__level\" [attr.data-richtext-field]=\"color.id\">\n {{ color.label }}\n <input\n #colorInput\n type=\"color\"\n [value]=\"color.value ?? color.fallback\"\n [disabled]=\"color.disabled\"\n [attr.aria-label]=\"color.ariaLabel\"\n (change)=\"color.change(colorInput.value)\"\n />\n </label>\n <kles-richtext-toolbar-button\n [control]=\"{\n label: '',\n icon: '×',\n ariaLabel: color.resetLabel,\n disabled: color.disabled,\n activate: resetColor[color.id],\n }\"\n />\n </div>\n }\n } @else if (field.control === 'select') {\n <label class=\"kles-richtext-toolbar__level\" [attr.data-richtext-field]=\"field.id\">\n {{ field.label }}\n <select\n #styleSelect\n [disabled]=\"field.disabled\"\n [attr.aria-label]=\"field.ariaLabel?.trim() || field.label\"\n (change)=\"toolbar().changeStyle(field.id, styleSelect.value)\"\n >\n @if (field.value === null) {\n <option disabled selected>{{ toolbar().text().mixedStyles }}</option>\n }\n <option value=\"\" [selected]=\"field.value === undefined\">\n {{ toolbar().text().defaultStyle }}\n </option>\n @for (value of field.options; track value) {\n <option [value]=\"value\" [selected]=\"field.value === value\">{{ value }}</option>\n }\n </select>\n </label>\n }\n @if (field.id === 'link') {\n <kles-richtext-toolbar-button [control]=\"linkControl(false)\" />\n <kles-richtext-toolbar-button [control]=\"linkControl(true)\" />\n }\n }\n</div>\n",
|
|
149
|
+
styles: [":host{display:contents}.kles-richtext-toolbar__fields{display:flex;align-items:flex-end;flex-wrap:wrap;gap:.5rem;margin-block-start:.75rem}.kles-richtext-toolbar__fields input,.kles-richtext-toolbar__fields select{box-sizing:border-box;font:inherit;min-height:2.75rem;max-width:100%;padding:.5rem .7rem;border:1px solid var(--kles-richtext-toolbar-accent, var(--accent, #174f89));border-radius:var(--kles-richtext-toolbar-radius, .5rem);background:var(--kles-richtext-toolbar-background, var(--surface, #fff));color:var(--kles-richtext-toolbar-accent, var(--accent, #174f89))}.kles-richtext-toolbar__fields input{min-width:0;width:100%;color:inherit}.kles-richtext-toolbar__fields input[type=color]{cursor:pointer;padding:.25rem;min-inline-size:2.75rem}.kles-richtext-toolbar__fields :is(input,select):disabled{opacity:.5;cursor:not-allowed}.kles-richtext-toolbar__fields :is(input,select):focus-visible{outline:3px solid var(--kles-richtext-toolbar-focus, var(--accent, #174f89));outline-offset:3px}.kles-richtext-toolbar__fields input[aria-invalid=true]{border-color:var(--kles-richtext-toolbar-error, var(--error, #9e2020))}.kles-richtext-toolbar__level,.kles-richtext-toolbar__link{display:flex;flex-direction:column;gap:.35rem;margin:0;font-weight:600;min-width:0}.kles-richtext-toolbar__link{flex:1 1 14rem;max-width:28rem}.kles-richtext-toolbar__color{display:flex;align-items:flex-end;gap:.25rem}\n"]
|
|
150
|
+
}]
|
|
151
|
+
}],
|
|
152
|
+
propDecorators: { toolbar: [{
|
|
153
|
+
type: i0.Input,
|
|
154
|
+
args: [{
|
|
155
|
+
isSignal: true,
|
|
156
|
+
alias: "toolbar",
|
|
157
|
+
required: true
|
|
158
|
+
}]
|
|
159
|
+
}] }
|
|
160
|
+
});
|
|
161
|
+
export { RichTextToolbarFieldsComponent };
|
|
162
|
+
|
|
163
|
+
//# sourceMappingURL=3kles-kles-richtext-editor-richtext-toolbar-fields.component-DZrj7frn.mjs.map
|
package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-fields.component-DZrj7frn.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3kles-kles-richtext-editor-richtext-toolbar-fields.component-DZrj7frn.mjs","names":[],"sources":["../../../projects/kles-richtext-editor/src/lib/toolbar/richtext-toolbar-fields.component.ts","../../../projects/kles-richtext-editor/src/lib/toolbar/richtext-toolbar-fields.component.html"],"sourcesContent":["import { NgComponentOutlet } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, inject, input } from '@angular/core';\nimport { RichTextToolbarButtonComponent } from './richtext-toolbar-button.component.js';\nimport type { RichTextToolbarComponent } from './richtext-toolbar.component.js';\nimport { RICHTEXT_TOOLBAR_APPEARANCE } from './toolbar-appearance.js';\nimport type {\n RichTextToolbarButtonControl,\n RichTextToolbarColorControl,\n RichTextToolbarFieldControl,\n} from './toolbar-appearance.js';\n\ntype FormField = Exclude<ReturnType<RichTextToolbarComponent['fields']>[number], { readonly control: 'color' }>;\n\n@Component({\n selector: 'kles-richtext-toolbar-fields',\n imports: [NgComponentOutlet, RichTextToolbarButtonComponent],\n templateUrl: './richtext-toolbar-fields.component.html',\n styleUrl: './richtext-toolbar-fields.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class RichTextToolbarFieldsComponent {\n readonly toolbar = input.required<RichTextToolbarComponent>();\n protected readonly colorRenderer = inject(RICHTEXT_TOOLBAR_APPEARANCE).color;\n protected readonly fieldRenderer = inject(RICHTEXT_TOOLBAR_APPEARANCE).field;\n protected readonly resetColor = {\n color: () => this.toolbar().changeStyle('color', ''),\n backgroundColor: () => this.toolbar().changeStyle('backgroundColor', ''),\n };\n\n protected fieldControl(field: FormField): RichTextToolbarFieldControl {\n const toolbar = this.toolbar();\n const ariaLabel = field.ariaLabel?.trim() || field.label;\n const shared = { id: field.id, label: field.label, ariaLabel };\n if (field.control === 'select') {\n const options = [\n ...(field.value === null\n ? [{ value: 'mixed', label: toolbar.text().mixedStyles, disabled: true }]\n : []),\n { value: '', label: toolbar.text().defaultStyle },\n ...field.options.map((value) => ({ label: value, value })),\n ];\n return {\n ...shared,\n kind: 'select',\n options,\n disabled: field.disabled,\n value: field.value === null ? 'mixed' : (field.value ?? ''),\n change: (value) => toolbar.changeStyle(field.id, value),\n };\n }\n if (field.id === 'link') {\n return {\n ...shared,\n kind: 'link',\n disabled: toolbar.linksDisabled(),\n value: toolbar.linkHref(),\n invalid: toolbar.linkInvalid(),\n errorId: toolbar.linkErrorId,\n change: (value) => toolbar.changeLink(value),\n submit: (event) => toolbar.applyLink(event),\n };\n }\n return {\n ...shared,\n kind: 'select',\n disabled: toolbar.headingDisabled(),\n value: String(toolbar.headingLevel()),\n ariaLabel: field.ariaLabel?.trim() || toolbar.text().headingLevelLabel,\n options: toolbar.headingLevels.map((level) => ({ label: String(level), value: String(level) })),\n change: (value) => toolbar.setHeadingLevel(value),\n };\n }\n\n protected linkControl(remove: boolean): RichTextToolbarButtonControl {\n const ariaLabel = this.toolbar().text()[remove ? 'removeLink' : 'applyLink'];\n const iconOnly = this.toolbar().iconOnly();\n return {\n label: iconOnly ? '' : ariaLabel,\n ariaLabel,\n disabled: remove ? this.toolbar().removeLinkDisabled() : this.toolbar().applyLinkDisabled(),\n icon: iconOnly ? (remove ? 'link_off' : 'link') : undefined,\n iconType: 'material',\n fieldId: 'link',\n activate: () => (remove ? this.toolbar().removeLink() : this.toolbar().applyLink()),\n };\n }\n\n protected colorControl(field: {\n readonly id: RichTextToolbarColorControl['id'];\n readonly label: string;\n readonly ariaLabel?: string;\n readonly disabled: boolean;\n readonly value: string | null | undefined;\n readonly fallback: string;\n }): RichTextToolbarColorControl {\n return {\n ...field,\n popoverId: `${this.toolbar().linkErrorId}-${field.id}`,\n ariaLabel: field.ariaLabel?.trim() || field.label,\n resetLabel: this.toolbar().text()[field.id === 'color' ? 'resetColor' : 'resetBackgroundColor'],\n change: (value) => this.toolbar().changeStyle(field.id, value),\n };\n }\n}\n","<div class=\"kles-richtext-toolbar__fields\" role=\"group\" [attr.aria-label]=\"toolbar().fieldsLabel()\">\n @for (field of toolbar().fields(); track field.id) {\n @if (fieldRenderer && field.control !== 'color') {\n <ng-container *ngComponentOutlet=\"fieldRenderer; inputs: { control: fieldControl(field) }\" />\n } @else if (field.id === 'headingLevel') {\n <label class=\"kles-richtext-toolbar__level\" data-richtext-field=\"headingLevel\">\n {{ field.label }}\n <select\n [attr.aria-label]=\"field.ariaLabel?.trim() || toolbar().text().headingLevelLabel\"\n [disabled]=\"toolbar().headingDisabled()\"\n (change)=\"toolbar().changeHeadingLevel($event)\"\n >\n @for (level of toolbar().headingLevels; track level) {\n <option [value]=\"level\" [selected]=\"level === toolbar().headingLevel()\">{{ level }}</option>\n }\n </select>\n </label>\n } @else if (field.id === 'link') {\n <label class=\"kles-richtext-toolbar__link\" data-richtext-field=\"link\">\n {{ field.label }}\n <input\n #linkInput\n type=\"text\"\n inputmode=\"url\"\n [disabled]=\"toolbar().linksDisabled()\"\n [value]=\"toolbar().linkHref()\"\n [attr.aria-label]=\"field.ariaLabel?.trim() || field.label\"\n [attr.aria-invalid]=\"toolbar().linkInvalid() ? 'true' : null\"\n [attr.aria-describedby]=\"toolbar().linkInvalid() ? toolbar().linkErrorId : null\"\n (input)=\"toolbar().changeLink(linkInput.value)\"\n (keydown.enter)=\"toolbar().applyLink($event)\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n </label>\n } @else if (field.control === 'color') {\n @let color = colorControl(field);\n @if (colorRenderer; as renderer) {\n <ng-container *ngComponentOutlet=\"renderer; inputs: { control: color }\" />\n } @else {\n <div class=\"kles-richtext-toolbar__color\">\n <label class=\"kles-richtext-toolbar__level\" [attr.data-richtext-field]=\"color.id\">\n {{ color.label }}\n <input\n #colorInput\n type=\"color\"\n [value]=\"color.value ?? color.fallback\"\n [disabled]=\"color.disabled\"\n [attr.aria-label]=\"color.ariaLabel\"\n (change)=\"color.change(colorInput.value)\"\n />\n </label>\n <kles-richtext-toolbar-button\n [control]=\"{\n label: '',\n icon: '×',\n ariaLabel: color.resetLabel,\n disabled: color.disabled,\n activate: resetColor[color.id],\n }\"\n />\n </div>\n }\n } @else if (field.control === 'select') {\n <label class=\"kles-richtext-toolbar__level\" [attr.data-richtext-field]=\"field.id\">\n {{ field.label }}\n <select\n #styleSelect\n [disabled]=\"field.disabled\"\n [attr.aria-label]=\"field.ariaLabel?.trim() || field.label\"\n (change)=\"toolbar().changeStyle(field.id, styleSelect.value)\"\n >\n @if (field.value === null) {\n <option disabled selected>{{ toolbar().text().mixedStyles }}</option>\n }\n <option value=\"\" [selected]=\"field.value === undefined\">\n {{ toolbar().text().defaultStyle }}\n </option>\n @for (value of field.options; track value) {\n <option [value]=\"value\" [selected]=\"field.value === value\">{{ value }}</option>\n }\n </select>\n </label>\n }\n @if (field.id === 'link') {\n <kles-richtext-toolbar-button [control]=\"linkControl(false)\" />\n <kles-richtext-toolbar-button [control]=\"linkControl(true)\" />\n }\n }\n</div>\n"],"mappings":";;;;AAoBA,IAAa,iCAAb,MAAa,+BAA8B;CAC9B,UAAU,MAAM,SAAoC,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAC1C,gBAAgB,OAAO,2BAA2B,CAAC,CAAC;CACpD,gBAAgB,OAAO,2BAA2B,CAAC,CAAC;CACpD,aAAa;EAC5B,aAAa,KAAK,QAAO,CAAE,CAAC,YAAY,SAAS,EAAE;EACnD,uBAAuB,KAAK,QAAO,CAAE,CAAC,YAAY,mBAAmB,EAAE;CAC1E;CAES,aAAa,OAAgB;EACnC,MAAM,UAAU,KAAK,QAAO;EAC5B,MAAM,YAAY,MAAM,WAAW,KAAI,KAAM,MAAM;EACnD,MAAM,SAAS;GAAE,IAAI,MAAM;GAAI,OAAO,MAAM;GAAO;EAAS;EAC5D,IAAI,MAAM,YAAY,UAAU;GAC5B,MAAM,UAAU;IACZ,GAAI,MAAM,UAAU,OACd,CAAC;KAAE,OAAO;KAAS,OAAO,QAAQ,KAAI,CAAE,CAAC;KAAa,UAAU;IAAI,CAAE,IACtE,CAAA;IACN;KAAE,OAAO;KAAI,OAAO,QAAQ,KAAI,CAAE,CAAC;IAAY;IAC/C,GAAG,MAAM,QAAQ,KAAK,WAAW;KAAE,OAAO;KAAO;IAAK,EAAG;GAC5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EXT_TOOLBAR_APPEARANCE, t as RichTextToolbarButtonComponent } from "./3kles-kles-richtext-editor-richtext-toolbar-button.component-B0aePmqW.mjs";
|
|
3
|
+
import { NgComponentOutlet } from "@angular/common";
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import { ChangeDetectionStrategy, Component, computed, effect, inject, input, output, signal, viewChild } from "@angular/core";
|
|
6
|
+
var RichTextToolbarMenuComponent = class RichTextToolbarMenuComponent {
|
|
7
|
+
button = input.required(...ngDevMode ? [{ debugName: "button" }] : /* istanbul ignore next */ []);
|
|
8
|
+
groups = input.required(...ngDevMode ? [{ debugName: "groups" }] : /* istanbul ignore next */ []);
|
|
9
|
+
messages = input.required(...ngDevMode ? [{ debugName: "messages" }] : /* istanbul ignore next */ []);
|
|
10
|
+
tabStop = input.required(...ngDevMode ? [{ debugName: "tabStop" }] : /* istanbul ignore next */ []);
|
|
11
|
+
command = output();
|
|
12
|
+
panelId = inject(RichTextAccessibilityIds).next("menu");
|
|
13
|
+
search = signal("", ...ngDevMode ? [{ debugName: "search" }] : /* istanbul ignore next */ []);
|
|
14
|
+
open = signal(false, ...ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []);
|
|
15
|
+
menuRenderer = inject(RICHTEXT_TOOLBAR_APPEARANCE).menu;
|
|
16
|
+
trigger = computed(() => ({
|
|
17
|
+
...this.button(),
|
|
18
|
+
actionId: this.button().id,
|
|
19
|
+
tabStop: this.tabStop(),
|
|
20
|
+
popoverTarget: this.panelId
|
|
21
|
+
}), ...ngDevMode ? [{ debugName: "trigger" }] : /* istanbul ignore next */ []);
|
|
22
|
+
panel = viewChild("panel", ...ngDevMode ? [{ debugName: "panel" }] : /* istanbul ignore next */ []);
|
|
23
|
+
results = computed(() => {
|
|
24
|
+
const messages = this.messages();
|
|
25
|
+
const search = this.search().trim().toLocaleLowerCase();
|
|
26
|
+
return this.groups().flatMap((group) => {
|
|
27
|
+
const label = toolbarPresentationLabel(group, messages, "");
|
|
28
|
+
const items = group.items.map((item) => ({
|
|
29
|
+
...item,
|
|
30
|
+
label: toolbarPresentationLabel(item, messages, item.label)
|
|
31
|
+
})).filter((item) => [
|
|
32
|
+
label,
|
|
33
|
+
item.label,
|
|
34
|
+
...item.searchTerms ?? []
|
|
35
|
+
].some((term) => term.toLocaleLowerCase().includes(search)));
|
|
36
|
+
return items.length ? [{
|
|
37
|
+
id: group.id,
|
|
38
|
+
label,
|
|
39
|
+
items
|
|
40
|
+
}] : [];
|
|
41
|
+
});
|
|
42
|
+
}, ...ngDevMode ? [{ debugName: "results" }] : /* istanbul ignore next */ []);
|
|
43
|
+
constructor() {
|
|
44
|
+
effect(() => {
|
|
45
|
+
if (this.button().disabled && this.open()) this.panel()?.nativeElement.hidePopover();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
syncPopover(panel) {
|
|
49
|
+
const open = panel.matches(":popover-open");
|
|
50
|
+
this.open.set(open);
|
|
51
|
+
if (!open) this.search.set("");
|
|
52
|
+
}
|
|
53
|
+
choose(item, panel) {
|
|
54
|
+
if (item.disabled || this.button().disabled || !panel.matches(":popover-open")) return;
|
|
55
|
+
this.command.emit(item.command);
|
|
56
|
+
panel.hidePopover();
|
|
57
|
+
}
|
|
58
|
+
menuControl(panel) {
|
|
59
|
+
return {
|
|
60
|
+
label: this.button().ariaLabel,
|
|
61
|
+
searchLabel: this.messages().menuSearch,
|
|
62
|
+
noResults: this.messages().menuNoResults,
|
|
63
|
+
open: this.open(),
|
|
64
|
+
query: this.search(),
|
|
65
|
+
groups: this.open() ? this.results() : [],
|
|
66
|
+
search: (query) => this.search.set(query),
|
|
67
|
+
choose: (item) => this.choose(item, panel)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
navigate(event, panel) {
|
|
71
|
+
if (this.menuRenderer || event.isComposing || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
|
|
72
|
+
const target = event.target;
|
|
73
|
+
const buttons = Array.from(panel.querySelectorAll("button[data-richtext-menu-command]:not(:disabled)"));
|
|
74
|
+
if (target instanceof HTMLInputElement && event.key === "Enter") {
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
buttons[0]?.click();
|
|
77
|
+
} else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
78
|
+
const index = buttons.findIndex((button) => button === target);
|
|
79
|
+
const next = event.key === "ArrowDown" ? buttons[index + 1] : buttons[index - 1];
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
if (next) next.focus();
|
|
82
|
+
else if (index === 0 && event.key === "ArrowUp") panel.querySelector("input")?.focus();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
86
|
+
minVersion: "12.0.0",
|
|
87
|
+
version: "22.2.6",
|
|
88
|
+
ngImport: i0,
|
|
89
|
+
type: RichTextToolbarMenuComponent,
|
|
90
|
+
deps: [],
|
|
91
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
92
|
+
});
|
|
93
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
94
|
+
minVersion: "17.0.0",
|
|
95
|
+
version: "22.2.6",
|
|
96
|
+
type: RichTextToolbarMenuComponent,
|
|
97
|
+
isStandalone: true,
|
|
98
|
+
selector: "kles-richtext-toolbar-menu",
|
|
99
|
+
inputs: {
|
|
100
|
+
button: {
|
|
101
|
+
classPropertyName: "button",
|
|
102
|
+
publicName: "button",
|
|
103
|
+
isSignal: true,
|
|
104
|
+
isRequired: true,
|
|
105
|
+
transformFunction: null
|
|
106
|
+
},
|
|
107
|
+
groups: {
|
|
108
|
+
classPropertyName: "groups",
|
|
109
|
+
publicName: "groups",
|
|
110
|
+
isSignal: true,
|
|
111
|
+
isRequired: true,
|
|
112
|
+
transformFunction: null
|
|
113
|
+
},
|
|
114
|
+
messages: {
|
|
115
|
+
classPropertyName: "messages",
|
|
116
|
+
publicName: "messages",
|
|
117
|
+
isSignal: true,
|
|
118
|
+
isRequired: true,
|
|
119
|
+
transformFunction: null
|
|
120
|
+
},
|
|
121
|
+
tabStop: {
|
|
122
|
+
classPropertyName: "tabStop",
|
|
123
|
+
publicName: "tabStop",
|
|
124
|
+
isSignal: true,
|
|
125
|
+
isRequired: true,
|
|
126
|
+
transformFunction: null
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
outputs: { command: "command" },
|
|
130
|
+
viewQueries: [{
|
|
131
|
+
propertyName: "panel",
|
|
132
|
+
first: true,
|
|
133
|
+
predicate: ["panel"],
|
|
134
|
+
descendants: true,
|
|
135
|
+
isSignal: true
|
|
136
|
+
}],
|
|
137
|
+
ngImport: i0,
|
|
138
|
+
template: "<kles-richtext-toolbar-button [control]=\"trigger()\" />\n<div\n #panel\n class=\"menu-panel\"\n [class.menu-panel-with-renderer]=\"menuRenderer\"\n [id]=\"panelId\"\n role=\"dialog\"\n [attr.aria-label]=\"button().ariaLabel\"\n popover=\"auto\"\n (toggle)=\"syncPopover(panel)\"\n (keydown)=\"navigate($event, panel)\"\n (keydown.escape)=\"$event.preventDefault(); $event.stopPropagation(); panel.hidePopover()\"\n>\n @if (menuRenderer; as renderer) {\n <ng-container *ngComponentOutlet=\"renderer; inputs: { control: menuControl(panel) }\" />\n } @else {\n <input\n #query\n type=\"search\"\n autofocus\n [value]=\"search()\"\n [attr.aria-label]=\"messages().menuSearch\"\n [placeholder]=\"messages().menuSearch\"\n (input)=\"search.set(query.value)\"\n />\n @if (open()) {\n <div class=\"menu-items\">\n @for (group of results(); track group.id) {\n <div [attr.role]=\"group.label ? 'group' : null\" [attr.aria-label]=\"group.label || null\">\n @if (group.label) {\n <p class=\"menu-heading\" aria-hidden=\"true\">{{ group.label }}</p>\n }\n @for (item of group.items; track item.id) {\n <button\n type=\"button\"\n [attr.data-richtext-menu-command]=\"item.id\"\n [disabled]=\"item.disabled\"\n (click)=\"choose(item, panel)\"\n >\n {{ item.label }}\n </button>\n }\n </div>\n } @empty {\n <p role=\"status\">{{ messages().menuNoResults }}</p>\n }\n </div>\n }\n }\n</div>\n",
|
|
139
|
+
styles: [":host{display:contents}button,input{box-sizing:border-box;font:inherit;min-height:2.75rem;max-width:100%;padding:.5rem .7rem;border:1px solid var(--kles-richtext-toolbar-accent, var(--accent, #174f89));border-radius:var(--kles-richtext-toolbar-radius, .5rem);background:var(--kles-richtext-toolbar-background, var(--surface, #fff));color:var(--kles-richtext-toolbar-accent, var(--accent, #174f89))}button:enabled{cursor:pointer}button:disabled{opacity:.5;cursor:not-allowed}:is(button,input):focus-visible{outline:3px solid var(--kles-richtext-toolbar-focus, var(--accent, #174f89));outline-offset:3px}.menu-panel{box-sizing:border-box;inline-size:min(20rem,100vw - 1.5rem);padding:.5rem;border:1px solid var(--kles-richtext-toolbar-accent, var(--accent, #174f89));border-radius:var(--kles-richtext-toolbar-radius, .5rem);background:var(--kles-richtext-toolbar-background, var(--surface, #fff));color:inherit}.menu-panel input{width:100%;color:inherit}@supports (position-area: block-end span-inline-end){.menu-panel{inset:auto;margin:.25rem 0;position-area:block-end span-inline-end;position-try-fallbacks:flip-inline,flip-block,flip-block flip-inline}}.menu-items{margin-block-start:.25rem;max-block-size:min(22rem,48dvh);overflow-y:auto}.menu-items button{display:block;inline-size:100%;text-align:start;border:0}.menu-items button:hover:enabled{text-decoration:underline}.menu-items button:focus-visible{outline-offset:-3px}.menu-panel-with-renderer{inline-size:min(22rem,100vw - 1.5rem);padding:0;border:0;background:transparent;overflow:visible}.menu-heading{margin:.5rem .7rem .25rem;font-weight:600}\n"],
|
|
140
|
+
dependencies: [{
|
|
141
|
+
kind: "directive",
|
|
142
|
+
type: NgComponentOutlet,
|
|
143
|
+
selector: "[ngComponentOutlet]",
|
|
144
|
+
inputs: [
|
|
145
|
+
"ngComponentOutlet",
|
|
146
|
+
"ngComponentOutletInputs",
|
|
147
|
+
"ngComponentOutletInjector",
|
|
148
|
+
"ngComponentOutletEnvironmentInjector",
|
|
149
|
+
"ngComponentOutletContent",
|
|
150
|
+
"ngComponentOutletNgModule"
|
|
151
|
+
],
|
|
152
|
+
exportAs: ["ngComponentOutlet"]
|
|
153
|
+
}, {
|
|
154
|
+
kind: "component",
|
|
155
|
+
type: RichTextToolbarButtonComponent,
|
|
156
|
+
selector: "kles-richtext-toolbar-button",
|
|
157
|
+
inputs: ["control"]
|
|
158
|
+
}],
|
|
159
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
163
|
+
minVersion: "12.0.0",
|
|
164
|
+
version: "22.2.6",
|
|
165
|
+
ngImport: i0,
|
|
166
|
+
type: RichTextToolbarMenuComponent,
|
|
167
|
+
decorators: [{
|
|
168
|
+
type: Component,
|
|
169
|
+
args: [{
|
|
170
|
+
selector: "kles-richtext-toolbar-menu",
|
|
171
|
+
standalone: true,
|
|
172
|
+
imports: [NgComponentOutlet, RichTextToolbarButtonComponent],
|
|
173
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
174
|
+
template: "<kles-richtext-toolbar-button [control]=\"trigger()\" />\n<div\n #panel\n class=\"menu-panel\"\n [class.menu-panel-with-renderer]=\"menuRenderer\"\n [id]=\"panelId\"\n role=\"dialog\"\n [attr.aria-label]=\"button().ariaLabel\"\n popover=\"auto\"\n (toggle)=\"syncPopover(panel)\"\n (keydown)=\"navigate($event, panel)\"\n (keydown.escape)=\"$event.preventDefault(); $event.stopPropagation(); panel.hidePopover()\"\n>\n @if (menuRenderer; as renderer) {\n <ng-container *ngComponentOutlet=\"renderer; inputs: { control: menuControl(panel) }\" />\n } @else {\n <input\n #query\n type=\"search\"\n autofocus\n [value]=\"search()\"\n [attr.aria-label]=\"messages().menuSearch\"\n [placeholder]=\"messages().menuSearch\"\n (input)=\"search.set(query.value)\"\n />\n @if (open()) {\n <div class=\"menu-items\">\n @for (group of results(); track group.id) {\n <div [attr.role]=\"group.label ? 'group' : null\" [attr.aria-label]=\"group.label || null\">\n @if (group.label) {\n <p class=\"menu-heading\" aria-hidden=\"true\">{{ group.label }}</p>\n }\n @for (item of group.items; track item.id) {\n <button\n type=\"button\"\n [attr.data-richtext-menu-command]=\"item.id\"\n [disabled]=\"item.disabled\"\n (click)=\"choose(item, panel)\"\n >\n {{ item.label }}\n </button>\n }\n </div>\n } @empty {\n <p role=\"status\">{{ messages().menuNoResults }}</p>\n }\n </div>\n }\n }\n</div>\n",
|
|
175
|
+
styles: [":host{display:contents}button,input{box-sizing:border-box;font:inherit;min-height:2.75rem;max-width:100%;padding:.5rem .7rem;border:1px solid var(--kles-richtext-toolbar-accent, var(--accent, #174f89));border-radius:var(--kles-richtext-toolbar-radius, .5rem);background:var(--kles-richtext-toolbar-background, var(--surface, #fff));color:var(--kles-richtext-toolbar-accent, var(--accent, #174f89))}button:enabled{cursor:pointer}button:disabled{opacity:.5;cursor:not-allowed}:is(button,input):focus-visible{outline:3px solid var(--kles-richtext-toolbar-focus, var(--accent, #174f89));outline-offset:3px}.menu-panel{box-sizing:border-box;inline-size:min(20rem,100vw - 1.5rem);padding:.5rem;border:1px solid var(--kles-richtext-toolbar-accent, var(--accent, #174f89));border-radius:var(--kles-richtext-toolbar-radius, .5rem);background:var(--kles-richtext-toolbar-background, var(--surface, #fff));color:inherit}.menu-panel input{width:100%;color:inherit}@supports (position-area: block-end span-inline-end){.menu-panel{inset:auto;margin:.25rem 0;position-area:block-end span-inline-end;position-try-fallbacks:flip-inline,flip-block,flip-block flip-inline}}.menu-items{margin-block-start:.25rem;max-block-size:min(22rem,48dvh);overflow-y:auto}.menu-items button{display:block;inline-size:100%;text-align:start;border:0}.menu-items button:hover:enabled{text-decoration:underline}.menu-items button:focus-visible{outline-offset:-3px}.menu-panel-with-renderer{inline-size:min(22rem,100vw - 1.5rem);padding:0;border:0;background:transparent;overflow:visible}.menu-heading{margin:.5rem .7rem .25rem;font-weight:600}\n"]
|
|
176
|
+
}]
|
|
177
|
+
}],
|
|
178
|
+
ctorParameters: () => [],
|
|
179
|
+
propDecorators: {
|
|
180
|
+
button: [{
|
|
181
|
+
type: i0.Input,
|
|
182
|
+
args: [{
|
|
183
|
+
isSignal: true,
|
|
184
|
+
alias: "button",
|
|
185
|
+
required: true
|
|
186
|
+
}]
|
|
187
|
+
}],
|
|
188
|
+
groups: [{
|
|
189
|
+
type: i0.Input,
|
|
190
|
+
args: [{
|
|
191
|
+
isSignal: true,
|
|
192
|
+
alias: "groups",
|
|
193
|
+
required: true
|
|
194
|
+
}]
|
|
195
|
+
}],
|
|
196
|
+
messages: [{
|
|
197
|
+
type: i0.Input,
|
|
198
|
+
args: [{
|
|
199
|
+
isSignal: true,
|
|
200
|
+
alias: "messages",
|
|
201
|
+
required: true
|
|
202
|
+
}]
|
|
203
|
+
}],
|
|
204
|
+
tabStop: [{
|
|
205
|
+
type: i0.Input,
|
|
206
|
+
args: [{
|
|
207
|
+
isSignal: true,
|
|
208
|
+
alias: "tabStop",
|
|
209
|
+
required: true
|
|
210
|
+
}]
|
|
211
|
+
}],
|
|
212
|
+
command: [{
|
|
213
|
+
type: i0.Output,
|
|
214
|
+
args: ["command"]
|
|
215
|
+
}],
|
|
216
|
+
panel: [{
|
|
217
|
+
type: i0.ViewChild,
|
|
218
|
+
args: ["panel", { isSignal: true }]
|
|
219
|
+
}]
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
export { RichTextToolbarMenuComponent };
|
|
223
|
+
|
|
224
|
+
//# sourceMappingURL=3kles-kles-richtext-editor-richtext-toolbar-menu.component-DkaxVVT8.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3kles-kles-richtext-editor-richtext-toolbar-menu.component-DkaxVVT8.mjs","names":[],"sources":["../../../projects/kles-richtext-editor/src/lib/toolbar/richtext-toolbar-menu.component.ts","../../../projects/kles-richtext-editor/src/lib/toolbar/richtext-toolbar-menu.component.html"],"sourcesContent":["import { NgComponentOutlet } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n computed,\n effect,\n input,\n output,\n signal,\n viewChild,\n inject,\n} from '@angular/core';\nimport type { ElementRef } from '@angular/core';\nimport type { EditorCommand } from '@3kles/richtext-dom';\nimport { RichTextAccessibilityIds } from '../editor/accessibility-ids.js';\nimport type { ResolvedRichTextMessages } from '../i18n/messages.js';\nimport { toolbarPresentationLabel } from './toolbar-configuration.js';\nimport { RichTextToolbarButtonComponent } from './richtext-toolbar-button.component.js';\nimport { RICHTEXT_TOOLBAR_APPEARANCE } from './toolbar-appearance.js';\nimport type { RichTextToolbarMenuControl } from './toolbar-appearance.js';\nimport type {\n RichTextToolbarButton,\n RichTextToolbarMenuCommand,\n RichTextToolbarMenuGroup,\n} from './toolbar-configuration.js';\n\n@Component({\n selector: 'kles-richtext-toolbar-menu',\n standalone: true,\n imports: [NgComponentOutlet, RichTextToolbarButtonComponent],\n templateUrl: './richtext-toolbar-menu.component.html',\n styleUrl: './richtext-toolbar-menu.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class RichTextToolbarMenuComponent {\n readonly button =\n input.required<Pick<RichTextToolbarButton, 'id' | 'label' | 'ariaLabel' | 'icon' | 'iconType' | 'disabled'>>();\n readonly groups = input.required<readonly RichTextToolbarMenuGroup[]>();\n readonly messages = input.required<ResolvedRichTextMessages>();\n readonly tabStop = input.required<number>();\n readonly command = output<EditorCommand>();\n protected readonly panelId = inject(RichTextAccessibilityIds).next('menu');\n protected readonly search = signal('');\n protected readonly open = signal(false);\n protected readonly menuRenderer = inject(RICHTEXT_TOOLBAR_APPEARANCE).menu;\n protected readonly trigger = computed(() => ({\n ...this.button(),\n actionId: this.button().id,\n tabStop: this.tabStop(),\n popoverTarget: this.panelId,\n }));\n private readonly panel = viewChild<ElementRef<HTMLElement>>('panel');\n\n protected readonly results = computed(() => {\n const messages = this.messages();\n const search = this.search().trim().toLocaleLowerCase();\n return this.groups().flatMap((group) => {\n const label = toolbarPresentationLabel(group, messages, '');\n const items = group.items\n .map((item) => ({ ...item, label: toolbarPresentationLabel(item, messages, item.label) }))\n .filter((item) =>\n [label, item.label, ...(item.searchTerms ?? [])].some((term) =>\n term.toLocaleLowerCase().includes(search),\n ),\n );\n return items.length ? [{ id: group.id, label, items }] : [];\n });\n });\n\n constructor() {\n effect(() => {\n if (this.button().disabled && this.open()) this.panel()?.nativeElement.hidePopover();\n });\n }\n\n protected syncPopover(panel: HTMLElement): void {\n const open = panel.matches(':popover-open');\n this.open.set(open);\n if (!open) this.search.set('');\n }\n\n protected choose(item: RichTextToolbarMenuCommand, panel: HTMLElement): void {\n if (item.disabled || this.button().disabled || !panel.matches(':popover-open')) return;\n // Run the command while focus is in the toolbar so the editor uses its saved selection.\n this.command.emit(item.command);\n panel.hidePopover();\n }\n\n protected menuControl(panel: HTMLElement): RichTextToolbarMenuControl {\n return {\n label: this.button().ariaLabel,\n searchLabel: this.messages().menuSearch,\n noResults: this.messages().menuNoResults,\n open: this.open(),\n query: this.search(),\n groups: this.open() ? this.results() : [],\n search: (query) => this.search.set(query),\n choose: (item) => this.choose(item, panel),\n };\n }\n\n protected navigate(event: KeyboardEvent, panel: HTMLElement): void {\n if (this.menuRenderer || event.isComposing || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)\n return;\n const target = event.target;\n const buttons = Array.from(\n panel.querySelectorAll<HTMLButtonElement>('button[data-richtext-menu-command]:not(:disabled)'),\n );\n if (target instanceof HTMLInputElement && event.key === 'Enter') {\n event.preventDefault();\n buttons[0]?.click();\n } else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n const index = buttons.findIndex((button) => button === target);\n const next = event.key === 'ArrowDown' ? buttons[index + 1] : buttons[index - 1];\n event.preventDefault();\n if (next) next.focus();\n else if (index === 0 && event.key === 'ArrowUp') panel.querySelector('input')?.focus();\n }\n }\n}\n","<kles-richtext-toolbar-button [control]=\"trigger()\" />\n<div\n #panel\n class=\"menu-panel\"\n [class.menu-panel-with-renderer]=\"menuRenderer\"\n [id]=\"panelId\"\n role=\"dialog\"\n [attr.aria-label]=\"button().ariaLabel\"\n popover=\"auto\"\n (toggle)=\"syncPopover(panel)\"\n (keydown)=\"navigate($event, panel)\"\n (keydown.escape)=\"$event.preventDefault(); $event.stopPropagation(); panel.hidePopover()\"\n>\n @if (menuRenderer; as renderer) {\n <ng-container *ngComponentOutlet=\"renderer; inputs: { control: menuControl(panel) }\" />\n } @else {\n <input\n #query\n type=\"search\"\n autofocus\n [value]=\"search()\"\n [attr.aria-label]=\"messages().menuSearch\"\n [placeholder]=\"messages().menuSearch\"\n (input)=\"search.set(query.value)\"\n />\n @if (open()) {\n <div class=\"menu-items\">\n @for (group of results(); track group.id) {\n <div [attr.role]=\"group.label ? 'group' : null\" [attr.aria-label]=\"group.label || null\">\n @if (group.label) {\n <p class=\"menu-heading\" aria-hidden=\"true\">{{ group.label }}</p>\n }\n @for (item of group.items; track item.id) {\n <button\n type=\"button\"\n [attr.data-richtext-menu-command]=\"item.id\"\n [disabled]=\"item.disabled\"\n (click)=\"choose(item, panel)\"\n >\n {{ item.label }}\n </button>\n }\n </div>\n } @empty {\n <p role=\"status\">{{ messages().menuNoResults }}</p>\n }\n </div>\n }\n }\n</div>\n"],"mappings":";;;;;AAkCA,IAAa,+BAAb,MAAa,6BAA4B;CAC5B,SACL,MAAM,SAAwG,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CACzG,SAAS,MAAM,SAA+C,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CAC9D,WAAW,MAAM,SAAoC,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CACrD,UAAU,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAClC,UAAU,OAAM;CACN,UAAU,OAAO,wBAAwB,CAAC,CAAC,KAAK,MAAM;CACtD,SAAS,OAAO,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;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