mn-angular-lib 2.0.34 → 2.0.35

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.
Files changed (52) hide show
  1. package/fesm2022/mn-angular-lib-alert.mjs +515 -527
  2. package/fesm2022/mn-angular-lib-alert.mjs.map +1 -1
  3. package/fesm2022/mn-angular-lib-bottom-sheet.mjs +264 -357
  4. package/fesm2022/mn-angular-lib-bottom-sheet.mjs.map +1 -1
  5. package/fesm2022/mn-angular-lib-button.mjs +819 -382
  6. package/fesm2022/mn-angular-lib-button.mjs.map +1 -1
  7. package/fesm2022/mn-angular-lib-calendar-core.mjs +240 -365
  8. package/fesm2022/mn-angular-lib-calendar-core.mjs.map +1 -1
  9. package/fesm2022/mn-angular-lib-calendar.mjs +1691 -1545
  10. package/fesm2022/mn-angular-lib-calendar.mjs.map +1 -1
  11. package/fesm2022/mn-angular-lib-collection.mjs +2367 -2796
  12. package/fesm2022/mn-angular-lib-collection.mjs.map +1 -1
  13. package/fesm2022/mn-angular-lib-core.mjs +693 -1241
  14. package/fesm2022/mn-angular-lib-core.mjs.map +1 -1
  15. package/fesm2022/mn-angular-lib-display.mjs +679 -712
  16. package/fesm2022/mn-angular-lib-display.mjs.map +1 -1
  17. package/fesm2022/mn-angular-lib-forms.mjs +3671 -4647
  18. package/fesm2022/mn-angular-lib-forms.mjs.map +1 -1
  19. package/fesm2022/mn-angular-lib-keyboard.mjs +221 -190
  20. package/fesm2022/mn-angular-lib-keyboard.mjs.map +1 -1
  21. package/fesm2022/mn-angular-lib-modal-core.mjs +711 -896
  22. package/fesm2022/mn-angular-lib-modal-core.mjs.map +1 -1
  23. package/fesm2022/mn-angular-lib-modal-ui.mjs +2089 -2035
  24. package/fesm2022/mn-angular-lib-modal-ui.mjs.map +1 -1
  25. package/fesm2022/mn-angular-lib-modal.mjs +76 -121
  26. package/fesm2022/mn-angular-lib-modal.mjs.map +1 -1
  27. package/fesm2022/mn-angular-lib-rich-text-editor.mjs +289 -277
  28. package/fesm2022/mn-angular-lib-rich-text-editor.mjs.map +1 -1
  29. package/fesm2022/mn-angular-lib-segmented.mjs +189 -241
  30. package/fesm2022/mn-angular-lib-segmented.mjs.map +1 -1
  31. package/fesm2022/mn-angular-lib-tab.mjs +409 -642
  32. package/fesm2022/mn-angular-lib-tab.mjs.map +1 -1
  33. package/fesm2022/mn-angular-lib.mjs +16 -29
  34. package/package.json +1 -1
  35. package/types/mn-angular-lib-alert.d.ts +239 -241
  36. package/types/mn-angular-lib-bottom-sheet.d.ts +190 -150
  37. package/types/mn-angular-lib-button.d.ts +319 -317
  38. package/types/mn-angular-lib-calendar-core.d.ts +199 -209
  39. package/types/mn-angular-lib-calendar.d.ts +656 -511
  40. package/types/mn-angular-lib-collection.d.ts +1649 -1585
  41. package/types/mn-angular-lib-core.d.ts +524 -535
  42. package/types/mn-angular-lib-display.d.ts +946 -886
  43. package/types/mn-angular-lib-forms.d.ts +3012 -3013
  44. package/types/mn-angular-lib-keyboard.d.ts +125 -85
  45. package/types/mn-angular-lib-modal-core.d.ts +978 -994
  46. package/types/mn-angular-lib-modal-ui.d.ts +541 -493
  47. package/types/mn-angular-lib-modal.d.ts +24 -27
  48. package/types/mn-angular-lib-rich-text-editor.d.ts +131 -98
  49. package/types/mn-angular-lib-segmented.d.ts +354 -341
  50. package/types/mn-angular-lib-tab.d.ts +345 -336
  51. package/types/mn-angular-lib.d.ts +16 -16
  52. package/fesm2022/mn-angular-lib.mjs.map +0 -1
