@3kles/kles-richtext-editor 1.4.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 +273 -0
- package/fesm2022/3kles-kles-richtext-editor-material.mjs.map +1 -1
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-button.component-B0aePmqW.mjs.map +1 -1
- 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-DzUmL7Je.mjs → 3kles-kles-richtext-editor-richtext-toolbar-menu.component-DkaxVVT8.mjs} +35 -8
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-menu.component-DkaxVVT8.mjs.map +1 -0
- package/fesm2022/3kles-kles-richtext-editor.mjs +6 -3
- package/fesm2022/3kles-kles-richtext-editor.mjs.map +1 -1
- package/package.json +4 -4
- package/types/3kles-kles-richtext-editor-material.d.ts.map +1 -1
- package/types/3kles-kles-richtext-editor.d.ts +38 -1
- package/types/3kles-kles-richtext-editor.d.ts.map +1 -1
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-fields.component-DVVzGrUm.mjs +0 -106
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-fields.component-DVVzGrUm.mjs.map +0 -1
- package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-menu.component-DzUmL7Je.mjs.map +0 -1
|
@@ -5,6 +5,10 @@ import { ChangeDetectionStrategy, Component, effect, input, signal, viewChild }
|
|
|
5
5
|
import { MatButton, MatIconButton } from "@angular/material/button";
|
|
6
6
|
import { MatIcon } from "@angular/material/icon";
|
|
7
7
|
import { MaterialColorPickerPanelComponent } from "@3kles/kles-material-color-picker";
|
|
8
|
+
import { MatFormField, MatLabel } from "@angular/material/form-field";
|
|
9
|
+
import { MatInput } from "@angular/material/input";
|
|
10
|
+
import * as i1 from "@angular/material/list";
|
|
11
|
+
import { MatListModule, MatSelectionList } from "@angular/material/list";
|
|
8
12
|
var RichTextMaterialToolbarButtonComponent = class RichTextMaterialToolbarButtonComponent {
|
|
9
13
|
control = input.required(...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
|
|
10
14
|
preserveSelection(event) {
|
|
@@ -238,10 +242,279 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
238
242
|
}]
|
|
239
243
|
}
|
|
240
244
|
});
|
|
245
|
+
var RichTextMaterialToolbarFieldComponent = class RichTextMaterialToolbarFieldComponent {
|
|
246
|
+
control = input.required(...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
|
|
247
|
+
errorStateMatcher = { isErrorState: () => {
|
|
248
|
+
const field = this.control();
|
|
249
|
+
return field.kind === "link" && field.invalid;
|
|
250
|
+
} };
|
|
251
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
252
|
+
minVersion: "12.0.0",
|
|
253
|
+
version: "22.2.6",
|
|
254
|
+
ngImport: i0,
|
|
255
|
+
type: RichTextMaterialToolbarFieldComponent,
|
|
256
|
+
deps: [],
|
|
257
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
258
|
+
});
|
|
259
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
260
|
+
minVersion: "17.0.0",
|
|
261
|
+
version: "22.2.6",
|
|
262
|
+
type: RichTextMaterialToolbarFieldComponent,
|
|
263
|
+
isStandalone: true,
|
|
264
|
+
selector: "kles-richtext-material-toolbar-field",
|
|
265
|
+
inputs: { control: {
|
|
266
|
+
classPropertyName: "control",
|
|
267
|
+
publicName: "control",
|
|
268
|
+
isSignal: true,
|
|
269
|
+
isRequired: true,
|
|
270
|
+
transformFunction: null
|
|
271
|
+
} },
|
|
272
|
+
host: { properties: { "class.link-field": "control().kind === \"link\"" } },
|
|
273
|
+
ngImport: i0,
|
|
274
|
+
template: "@let field = control();\n<mat-form-field appearance=\"outline\" subscriptSizing=\"dynamic\" [attr.data-richtext-field]=\"field.id\">\n <mat-label>{{ field.label }}</mat-label>\n @if (field.kind === 'link') {\n <input\n #url\n matInput\n type=\"text\"\n inputmode=\"url\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [errorStateMatcher]=\"errorStateMatcher\"\n [attr.aria-label]=\"field.ariaLabel\"\n [aria-describedby]=\"field.invalid ? field.errorId : ''\"\n [disabled]=\"field.disabled\"\n [value]=\"field.value\"\n (input)=\"field.change(url.value)\"\n (keydown.enter)=\"field.submit($event)\"\n />\n } @else {\n <select\n #choice\n matNativeControl\n [attr.aria-label]=\"field.ariaLabel\"\n [disabled]=\"field.disabled\"\n (change)=\"field.change(choice.value)\"\n >\n @for (option of field.options; track option.value) {\n <option\n [value]=\"option.value\"\n [selected]=\"option.value === field.value\"\n [disabled]=\"option.disabled ?? false\"\n >\n {{ option.label }}\n </option>\n }\n </select>\n }\n</mat-form-field>\n",
|
|
275
|
+
styles: [":host{display:block;min-inline-size:0}:host(.link-field){flex:1 1 14rem;max-inline-size:28rem}mat-form-field{inline-size:100%}\n"],
|
|
276
|
+
dependencies: [
|
|
277
|
+
{
|
|
278
|
+
kind: "component",
|
|
279
|
+
type: MatFormField,
|
|
280
|
+
selector: "mat-form-field",
|
|
281
|
+
inputs: [
|
|
282
|
+
"hideRequiredMarker",
|
|
283
|
+
"color",
|
|
284
|
+
"floatLabel",
|
|
285
|
+
"appearance",
|
|
286
|
+
"subscriptSizing",
|
|
287
|
+
"hintLabel"
|
|
288
|
+
],
|
|
289
|
+
exportAs: ["matFormField"]
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
kind: "directive",
|
|
293
|
+
type: MatLabel,
|
|
294
|
+
selector: "mat-label"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
kind: "directive",
|
|
298
|
+
type: MatInput,
|
|
299
|
+
selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
|
|
300
|
+
inputs: [
|
|
301
|
+
"disabled",
|
|
302
|
+
"id",
|
|
303
|
+
"placeholder",
|
|
304
|
+
"name",
|
|
305
|
+
"required",
|
|
306
|
+
"type",
|
|
307
|
+
"errorStateMatcher",
|
|
308
|
+
"aria-describedby",
|
|
309
|
+
"value",
|
|
310
|
+
"readonly",
|
|
311
|
+
"disabledInteractive"
|
|
312
|
+
],
|
|
313
|
+
exportAs: ["matInput"]
|
|
314
|
+
}
|
|
315
|
+
],
|
|
316
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
320
|
+
minVersion: "12.0.0",
|
|
321
|
+
version: "22.2.6",
|
|
322
|
+
ngImport: i0,
|
|
323
|
+
type: RichTextMaterialToolbarFieldComponent,
|
|
324
|
+
decorators: [{
|
|
325
|
+
type: Component,
|
|
326
|
+
args: [{
|
|
327
|
+
selector: "kles-richtext-material-toolbar-field",
|
|
328
|
+
imports: [
|
|
329
|
+
MatFormField,
|
|
330
|
+
MatLabel,
|
|
331
|
+
MatInput
|
|
332
|
+
],
|
|
333
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
334
|
+
host: { "[class.link-field]": "control().kind === \"link\"" },
|
|
335
|
+
template: "@let field = control();\n<mat-form-field appearance=\"outline\" subscriptSizing=\"dynamic\" [attr.data-richtext-field]=\"field.id\">\n <mat-label>{{ field.label }}</mat-label>\n @if (field.kind === 'link') {\n <input\n #url\n matInput\n type=\"text\"\n inputmode=\"url\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [errorStateMatcher]=\"errorStateMatcher\"\n [attr.aria-label]=\"field.ariaLabel\"\n [aria-describedby]=\"field.invalid ? field.errorId : ''\"\n [disabled]=\"field.disabled\"\n [value]=\"field.value\"\n (input)=\"field.change(url.value)\"\n (keydown.enter)=\"field.submit($event)\"\n />\n } @else {\n <select\n #choice\n matNativeControl\n [attr.aria-label]=\"field.ariaLabel\"\n [disabled]=\"field.disabled\"\n (change)=\"field.change(choice.value)\"\n >\n @for (option of field.options; track option.value) {\n <option\n [value]=\"option.value\"\n [selected]=\"option.value === field.value\"\n [disabled]=\"option.disabled ?? false\"\n >\n {{ option.label }}\n </option>\n }\n </select>\n }\n</mat-form-field>\n",
|
|
336
|
+
styles: [":host{display:block;min-inline-size:0}:host(.link-field){flex:1 1 14rem;max-inline-size:28rem}mat-form-field{inline-size:100%}\n"]
|
|
337
|
+
}]
|
|
338
|
+
}],
|
|
339
|
+
propDecorators: { control: [{
|
|
340
|
+
type: i0.Input,
|
|
341
|
+
args: [{
|
|
342
|
+
isSignal: true,
|
|
343
|
+
alias: "control",
|
|
344
|
+
required: true
|
|
345
|
+
}]
|
|
346
|
+
}] }
|
|
347
|
+
});
|
|
348
|
+
var RichTextMaterialToolbarMenuComponent = class RichTextMaterialToolbarMenuComponent {
|
|
349
|
+
control = input.required(...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
|
|
350
|
+
list = viewChild(MatSelectionList, ...ngDevMode ? [{ debugName: "list" }] : /* istanbul ignore next */ []);
|
|
351
|
+
choose(event) {
|
|
352
|
+
const value = event.options[0]?.value;
|
|
353
|
+
const menu = this.control();
|
|
354
|
+
const item = menu.groups.flatMap((group) => group.items).find((item) => item === value);
|
|
355
|
+
if (item) menu.choose(item);
|
|
356
|
+
}
|
|
357
|
+
focusResults(event) {
|
|
358
|
+
event.preventDefault();
|
|
359
|
+
this.list()?.options.find((option) => !option.disabled)?.focus();
|
|
360
|
+
}
|
|
361
|
+
chooseFirst(event) {
|
|
362
|
+
event.preventDefault();
|
|
363
|
+
const menu = this.control();
|
|
364
|
+
const item = menu.groups.flatMap((group) => group.items).find((item) => !item.disabled);
|
|
365
|
+
if (item) menu.choose(item);
|
|
366
|
+
}
|
|
367
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
368
|
+
minVersion: "12.0.0",
|
|
369
|
+
version: "22.2.6",
|
|
370
|
+
ngImport: i0,
|
|
371
|
+
type: RichTextMaterialToolbarMenuComponent,
|
|
372
|
+
deps: [],
|
|
373
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
374
|
+
});
|
|
375
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
376
|
+
minVersion: "17.0.0",
|
|
377
|
+
version: "22.2.6",
|
|
378
|
+
type: RichTextMaterialToolbarMenuComponent,
|
|
379
|
+
isStandalone: true,
|
|
380
|
+
selector: "kles-richtext-material-toolbar-menu",
|
|
381
|
+
inputs: { control: {
|
|
382
|
+
classPropertyName: "control",
|
|
383
|
+
publicName: "control",
|
|
384
|
+
isSignal: true,
|
|
385
|
+
isRequired: true,
|
|
386
|
+
transformFunction: null
|
|
387
|
+
} },
|
|
388
|
+
viewQueries: [{
|
|
389
|
+
propertyName: "list",
|
|
390
|
+
first: true,
|
|
391
|
+
predicate: MatSelectionList,
|
|
392
|
+
descendants: true,
|
|
393
|
+
isSignal: true
|
|
394
|
+
}],
|
|
395
|
+
ngImport: i0,
|
|
396
|
+
template: "@let menu = control();\n<div class=\"menu\">\n <mat-form-field class=\"menu-search\" appearance=\"outline\" subscriptSizing=\"dynamic\">\n <mat-label>{{ menu.searchLabel }}</mat-label>\n <input\n #query\n matInput\n type=\"search\"\n autofocus\n [value]=\"menu.query\"\n [attr.aria-label]=\"menu.searchLabel\"\n (input)=\"menu.search(query.value)\"\n (keydown.arrowdown)=\"focusResults($event)\"\n (keydown.enter)=\"chooseFirst($event)\"\n />\n </mat-form-field>\n @if (menu.open) {\n @if (menu.groups.length) {\n <mat-selection-list\n class=\"menu-list\"\n [multiple]=\"false\"\n [hideSingleSelectionIndicator]=\"true\"\n [attr.aria-label]=\"menu.label\"\n (selectionChange)=\"choose($event)\"\n >\n @for (group of menu.groups; track group.id) {\n <div [attr.role]=\"group.label ? 'group' : null\" [attr.aria-label]=\"group.label || null\">\n @if (group.label) {\n <div mat-subheader aria-hidden=\"true\">{{ group.label }}</div>\n }\n @for (item of group.items; track item.id) {\n <mat-list-option\n [attr.data-richtext-menu-command]=\"item.id\"\n [value]=\"item\"\n [disabled]=\"item.disabled ?? false\"\n >\n {{ item.label }}\n </mat-list-option>\n }\n </div>\n }\n </mat-selection-list>\n } @else {\n <div class=\"menu-empty\" role=\"status\">{{ menu.noResults }}</div>\n }\n }\n</div>\n",
|
|
397
|
+
styles: [".menu{display:flex;flex-direction:column;max-block-size:min(24rem,55dvh);border-radius:var(--mat-sys-corner-medium);background:var(--mat-sys-surface-container);color:var(--mat-sys-on-surface);box-shadow:var(--mat-sys-level2)}.menu-search{box-sizing:border-box;inline-size:100%;padding:.5rem .5rem 0;flex:none}.menu-list{min-block-size:0;overflow-y:auto}.menu-list [mat-subheader]{color:var(--mat-sys-on-surface);font:var(--mat-sys-title-small);font-weight:600;letter-spacing:var(--mat-sys-title-small-tracking)}.menu-list [role=group] mat-list-option{padding-inline-start:2rem}.menu-empty{padding:.75rem;color:var(--mat-sys-on-surface-variant)}\n"],
|
|
398
|
+
dependencies: [
|
|
399
|
+
{
|
|
400
|
+
kind: "component",
|
|
401
|
+
type: MatFormField,
|
|
402
|
+
selector: "mat-form-field",
|
|
403
|
+
inputs: [
|
|
404
|
+
"hideRequiredMarker",
|
|
405
|
+
"color",
|
|
406
|
+
"floatLabel",
|
|
407
|
+
"appearance",
|
|
408
|
+
"subscriptSizing",
|
|
409
|
+
"hintLabel"
|
|
410
|
+
],
|
|
411
|
+
exportAs: ["matFormField"]
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
kind: "directive",
|
|
415
|
+
type: MatLabel,
|
|
416
|
+
selector: "mat-label"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
kind: "directive",
|
|
420
|
+
type: MatInput,
|
|
421
|
+
selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
|
|
422
|
+
inputs: [
|
|
423
|
+
"disabled",
|
|
424
|
+
"id",
|
|
425
|
+
"placeholder",
|
|
426
|
+
"name",
|
|
427
|
+
"required",
|
|
428
|
+
"type",
|
|
429
|
+
"errorStateMatcher",
|
|
430
|
+
"aria-describedby",
|
|
431
|
+
"value",
|
|
432
|
+
"readonly",
|
|
433
|
+
"disabledInteractive"
|
|
434
|
+
],
|
|
435
|
+
exportAs: ["matInput"]
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
kind: "ngmodule",
|
|
439
|
+
type: MatListModule
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
kind: "component",
|
|
443
|
+
type: i1.MatSelectionList,
|
|
444
|
+
selector: "mat-selection-list",
|
|
445
|
+
inputs: [
|
|
446
|
+
"color",
|
|
447
|
+
"compareWith",
|
|
448
|
+
"multiple",
|
|
449
|
+
"hideSingleSelectionIndicator",
|
|
450
|
+
"disabled"
|
|
451
|
+
],
|
|
452
|
+
outputs: ["selectionChange"],
|
|
453
|
+
exportAs: ["matSelectionList"]
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
kind: "component",
|
|
457
|
+
type: i1.MatListOption,
|
|
458
|
+
selector: "mat-list-option",
|
|
459
|
+
inputs: [
|
|
460
|
+
"togglePosition",
|
|
461
|
+
"color",
|
|
462
|
+
"value",
|
|
463
|
+
"selected"
|
|
464
|
+
],
|
|
465
|
+
outputs: ["selectedChange"],
|
|
466
|
+
exportAs: ["matListOption"]
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
kind: "directive",
|
|
470
|
+
type: i1.MatListSubheaderCssMatStyler,
|
|
471
|
+
selector: "[mat-subheader], [matSubheader]"
|
|
472
|
+
}
|
|
473
|
+
],
|
|
474
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
475
|
+
});
|
|
476
|
+
};
|
|
477
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
478
|
+
minVersion: "12.0.0",
|
|
479
|
+
version: "22.2.6",
|
|
480
|
+
ngImport: i0,
|
|
481
|
+
type: RichTextMaterialToolbarMenuComponent,
|
|
482
|
+
decorators: [{
|
|
483
|
+
type: Component,
|
|
484
|
+
args: [{
|
|
485
|
+
selector: "kles-richtext-material-toolbar-menu",
|
|
486
|
+
imports: [
|
|
487
|
+
MatFormField,
|
|
488
|
+
MatLabel,
|
|
489
|
+
MatInput,
|
|
490
|
+
MatListModule
|
|
491
|
+
],
|
|
492
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
493
|
+
template: "@let menu = control();\n<div class=\"menu\">\n <mat-form-field class=\"menu-search\" appearance=\"outline\" subscriptSizing=\"dynamic\">\n <mat-label>{{ menu.searchLabel }}</mat-label>\n <input\n #query\n matInput\n type=\"search\"\n autofocus\n [value]=\"menu.query\"\n [attr.aria-label]=\"menu.searchLabel\"\n (input)=\"menu.search(query.value)\"\n (keydown.arrowdown)=\"focusResults($event)\"\n (keydown.enter)=\"chooseFirst($event)\"\n />\n </mat-form-field>\n @if (menu.open) {\n @if (menu.groups.length) {\n <mat-selection-list\n class=\"menu-list\"\n [multiple]=\"false\"\n [hideSingleSelectionIndicator]=\"true\"\n [attr.aria-label]=\"menu.label\"\n (selectionChange)=\"choose($event)\"\n >\n @for (group of menu.groups; track group.id) {\n <div [attr.role]=\"group.label ? 'group' : null\" [attr.aria-label]=\"group.label || null\">\n @if (group.label) {\n <div mat-subheader aria-hidden=\"true\">{{ group.label }}</div>\n }\n @for (item of group.items; track item.id) {\n <mat-list-option\n [attr.data-richtext-menu-command]=\"item.id\"\n [value]=\"item\"\n [disabled]=\"item.disabled ?? false\"\n >\n {{ item.label }}\n </mat-list-option>\n }\n </div>\n }\n </mat-selection-list>\n } @else {\n <div class=\"menu-empty\" role=\"status\">{{ menu.noResults }}</div>\n }\n }\n</div>\n",
|
|
494
|
+
styles: [".menu{display:flex;flex-direction:column;max-block-size:min(24rem,55dvh);border-radius:var(--mat-sys-corner-medium);background:var(--mat-sys-surface-container);color:var(--mat-sys-on-surface);box-shadow:var(--mat-sys-level2)}.menu-search{box-sizing:border-box;inline-size:100%;padding:.5rem .5rem 0;flex:none}.menu-list{min-block-size:0;overflow-y:auto}.menu-list [mat-subheader]{color:var(--mat-sys-on-surface);font:var(--mat-sys-title-small);font-weight:600;letter-spacing:var(--mat-sys-title-small-tracking)}.menu-list [role=group] mat-list-option{padding-inline-start:2rem}.menu-empty{padding:.75rem;color:var(--mat-sys-on-surface-variant)}\n"]
|
|
495
|
+
}]
|
|
496
|
+
}],
|
|
497
|
+
propDecorators: {
|
|
498
|
+
control: [{
|
|
499
|
+
type: i0.Input,
|
|
500
|
+
args: [{
|
|
501
|
+
isSignal: true,
|
|
502
|
+
alias: "control",
|
|
503
|
+
required: true
|
|
504
|
+
}]
|
|
505
|
+
}],
|
|
506
|
+
list: [{
|
|
507
|
+
type: i0.ViewChild,
|
|
508
|
+
args: [i0.forwardRef(() => MatSelectionList), { isSignal: true }]
|
|
509
|
+
}]
|
|
510
|
+
}
|
|
511
|
+
});
|
|
241
512
|
function provideRichTextMaterialToolbar(overrides = {}) {
|
|
242
513
|
return provideRichTextToolbarAppearance({
|
|
243
514
|
button: RichTextMaterialToolbarButtonComponent,
|
|
244
515
|
color: RichTextMaterialToolbarColorComponent,
|
|
516
|
+
field: RichTextMaterialToolbarFieldComponent,
|
|
517
|
+
menu: RichTextMaterialToolbarMenuComponent,
|
|
245
518
|
...overrides
|
|
246
519
|
});
|
|
247
520
|
}
|
|
@@ -1 +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":";;;;;;;AAaA,IAAa,yCAAb,MAAa,uCAAsC;CACtC,UAAU,MAAM,SAAwC,GAAA,YAAA,CAAA,EA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AA;EAAA,cAAA;GAAA;IAAA,MAAA;IAAA,MD/Cc;IAAa,UAAA;IAAA,UAAA,CAAA,aAAA,WAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAO,UAAA;IAAA,QAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IAAA;IAAA,UAAA,CAAA,SAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAiC,UAAA;IAAA,QAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IAAA;IAAA,SAAA;KAAA;KAAA;KAAA;KAAA;IAAA;GAAA;EAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AAK1D,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAqC,YAAA,CAAA;EAPjD,MAAA;EACa,MAAA,CAAA;GAAA,UAAA;GAAsC,SACvC;IAAC;IAAe;IAAS;GAAiC;GAAC,iBAGnD,wBAAwB;GAAM,UAAA;GAAA,QAAA,CAAA,irBAAA;EAAA,CAAA;CAKa,CAAA;CAAA,sBAAA,CAAA;CAAA,gBAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,SAAO,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA;AEVvE,SAAgB,+BAA+B,YAAuC,CAAA,GAAE;CACpF,OAAO,iCAAiC;EACpC,QAAQ;EACR,OAAO;EACP,GAAG;CACN,CAAA;AACL"}
|
|
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/material-toolbar-field.component.ts","../../../projects/kles-richtext-editor/material/src/material-toolbar-field.component.html","../../../projects/kles-richtext-editor/material/src/material-toolbar-menu.component.ts","../../../projects/kles-richtext-editor/material/src/material-toolbar-menu.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 { ChangeDetectionStrategy, Component, input } from '@angular/core';\nimport type { ErrorStateMatcher } from '@angular/material/core';\nimport { MatFormField, MatLabel } from '@angular/material/form-field';\nimport { MatInput } from '@angular/material/input';\nimport type { RichTextToolbarFieldControl } from '@3kles/kles-richtext-editor';\n\n@Component({\n selector: 'kles-richtext-material-toolbar-field',\n imports: [MatFormField, MatLabel, MatInput],\n templateUrl: './material-toolbar-field.component.html',\n styleUrl: './material-toolbar-field.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: { '[class.link-field]': 'control().kind === \"link\"' },\n})\nexport class RichTextMaterialToolbarFieldComponent {\n readonly control = input.required<RichTextToolbarFieldControl>();\n protected readonly errorStateMatcher: ErrorStateMatcher = {\n isErrorState: () => {\n const field = this.control();\n return field.kind === 'link' && field.invalid;\n },\n };\n}\n","@let field = control();\n<mat-form-field appearance=\"outline\" subscriptSizing=\"dynamic\" [attr.data-richtext-field]=\"field.id\">\n <mat-label>{{ field.label }}</mat-label>\n @if (field.kind === 'link') {\n <input\n #url\n matInput\n type=\"text\"\n inputmode=\"url\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [errorStateMatcher]=\"errorStateMatcher\"\n [attr.aria-label]=\"field.ariaLabel\"\n [aria-describedby]=\"field.invalid ? field.errorId : ''\"\n [disabled]=\"field.disabled\"\n [value]=\"field.value\"\n (input)=\"field.change(url.value)\"\n (keydown.enter)=\"field.submit($event)\"\n />\n } @else {\n <select\n #choice\n matNativeControl\n [attr.aria-label]=\"field.ariaLabel\"\n [disabled]=\"field.disabled\"\n (change)=\"field.change(choice.value)\"\n >\n @for (option of field.options; track option.value) {\n <option\n [value]=\"option.value\"\n [selected]=\"option.value === field.value\"\n [disabled]=\"option.disabled ?? false\"\n >\n {{ option.label }}\n </option>\n }\n </select>\n }\n</mat-form-field>\n","import { ChangeDetectionStrategy, Component, input, viewChild } from '@angular/core';\nimport { MatFormField, MatLabel } from '@angular/material/form-field';\nimport { MatInput } from '@angular/material/input';\nimport { MatListModule, MatSelectionList } from '@angular/material/list';\nimport type { MatSelectionListChange } from '@angular/material/list';\nimport type { RichTextToolbarMenuControl } from '@3kles/kles-richtext-editor';\n\n@Component({\n selector: 'kles-richtext-material-toolbar-menu',\n imports: [MatFormField, MatLabel, MatInput, MatListModule],\n templateUrl: './material-toolbar-menu.component.html',\n styleUrl: './material-toolbar-menu.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class RichTextMaterialToolbarMenuComponent {\n readonly control = input.required<RichTextToolbarMenuControl>();\n private readonly list = viewChild(MatSelectionList);\n\n protected choose(event: MatSelectionListChange): void {\n const value: unknown = event.options[0]?.value;\n const menu = this.control();\n const item = menu.groups.flatMap((group) => group.items).find((item) => item === value);\n if (item) menu.choose(item);\n }\n\n protected focusResults(event: Event): void {\n event.preventDefault();\n this.list()\n ?.options.find((option) => !option.disabled)\n ?.focus();\n }\n\n protected chooseFirst(event: Event): void {\n event.preventDefault();\n const menu = this.control();\n const item = menu.groups.flatMap((group) => group.items).find((item) => !item.disabled);\n if (item) menu.choose(item);\n }\n}\n","@let menu = control();\n<div class=\"menu\">\n <mat-form-field class=\"menu-search\" appearance=\"outline\" subscriptSizing=\"dynamic\">\n <mat-label>{{ menu.searchLabel }}</mat-label>\n <input\n #query\n matInput\n type=\"search\"\n autofocus\n [value]=\"menu.query\"\n [attr.aria-label]=\"menu.searchLabel\"\n (input)=\"menu.search(query.value)\"\n (keydown.arrowdown)=\"focusResults($event)\"\n (keydown.enter)=\"chooseFirst($event)\"\n />\n </mat-form-field>\n @if (menu.open) {\n @if (menu.groups.length) {\n <mat-selection-list\n class=\"menu-list\"\n [multiple]=\"false\"\n [hideSingleSelectionIndicator]=\"true\"\n [attr.aria-label]=\"menu.label\"\n (selectionChange)=\"choose($event)\"\n >\n @for (group of menu.groups; track group.id) {\n <div [attr.role]=\"group.label ? 'group' : null\" [attr.aria-label]=\"group.label || null\">\n @if (group.label) {\n <div mat-subheader aria-hidden=\"true\">{{ group.label }}</div>\n }\n @for (item of group.items; track item.id) {\n <mat-list-option\n [attr.data-richtext-menu-command]=\"item.id\"\n [value]=\"item\"\n [disabled]=\"item.disabled ?? false\"\n >\n {{ item.label }}\n </mat-list-option>\n }\n </div>\n }\n </mat-selection-list>\n } @else {\n <div class=\"menu-empty\" role=\"status\">{{ menu.noResults }}</div>\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';\nimport { RichTextMaterialToolbarFieldComponent } from './material-toolbar-field.component.js';\nimport { RichTextMaterialToolbarMenuComponent } from './material-toolbar-menu.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 field: RichTextMaterialToolbarFieldComponent,\n menu: RichTextMaterialToolbarMenuComponent,\n ...overrides,\n });\n}\n"],"mappings":";;;;;;;;;;;AAaA,IAAa,yCAAb,MAAa,uCAAsC;CACtC,UAAU,MAAM,SAAwC,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAEvD,kBAAkB,OAAiB;EACzC,IAAI,MAAM,WAAW,GAAG,MAAM,eAAc;CAChD;CALS,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAsC,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAtC,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAsC,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,SAAA;GAAA,mBAAA;GAAA,YAAA;GAAA,UAAA;GAAA,YAAA;GAAA,mBAAA;EAAA,EAAA;EAAA,UAAA;EAAA,UCbnD;EAkDA,QAAA,CAAA,qRAAA;EAAA,cAAA;GAAA;IAAA,MAAA;IAAA,MD1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A,MAAA,GAAA;IAAA,UAAA;GAAA;EAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AAKhD,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAoC,YAAA,CAAA;EAPhD,MAAA;EACa,MAAA,CAAA;GAAA,UAAA;GAAqC,SACtC;IAAC;IAAc;IAAU;IAAU;GAAa;GAAC,iBAGzC,wBAAwB;GAAM,UAAA;GAAA,QAAA,CAAA,woBAAA;EAAA,CAAA;CAIb,CAAA;CAAA,gBAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,MAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,GAAA,iBAAA,gBAAgB,GAAA,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA;AEPtD,SAAgB,+BAA+B,YAAuC,CAAA,GAAE;CACpF,OAAO,iCAAiC;EACpC,QAAQ;EACR,OAAO;EACP,OAAO;EACP,MAAM;EACN,GAAG;CACN,CAAA;AACL"}
|
package/fesm2022/3kles-kles-richtext-editor-richtext-toolbar-button.component-B0aePmqW.mjs.map
CHANGED
|
@@ -1 +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 {
|
|
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,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