@3kles/kles-richtext-editor 1.3.0 → 1.4.0
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 +250 -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-DVVzGrUm.mjs +106 -0
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-fields.component-DVVzGrUm.mjs.map +1 -0
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-menu.component-DzUmL7Je.mjs +197 -0
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-menu.component-DzUmL7Je.mjs.map +1 -0
- package/fesm2022/3kles-kles-richtext-editor.mjs +36 -21
- 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 +45 -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,250 @@
|
|
|
1
|
+
import { provideRichTextToolbarAppearance } from "@3kles/kles-richtext-editor";
|
|
2
|
+
import { NgTemplateOutlet } from "@angular/common";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import { ChangeDetectionStrategy, Component, effect, input, signal, viewChild } from "@angular/core";
|
|
5
|
+
import { MatButton, MatIconButton } from "@angular/material/button";
|
|
6
|
+
import { MatIcon } from "@angular/material/icon";
|
|
7
|
+
import { MaterialColorPickerPanelComponent } from "@3kles/kles-material-color-picker";
|
|
8
|
+
var RichTextMaterialToolbarButtonComponent = class RichTextMaterialToolbarButtonComponent {
|
|
9
|
+
control = input.required(...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
|
|
10
|
+
preserveSelection(event) {
|
|
11
|
+
if (event.button === 0) event.preventDefault();
|
|
12
|
+
}
|
|
13
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
14
|
+
minVersion: "12.0.0",
|
|
15
|
+
version: "22.2.6",
|
|
16
|
+
ngImport: i0,
|
|
17
|
+
type: RichTextMaterialToolbarButtonComponent,
|
|
18
|
+
deps: [],
|
|
19
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
20
|
+
});
|
|
21
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
22
|
+
minVersion: "17.0.0",
|
|
23
|
+
version: "22.2.6",
|
|
24
|
+
type: RichTextMaterialToolbarButtonComponent,
|
|
25
|
+
isStandalone: true,
|
|
26
|
+
selector: "kles-richtext-material-toolbar-button",
|
|
27
|
+
inputs: { control: {
|
|
28
|
+
classPropertyName: "control",
|
|
29
|
+
publicName: "control",
|
|
30
|
+
isSignal: true,
|
|
31
|
+
isRequired: true,
|
|
32
|
+
transformFunction: null
|
|
33
|
+
} },
|
|
34
|
+
ngImport: i0,
|
|
35
|
+
template: "@let button = control();\n<ng-template #contents>\n @if (button.content; as content) {\n <ng-container [ngTemplateOutlet]=\"content.template\" [ngTemplateOutletContext]=\"content.context\" />\n } @else {\n @if (button.iconType === 'material' && button.icon) {\n <mat-icon aria-hidden=\"true\">{{ button.icon }}</mat-icon>\n } @else if (button.icon) {\n <span aria-hidden=\"true\">{{ button.icon }}</span>\n }\n {{ button.label }}\n }\n</ng-template>\n\n@if (!button.label && button.icon && !button.content) {\n <button\n matIconButton\n type=\"button\"\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 [title]=\"button.ariaLabel\"\n [tabIndex]=\"button.tabStop ?? 0\"\n [disabled]=\"button.disabled\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"button.activate?.()\"\n >\n <ng-container *ngTemplateOutlet=\"contents\" />\n </button>\n} @else {\n <button\n [matButton]=\"button.pressed ? 'tonal' : 'text'\"\n type=\"button\"\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 [tabIndex]=\"button.tabStop ?? 0\"\n [disabled]=\"button.disabled\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"button.activate?.()\"\n >\n <ng-container *ngTemplateOutlet=\"contents\" />\n </button>\n}\n",
|
|
36
|
+
styles: [":host{display:contents}mat-icon{font-family:var(--kles-richtext-toolbar-material-icon-font, \"Material Icons\")}button[matIconButton][aria-pressed=true]{--mat-icon-button-icon-color: var(--mat-sys-on-secondary-container);background-color:var(--mat-sys-secondary-container)}\n"],
|
|
37
|
+
dependencies: [
|
|
38
|
+
{
|
|
39
|
+
kind: "component",
|
|
40
|
+
type: MatButton,
|
|
41
|
+
selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ",
|
|
42
|
+
inputs: ["matButton"],
|
|
43
|
+
exportAs: ["matButton", "matAnchor"]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
kind: "component",
|
|
47
|
+
type: MatIconButton,
|
|
48
|
+
selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
|
|
49
|
+
exportAs: ["matButton", "matAnchor"]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
kind: "component",
|
|
53
|
+
type: MatIcon,
|
|
54
|
+
selector: "mat-icon",
|
|
55
|
+
inputs: [
|
|
56
|
+
"color",
|
|
57
|
+
"inline",
|
|
58
|
+
"svgIcon",
|
|
59
|
+
"fontSet",
|
|
60
|
+
"fontIcon"
|
|
61
|
+
],
|
|
62
|
+
exportAs: ["matIcon"]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
kind: "directive",
|
|
66
|
+
type: NgTemplateOutlet,
|
|
67
|
+
selector: "[ngTemplateOutlet]",
|
|
68
|
+
inputs: [
|
|
69
|
+
"ngTemplateOutletContext",
|
|
70
|
+
"ngTemplateOutlet",
|
|
71
|
+
"ngTemplateOutletInjector"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
79
|
+
minVersion: "12.0.0",
|
|
80
|
+
version: "22.2.6",
|
|
81
|
+
ngImport: i0,
|
|
82
|
+
type: RichTextMaterialToolbarButtonComponent,
|
|
83
|
+
decorators: [{
|
|
84
|
+
type: Component,
|
|
85
|
+
args: [{
|
|
86
|
+
selector: "kles-richtext-material-toolbar-button",
|
|
87
|
+
imports: [
|
|
88
|
+
MatButton,
|
|
89
|
+
MatIconButton,
|
|
90
|
+
MatIcon,
|
|
91
|
+
NgTemplateOutlet
|
|
92
|
+
],
|
|
93
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
94
|
+
template: "@let button = control();\n<ng-template #contents>\n @if (button.content; as content) {\n <ng-container [ngTemplateOutlet]=\"content.template\" [ngTemplateOutletContext]=\"content.context\" />\n } @else {\n @if (button.iconType === 'material' && button.icon) {\n <mat-icon aria-hidden=\"true\">{{ button.icon }}</mat-icon>\n } @else if (button.icon) {\n <span aria-hidden=\"true\">{{ button.icon }}</span>\n }\n {{ button.label }}\n }\n</ng-template>\n\n@if (!button.label && button.icon && !button.content) {\n <button\n matIconButton\n type=\"button\"\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 [title]=\"button.ariaLabel\"\n [tabIndex]=\"button.tabStop ?? 0\"\n [disabled]=\"button.disabled\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"button.activate?.()\"\n >\n <ng-container *ngTemplateOutlet=\"contents\" />\n </button>\n} @else {\n <button\n [matButton]=\"button.pressed ? 'tonal' : 'text'\"\n type=\"button\"\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 [tabIndex]=\"button.tabStop ?? 0\"\n [disabled]=\"button.disabled\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"button.activate?.()\"\n >\n <ng-container *ngTemplateOutlet=\"contents\" />\n </button>\n}\n",
|
|
95
|
+
styles: [":host{display:contents}mat-icon{font-family:var(--kles-richtext-toolbar-material-icon-font, \"Material Icons\")}button[matIconButton][aria-pressed=true]{--mat-icon-button-icon-color: var(--mat-sys-on-secondary-container);background-color:var(--mat-sys-secondary-container)}\n"]
|
|
96
|
+
}]
|
|
97
|
+
}],
|
|
98
|
+
propDecorators: { control: [{
|
|
99
|
+
type: i0.Input,
|
|
100
|
+
args: [{
|
|
101
|
+
isSignal: true,
|
|
102
|
+
alias: "control",
|
|
103
|
+
required: true
|
|
104
|
+
}]
|
|
105
|
+
}] }
|
|
106
|
+
});
|
|
107
|
+
var RichTextMaterialToolbarColorComponent = class RichTextMaterialToolbarColorComponent {
|
|
108
|
+
control = input.required(...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
|
|
109
|
+
open = signal(false, ...ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []);
|
|
110
|
+
panel = viewChild("panel", ...ngDevMode ? [{ debugName: "panel" }] : /* istanbul ignore next */ []);
|
|
111
|
+
constructor() {
|
|
112
|
+
effect(() => {
|
|
113
|
+
const panel = this.panel()?.nativeElement;
|
|
114
|
+
if (this.control().disabled && panel?.matches(":popover-open")) panel.hidePopover();
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
preserveSelection(event) {
|
|
118
|
+
if (event.button === 0) event.preventDefault();
|
|
119
|
+
}
|
|
120
|
+
syncPopover(panel) {
|
|
121
|
+
this.open.set(panel.matches(":popover-open"));
|
|
122
|
+
}
|
|
123
|
+
cancel(panel, trigger, event) {
|
|
124
|
+
if (event instanceof KeyboardEvent && event.isComposing) return;
|
|
125
|
+
event?.preventDefault();
|
|
126
|
+
event?.stopPropagation();
|
|
127
|
+
trigger.focus("program", { preventScroll: true });
|
|
128
|
+
panel.hidePopover();
|
|
129
|
+
}
|
|
130
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
131
|
+
minVersion: "12.0.0",
|
|
132
|
+
version: "22.2.6",
|
|
133
|
+
ngImport: i0,
|
|
134
|
+
type: RichTextMaterialToolbarColorComponent,
|
|
135
|
+
deps: [],
|
|
136
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
137
|
+
});
|
|
138
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
139
|
+
minVersion: "17.0.0",
|
|
140
|
+
version: "22.2.6",
|
|
141
|
+
type: RichTextMaterialToolbarColorComponent,
|
|
142
|
+
isStandalone: true,
|
|
143
|
+
selector: "kles-richtext-material-toolbar-color",
|
|
144
|
+
inputs: { control: {
|
|
145
|
+
classPropertyName: "control",
|
|
146
|
+
publicName: "control",
|
|
147
|
+
isSignal: true,
|
|
148
|
+
isRequired: true,
|
|
149
|
+
transformFunction: null
|
|
150
|
+
} },
|
|
151
|
+
viewQueries: [{
|
|
152
|
+
propertyName: "panel",
|
|
153
|
+
first: true,
|
|
154
|
+
predicate: ["panel"],
|
|
155
|
+
descendants: true,
|
|
156
|
+
isSignal: true
|
|
157
|
+
}],
|
|
158
|
+
ngImport: i0,
|
|
159
|
+
template: "@let color = control();\n<div class=\"color-field\" [attr.data-richtext-field]=\"color.id\">\n <button\n matIconButton\n #trigger\n type=\"button\"\n [disabled]=\"color.disabled\"\n [attr.aria-label]=\"color.ariaLabel\"\n [title]=\"color.label\"\n [attr.popovertarget]=\"color.popoverId\"\n aria-haspopup=\"dialog\"\n (mousedown)=\"preserveSelection($event)\"\n >\n <mat-icon [style.border-block-end-color]=\"color.value || null\">\n {{ color.id === 'color' ? 'format_color_text' : 'format_color_fill' }}\n </mat-icon>\n </button>\n @if (color.value !== undefined) {\n <button\n matIconButton\n type=\"button\"\n [disabled]=\"color.disabled\"\n [attr.aria-label]=\"color.resetLabel\"\n [title]=\"color.resetLabel\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"color.change('')\"\n >\n <mat-icon>close</mat-icon>\n </button>\n }\n</div>\n<div\n #panel\n [id]=\"color.popoverId\"\n class=\"color-panel\"\n role=\"dialog\"\n [attr.aria-label]=\"color.ariaLabel\"\n popover=\"auto\"\n tabindex=\"-1\"\n autofocus\n (toggle)=\"syncPopover(panel)\"\n (keydown.escape)=\"cancel(panel, trigger, $event)\"\n>\n @if (open()) {\n <kles-material-color-picker-panel\n [color]=\"color.value ?? color.fallback\"\n [fallbackColor]=\"color.fallback\"\n [disabled]=\"color.disabled\"\n commitMode=\"apply\"\n outputFormat=\"hex8\"\n (colorChange)=\"color.change($event)\"\n (applied)=\"panel.hidePopover()\"\n (cancelled)=\"cancel(panel, trigger)\"\n />\n }\n</div>\n",
|
|
160
|
+
styles: [":host{display:contents}.color-field{display:inline-flex;align-items:center}mat-icon{font-family:var(--kles-richtext-toolbar-material-icon-font, \"Material Icons\");border-block-end:.15em solid transparent}.color-panel{max-inline-size:calc(100vw - 1rem);max-block-size:calc(100dvh - 1rem);overflow:auto;border:none;padding:0;background-color:var(--mat-sys-surface-container);color:var(--mat-sys-on-surface);border-radius:var(--mat-sys-corner-medium);box-shadow:var(--mat-sys-level3)}@supports (position-area: block-end span-inline-end){.color-panel{inset:auto;margin:.25rem 0;position-area:block-end span-inline-end;position-try-fallbacks:flip-inline,flip-block,flip-block flip-inline}}\n"],
|
|
161
|
+
dependencies: [
|
|
162
|
+
{
|
|
163
|
+
kind: "component",
|
|
164
|
+
type: MatIconButton,
|
|
165
|
+
selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
|
|
166
|
+
exportAs: ["matButton", "matAnchor"]
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
kind: "component",
|
|
170
|
+
type: MatIcon,
|
|
171
|
+
selector: "mat-icon",
|
|
172
|
+
inputs: [
|
|
173
|
+
"color",
|
|
174
|
+
"inline",
|
|
175
|
+
"svgIcon",
|
|
176
|
+
"fontSet",
|
|
177
|
+
"fontIcon"
|
|
178
|
+
],
|
|
179
|
+
exportAs: ["matIcon"]
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
kind: "component",
|
|
183
|
+
type: MaterialColorPickerPanelComponent,
|
|
184
|
+
selector: "kles-material-color-picker-panel",
|
|
185
|
+
inputs: [
|
|
186
|
+
"color",
|
|
187
|
+
"outputFormat",
|
|
188
|
+
"commitMode",
|
|
189
|
+
"alpha",
|
|
190
|
+
"eyeDropper",
|
|
191
|
+
"disabled",
|
|
192
|
+
"fallbackColor",
|
|
193
|
+
"presets"
|
|
194
|
+
],
|
|
195
|
+
outputs: [
|
|
196
|
+
"draftChange",
|
|
197
|
+
"colorChange",
|
|
198
|
+
"applied",
|
|
199
|
+
"cancelled"
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
207
|
+
minVersion: "12.0.0",
|
|
208
|
+
version: "22.2.6",
|
|
209
|
+
ngImport: i0,
|
|
210
|
+
type: RichTextMaterialToolbarColorComponent,
|
|
211
|
+
decorators: [{
|
|
212
|
+
type: Component,
|
|
213
|
+
args: [{
|
|
214
|
+
selector: "kles-richtext-material-toolbar-color",
|
|
215
|
+
imports: [
|
|
216
|
+
MatIconButton,
|
|
217
|
+
MatIcon,
|
|
218
|
+
MaterialColorPickerPanelComponent
|
|
219
|
+
],
|
|
220
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
221
|
+
template: "@let color = control();\n<div class=\"color-field\" [attr.data-richtext-field]=\"color.id\">\n <button\n matIconButton\n #trigger\n type=\"button\"\n [disabled]=\"color.disabled\"\n [attr.aria-label]=\"color.ariaLabel\"\n [title]=\"color.label\"\n [attr.popovertarget]=\"color.popoverId\"\n aria-haspopup=\"dialog\"\n (mousedown)=\"preserveSelection($event)\"\n >\n <mat-icon [style.border-block-end-color]=\"color.value || null\">\n {{ color.id === 'color' ? 'format_color_text' : 'format_color_fill' }}\n </mat-icon>\n </button>\n @if (color.value !== undefined) {\n <button\n matIconButton\n type=\"button\"\n [disabled]=\"color.disabled\"\n [attr.aria-label]=\"color.resetLabel\"\n [title]=\"color.resetLabel\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"color.change('')\"\n >\n <mat-icon>close</mat-icon>\n </button>\n }\n</div>\n<div\n #panel\n [id]=\"color.popoverId\"\n class=\"color-panel\"\n role=\"dialog\"\n [attr.aria-label]=\"color.ariaLabel\"\n popover=\"auto\"\n tabindex=\"-1\"\n autofocus\n (toggle)=\"syncPopover(panel)\"\n (keydown.escape)=\"cancel(panel, trigger, $event)\"\n>\n @if (open()) {\n <kles-material-color-picker-panel\n [color]=\"color.value ?? color.fallback\"\n [fallbackColor]=\"color.fallback\"\n [disabled]=\"color.disabled\"\n commitMode=\"apply\"\n outputFormat=\"hex8\"\n (colorChange)=\"color.change($event)\"\n (applied)=\"panel.hidePopover()\"\n (cancelled)=\"cancel(panel, trigger)\"\n />\n }\n</div>\n",
|
|
222
|
+
styles: [":host{display:contents}.color-field{display:inline-flex;align-items:center}mat-icon{font-family:var(--kles-richtext-toolbar-material-icon-font, \"Material Icons\");border-block-end:.15em solid transparent}.color-panel{max-inline-size:calc(100vw - 1rem);max-block-size:calc(100dvh - 1rem);overflow:auto;border:none;padding:0;background-color:var(--mat-sys-surface-container);color:var(--mat-sys-on-surface);border-radius:var(--mat-sys-corner-medium);box-shadow:var(--mat-sys-level3)}@supports (position-area: block-end span-inline-end){.color-panel{inset:auto;margin:.25rem 0;position-area:block-end span-inline-end;position-try-fallbacks:flip-inline,flip-block,flip-block flip-inline}}\n"]
|
|
223
|
+
}]
|
|
224
|
+
}],
|
|
225
|
+
ctorParameters: () => [],
|
|
226
|
+
propDecorators: {
|
|
227
|
+
control: [{
|
|
228
|
+
type: i0.Input,
|
|
229
|
+
args: [{
|
|
230
|
+
isSignal: true,
|
|
231
|
+
alias: "control",
|
|
232
|
+
required: true
|
|
233
|
+
}]
|
|
234
|
+
}],
|
|
235
|
+
panel: [{
|
|
236
|
+
type: i0.ViewChild,
|
|
237
|
+
args: ["panel", { isSignal: true }]
|
|
238
|
+
}]
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
function provideRichTextMaterialToolbar(overrides = {}) {
|
|
242
|
+
return provideRichTextToolbarAppearance({
|
|
243
|
+
button: RichTextMaterialToolbarButtonComponent,
|
|
244
|
+
color: RichTextMaterialToolbarColorComponent,
|
|
245
|
+
...overrides
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
export { provideRichTextMaterialToolbar };
|
|
249
|
+
|
|
250
|
+
//# sourceMappingURL=3kles-kles-richtext-editor-material.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3kles-kles-richtext-editor-material.mjs","names":[],"sources":["../../../projects/kles-richtext-editor/material/src/material-toolbar-button.component.ts","../../../projects/kles-richtext-editor/material/src/material-toolbar-button.component.html","../../../projects/kles-richtext-editor/material/src/material-toolbar-color.component.ts","../../../projects/kles-richtext-editor/material/src/material-toolbar-color.component.html","../../../projects/kles-richtext-editor/material/src/public-api.ts"],"sourcesContent":["import { NgTemplateOutlet } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, input } from '@angular/core';\nimport { MatButton, MatIconButton } from '@angular/material/button';\nimport { MatIcon } from '@angular/material/icon';\nimport type { RichTextToolbarButtonControl } from '@3kles/kles-richtext-editor';\n\n@Component({\n selector: 'kles-richtext-material-toolbar-button',\n imports: [MatButton, MatIconButton, MatIcon, NgTemplateOutlet],\n templateUrl: './material-toolbar-button.component.html',\n styleUrl: './material-toolbar-button.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class RichTextMaterialToolbarButtonComponent {\n readonly control = input.required<RichTextToolbarButtonControl>();\n\n protected preserveSelection(event: MouseEvent): void {\n if (event.button === 0) event.preventDefault();\n }\n}\n","@let button = control();\n<ng-template #contents>\n @if (button.content; as content) {\n <ng-container [ngTemplateOutlet]=\"content.template\" [ngTemplateOutletContext]=\"content.context\" />\n } @else {\n @if (button.iconType === 'material' && button.icon) {\n <mat-icon aria-hidden=\"true\">{{ button.icon }}</mat-icon>\n } @else if (button.icon) {\n <span aria-hidden=\"true\">{{ button.icon }}</span>\n }\n {{ button.label }}\n }\n</ng-template>\n\n@if (!button.label && button.icon && !button.content) {\n <button\n matIconButton\n type=\"button\"\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 [title]=\"button.ariaLabel\"\n [tabIndex]=\"button.tabStop ?? 0\"\n [disabled]=\"button.disabled\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"button.activate?.()\"\n >\n <ng-container *ngTemplateOutlet=\"contents\" />\n </button>\n} @else {\n <button\n [matButton]=\"button.pressed ? 'tonal' : 'text'\"\n type=\"button\"\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 [tabIndex]=\"button.tabStop ?? 0\"\n [disabled]=\"button.disabled\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"button.activate?.()\"\n >\n <ng-container *ngTemplateOutlet=\"contents\" />\n </button>\n}\n","import { ChangeDetectionStrategy, Component, effect, input, signal, viewChild } from '@angular/core';\nimport type { ElementRef } from '@angular/core';\nimport { MatIconButton } from '@angular/material/button';\nimport { MatIcon } from '@angular/material/icon';\nimport { MaterialColorPickerPanelComponent } from '@3kles/kles-material-color-picker';\nimport type { RichTextToolbarColorControl } from '@3kles/kles-richtext-editor';\n\n@Component({\n selector: 'kles-richtext-material-toolbar-color',\n imports: [MatIconButton, MatIcon, MaterialColorPickerPanelComponent],\n templateUrl: './material-toolbar-color.component.html',\n styleUrl: './material-toolbar-color.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class RichTextMaterialToolbarColorComponent {\n readonly control = input.required<RichTextToolbarColorControl>();\n protected readonly open = signal(false);\n private readonly panel = viewChild<ElementRef<HTMLElement>>('panel');\n\n constructor() {\n effect(() => {\n const panel = this.panel()?.nativeElement;\n if (this.control().disabled && panel?.matches(':popover-open')) panel.hidePopover();\n });\n }\n\n protected preserveSelection(event: MouseEvent): void {\n if (event.button === 0) event.preventDefault();\n }\n\n protected syncPopover(panel: HTMLElement): void {\n this.open.set(panel.matches(':popover-open'));\n }\n\n protected cancel(panel: HTMLElement, trigger: MatIconButton, event?: Event): void {\n if (event instanceof KeyboardEvent && event.isComposing) return;\n event?.preventDefault();\n event?.stopPropagation();\n trigger.focus('program', { preventScroll: true });\n panel.hidePopover();\n }\n}\n","@let color = control();\n<div class=\"color-field\" [attr.data-richtext-field]=\"color.id\">\n <button\n matIconButton\n #trigger\n type=\"button\"\n [disabled]=\"color.disabled\"\n [attr.aria-label]=\"color.ariaLabel\"\n [title]=\"color.label\"\n [attr.popovertarget]=\"color.popoverId\"\n aria-haspopup=\"dialog\"\n (mousedown)=\"preserveSelection($event)\"\n >\n <mat-icon [style.border-block-end-color]=\"color.value || null\">\n {{ color.id === 'color' ? 'format_color_text' : 'format_color_fill' }}\n </mat-icon>\n </button>\n @if (color.value !== undefined) {\n <button\n matIconButton\n type=\"button\"\n [disabled]=\"color.disabled\"\n [attr.aria-label]=\"color.resetLabel\"\n [title]=\"color.resetLabel\"\n (mousedown)=\"preserveSelection($event)\"\n (click)=\"color.change('')\"\n >\n <mat-icon>close</mat-icon>\n </button>\n }\n</div>\n<div\n #panel\n [id]=\"color.popoverId\"\n class=\"color-panel\"\n role=\"dialog\"\n [attr.aria-label]=\"color.ariaLabel\"\n popover=\"auto\"\n tabindex=\"-1\"\n autofocus\n (toggle)=\"syncPopover(panel)\"\n (keydown.escape)=\"cancel(panel, trigger, $event)\"\n>\n @if (open()) {\n <kles-material-color-picker-panel\n [color]=\"color.value ?? color.fallback\"\n [fallbackColor]=\"color.fallback\"\n [disabled]=\"color.disabled\"\n commitMode=\"apply\"\n outputFormat=\"hex8\"\n (colorChange)=\"color.change($event)\"\n (applied)=\"panel.hidePopover()\"\n (cancelled)=\"cancel(panel, trigger)\"\n />\n }\n</div>\n","import { provideRichTextToolbarAppearance } from '@3kles/kles-richtext-editor';\nimport type { RichTextToolbarAppearance } from '@3kles/kles-richtext-editor';\nimport type { Provider } from '@angular/core';\nimport { RichTextMaterialToolbarButtonComponent } from './material-toolbar-button.component.js';\nimport { RichTextMaterialToolbarColorComponent } from './material-toolbar-color.component.js';\n\n/** Display toolbar controls using the application's Angular Material theme. */\nexport function provideRichTextMaterialToolbar(overrides: RichTextToolbarAppearance = {}): Provider {\n return provideRichTextToolbarAppearance({\n button: RichTextMaterialToolbarButtonComponent,\n color: RichTextMaterialToolbarColorComponent,\n ...overrides,\n });\n}\n"],"mappings":"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"}
|
|
@@ -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 { RichTextToolbarButtonContext, RichTextToolbarIconType } 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 interface RichTextToolbarAppearance {\n readonly button?: Type<{ readonly control: InputSignal<RichTextToolbarButtonControl> }>;\n readonly color?: Type<{ readonly control: InputSignal<RichTextToolbarColorControl> }>;\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":";;;AA0CA,MAAa,8BAA8B,IAAI,eAC3C,+BACA;CACI,YAAY;CACZ,gBAAgB,CAAA;AACnB,CAAA;AAGL,SAAgB,iCAAiC,YAAqC;CAClF,OAAO;EAAE,SAAS;EAA6B,UAAU;CAAU;AACvE;ACxCA,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,106 @@
|
|
|
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
|
+
resetColor = {
|
|
9
|
+
color: () => this.toolbar().changeStyle("color", ""),
|
|
10
|
+
backgroundColor: () => this.toolbar().changeStyle("backgroundColor", "")
|
|
11
|
+
};
|
|
12
|
+
linkControl(remove) {
|
|
13
|
+
const ariaLabel = this.toolbar().text()[remove ? "removeLink" : "applyLink"];
|
|
14
|
+
const iconOnly = this.toolbar().iconOnly();
|
|
15
|
+
return {
|
|
16
|
+
label: iconOnly ? "" : ariaLabel,
|
|
17
|
+
ariaLabel,
|
|
18
|
+
disabled: remove ? this.toolbar().removeLinkDisabled() : this.toolbar().applyLinkDisabled(),
|
|
19
|
+
icon: iconOnly ? remove ? "link_off" : "link" : void 0,
|
|
20
|
+
iconType: "material",
|
|
21
|
+
fieldId: "link",
|
|
22
|
+
activate: () => remove ? this.toolbar().removeLink() : this.toolbar().applyLink()
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
colorControl(field) {
|
|
26
|
+
return {
|
|
27
|
+
...field,
|
|
28
|
+
popoverId: `${this.toolbar().linkErrorId}-${field.id}`,
|
|
29
|
+
ariaLabel: field.ariaLabel?.trim() || field.label,
|
|
30
|
+
resetLabel: this.toolbar().text()[field.id === "color" ? "resetColor" : "resetBackgroundColor"],
|
|
31
|
+
change: (value) => this.toolbar().changeStyle(field.id, value)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
35
|
+
minVersion: "12.0.0",
|
|
36
|
+
version: "22.2.6",
|
|
37
|
+
ngImport: i0,
|
|
38
|
+
type: RichTextToolbarFieldsComponent,
|
|
39
|
+
deps: [],
|
|
40
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
41
|
+
});
|
|
42
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
43
|
+
minVersion: "17.0.0",
|
|
44
|
+
version: "22.2.6",
|
|
45
|
+
type: RichTextToolbarFieldsComponent,
|
|
46
|
+
isStandalone: true,
|
|
47
|
+
selector: "kles-richtext-toolbar-fields",
|
|
48
|
+
inputs: { toolbar: {
|
|
49
|
+
classPropertyName: "toolbar",
|
|
50
|
+
publicName: "toolbar",
|
|
51
|
+
isSignal: true,
|
|
52
|
+
isRequired: true,
|
|
53
|
+
transformFunction: null
|
|
54
|
+
} },
|
|
55
|
+
ngImport: i0,
|
|
56
|
+
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 (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 <kles-richtext-toolbar-button [control]=\"linkControl(false)\" />\n <kles-richtext-toolbar-button [control]=\"linkControl(true)\" />\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 }\n</div>\n",
|
|
57
|
+
styles: [":host{display:contents}.kles-richtext-toolbar__fields{display:flex;align-items:center;flex-wrap:wrap;gap:.5rem}.kles-richtext-toolbar__fields{display:flex;align-items:flex-end;flex-wrap:wrap;gap:.5rem;margin-block-start:.75rem}.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}.kles-richtext-toolbar input,.kles-richtext-toolbar 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 input{min-width:0;width:100%;color:inherit}.kles-richtext-toolbar input[type=color]{cursor:pointer;padding:.25rem;min-inline-size:2.75rem}.kles-richtext-toolbar :is(input,select):disabled{opacity:.5;cursor:not-allowed}.kles-richtext-toolbar :is(input,select):focus-visible{outline:3px solid var(--kles-richtext-toolbar-focus, var(--accent, #174f89));outline-offset:3px}.kles-richtext-toolbar input[aria-invalid=true]{border-color:var(--kles-richtext-toolbar-error, var(--error, #9e2020))}\n"],
|
|
58
|
+
dependencies: [{
|
|
59
|
+
kind: "directive",
|
|
60
|
+
type: NgComponentOutlet,
|
|
61
|
+
selector: "[ngComponentOutlet]",
|
|
62
|
+
inputs: [
|
|
63
|
+
"ngComponentOutlet",
|
|
64
|
+
"ngComponentOutletInputs",
|
|
65
|
+
"ngComponentOutletInjector",
|
|
66
|
+
"ngComponentOutletEnvironmentInjector",
|
|
67
|
+
"ngComponentOutletContent",
|
|
68
|
+
"ngComponentOutletNgModule"
|
|
69
|
+
],
|
|
70
|
+
exportAs: ["ngComponentOutlet"]
|
|
71
|
+
}, {
|
|
72
|
+
kind: "component",
|
|
73
|
+
type: RichTextToolbarButtonComponent,
|
|
74
|
+
selector: "kles-richtext-toolbar-button",
|
|
75
|
+
inputs: ["control"]
|
|
76
|
+
}],
|
|
77
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
81
|
+
minVersion: "12.0.0",
|
|
82
|
+
version: "22.2.6",
|
|
83
|
+
ngImport: i0,
|
|
84
|
+
type: RichTextToolbarFieldsComponent,
|
|
85
|
+
decorators: [{
|
|
86
|
+
type: Component,
|
|
87
|
+
args: [{
|
|
88
|
+
selector: "kles-richtext-toolbar-fields",
|
|
89
|
+
imports: [NgComponentOutlet, RichTextToolbarButtonComponent],
|
|
90
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
91
|
+
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 (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 <kles-richtext-toolbar-button [control]=\"linkControl(false)\" />\n <kles-richtext-toolbar-button [control]=\"linkControl(true)\" />\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 }\n</div>\n",
|
|
92
|
+
styles: [":host{display:contents}.kles-richtext-toolbar__fields{display:flex;align-items:center;flex-wrap:wrap;gap:.5rem}.kles-richtext-toolbar__fields{display:flex;align-items:flex-end;flex-wrap:wrap;gap:.5rem;margin-block-start:.75rem}.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}.kles-richtext-toolbar input,.kles-richtext-toolbar 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 input{min-width:0;width:100%;color:inherit}.kles-richtext-toolbar input[type=color]{cursor:pointer;padding:.25rem;min-inline-size:2.75rem}.kles-richtext-toolbar :is(input,select):disabled{opacity:.5;cursor:not-allowed}.kles-richtext-toolbar :is(input,select):focus-visible{outline:3px solid var(--kles-richtext-toolbar-focus, var(--accent, #174f89));outline-offset:3px}.kles-richtext-toolbar input[aria-invalid=true]{border-color:var(--kles-richtext-toolbar-error, var(--error, #9e2020))}\n"]
|
|
93
|
+
}]
|
|
94
|
+
}],
|
|
95
|
+
propDecorators: { toolbar: [{
|
|
96
|
+
type: i0.Input,
|
|
97
|
+
args: [{
|
|
98
|
+
isSignal: true,
|
|
99
|
+
alias: "toolbar",
|
|
100
|
+
required: true
|
|
101
|
+
}]
|
|
102
|
+
}] }
|
|
103
|
+
});
|
|
104
|
+
export { RichTextToolbarFieldsComponent };
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=3kles-kles-richtext-editor-richtext-toolbar-fields.component-DVVzGrUm.mjs.map
|
package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-fields.component-DVVzGrUm.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3kles-kles-richtext-editor-richtext-toolbar-fields.component-DVVzGrUm.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 { RichTextToolbarButtonControl, RichTextToolbarColorControl } from './toolbar-appearance.js';\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 resetColor = {\n color: () => this.toolbar().changeStyle('color', ''),\n backgroundColor: () => this.toolbar().changeStyle('backgroundColor', ''),\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 (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 <kles-richtext-toolbar-button [control]=\"linkControl(false)\" />\n <kles-richtext-toolbar-button [control]=\"linkControl(true)\" />\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 }\n</div>\n"],"mappings":";;;;AAcA,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,aAAa;EAC5B,aAAa,KAAK,QAAO,CAAE,CAAC,YAAY,SAAS,EAAE;EACnD,uBAAuB,KAAK,QAAO,CAAE,CAAC,YAAY,mBAAmB,EAAE;CAC1E;CAES,YAAY,QAAe;EACjC,MAAM,YAAY,KAAK,QAAO,CAAE,CAAC,KAAI,CAAE,CAAC,SAAS,eAAe;EAChE,MAAM,WAAW,KAAK,QAAO,CAAE,CAAC,SAAQ;EACxC,OAAO;GACH,OAAO,WAAW,KAAK;GACvB;GACA,UAAU,SAAS,KAAK,QAAO,CAAE,CAAC,mBAAkB,IAAK,KAAK,QAAO,CAAE,CAAC,kBAAiB;GACzF,MAAM,WAAY,SAAS,aAAa,SAAU;GAClD,UAAU;GACV,SAAS;GACT,gBAAiB,SAAS,KAAK,QAAO,CAAE,CAAC,WAAU,IAAK,KAAK,QAAO,CAAE,CAAC,UAAS;EACnF;CACL;CAEU,aAAa,OAOtB;EACG,OAAO;GACH,GAAG;GACH,WAAW,GAAG,KAAK,QAAO,CAAE,CAAC,YAAW,GAAI,MAAM;GAClD,WAAW,MAAM,WAAW,KAAI,KAAM,MAAM;GAC5C,YAAY,KAAK,QAAO,CAAE,CAAC,KAAI,CAAE,CAAC,MAAM,OAAO,UAAU,eAAe;GACxE,SAAS,UAAU,KAAK,QAAO,CAAE,CAAC,YAAY,MAAM,IAAI,KAAK;EAChE;CACL;CArCS,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,UCd3C;EAsFA,QAAA,CAAA,g6CAAA;EAAA,cAAA,CAAA;GAAA,MAAA;GAAA,MD7Ec;GAAiB,UAAA;GAAA,QAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;GAAA;GAAA,UAAA,CAAA,mBAAA;EAAA,GAAA;GAAA,MAAA;GAAA,MAAE;GAA8B,UAAA;GAAA,QAAA,CAAA,SAAA;EAAA,CAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AAKlD,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,8BAA8B;GAAC,iBAG3C,wBAAwB;GAAM,UAAA;GAAA,QAAA,CAAA,g6CAAA;EAAA,CAAA"}
|