@@ -1,284 +1,296 @@
1
- import * as i0 from '@angular/core';
2
- import { input, output, inject, ElementRef, viewChild, signal, afterNextRender, effect, untracked, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
3
- import { MnLanguageService } from 'mn-angular-lib/core';
4
-
5
- /**
6
- * Toolbar the editor renders when the consumer does not supply one. Deliberately
7
- * small: it covers written prose, so there is no colour picker, no font picker
8
- * and no image embedding (an image needs an upload and storage path the editor
9
- * knows nothing about).
10
- */
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, ElementRef, ViewEncapsulation, afterNextRender, effect, inject, input, output, signal, untracked, viewChild } from "@angular/core";
3
+ import { MnLanguageService } from "mn-angular-lib/core";
11
4
  const DEFAULT_TOOLBAR = [
12
- [{ header: [2, 3, false] }],
13
- ['bold', 'italic', 'underline', 'strike'],
14
- [{ list: 'ordered' }, { list: 'bullet' }],
15
- ['blockquote', 'code-block'],
16
- ['link'],
17
- ['clean'],
5
+ [{ header: [
6
+ 2,
7
+ 3,
8
+ false
9
+ ] }],
10
+ [
11
+ "bold",
12
+ "italic",
13
+ "underline",
14
+ "strike"
15
+ ],
16
+ [{ list: "ordered" }, { list: "bullet" }],
17
+ ["blockquote", "code-block"],
18
+ ["link"],
19
+ ["clean"]
18
20
  ];
19
- /** Where each control sits in the toolbar Quill builds. */
20
21
  const CONTROL_SELECTORS = {
21
- textStyle: '.ql-header .ql-picker-label',
22
- bold: 'button.ql-bold',
23
- italic: 'button.ql-italic',
24
- underline: 'button.ql-underline',
25
- strike: 'button.ql-strike',
26
- orderedList: 'button.ql-list[value="ordered"]',
27
- bulletList: 'button.ql-list[value="bullet"]',
28
- blockquote: 'button.ql-blockquote',
29
- codeBlock: 'button.ql-code-block',
30
- link: 'button.ql-link',
31
- clean: 'button.ql-clean',
22
+ textStyle: ".ql-header .ql-picker-label",
23
+ bold: "button.ql-bold",
24
+ italic: "button.ql-italic",
25
+ underline: "button.ql-underline",
26
+ strike: "button.ql-strike",
27
+ orderedList: "button.ql-list[value=\"ordered\"]",
28
+ bulletList: "button.ql-list[value=\"bullet\"]",
29
+ blockquote: "button.ql-blockquote",
30
+ codeBlock: "button.ql-code-block",
31
+ link: "button.ql-link",
32
+ clean: "button.ql-clean"
32
33
  };
33
- /** Hover labels used when the consumer supplies neither a label nor a key. */
34
34
  const DEFAULT_LABELS = {
35
- textStyle: 'Text style',
36
- bold: 'Bold',
37
- italic: 'Italic',
38
- underline: 'Underline',
39
- strike: 'Strikethrough',
40
- orderedList: 'Numbered list',
41
- bulletList: 'Bulleted list',
42
- blockquote: 'Quote',
43
- codeBlock: 'Code block',
44
- link: 'Link',
45
- clean: 'Clear formatting',
35
+ textStyle: "Text style",
36
+ bold: "Bold",
37
+ italic: "Italic",
38
+ underline: "Underline",
39
+ strike: "Strikethrough",
40
+ orderedList: "Numbered list",
41
+ bulletList: "Bulleted list",
42
+ blockquote: "Quote",
43
+ codeBlock: "Code block",
44
+ link: "Link",
45
+ clean: "Clear formatting"
46
46
  };
