import * as _angular_core from '@angular/core'; import { OnDestroy } from '@angular/core'; /** * One control on the editor's default toolbar. * * The list doubles as the key space for {@link MnRichTextEditorLabels}: a label * can only be given for a control the default toolbar actually renders. */ type MnRichTextEditorControl = 'textStyle' | 'bold' | 'italic' | 'underline' | 'strike' | 'orderedList' | 'bulletList' | 'blockquote' | 'codeBlock' | 'link' | 'clean'; /** * Hover labels for the toolbar controls. * * Values are either literal text (`labels`) or translation keys resolved through * `MnLanguageService` (`labelKeys`); anything left out falls back to the * component's built-in English label. */ type MnRichTextEditorLabels = Partial>; /** * A Quill toolbar definition: rows of control descriptors, exactly as Quill's * `modules.toolbar` option takes them. * * Typed loosely on purpose — Quill accepts strings (`'bold'`) and objects * (`{ header: [2, 3, false] }`) in the same row, and the library does not export * a type for it. */ type MnRichTextEditorToolbar = readonly (readonly unknown[])[]; /** * Thin wrapper around the {@link Quill} rich-text editor. * * Quill is used **directly** rather than through an Angular wrapper package: the * wrapper libraries carry peer-dependency ranges that lag behind Angular's * release train, and none of them add anything this component needs. * * Consumers must install `quill` themselves (it is an optional peer dependency) * and load its snow theme, e.g. `node_modules/quill/dist/quill.snow.css` in the * `styles` array of `angular.json`. Only the chrome around that theme — radius, * borders, height limits and the toolbar tooltips — belongs to this component; * recolouring Quill's own palette to an app theme stays with the app, because * the same `.ql-snow` markup is normally reused to render stored HTML in places * where no editor is mounted. * * Quill itself is pulled in with a dynamic `import()` when the editor mounts. * This component sits in the library's single entry point, which apps import * eagerly, so a static import would put the whole editor engine in every app's * initial bundle — including the pages that never open one. * * Zoneless notes: nothing here relies on an implicit change-detection tick. The * editor is created inside {@link afterNextRender} (the host element only exists * after the first render pass) and every value that flows back out is written to * a signal or emitted through an `output`, both of which schedule change * detection themselves. No `setTimeout`, no manual `detectChanges`. * * The produced HTML is **not** trusted: sanitise it before rendering it anywhere. * * @example * ```html * * * ``` */ declare class MnRichTextEditor implements OnDestroy { /** * The initial HTML content. Later changes are applied only when they differ * from what the editor currently holds, so a parent echoing the emitted value * back never moves the caret. */ readonly content: _angular_core.InputSignal; /** Placeholder shown while the editor is empty. */ readonly placeholder: _angular_core.InputSignal; /** Accessible label for the editing surface. */ readonly ariaLabel: _angular_core.InputSignal; /** Toolbar layout, in Quill's own format. Defaults to a prose-oriented set. */ readonly toolbar: _angular_core.InputSignal; /** Literal hover labels per toolbar control. */ readonly labels: _angular_core.InputSignal>>; /** Translation keys per toolbar control; takes precedence over `labels`. */ readonly labelKeys: _angular_core.InputSignal>>; /** * Utilities applied to the wrapper, for sizing the writing surface. Overriding * this replaces the default height limits, so pass both bounds when you do. */ readonly editorClass: _angular_core.InputSignal; /** Emits the editor's HTML on every user edit. */ readonly contentChange: _angular_core.OutputEmitterRef; /** * Chrome around Quill's snow theme: the field's radius, border and surface. * * Descendant variants rather than a stylesheet — the utilities come from the * consuming app's Tailwind build (which scans this bundle), so they follow the * app's theme tokens the same way the rest of the library does. */ protected readonly chromeClass: string; /** Host element, used to keep DOM queries inside this component. */ private readonly host; /** Language service, used to resolve the toolbar labels from keys. */ private readonly lang; /** The container Quill mounts into. */ private readonly editorHost; /** The live editor instance, or null before Quill has loaded. */ private quill; /** Whether the component is gone, so a late Quill load knows to stop. */ private destroyed; /** The last HTML this component emitted, used to skip redundant writes. */ private readonly lastEmitted; constructor(); /** Drops the editor reference so the instance can be garbage collected. */ ngOnDestroy(): void; /** Moves focus into the editing surface. */ focusEditor(): void; /** * Loads Quill, builds the instance and wires its change handler. * * Nothing awaits this beyond the component itself: the surface appears once * the engine has loaded, and until then the `content` effect is a no-op that * the seeding below makes good. */ private createEditor; /** * Gives each toolbar control a hover label, so hovering explains what the * style does. Set on the Quill-generated DOM after init; a control the current * toolbar does not render is simply skipped. */ private applyToolbarLabels; /** * Picks the hover label for one control. * @param control The control being labelled. * @param labels Literal labels supplied by the consumer. * @param keys Translation keys supplied by the consumer. * @returns The translated key, the literal label, or the built-in default. */ private resolveLabel; /** * Replaces the editor content with stored HTML. Quill parses it into its own * document model, which silently drops anything it has no format for — a * useful extra filter on top of the consumer's sanitiser. * @param html The HTML to load into the editor. */ private setEditorHtml; /** Emits the editor's current HTML, normalising Quill's "empty" document. */ private emitCurrentHtml; /** * Reads the editor's HTML. * @returns The current HTML, or an empty string when the editor is blank. */ private readHtml; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } export { MnRichTextEditor }; export type { MnRichTextEditorControl, MnRichTextEditorLabels, MnRichTextEditorToolbar };