@malva-ui/editor 0.1.13 → 0.1.14

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 (134) hide show
  1. package/README.md +5 -5
  2. package/fesm2022/malva-ui-editor-ai.mjs +17 -0
  3. package/fesm2022/malva-ui-editor-ai.mjs.map +1 -0
  4. package/fesm2022/malva-ui-editor.mjs +10227 -0
  5. package/fesm2022/malva-ui-editor.mjs.map +1 -0
  6. package/package.json +35 -26
  7. package/types/malva-ui-editor-ai.d.ts +1 -0
  8. package/types/malva-ui-editor.d.ts +2995 -0
  9. package/ai/index.d.ts +0 -12
  10. package/ai/malva-ui-editor-ai.d.ts +0 -5
  11. package/esm2022/ai/index.js +0 -12
  12. package/esm2022/ai/index.js.map +0 -1
  13. package/esm2022/ai/malva-ui-editor-ai.js +0 -5
  14. package/esm2022/ai/malva-ui-editor-ai.js.map +0 -1
  15. package/esm2022/index.js +0 -37
  16. package/esm2022/index.js.map +0 -1
  17. package/esm2022/lib/ai/editor-ai-actions.js +0 -69
  18. package/esm2022/lib/ai/editor-ai-actions.js.map +0 -1
  19. package/esm2022/lib/ai/editor-ai-context.js +0 -612
  20. package/esm2022/lib/ai/editor-ai-context.js.map +0 -1
  21. package/esm2022/lib/ai/editor-ai-menu.js +0 -288
  22. package/esm2022/lib/ai/editor-ai-menu.js.map +0 -1
  23. package/esm2022/lib/ai/editor-ai-review-bar.js +0 -223
  24. package/esm2022/lib/ai/editor-ai-review-bar.js.map +0 -1
  25. package/esm2022/lib/ai/editor-ai-stream.js +0 -677
  26. package/esm2022/lib/ai/editor-ai-stream.js.map +0 -1
  27. package/esm2022/lib/ai/editor-ai-suggestions.js +0 -751
  28. package/esm2022/lib/ai/editor-ai-suggestions.js.map +0 -1
  29. package/esm2022/lib/ai/editor-ai.tokens.js +0 -10
  30. package/esm2022/lib/ai/editor-ai.tokens.js.map +0 -1
  31. package/esm2022/lib/ai/editor-ai.types.js +0 -1
  32. package/esm2022/lib/ai/editor-ai.types.js.map +0 -1
  33. package/esm2022/lib/editor/editor.js +0 -985
  34. package/esm2022/lib/editor/editor.js.map +0 -1
  35. package/esm2022/lib/editor-extension-preflight.js +0 -83
  36. package/esm2022/lib/editor-extension-preflight.js.map +0 -1
  37. package/esm2022/lib/editor-serialization.js +0 -152
  38. package/esm2022/lib/editor-serialization.js.map +0 -1
  39. package/esm2022/lib/editor-toolbar-context.js +0 -259
  40. package/esm2022/lib/editor-toolbar-context.js.map +0 -1
  41. package/esm2022/lib/editor.tokens.js +0 -10
  42. package/esm2022/lib/editor.tokens.js.map +0 -1
  43. package/esm2022/lib/editor.types.js +0 -48
  44. package/esm2022/lib/editor.types.js.map +0 -1
  45. package/esm2022/lib/extensions/editor-block-handle.js +0 -760
  46. package/esm2022/lib/extensions/editor-block-handle.js.map +0 -1
  47. package/esm2022/lib/extensions/editor-extensions.js +0 -321
  48. package/esm2022/lib/extensions/editor-extensions.js.map +0 -1
  49. package/esm2022/lib/extensions/editor-markdown-compatibility.js +0 -162
  50. package/esm2022/lib/extensions/editor-markdown-compatibility.js.map +0 -1
  51. package/esm2022/lib/extensions/editor-upload-placeholder.js +0 -156
  52. package/esm2022/lib/extensions/editor-upload-placeholder.js.map +0 -1
  53. package/esm2022/lib/status/editor-status.js +0 -64
  54. package/esm2022/lib/status/editor-status.js.map +0 -1
  55. package/esm2022/lib/toolbar/editor-alignment.js +0 -203
  56. package/esm2022/lib/toolbar/editor-alignment.js.map +0 -1
  57. package/esm2022/lib/toolbar/editor-block-insert.js +0 -101
  58. package/esm2022/lib/toolbar/editor-block-insert.js.map +0 -1
  59. package/esm2022/lib/toolbar/editor-color-control.js +0 -71
  60. package/esm2022/lib/toolbar/editor-color-control.js.map +0 -1
  61. package/esm2022/lib/toolbar/editor-command-button.js +0 -115
  62. package/esm2022/lib/toolbar/editor-command-button.js.map +0 -1
  63. package/esm2022/lib/toolbar/editor-heading.js +0 -266
  64. package/esm2022/lib/toolbar/editor-heading.js.map +0 -1
  65. package/esm2022/lib/toolbar/editor-highlight.js +0 -84
  66. package/esm2022/lib/toolbar/editor-highlight.js.map +0 -1
  67. package/esm2022/lib/toolbar/editor-image-upload-dialog.js +0 -289
  68. package/esm2022/lib/toolbar/editor-image-upload-dialog.js.map +0 -1
  69. package/esm2022/lib/toolbar/editor-image-upload.js +0 -315
  70. package/esm2022/lib/toolbar/editor-image-upload.js.map +0 -1
  71. package/esm2022/lib/toolbar/editor-inline-marks.js +0 -124
  72. package/esm2022/lib/toolbar/editor-inline-marks.js.map +0 -1
  73. package/esm2022/lib/toolbar/editor-link.js +0 -265
  74. package/esm2022/lib/toolbar/editor-link.js.map +0 -1
  75. package/esm2022/lib/toolbar/editor-list.js +0 -249
  76. package/esm2022/lib/toolbar/editor-list.js.map +0 -1
  77. package/esm2022/lib/toolbar/editor-table.js +0 -292
  78. package/esm2022/lib/toolbar/editor-table.js.map +0 -1
  79. package/esm2022/lib/toolbar/editor-text-color.js +0 -82
  80. package/esm2022/lib/toolbar/editor-text-color.js.map +0 -1
  81. package/esm2022/lib/toolbar/editor-toolbar-widget.js +0 -41
  82. package/esm2022/lib/toolbar/editor-toolbar-widget.js.map +0 -1
  83. package/esm2022/lib/toolbar/editor-toolbar.defs.js +0 -60
  84. package/esm2022/lib/toolbar/editor-toolbar.defs.js.map +0 -1
  85. package/esm2022/lib/toolbar/editor-toolbar.js +0 -826
  86. package/esm2022/lib/toolbar/editor-toolbar.js.map +0 -1
  87. package/esm2022/lib/toolbar/editor-undo-redo.js +0 -72
  88. package/esm2022/lib/toolbar/editor-undo-redo.js.map +0 -1
  89. package/esm2022/lib/toolbar/editor-zoom.js +0 -330
  90. package/esm2022/lib/toolbar/editor-zoom.js.map +0 -1
  91. package/esm2022/lib/upload/editor-image-upload-coordinator.js +0 -480
  92. package/esm2022/lib/upload/editor-image-upload-coordinator.js.map +0 -1
  93. package/esm2022/malva-ui-editor.js +0 -5
  94. package/esm2022/malva-ui-editor.js.map +0 -1
  95. package/index.d.ts +0 -35
  96. package/lib/ai/editor-ai-actions.d.ts +0 -27
  97. package/lib/ai/editor-ai-context.d.ts +0 -307
  98. package/lib/ai/editor-ai-menu.d.ts +0 -142
  99. package/lib/ai/editor-ai-review-bar.d.ts +0 -116
  100. package/lib/ai/editor-ai-stream.d.ts +0 -207
  101. package/lib/ai/editor-ai-suggestions.d.ts +0 -219
  102. package/lib/ai/editor-ai.tokens.d.ts +0 -10
  103. package/lib/ai/editor-ai.types.d.ts +0 -176
  104. package/lib/editor/editor.d.ts +0 -243
  105. package/lib/editor-extension-preflight.d.ts +0 -23
  106. package/lib/editor-serialization.d.ts +0 -74
  107. package/lib/editor-toolbar-context.d.ts +0 -116
  108. package/lib/editor.tokens.d.ts +0 -6
  109. package/lib/editor.types.d.ts +0 -194
  110. package/lib/extensions/editor-block-handle.d.ts +0 -59
  111. package/lib/extensions/editor-extensions.d.ts +0 -165
  112. package/lib/extensions/editor-markdown-compatibility.d.ts +0 -11
  113. package/lib/extensions/editor-upload-placeholder.d.ts +0 -75
  114. package/lib/status/editor-status.d.ts +0 -24
  115. package/lib/toolbar/editor-alignment.d.ts +0 -61
  116. package/lib/toolbar/editor-block-insert.d.ts +0 -26
  117. package/lib/toolbar/editor-color-control.d.ts +0 -32
  118. package/lib/toolbar/editor-command-button.d.ts +0 -29
  119. package/lib/toolbar/editor-heading.d.ts +0 -68
  120. package/lib/toolbar/editor-highlight.d.ts +0 -21
  121. package/lib/toolbar/editor-image-upload-dialog.d.ts +0 -96
  122. package/lib/toolbar/editor-image-upload.d.ts +0 -71
  123. package/lib/toolbar/editor-inline-marks.d.ts +0 -30
  124. package/lib/toolbar/editor-link.d.ts +0 -78
  125. package/lib/toolbar/editor-list.d.ts +0 -67
  126. package/lib/toolbar/editor-table.d.ts +0 -133
  127. package/lib/toolbar/editor-text-color.d.ts +0 -21
  128. package/lib/toolbar/editor-toolbar-widget.d.ts +0 -19
  129. package/lib/toolbar/editor-toolbar.d.ts +0 -157
  130. package/lib/toolbar/editor-toolbar.defs.d.ts +0 -35
  131. package/lib/toolbar/editor-undo-redo.d.ts +0 -26
  132. package/lib/toolbar/editor-zoom.d.ts +0 -108
  133. package/lib/upload/editor-image-upload-coordinator.d.ts +0 -55
  134. package/malva-ui-editor.d.ts +0 -5