47
- /** Quill's document when it holds no text; treated as an empty value. */
48
- const EMPTY_DOCUMENT = '<p><br></p>';
49
- /**
50
- * Thin wrapper around the {@link Quill} rich-text editor.
51
- *
52
- * Quill is used **directly** rather than through an Angular wrapper package: the
53
- * wrapper libraries carry peer-dependency ranges that lag behind Angular's
54
- * release train, and none of them add anything this component needs.
55
- *
56
- * Consumers must install `quill` themselves (it is an optional peer dependency)
57
- * and load its snow theme, e.g. `node_modules/quill/dist/quill.snow.css` in the
58
- * `styles` array of `angular.json`. Only the chrome around that theme — radius,
59
- * borders, height limits and the toolbar tooltips — belongs to this component;
60
- * recolouring Quill's own palette to an app theme stays with the app, because
61
- * the same `.ql-snow` markup is normally reused to render stored HTML in places
62
- * where no editor is mounted.
63
- *
64
- * Quill itself is pulled in with a dynamic `import()` when the editor mounts.
65
- * This component sits in the library's single entry point, which apps import
66
- * eagerly, so a static import would put the whole editor engine in every app's
67
- * initial bundle — including the pages that never open one.
68
- *
69
- * Zoneless notes: nothing here relies on an implicit change-detection tick. The
70
- * editor is created inside {@link afterNextRender} (the host element only exists
71
- * after the first render pass) and every value that flows back out is written to
72
- * a signal or emitted through an `output`, both of which schedule change
73
- * detection themselves. No `setTimeout`, no manual `detectChanges`.
74
- *
75
- * The produced HTML is **not** trusted: sanitise it before rendering it anywhere.
76
- *
77
- * @example
78
- * ```html
79
- * <mn-rich-text-editor
80
- * [content]="draft()"
81
- * [placeholder]="'minutes.placeholder' | mnTranslate"
82
- * [labelKeys]="{ bold: 'editor.bold', italic: 'editor.italic' }"
83
- * (contentChange)="draft.set($event)">
84
- * </mn-rich-text-editor>
85
- * ```
86
- */
87
- class MnRichTextEditor {
88
- /**
89
- * The initial HTML content. Later changes are applied only when they differ
90
- * from what the editor currently holds, so a parent echoing the emitted value
91
- * back never moves the caret.
92
- */
93
- content = input('', /* @ts-ignore */
94
- ...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
95
- /** Placeholder shown while the editor is empty. */
96
- placeholder = input('', /* @ts-ignore */
97
- ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
98
- /** Accessible label for the editing surface. */
99
- ariaLabel = input('', /* @ts-ignore */
100
- ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
101
- /** Toolbar layout, in Quill's own format. Defaults to a prose-oriented set. */
102
- toolbar = input(DEFAULT_TOOLBAR, /* @ts-ignore */
103
- ...(ngDevMode ? [{ debugName: "toolbar" }] : /* istanbul ignore next */ []));
104
- /** Literal hover labels per toolbar control. */
105
- labels = input({}, /* @ts-ignore */
106
- ...(ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []));
107
- /** Translation keys per toolbar control; takes precedence over `labels`. */
108
- labelKeys = input({}, /* @ts-ignore */
109
- ...(ngDevMode ? [{ debugName: "labelKeys" }] : /* istanbul ignore next */ []));
110
- /**
111
- * Utilities applied to the wrapper, for sizing the writing surface. Overriding
112
- * this replaces the default height limits, so pass both bounds when you do.
113
- */
114
- editorClass = input('[&_.ql-editor]:max-h-104 [&_.ql-editor]:min-h-72 [&_.ql-editor]:overflow-y-auto', /* @ts-ignore */
115
- ...(ngDevMode ? [{ debugName: "editorClass" }] : /* istanbul ignore next */ []));
116
- /** Emits the editor's HTML on every user edit. */
117
- contentChange = output();
118
- /**
119
- * Chrome around Quill's snow theme: the field's radius, border and surface.
120
- *
121
- * Descendant variants rather than a stylesheet — the utilities come from the
122
- * consuming app's Tailwind build (which scans this bundle), so they follow the
123
- * app's theme tokens the same way the rest of the library does.
124
- */
125
- chromeClass = '[&_.ql-container.ql-snow]:rounded-b-xl [&_.ql-container.ql-snow]:border-base-300 ' +
126
- '[&_.ql-container.ql-snow]:bg-base-100 [&_.ql-container.ql-snow]:text-base ' +
127
- '[&_.ql-toolbar.ql-snow]:rounded-t-xl [&_.ql-toolbar.ql-snow]:border-base-300 ' +
128
- '[&_.ql-toolbar.ql-snow]:bg-base-100';
129
- /** Host element, used to keep DOM queries inside this component. */
130
- host = inject(ElementRef);
131
- /** Language service, used to resolve the toolbar labels from keys. */
132
- lang = inject(MnLanguageService);
133
- /** The container Quill mounts into. */
134
- editorHost = viewChild.required('editorHost', /* @ts-ignore */
135
- ...(ngDevMode ? [{ debugName: "editorHost" }] : /* istanbul ignore next */ []));
136
- /** The live editor instance, or null before Quill has loaded. */
137
- quill = null;
138
- /** Whether the component is gone, so a late Quill load knows to stop. */
139
- destroyed = false;
140
- /** The last HTML this component emitted, used to skip redundant writes. */
141
- lastEmitted = signal('', /* @ts-ignore */
142
- ...(ngDevMode ? [{ debugName: "lastEmitted" }] : /* istanbul ignore next */ []));
143
- constructor() {
144
- afterNextRender(() => void this.createEditor());
145
- // Push a changed `content` input into a live editor. `lastEmitted` is read
146
- // `untracked` on purpose: it must gate the write (skip when the incoming HTML
147
- // already matches what we hold) WITHOUT making the effect depend on it. If it
148
- // were tracked, every keystroke (which updates `lastEmitted`) would re-run the
149
- // effect and re-paste the now-stale `content` seed — wiping the user's typing
150
- // and resetting the caret after any wholesale reseed.
151
- effect(() => {
152
- const incoming = this.content();
153
- if (!this.quill || incoming === untracked(this.lastEmitted))
154
- return;
155
- this.setEditorHtml(incoming);
156
- });
157
- }
158
- /** Drops the editor reference so the instance can be garbage collected. */
159
- ngOnDestroy() {
160
- this.destroyed = true;
161
- this.quill = null;
162
- }
163
- /** Moves focus into the editing surface. */
164
- focusEditor() {
165
- this.quill?.focus();
166
- if (!this.quill) {
167
- this.host.nativeElement.querySelector('.ql-editor')?.focus();
168
- }
169
- }
170
- /**
171
- * Loads Quill, builds the instance and wires its change handler.
172
- *
173
- * Nothing awaits this beyond the component itself: the surface appears once
174
- * the engine has loaded, and until then the `content` effect is a no-op that
175
- * the seeding below makes good.
176
- */
177
- async createEditor() {
178
- const { default: QuillEditor } = await import('quill');
179
- if (this.destroyed)
180
- return;
181
- const container = this.editorHost().nativeElement;
182
- this.quill = new QuillEditor(container, {
183
- theme: 'snow',
184
- placeholder: this.placeholder(),
185
- modules: { toolbar: this.toolbar() },
186
- });
187
- const label = this.ariaLabel();
188
- if (label) {
189
- this.quill.root.setAttribute('aria-label', label);
190
- }
191
- this.applyToolbarLabels();
192
- this.setEditorHtml(this.content());
193
- this.quill.on('text-change', () => this.emitCurrentHtml());
194
- }
195
- /**
196
- * Gives each toolbar control a hover label, so hovering explains what the
197
- * style does. Set on the Quill-generated DOM after init; a control the current
198
- * toolbar does not render is simply skipped.
199
- */
200
- applyToolbarLabels() {
201
- const toolbar = this.host.nativeElement.querySelector('.ql-toolbar');
202
- if (!toolbar)
203
- return;
204
- const labels = this.labels();
205
- const keys = this.labelKeys();
206
- for (const [control, selector] of Object.entries(CONTROL_SELECTORS)) {
207
- const element = toolbar.querySelector(selector);
208
- if (!element)
209
- continue;
210
- element.classList.add('mn-rte-tooltip');
211
- element.setAttribute('data-tip', this.resolveLabel(control, labels, keys));
212
- }
213
- }
214
- /**
215
- * Picks the hover label for one control.
216
- * @param control The control being labelled.
217
- * @param labels Literal labels supplied by the consumer.
218
- * @param keys Translation keys supplied by the consumer.
219
- * @returns The translated key, the literal label, or the built-in default.
220
- */
221
- resolveLabel(control, labels, keys) {
222
- const key = keys[control];
223
- if (key) {
224
- // `t()` echoes the key back when the consumer has no translation for it;
225
- // that is a miss, not a label, so fall through to the remaining sources.
226
- const translated = this.lang.t(key);
227
- if (translated !== key)
228
- return translated;
229
- }
230
- return labels[control] ?? DEFAULT_LABELS[control];
231
- }
232
- /**
233
- * Replaces the editor content with stored HTML. Quill parses it into its own
234
- * document model, which silently drops anything it has no format for — a
235
- * useful extra filter on top of the consumer's sanitiser.
236
- * @param html The HTML to load into the editor.
237
- */
238
- setEditorHtml(html) {
239
- if (!this.quill)
240
- return;
241
- // `dangerouslyPasteHTML` is Quill's documented name for "parse this HTML".
242
- this.quill.clipboard.dangerouslyPasteHTML(html ?? '', 'silent');
243
- this.lastEmitted.set(this.readHtml());
244
- }
245
- /** Emits the editor's current HTML, normalising Quill's "empty" document. */
246
- emitCurrentHtml() {
247
- const html = this.readHtml();
248
- this.lastEmitted.set(html);
249
- this.contentChange.emit(html);
250
- }
251
- /**
252
- * Reads the editor's HTML.
253
- * @returns The current HTML, or an empty string when the editor is blank.
254
- */
255
- readHtml() {
256
- if (!this.quill)
257
- return '';
258
- // Quill leaves an empty paragraph behind after a clear; treat that as empty
259
- // so an untouched editor does not count as authored content.
260
- const html = this.quill.root.innerHTML;
261
- return html === EMPTY_DOCUMENT ? '' : html;
262
- }
263
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnRichTextEditor, deps: [], target: i0.ɵɵFactoryTarget.Component });
264
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.1.7", type: MnRichTextEditor, isStandalone: true, selector: "mn-rich-text-editor", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, toolbar: { classPropertyName: "toolbar", publicName: "toolbar", isSignal: true, isRequired: false, transformFunction: null }, labels: { classPropertyName: "labels", publicName: "labels", isSignal: true, isRequired: false, transformFunction: null }, labelKeys: { classPropertyName: "labelKeys", publicName: "labelKeys", isSignal: true, isRequired: false, transformFunction: null }, editorClass: { classPropertyName: "editorClass", publicName: "editorClass", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { contentChange: "contentChange" }, viewQueries: [{ propertyName: "editorHost", first: true, predicate: ["editorHost"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"mn-rich-text-editor {{ chromeClass }} {{ editorClass() }}\">\n <div #editorHost></div>\n</div>\n", styles: [".mn-rich-text-editor .mn-rte-tooltip{position:relative}.mn-rich-text-editor .mn-rte-tooltip[data-tip]:after{content:attr(data-tip);position:absolute;bottom:100%;left:50%;translate:-50% -.375rem;padding:.25rem .5rem;border-radius:.375rem;background-color:var(--color-secondary);color:var(--color-secondary-content);font-size:.75rem;line-height:1rem;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s;z-index:50}.mn-rich-text-editor .mn-rte-tooltip[data-tip]:hover:after,.mn-rich-text-editor .mn-rte-tooltip[data-tip]:focus-visible:after{opacity:1}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
265
- }
266
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnRichTextEditor, decorators: [{
267
- type: Component,
268
- args: [{ selector: 'mn-rich-text-editor', standalone: true, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"mn-rich-text-editor {{ chromeClass }} {{ editorClass() }}\">\n <div #editorHost></div>\n</div>\n", styles: [".mn-rich-text-editor .mn-rte-tooltip{position:relative}.mn-rich-text-editor .mn-rte-tooltip[data-tip]:after{content:attr(data-tip);position:absolute;bottom:100%;left:50%;translate:-50% -.375rem;padding:.25rem .5rem;border-radius:.375rem;background-color:var(--color-secondary);color:var(--color-secondary-content);font-size:.75rem;line-height:1rem;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s;z-index:50}.mn-rich-text-editor .mn-rte-tooltip[data-tip]:hover:after,.mn-rich-text-editor .mn-rte-tooltip[data-tip]:focus-visible:after{opacity:1}\n"] }]
269
- }], ctorParameters: () => [], propDecorators: { content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], toolbar: [{ type: i0.Input, args: [{ isSignal: true, alias: "toolbar", required: false }] }], labels: [{ type: i0.Input, args: [{ isSignal: true, alias: "labels", required: false }] }], labelKeys: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelKeys", required: false }] }], editorClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "editorClass", required: false }] }], contentChange: [{ type: i0.Output, args: ["contentChange"] }], editorHost: [{ type: i0.ViewChild, args: ['editorHost', { isSignal: true }] }] } });
270
-
271
- /**
272
- * Public API of the `mn-angular-lib/rich-text-editor` entry point: the rich-text editor.
273
- *
274
- * Each entry point is its own module in the published package, so a consumer's bundler
275
- * splits it into the chunk that uses it instead of loading the whole library at startup.
276
- * The root `mn-angular-lib` entry re-exports every entry point.
277
- */
278
-
279
- /**
280
- * Generated bundle index. Do not edit.
281
- */
282
-
47
+ const EMPTY_DOCUMENT = "<p><br></p>";
48
+ var MnRichTextEditor = class MnRichTextEditor {
49
+ content = input("", ...ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []);
50
+ placeholder = input("", ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
51
+ ariaLabel = input("", ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
52
+ toolbar = input(DEFAULT_TOOLBAR, ...ngDevMode ? [{ debugName: "toolbar" }] : /* istanbul ignore next */ []);
53
+ labels = input({}, ...ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []);
54
+ labelKeys = input({}, ...ngDevMode ? [{ debugName: "labelKeys" }] : /* istanbul ignore next */ []);
55
+ editorClass = input("[&_.ql-editor]:max-h-104 [&_.ql-editor]:min-h-72 [&_.ql-editor]:overflow-y-auto", ...ngDevMode ? [{ debugName: "editorClass" }] : /* istanbul ignore next */ []);
56
+ contentChange = output();
57
+ chromeClass = "[&_.ql-container.ql-snow]:rounded-b-xl [&_.ql-container.ql-snow]:border-base-300 [&_.ql-container.ql-snow]:bg-base-100 [&_.ql-container.ql-snow]:text-base [&_.ql-toolbar.ql-snow]:rounded-t-xl [&_.ql-toolbar.ql-snow]:border-base-300 [&_.ql-toolbar.ql-snow]:bg-base-100";
58
+ host = inject(ElementRef);
59
+ lang = inject(MnLanguageService);
60
+ editorHost = viewChild.required("editorHost", ...ngDevMode ? [{ debugName: "editorHost" }] : /* istanbul ignore next */ []);
61
+ quill = null;
62
+ destroyed = false;
63
+ lastEmitted = signal("", ...ngDevMode ? [{ debugName: "lastEmitted" }] : /* istanbul ignore next */ []);
64
+ constructor() {
65
+ afterNextRender(() => void this.createEditor());
66
+ effect(() => {
67
+ const incoming = this.content();
68
+ if (!this.quill || incoming === untracked(this.lastEmitted)) return;
69
+ this.setEditorHtml(incoming);
70
+ });
71
+ }
72
+ ngOnDestroy() {
73
+ this.destroyed = true;
74
+ this.quill = null;
75
+ }
76
+ focusEditor() {
77
+ this.quill?.focus();
78
+ if (!this.quill) this.host.nativeElement.querySelector(".ql-editor")?.focus();
79
+ }
80
+ async createEditor() {
81
+ const { default: QuillEditor } = await import("quill");
82
+ if (this.destroyed) return;
83
+ const container = this.editorHost().nativeElement;
84
+ this.quill = new QuillEditor(container, {
85
+ theme: "snow",
86
+ placeholder: this.placeholder(),
87
+ modules: { toolbar: this.toolbar() }
88
+ });
89
+ const label = this.ariaLabel();
90
+ if (label) this.quill.root.setAttribute("aria-label", label);
91
+ this.applyToolbarLabels();
92
+ this.setEditorHtml(this.content());
93
+ this.quill.on("text-change", () => this.emitCurrentHtml());
94
+ }
95
+ applyToolbarLabels() {
96
+ const toolbar = this.host.nativeElement.querySelector(".ql-toolbar");
97
+ if (!toolbar) return;
98
+ const labels = this.labels();
99
+ const keys = this.labelKeys();
100
+ for (const [control, selector] of Object.entries(CONTROL_SELECTORS)) {
101
+ const element = toolbar.querySelector(selector);
102
+ if (!element) continue;
103
+ element.classList.add("mn-rte-tooltip");
104
+ element.setAttribute("data-tip", this.resolveLabel(control, labels, keys));
105
+ }
106
+ }
107
+ resolveLabel(control, labels, keys) {
108
+ const key = keys[control];
109
+ if (key) {
110
+ const translated = this.lang.t(key);
111
+ if (translated !== key) return translated;
112
+ }
113
+ return labels[control] ?? DEFAULT_LABELS[control];
114
+ }
115
+ setEditorHtml(html) {
116
+ if (!this.quill) return;
117
+ this.quill.clipboard.dangerouslyPasteHTML(html ?? "", "silent");
118
+ this.lastEmitted.set(this.readHtml());
119
+ }
120
+ emitCurrentHtml() {
121
+ const html = this.readHtml();
122
+ this.lastEmitted.set(html);
123
+ this.contentChange.emit(html);
124
+ }
125
+ readHtml() {
126
+ if (!this.quill) return "";
127
+ const html = this.quill.root.innerHTML;
128
+ return html === EMPTY_DOCUMENT ? "" : html;
129
+ }
130
+ static ɵfac = i0.ɵɵngDeclareFactory({
131
+ minVersion: "12.0.0",
132
+ version: "22.2.2",
133
+ ngImport: i0,
134
+ type: MnRichTextEditor,
135
+ deps: [],
136
+ target: i0.ɵɵFactoryTarget.Component
137
+ });
138
+ static ɵcmp = i0.ɵɵngDeclareComponent({
139
+ minVersion: "17.2.0",
140
+ version: "22.2.2",
141
+ type: MnRichTextEditor,
142
+ isStandalone: true,
143
+ selector: "mn-rich-text-editor",
144
+ inputs: {
145
+ content: {
146
+ classPropertyName: "content",
147
+ publicName: "content",
148
+ isSignal: true,
149
+ isRequired: false,
150
+ transformFunction: null
151
+ },
152
+ placeholder: {
153
+ classPropertyName: "placeholder",
154
+ publicName: "placeholder",
155
+ isSignal: true,
156
+ isRequired: false,
157
+ transformFunction: null
158
+ },
159
+ ariaLabel: {
160
+ classPropertyName: "ariaLabel",
161
+ publicName: "ariaLabel",
162
+ isSignal: true,
163
+ isRequired: false,
164
+ transformFunction: null
165
+ },
166
+ toolbar: {
167
+ classPropertyName: "toolbar",
168
+ publicName: "toolbar",
169
+ isSignal: true,
170
+ isRequired: false,
171
+ transformFunction: null
172
+ },
173
+ labels: {
174
+ classPropertyName: "labels",
175
+ publicName: "labels",
176
+ isSignal: true,
177
+ isRequired: false,
178
+ transformFunction: null
179
+ },
180
+ labelKeys: {
181
+ classPropertyName: "labelKeys",
182
+ publicName: "labelKeys",
183
+ isSignal: true,
184
+ isRequired: false,
185
+ transformFunction: null
186
+ },
187
+ editorClass: {
188
+ classPropertyName: "editorClass",
189
+ publicName: "editorClass",
190
+ isSignal: true,
191
+ isRequired: false,
192
+ transformFunction: null
193
+ }
194
+ },
195
+ outputs: { contentChange: "contentChange" },
196
+ viewQueries: [{
197
+ propertyName: "editorHost",
198
+ first: true,
199
+ predicate: ["editorHost"],
200
+ descendants: true,
201
+ isSignal: true
202
+ }],
203
+ ngImport: i0,
204
+ template: "<div class=\"mn-rich-text-editor {{ chromeClass }} {{ editorClass() }}\">\n <div #editorHost></div>\n</div>\n",
205
+ styles: [".mn-rich-text-editor .mn-rte-tooltip{position:relative}.mn-rich-text-editor .mn-rte-tooltip[data-tip]:after{content:attr(data-tip);position:absolute;bottom:100%;left:50%;translate:-50% -.375rem;padding:.25rem .5rem;border-radius:.375rem;background-color:var(--color-secondary);color:var(--color-secondary-content);font-size:.75rem;line-height:1rem;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s;z-index:50}.mn-rich-text-editor .mn-rte-tooltip[data-tip]:hover:after,.mn-rich-text-editor .mn-rte-tooltip[data-tip]:focus-visible:after{opacity:1}\n"],
206
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
207
+ encapsulation: i0.ViewEncapsulation.None
208
+ });
209
+ };
210
+ i0.ɵɵngDeclareClassMetadata({
211
+ minVersion: "12.0.0",
212
+ version: "22.2.2",
213
+ ngImport: i0,
214
+ type: MnRichTextEditor,
215
+ decorators: [{
216
+ type: Component,
217
+ args: [{
218
+ selector: "mn-rich-text-editor",
219
+ standalone: true,
220
+ encapsulation: ViewEncapsulation.None,
221
+ changeDetection: ChangeDetectionStrategy.OnPush,
222
+ template: "<div class=\"mn-rich-text-editor {{ chromeClass }} {{ editorClass() }}\">\n <div #editorHost></div>\n</div>\n",
223
+ styles: [".mn-rich-text-editor .mn-rte-tooltip{position:relative}.mn-rich-text-editor .mn-rte-tooltip[data-tip]:after{content:attr(data-tip);position:absolute;bottom:100%;left:50%;translate:-50% -.375rem;padding:.25rem .5rem;border-radius:.375rem;background-color:var(--color-secondary);color:var(--color-secondary-content);font-size:.75rem;line-height:1rem;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s;z-index:50}.mn-rich-text-editor .mn-rte-tooltip[data-tip]:hover:after,.mn-rich-text-editor .mn-rte-tooltip[data-tip]:focus-visible:after{opacity:1}\n"]
224
+ }]
225
+ }],
226
+ ctorParameters: () => [],
227
+ propDecorators: {
228
+ content: [{
229
+ type: i0.Input,
230
+ args: [{
231
+ isSignal: true,
232
+ alias: "content",
233
+ required: false
234
+ }]
235
+ }],
236
+ placeholder: [{
237
+ type: i0.Input,
238
+ args: [{
239
+ isSignal: true,
240
+ alias: "placeholder",
241
+ required: false
242
+ }]
243
+ }],
244
+ ariaLabel: [{
245
+ type: i0.Input,
246
+ args: [{
247
+ isSignal: true,
248
+ alias: "ariaLabel",
249
+ required: false
250
+ }]
251
+ }],
252
+ toolbar: [{
253
+ type: i0.Input,
254
+ args: [{
255
+ isSignal: true,
256
+ alias: "toolbar",
257
+ required: false
258
+ }]
259
+ }],
260
+ labels: [{
261
+ type: i0.Input,
262
+ args: [{
263
+ isSignal: true,
264
+ alias: "labels",
265
+ required: false
266
+ }]
267
+ }],
268
+ labelKeys: [{
269
+ type: i0.Input,
270
+ args: [{
271
+ isSignal: true,
272
+ alias: "labelKeys",
273
+ required: false
274
+ }]
275
+ }],
276
+ editorClass: [{
277
+ type: i0.Input,
278
+ args: [{
279
+ isSignal: true,
280
+ alias: "editorClass",
281
+ required: false
282
+ }]
283
+ }],
284
+ contentChange: [{
285
+ type: i0.Output,
286
+ args: ["contentChange"]
287
+ }],
288
+ editorHost: [{
289
+ type: i0.ViewChild,
290
+ args: ["editorHost", { isSignal: true }]
291
+ }]
292
+ }
293
+ });
283
294
  export { MnRichTextEditor };
284
- //# sourceMappingURL=mn-angular-lib-rich-text-editor.mjs.map
295
+
296
+ //# sourceMappingURL=mn-angular-lib-rich-text-editor.mjs.map