@@ -1,266 +0,0 @@
1
- import { DOCUMENT } from '@angular/common';
2
- import { ChangeDetectionStrategy, Component, DestroyRef, computed, inject, input, ViewEncapsulation, viewChild, } from '@angular/core';
3
- import { LucideHeading } from '@lucide/angular';
4
- import { MlvButton, MlvButtonIcon } from '@malva-ui/core/button';
5
- import { MlvListItem } from '@malva-ui/core/list';
6
- import { MlvMenu, MlvMenuItem, MlvMenuTrigger } from '@malva-ui/core/menu';
7
- import { MlvTooltip } from '@malva-ui/core/tooltip';
8
- import { MLV_EDITOR_I18N } from '@malva-ui/i18n';
9
- import { MLV_EDITOR_OVERLAY_REGISTRY, MLV_EDITOR_TOOLBAR_CONTEXT, MLV_EDITOR_TOOLBAR_REVISION, } from '../editor-toolbar-context';
10
- import { MlvEditorToolbarWidget } from './editor-toolbar-widget';
11
- import * as i0 from "@angular/core";
12
- const DEFAULT_HEADING_LEVELS = [
13
- 1, 2, 3, 4, 5, 6,
14
- ];
15
- /** Keeps valid heading levels in caller order while removing duplicates. */
16
- function normalizeHeadingLevels(levels) {
17
- const normalized = [];
18
- for (const candidate of levels) {
19
- if (typeof candidate === 'number' &&
20
- Number.isInteger(candidate) &&
21
- candidate >= 1 &&
22
- candidate <= 6 &&
23
- !normalized.includes(candidate)) {
24
- normalized.push(candidate);
25
- }
26
- }
27
- return normalized;
28
- }
29
- /** Paragraph and heading-level dropdown commands. */
30
- export class MlvEditorHeading {
31
- /** Heading levels displayed in the menu; paragraph is always retained. */
32
- levels = input(DEFAULT_HEADING_LEVELS, /* @ts-ignore */
33
- ...(ngDevMode ? [{ debugName: "levels" }] : /* istanbul ignore next */ []));
34
- /** @protected Editor command state. */
35
- _context = inject(MLV_EDITOR_TOOLBAR_CONTEXT);
36
- /** @private Per-editor state invalidation signal. */
37
- _revision = inject(MLV_EDITOR_TOOLBAR_REVISION);
38
- /** @private The editor-owned overlay registry. */
39
- _overlays = inject(MLV_EDITOR_OVERLAY_REGISTRY);
40
- /** @private Document used to resolve the public menu panel id. */
41
- _document = inject(DOCUMENT);
42
- /** @private Cleans an active overlay registration. */
43
- _destroyRef = inject(DestroyRef);
44
- /** @private Optional localized editor copy. */
45
- _i18n = inject(MLV_EDITOR_I18N, { optional: true });
46
- /** @protected Rendered Malva menu. */
47
- _menu = viewChild.required('_menu', /* @ts-ignore */
48
- ...(ngDevMode ? [{ debugName: "_menu" }] : /* istanbul ignore next */ []));
49
- /** @protected Trigger owning the menu overlay. */
50
- _trigger = viewChild.required(MlvMenuTrigger, /* @ts-ignore */
51
- ...(ngDevMode ? [{ debugName: "_trigger" }] : /* istanbul ignore next */ []));
52
- /** @private Overlay-registration teardown. */
53
- _unregister;
54
- /** @private Guards queued registration after a quick close or destroy. */
55
- _menuOpen = false;
56
- /** @protected Normalized levels supported by the active heading extension. */
57
- _levels = computed(() => {
58
- this._revision();
59
- const requested = normalizeHeadingLevels(this.levels());
60
- const editor = this._context.editor();
61
- if (!editor?.commands.toggleHeading)
62
- return [];
63
- const heading = editor.extensionManager.extensions.find((extension) => extension.name === 'heading');
64
- const configured = heading?.options
65
- ?.levels;
66
- if (!Array.isArray(configured))
67
- return requested;
68
- return requested.filter((level) => configured.includes(level));
69
- }, /* @ts-ignore */
70
- ...(ngDevMode ? [{ debugName: "_levels" }] : /* istanbul ignore next */ []));
71
- /** @protected Localized labels. */
72
- _copy = computed(() => ({
73
- paragraph: this._i18n?.().paragraph ?? 'Paragraph',
74
- headingLevel: this._i18n?.().headingLevel ?? 'Heading level',
75
- }), /* @ts-ignore */
76
- ...(ngDevMode ? [{ debugName: "_copy" }] : /* istanbul ignore next */ []));
77
- /** @protected Paragraph command availability at the current selection. */
78
- _canParagraph = (editor) => editor.can().chain().setParagraph().run();
79
- constructor() {
80
- this._destroyRef.onDestroy(() => this._unregisterOverlay());
81
- }
82
- /** @protected Label describing the active block type. */
83
- _label() {
84
- const active = this._levels().find((level) => this._context.isActive('heading', { level }));
85
- return active ? this._headingLabel(active) : this._copy().paragraph;
86
- }
87
- /** @protected Localized heading label. */
88
- _headingLabel(level) {
89
- return `${this._copy().headingLevel} ${level}`;
90
- }
91
- /** @protected Whether a heading command is registered by the extension set. */
92
- _supported() {
93
- this._revision();
94
- const editor = this._context.editor();
95
- return (!!editor &&
96
- (editor.commands.setParagraph !== undefined ||
97
- editor.commands.toggleHeading !== undefined));
98
- }
99
- /** @protected Whether the paragraph command is registered. */
100
- _hasParagraph() {
101
- this._revision();
102
- return this._context.editor()?.commands.setParagraph !== undefined;
103
- }
104
- /** @protected Whether heading commands are registered. */
105
- _hasHeading() {
106
- this._revision();
107
- return this._context.editor()?.commands.toggleHeading !== undefined;
108
- }
109
- /** @protected Whether the trigger cannot be opened. */
110
- _triggerDisabled() {
111
- return (!this._supported() || this._context.disabled() || this._context.readonly());
112
- }
113
- /** @protected Whether one menu action currently cannot mutate the editor. */
114
- _disabled(command) {
115
- this._revision();
116
- return this._triggerDisabled() || !this._context.can(command);
117
- }
118
- /** @protected Paragraph command. */
119
- _paragraph = (editor) => editor.chain().focus().setParagraph().run();
120
- /** @protected Heading command factory. */
121
- _heading(level) {
122
- return (editor) => editor.chain().focus().toggleHeading({ level }).run();
123
- }
124
- /** @protected Heading command availability factory. */
125
- _canHeading(level) {
126
- return (editor) => editor.can().chain().toggleHeading({ level }).run();
127
- }
128
- /** @protected Runs a selection-restoring command. */
129
- _run(command) {
130
- this._context.run(command);
131
- }
132
- /** @protected Registers the portaled panel with the editor composite. */
133
- _registerOverlay() {
134
- this._menuOpen = true;
135
- queueMicrotask(() => {
136
- if (!this._menuOpen)
137
- return;
138
- const panel = this._document.getElementById(this._menu().panelId);
139
- if (!panel)
140
- return;
141
- this._unregister?.();
142
- this._unregister = this._overlays.register(panel, () => this._trigger().close());
143
- });
144
- }
145
- /** @protected Removes menu panel focus ownership after close. */
146
- _unregisterOverlay() {
147
- this._menuOpen = false;
148
- this._unregister?.();
149
- this._unregister = undefined;
150
- }
151
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MlvEditorHeading, deps: [], target: i0.ɵɵFactoryTarget.Component });
152
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: MlvEditorHeading, isStandalone: true, selector: "mlv-editor-heading", inputs: { levels: { classPropertyName: "levels", publicName: "levels", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "hidden": "!_supported()" }, classAttribute: "mlv-editor-heading" }, viewQueries: [{ propertyName: "_menu", first: true, predicate: ["_menu"], descendants: true, isSignal: true }, { propertyName: "_trigger", first: true, predicate: MlvMenuTrigger, descendants: true, isSignal: true }], ngImport: i0, template: `
153
- <button
154
- mlvButton
155
- mlvEditorToolbarWidget
156
- type="button"
157
- shape="square"
158
- mlvDensity="tight"
159
- variant="transparent"
160
- [disabled]="_triggerDisabled()"
161
- [mlvMenuTrigger]="_menu"
162
- [menuTriggerDisabled]="_triggerDisabled()"
163
- [attr.aria-label]="_copy().headingLevel"
164
- [mlvTooltip]="_label()"
165
- (menuOpened)="_registerOverlay()"
166
- (menuClosed)="_unregisterOverlay()"
167
- >
168
- <svg mlvButtonIcon lucideHeading aria-hidden="true" />
169
- </button>
170
- <mlv-menu #_menu [label]="_copy().headingLevel">
171
- @if (_hasParagraph()) {
172
- <mlv-list-item
173
- mlvMenuItem
174
- [disabled]="_disabled(_canParagraph)"
175
- [attr.aria-current]="_context.isActive('paragraph') ? 'true' : null"
176
- (itemClick)="_run(_paragraph)"
177
- >
178
- {{ _copy().paragraph }}
179
- </mlv-list-item>
180
- }
181
- @for (level of _levels(); track level) {
182
- @if (_hasHeading()) {
183
- <mlv-list-item
184
- mlvMenuItem
185
- [disabled]="_disabled(_canHeading(level))"
186
- [attr.aria-current]="
187
- _context.isActive('heading', { level }) ? 'true' : null
188
- "
189
- (itemClick)="_run(_heading(level))"
190
- >
191
- {{ _headingLabel(level) }}
192
- </mlv-list-item>
193
- }
194
- }
195
- </mlv-menu>
196
- `, isInline: true, dependencies: [{ kind: "component", type: MlvButton, selector: "button[mlvButton], a[mlvButton]", inputs: ["variant", "shape", "disabled", "loading"] }, { kind: "directive", type: MlvButtonIcon, selector: "[mlvButtonIcon]" }, { kind: "directive", type: MlvTooltip, selector: "[mlvTooltip]", inputs: ["mlvTooltip", "tooltipPlacement", "tooltipTone", "tooltipDelay", "tooltipDisabled", "tooltipArrow"] }, { kind: "component", type: LucideHeading, selector: "svg[lucideHeading]" }, { kind: "component", type: MlvListItem, selector: "mlv-list-item", inputs: ["itemRole", "unread", "accent"] }, { kind: "component", type: MlvMenu, selector: "mlv-menu", inputs: ["label", "mlvDensity"], outputs: ["closed"] }, { kind: "directive", type: MlvMenuItem, selector: "mlv-list-item[mlvMenuItem]", inputs: ["disabled"], outputs: ["itemClick"] }, { kind: "directive", type: MlvMenuTrigger, selector: "[mlvMenuTrigger]", inputs: ["mlvMenuTrigger", "isSubmenuTrigger", "menuTriggerDisabled"], outputs: ["menuOpened", "menuClosed"] }, { kind: "directive", type: MlvEditorToolbarWidget, selector: "[mlvEditorToolbarWidget]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
197
- }
198
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MlvEditorHeading, decorators: [{
199
- type: Component,
200
- args: [{
201
- selector: 'mlv-editor-heading',
202
- imports: [
203
- MlvButton,
204
- MlvButtonIcon,
205
- MlvTooltip,
206
- LucideHeading,
207
- MlvListItem,
208
- MlvMenu,
209
- MlvMenuItem,
210
- MlvMenuTrigger,
211
- MlvEditorToolbarWidget,
212
- ],
213
- template: `
214
- <button
215
- mlvButton
216
- mlvEditorToolbarWidget
217
- type="button"
218
- shape="square"
219
- mlvDensity="tight"
220
- variant="transparent"
221
- [disabled]="_triggerDisabled()"
222
- [mlvMenuTrigger]="_menu"
223
- [menuTriggerDisabled]="_triggerDisabled()"
224
- [attr.aria-label]="_copy().headingLevel"
225
- [mlvTooltip]="_label()"
226
- (menuOpened)="_registerOverlay()"
227
- (menuClosed)="_unregisterOverlay()"
228
- >
229
- <svg mlvButtonIcon lucideHeading aria-hidden="true" />
230
- </button>
231
- <mlv-menu #_menu [label]="_copy().headingLevel">
232
- @if (_hasParagraph()) {
233
- <mlv-list-item
234
- mlvMenuItem
235
- [disabled]="_disabled(_canParagraph)"
236
- [attr.aria-current]="_context.isActive('paragraph') ? 'true' : null"
237
- (itemClick)="_run(_paragraph)"
238
- >
239
- {{ _copy().paragraph }}
240
- </mlv-list-item>
241
- }
242
- @for (level of _levels(); track level) {
243
- @if (_hasHeading()) {
244
- <mlv-list-item
245
- mlvMenuItem
246
- [disabled]="_disabled(_canHeading(level))"
247
- [attr.aria-current]="
248
- _context.isActive('heading', { level }) ? 'true' : null
249
- "
250
- (itemClick)="_run(_heading(level))"
251
- >
252
- {{ _headingLabel(level) }}
253
- </mlv-list-item>
254
- }
255
- }
256
- </mlv-menu>
257
- `,
258
- encapsulation: ViewEncapsulation.None,
259
- changeDetection: ChangeDetectionStrategy.OnPush,
260
- host: {
261
- class: 'mlv-editor-heading',
262
- '[hidden]': '!_supported()',
263
- },
264
- }]
265
- }], ctorParameters: () => [], propDecorators: { levels: [{ type: i0.Input, args: [{ isSignal: true, alias: "levels", required: false }] }], _menu: [{ type: i0.ViewChild, args: ['_menu', { isSignal: true }] }], _trigger: [{ type: i0.ViewChild, args: [i0.forwardRef(() => MlvMenuTrigger), { isSignal: true }] }] } });
266
- //# sourceMappingURL=editor-heading.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor-heading.js","sourceRoot":"","sources":["../../../../../../libs/editor/src/lib/toolbar/editor-heading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ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;;;;;;;;;;;;;;;;;;;;;;;GA4CT,4DAtDC,SAAS,iIACT,aAAa,4DACb,UAAU,uKACV,aAAa,+DACb,WAAW,oGACX,OAAO,2GACP,WAAW,qHACX,cAAc,2KACd,sBAAsB;;2FAsDb,gBAAgB;kBAjE5B,SAAS;mBAAC;oBACT,QAAQ,EAAE,oBAAoB;oBAC9B,OAAO,EAAE;wBACP,SAAS;wBACT,aAAa;wBACb,UAAU;wBACV,aAAa;wBACb,WAAW;wBACX,OAAO;wBACP,WAAW;wBACX,cAAc;wBACd,sBAAsB;qBACvB;oBACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CT;oBACD,aAAa,EAAE,iBAAiB,CAAC,IAAI;oBACrC,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,IAAI,EAAE;wBACJ,KAAK,EAAE,oBAAoB;wBAC3B,UAAU,EAAE,eAAe;qBAC5B;iBACF;yLA4BwD,OAAO,sFAGb,cAAc","sourcesContent":["import { DOCUMENT } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n computed,\n inject,\n input,\n ViewEncapsulation,\n viewChild,\n} from '@angular/core';\nimport type { Editor } from '@tiptap/core';\nimport { LucideHeading } from '@lucide/angular';\nimport { MlvButton, MlvButtonIcon } from '@malva-ui/core/button';\nimport { MlvListItem } from '@malva-ui/core/list';\nimport { MlvMenu, MlvMenuItem, MlvMenuTrigger } from '@malva-ui/core/menu';\nimport { MlvTooltip } from '@malva-ui/core/tooltip';\nimport { MLV_EDITOR_I18N } from '@malva-ui/i18n';\nimport {\n MLV_EDITOR_OVERLAY_REGISTRY,\n MLV_EDITOR_TOOLBAR_CONTEXT,\n MLV_EDITOR_TOOLBAR_REVISION,\n} from '../editor-toolbar-context';\nimport type { MlvEditorOverlayRegistry } from '../editor-toolbar-context';\nimport { MlvEditorToolbarWidget } from './editor-toolbar-widget';\n\n/** Heading levels supported by Tiptap's standard heading node. */\nexport type MlvEditorHeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\nconst DEFAULT_HEADING_LEVELS: readonly MlvEditorHeadingLevel[] = [\n 1, 2, 3, 4, 5, 6,\n];\n\n/** Keeps valid heading levels in caller order while removing duplicates. */\nfunction normalizeHeadingLevels(\n levels: readonly MlvEditorHeadingLevel[],\n): readonly MlvEditorHeadingLevel[] {\n const normalized: MlvEditorHeadingLevel[] = [];\n for (const candidate of levels as readonly unknown[]) {\n if (\n typeof candidate === 'number' &&\n Number.isInteger(candidate) &&\n candidate >= 1 &&\n candidate <= 6 &&\n !normalized.includes(candidate as MlvEditorHeadingLevel)\n ) {\n normalized.push(candidate as MlvEditorHeadingLevel);\n }\n }\n return normalized;\n}\n\n/** Paragraph and heading-level dropdown commands. */\n@Component({\n selector: 'mlv-editor-heading',\n imports: [\n MlvButton,\n MlvButtonIcon,\n MlvTooltip,\n LucideHeading,\n MlvListItem,\n MlvMenu,\n MlvMenuItem,\n MlvMenuTrigger,\n MlvEditorToolbarWidget,\n ],\n template: `\n <button\n mlvButton\n mlvEditorToolbarWidget\n type=\"button\"\n shape=\"square\"\n mlvDensity=\"tight\"\n variant=\"transparent\"\n [disabled]=\"_triggerDisabled()\"\n [mlvMenuTrigger]=\"_menu\"\n [menuTriggerDisabled]=\"_triggerDisabled()\"\n [attr.aria-label]=\"_copy().headingLevel\"\n [mlvTooltip]=\"_label()\"\n (menuOpened)=\"_registerOverlay()\"\n (menuClosed)=\"_unregisterOverlay()\"\n >\n <svg mlvButtonIcon lucideHeading aria-hidden=\"true\" />\n </button>\n <mlv-menu #_menu [label]=\"_copy().headingLevel\">\n @if (_hasParagraph()) {\n <mlv-list-item\n mlvMenuItem\n [disabled]=\"_disabled(_canParagraph)\"\n [attr.aria-current]=\"_context.isActive('paragraph') ? 'true' : null\"\n (itemClick)=\"_run(_paragraph)\"\n >\n {{ _copy().paragraph }}\n </mlv-list-item>\n }\n @for (level of _levels(); track level) {\n @if (_hasHeading()) {\n <mlv-list-item\n mlvMenuItem\n [disabled]=\"_disabled(_canHeading(level))\"\n [attr.aria-current]=\"\n _context.isActive('heading', { level }) ? 'true' : null\n \"\n (itemClick)=\"_run(_heading(level))\"\n >\n {{ _headingLabel(level) }}\n </mlv-list-item>\n }\n }\n </mlv-menu>\n `,\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'mlv-editor-heading',\n '[hidden]': '!_supported()',\n },\n})\nexport class MlvEditorHeading {\n /** Heading levels displayed in the menu; paragraph is always retained. */\n readonly levels = input<readonly MlvEditorHeadingLevel[]>(\n DEFAULT_HEADING_LEVELS,\n );\n\n /** @protected Editor command state. */\n protected readonly _context = inject(MLV_EDITOR_TOOLBAR_CONTEXT);\n\n /** @private Per-editor state invalidation signal. */\n private readonly _revision = inject(MLV_EDITOR_TOOLBAR_REVISION);\n\n /** @private The editor-owned overlay registry. */\n private readonly _overlays = inject<MlvEditorOverlayRegistry>(\n MLV_EDITOR_OVERLAY_REGISTRY,\n );\n\n /** @private Document used to resolve the public menu panel id. */\n private readonly _document = inject(DOCUMENT);\n\n /** @private Cleans an active overlay registration. */\n private readonly _destroyRef = inject(DestroyRef);\n\n /** @private Optional localized editor copy. */\n private readonly _i18n = inject(MLV_EDITOR_I18N, { optional: true });\n\n /** @protected Rendered Malva menu. */\n protected readonly _menu = viewChild.required<MlvMenu>('_menu');\n\n /** @protected Trigger owning the menu overlay. */\n protected readonly _trigger = viewChild.required(MlvMenuTrigger);\n\n /** @private Overlay-registration teardown. */\n private _unregister: (() => void) | undefined;\n\n /** @private Guards queued registration after a quick close or destroy. */\n private _menuOpen = false;\n\n /** @protected Normalized levels supported by the active heading extension. */\n protected readonly _levels = computed(() => {\n this._revision();\n const requested = normalizeHeadingLevels(this.levels());\n const editor = this._context.editor();\n if (!editor?.commands.toggleHeading) return [];\n const heading = editor.extensionManager.extensions.find(\n (extension) => extension.name === 'heading',\n );\n const configured = (heading?.options as { levels?: unknown } | undefined)\n ?.levels;\n if (!Array.isArray(configured)) return requested;\n return requested.filter((level) => configured.includes(level));\n });\n\n /** @protected Localized labels. */\n protected readonly _copy = computed(() => ({\n paragraph: this._i18n?.().paragraph ?? 'Paragraph',\n headingLevel: this._i18n?.().headingLevel ?? 'Heading level',\n }));\n\n /** @protected Paragraph command availability at the current selection. */\n protected readonly _canParagraph = (editor: Editor): boolean =>\n editor.can().chain().setParagraph().run();\n\n constructor() {\n this._destroyRef.onDestroy(() => this._unregisterOverlay());\n }\n\n /** @protected Label describing the active block type. */\n protected _label(): string {\n const active = this._levels().find((level) =>\n this._context.isActive('heading', { level }),\n );\n return active ? this._headingLabel(active) : this._copy().paragraph;\n }\n\n /** @protected Localized heading label. */\n protected _headingLabel(level: number): string {\n return `${this._copy().headingLevel} ${level}`;\n }\n\n /** @protected Whether a heading command is registered by the extension set. */\n protected _supported(): boolean {\n this._revision();\n const editor = this._context.editor();\n return (\n !!editor &&\n (editor.commands.setParagraph !== undefined ||\n editor.commands.toggleHeading !== undefined)\n );\n }\n\n /** @protected Whether the paragraph command is registered. */\n protected _hasParagraph(): boolean {\n this._revision();\n return this._context.editor()?.commands.setParagraph !== undefined;\n }\n\n /** @protected Whether heading commands are registered. */\n protected _hasHeading(): boolean {\n this._revision();\n return this._context.editor()?.commands.toggleHeading !== undefined;\n }\n\n /** @protected Whether the trigger cannot be opened. */\n protected _triggerDisabled(): boolean {\n return (\n !this._supported() || this._context.disabled() || this._context.readonly()\n );\n }\n\n /** @protected Whether one menu action currently cannot mutate the editor. */\n protected _disabled(command: (editor: Editor) => boolean): boolean {\n this._revision();\n return this._triggerDisabled() || !this._context.can(command);\n }\n\n /** @protected Paragraph command. */\n protected readonly _paragraph = (editor: Editor): boolean =>\n editor.chain().focus().setParagraph().run();\n\n /** @protected Heading command factory. */\n protected _heading(\n level: MlvEditorHeadingLevel,\n ): (editor: Editor) => boolean {\n return (editor) => editor.chain().focus().toggleHeading({ level }).run();\n }\n\n /** @protected Heading command availability factory. */\n protected _canHeading(\n level: MlvEditorHeadingLevel,\n ): (editor: Editor) => boolean {\n return (editor) => editor.can().chain().toggleHeading({ level }).run();\n }\n\n /** @protected Runs a selection-restoring command. */\n protected _run(command: (editor: Editor) => boolean): void {\n this._context.run(command);\n }\n\n /** @protected Registers the portaled panel with the editor composite. */\n protected _registerOverlay(): void {\n this._menuOpen = true;\n queueMicrotask(() => {\n if (!this._menuOpen) return;\n const panel = this._document.getElementById(this._menu().panelId);\n if (!panel) return;\n this._unregister?.();\n this._unregister = this._overlays.register(panel, () =>\n this._trigger().close(),\n );\n });\n }\n\n /** @protected Removes menu panel focus ownership after close. */\n protected _unregisterOverlay(): void {\n this._menuOpen = false;\n this._unregister?.();\n this._unregister = undefined;\n }\n}\n"]}
@@ -1,84 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, computed, inject, ViewEncapsulation, } from '@angular/core';
2
- import { LucideHighlighter } from '@lucide/angular';
3
- import { MlvButtonIcon } from '@malva-ui/core/button';
4
- import { MlvColorPickerPopup } from '@malva-ui/core/color-picker';
5
- import { MLV_EDITOR_I18N } from '@malva-ui/i18n';
6
- import { MlvEditorColorControl } from './editor-color-control';
7
- import * as i0 from "@angular/core";
8
- /** Background-highlight toolbar control backed by the reusable swatch picker. */
9
- export class MlvEditorHighlight extends MlvEditorColorControl {
10
- /** @private Optional localized editor labels. */
11
- _i18n = inject(MLV_EDITOR_I18N, { optional: true });
12
- /** @protected Localized accessible trigger and dialog label. */
13
- _label = computed(() => this._i18n?.().highlightColor ?? 'Highlight color', /* @ts-ignore */
14
- ...(ngDevMode ? [{ debugName: "_label" }] : /* istanbul ignore next */ []));
15
- /** @protected Exact command-presence capability without command execution. */
16
- _supported = computed(() => {
17
- this._revision?.();
18
- const commands = this._context.editor()?.commands;
19
- return (typeof commands?.['toggleHighlight'] === 'function' &&
20
- typeof commands['unsetHighlight'] === 'function');
21
- }, /* @ts-ignore */
22
- ...(ngDevMode ? [{ debugName: "_supported" }] : /* istanbul ignore next */ []));
23
- /** @protected Active highlight colour rendered by the independent swatch. */
24
- _activeColor = computed(() => {
25
- this._revision?.();
26
- const color = this._context.editor()?.getAttributes('highlight')['color'];
27
- return typeof color === 'string' && color ? color : '#ffff00';
28
- }, /* @ts-ignore */
29
- ...(ngDevMode ? [{ debugName: "_activeColor" }] : /* istanbul ignore next */ []));
30
- /** @protected Applies or clears highlight colour without focusing Tiptap. */
31
- _run(editor, selection, color) {
32
- const chain = editor.chain().setTextSelection(selection);
33
- return color
34
- ? chain.toggleHighlight({ color }).run()
35
- : chain.unsetHighlight().run();
36
- }
37
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MlvEditorHighlight, deps: null, target: i0.ɵɵFactoryTarget.Component });
38
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.7", type: MlvEditorHighlight, isStandalone: true, selector: "mlv-editor-highlight", host: { properties: { "hidden": "!_supported()" }, classAttribute: "mlv-editor-highlight" }, usesInheritance: true, ngImport: i0, template: `
39
- <mlv-color-picker-popup
40
- #picker
41
- presentation="icon"
42
- clearable
43
- live
44
- [ariaLabel]="_label()"
45
- [value]="_activeColor()"
46
- [disabled]="_context.disabled()"
47
- [readonly]="_context.readonly()"
48
- (openedChange)="_onOpenedChange($event)"
49
- (colorChange)="_apply($event)"
50
- >
51
- <svg mlvButtonIcon lucideHighlighter aria-hidden="true" />
52
- </mlv-color-picker-popup>
53
- `, isInline: true, dependencies: [{ kind: "component", type: MlvColorPickerPopup, selector: "mlv-color-picker-popup", inputs: ["value", "presentation", "opened", "showOpacity", "defaultMode", "supportedFormats", "live"], outputs: ["valueChange", "openedChange", "afterOpened", "afterClosed", "colorChange"] }, { kind: "directive", type: MlvButtonIcon, selector: "[mlvButtonIcon]" }, { kind: "component", type: LucideHighlighter, selector: "svg[lucideHighlighter]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
54
- }
55
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MlvEditorHighlight, decorators: [{
56
- type: Component,
57
- args: [{
58
- selector: 'mlv-editor-highlight',
59
- imports: [MlvColorPickerPopup, MlvButtonIcon, LucideHighlighter],
60
- template: `
61
- <mlv-color-picker-popup
62
- #picker
63
- presentation="icon"
64
- clearable
65
- live
66
- [ariaLabel]="_label()"
67
- [value]="_activeColor()"
68
- [disabled]="_context.disabled()"
69
- [readonly]="_context.readonly()"
70
- (openedChange)="_onOpenedChange($event)"
71
- (colorChange)="_apply($event)"
72
- >
73
- <svg mlvButtonIcon lucideHighlighter aria-hidden="true" />
74
- </mlv-color-picker-popup>
75
- `,
76
- encapsulation: ViewEncapsulation.None,
77
- changeDetection: ChangeDetectionStrategy.OnPush,
78
- host: {
79
- class: 'mlv-editor-highlight',
80
- '[hidden]': '!_supported()',
81
- },
82
- }]
83
- }] });
84
- //# sourceMappingURL=editor-highlight.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor-highlight.js","sourceRoot":"","sources":["../../../../../../libs/editor/src/lib/toolbar/editor-highlight.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,QAAQ,EACR,MAAM,EACN,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;;AAE/D,iFAAiF;AA2BjF,MAAM,OAAO,kBAAmB,SAAQ,qBAAqB;IAC3D,iDAAiD;IAChC,KAAK,GAAG,MAAM,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,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;;;;GAeT,4DAhBS,mBAAmB,iQAAE,aAAa,4DAAE,iBAAiB;;2FAwBpD,kBAAkB;kBA1B9B,SAAS;mBAAC;oBACT,QAAQ,EAAE,sBAAsB;oBAChC,OAAO,EAAE,CAAC,mBAAmB,EAAE,aAAa,EAAE,iBAAiB,CAAC;oBAChE,QAAQ,EAAE;;;;;;;;;;;;;;;GAeT;oBACD,aAAa,EAAE,iBAAiB,CAAC,IAAI;oBACrC,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,IAAI,EAAE;wBACJ,KAAK,EAAE,sBAAsB;wBAC7B,UAAU,EAAE,eAAe;qBAC5B;iBACF","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n computed,\n inject,\n ViewEncapsulation,\n} from '@angular/core';\nimport type { Editor } from '@tiptap/core';\nimport { LucideHighlighter } from '@lucide/angular';\nimport { MlvButtonIcon } from '@malva-ui/core/button';\nimport { MlvColorPickerPopup } from '@malva-ui/core/color-picker';\nimport { MLV_EDITOR_I18N } from '@malva-ui/i18n';\nimport { MlvEditorColorControl } from './editor-color-control';\n\n/** Background-highlight toolbar control backed by the reusable swatch picker. */\n@Component({\n selector: 'mlv-editor-highlight',\n imports: [MlvColorPickerPopup, MlvButtonIcon, LucideHighlighter],\n template: `\n <mlv-color-picker-popup\n #picker\n presentation=\"icon\"\n clearable\n live\n [ariaLabel]=\"_label()\"\n [value]=\"_activeColor()\"\n [disabled]=\"_context.disabled()\"\n [readonly]=\"_context.readonly()\"\n (openedChange)=\"_onOpenedChange($event)\"\n (colorChange)=\"_apply($event)\"\n >\n <svg mlvButtonIcon lucideHighlighter aria-hidden=\"true\" />\n </mlv-color-picker-popup>\n `,\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'mlv-editor-highlight',\n '[hidden]': '!_supported()',\n },\n})\nexport class MlvEditorHighlight extends MlvEditorColorControl {\n /** @private Optional localized editor labels. */\n private readonly _i18n = inject(MLV_EDITOR_I18N, { optional: true });\n\n /** @protected Localized accessible trigger and dialog label. */\n protected readonly _label = computed(\n () => this._i18n?.().highlightColor ?? 'Highlight color',\n );\n\n /** @protected Exact command-presence capability without command execution. */\n protected readonly _supported = computed(() => {\n this._revision?.();\n const commands = this._context.editor()?.commands as\n | Record<string, unknown>\n | undefined;\n return (\n typeof commands?.['toggleHighlight'] === 'function' &&\n typeof commands['unsetHighlight'] === 'function'\n );\n });\n\n /** @protected Active highlight colour rendered by the independent swatch. */\n protected readonly _activeColor = computed(() => {\n this._revision?.();\n const color = this._context.editor()?.getAttributes('highlight')['color'];\n return typeof color === 'string' && color ? color : '#ffff00';\n });\n\n /** @protected Applies or clears highlight colour without focusing Tiptap. */\n protected override _run(\n editor: Editor,\n selection: { readonly from: number; readonly to: number },\n color: string,\n ): boolean {\n const chain = editor.chain().setTextSelection(selection);\n return color\n ? chain.toggleHighlight({ color }).run()\n : chain.unsetHighlight().run();\n }\n}\n"]}