@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,203 +0,0 @@
1
- import { DOCUMENT } from '@angular/common';
2
- import { ChangeDetectionStrategy, Component, DestroyRef, inject, ViewEncapsulation, viewChild, } from '@angular/core';
3
- import { LucideAlignLeft } 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
- /** Left, center, right, and justified paragraph alignment commands in a menu. */
13
- export class MlvEditorAlignment {
14
- /** @protected Editor command state. */
15
- _context = inject(MLV_EDITOR_TOOLBAR_CONTEXT);
16
- /** @private Per-editor state invalidation signal. */
17
- _revision = inject(MLV_EDITOR_TOOLBAR_REVISION);
18
- /** @private The editor-owned overlay registry. */
19
- _overlays = inject(MLV_EDITOR_OVERLAY_REGISTRY);
20
- /** @private Document used to resolve the public menu panel id. */
21
- _document = inject(DOCUMENT);
22
- /** @private Removes a pending or active overlay registration. */
23
- _destroyRef = inject(DestroyRef);
24
- /** @private Optional localized editor copy. */
25
- _i18n = inject(MLV_EDITOR_I18N, { optional: true });
26
- /** @protected Rendered Malva menu. */
27
- _menu = viewChild.required('_menu', /* @ts-ignore */
28
- ...(ngDevMode ? [{ debugName: "_menu" }] : /* istanbul ignore next */ []));
29
- /** @protected Trigger owning the menu overlay. */
30
- _trigger = viewChild.required(MlvMenuTrigger, /* @ts-ignore */
31
- ...(ngDevMode ? [{ debugName: "_trigger" }] : /* istanbul ignore next */ []));
32
- /** @private Tears down the active panel registration. */
33
- _unregister;
34
- /** @private Guards queued registration after a quick close or destroy. */
35
- _menuOpen = false;
36
- /** @protected Supported alignments in visual order. */
37
- _alignments = [
38
- 'left',
39
- 'center',
40
- 'right',
41
- 'justify',
42
- ];
43
- /** @protected Resolved localized copy. */
44
- _copy() {
45
- const copy = this._i18n?.();
46
- return {
47
- alignment: copy?.alignment ?? 'Alignment',
48
- left: copy?.alignLeft ?? 'Align left',
49
- center: copy?.alignCenter ?? 'Align center',
50
- right: copy?.alignRight ?? 'Align right',
51
- justify: copy?.alignJustify ?? 'Justify',
52
- };
53
- }
54
- constructor() {
55
- this._destroyRef.onDestroy(() => this._unregisterOverlay());
56
- }
57
- /** @protected Resolves a translated alignment label. */
58
- _label(alignment) {
59
- return this._copy()[alignment];
60
- }
61
- /** @protected Current alignment, with left as the semantic default. */
62
- _activeAlignment() {
63
- return (this._alignments.find((alignment) => this._isActive(alignment)) ?? 'left');
64
- }
65
- /** @protected Whether the current selection has this alignment. */
66
- _isActive(alignment) {
67
- return (this._context.isActive('paragraph', { textAlign: alignment }) ||
68
- this._context.isActive('heading', { textAlign: alignment }));
69
- }
70
- /** @protected Whether alignment is registered by the active extension set. */
71
- _supported() {
72
- this._revision();
73
- return this._context.editor()?.commands.setTextAlign !== undefined;
74
- }
75
- /** @protected Whether the menu trigger cannot be opened. */
76
- _triggerDisabled() {
77
- return (!this._supported() || this._context.disabled() || this._context.readonly());
78
- }
79
- /** @protected Whether an alignment cannot be applied at the current selection. */
80
- _disabled(alignment) {
81
- this._revision();
82
- return (this._triggerDisabled() || !this._context.can(this._canAlign(alignment)));
83
- }
84
- /** @private Checks whether alignment can be applied without changing focus or selection. */
85
- _canAlign(alignment) {
86
- return (editor) => editor.can().chain().setTextAlign(alignment).run();
87
- }
88
- /** @protected Alignment command factory. */
89
- _align(alignment) {
90
- return (editor) => editor.chain().focus().setTextAlign(alignment).run();
91
- }
92
- /** @protected Runs a selection-restoring alignment command. */
93
- _run(alignment) {
94
- const command = this._align(alignment);
95
- this._context.run(command);
96
- }
97
- /** @protected Registers the portaled panel as editor-owned focus. */
98
- _registerOverlay() {
99
- this._menuOpen = true;
100
- queueMicrotask(() => {
101
- if (!this._menuOpen)
102
- return;
103
- const panel = this._document.getElementById(this._menu().panelId);
104
- if (!panel)
105
- return;
106
- this._unregister?.();
107
- this._unregister = this._overlays.register(panel, () => this._trigger().close());
108
- });
109
- }
110
- /** @protected Removes menu-panel focus ownership after close. */
111
- _unregisterOverlay() {
112
- this._menuOpen = false;
113
- this._unregister?.();
114
- this._unregister = undefined;
115
- }
116
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MlvEditorAlignment, deps: [], target: i0.ɵɵFactoryTarget.Component });
117
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: MlvEditorAlignment, isStandalone: true, selector: "mlv-editor-alignment", host: { properties: { "hidden": "!_supported()" }, classAttribute: "mlv-editor-alignment" }, viewQueries: [{ propertyName: "_menu", first: true, predicate: ["_menu"], descendants: true, isSignal: true }, { propertyName: "_trigger", first: true, predicate: MlvMenuTrigger, descendants: true, isSignal: true }], ngImport: i0, template: `
118
- <button
119
- mlvButton
120
- mlvEditorToolbarWidget
121
- type="button"
122
- shape="square"
123
- mlvDensity="tight"
124
- variant="transparent"
125
- [disabled]="_triggerDisabled()"
126
- [mlvMenuTrigger]="_menu"
127
- [menuTriggerDisabled]="_triggerDisabled()"
128
- [attr.aria-label]="_copy().alignment"
129
- [mlvTooltip]="_label(_activeAlignment())"
130
- (menuOpened)="_registerOverlay()"
131
- (menuClosed)="_unregisterOverlay()"
132
- >
133
- <svg mlvButtonIcon lucideAlignLeft aria-hidden="true" />
134
- </button>
135
- <mlv-menu #_menu [label]="_copy().alignment">
136
- @for (alignment of _alignments; track alignment) {
137
- <mlv-list-item
138
- mlvMenuItem
139
- [disabled]="_disabled(alignment)"
140
- [attr.aria-current]="_isActive(alignment) ? 'true' : null"
141
- (itemClick)="_run(alignment)"
142
- >
143
- {{ _label(alignment) }}
144
- </mlv-list-item>
145
- }
146
- </mlv-menu>
147
- `, 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: LucideAlignLeft, selector: "svg[lucideTextAlignStart], svg[lucideText], svg[lucideAlignLeft]" }, { 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 });
148
- }
149
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MlvEditorAlignment, decorators: [{
150
- type: Component,
151
- args: [{
152
- selector: 'mlv-editor-alignment',
153
- imports: [
154
- MlvButton,
155
- MlvButtonIcon,
156
- MlvTooltip,
157
- LucideAlignLeft,
158
- MlvListItem,
159
- MlvMenu,
160
- MlvMenuItem,
161
- MlvMenuTrigger,
162
- MlvEditorToolbarWidget,
163
- ],
164
- template: `
165
- <button
166
- mlvButton
167
- mlvEditorToolbarWidget
168
- type="button"
169
- shape="square"
170
- mlvDensity="tight"
171
- variant="transparent"
172
- [disabled]="_triggerDisabled()"
173
- [mlvMenuTrigger]="_menu"
174
- [menuTriggerDisabled]="_triggerDisabled()"
175
- [attr.aria-label]="_copy().alignment"
176
- [mlvTooltip]="_label(_activeAlignment())"
177
- (menuOpened)="_registerOverlay()"
178
- (menuClosed)="_unregisterOverlay()"
179
- >
180
- <svg mlvButtonIcon lucideAlignLeft aria-hidden="true" />
181
- </button>
182
- <mlv-menu #_menu [label]="_copy().alignment">
183
- @for (alignment of _alignments; track alignment) {
184
- <mlv-list-item
185
- mlvMenuItem
186
- [disabled]="_disabled(alignment)"
187
- [attr.aria-current]="_isActive(alignment) ? 'true' : null"
188
- (itemClick)="_run(alignment)"
189
- >
190
- {{ _label(alignment) }}
191
- </mlv-list-item>
192
- }
193
- </mlv-menu>
194
- `,
195
- encapsulation: ViewEncapsulation.None,
196
- changeDetection: ChangeDetectionStrategy.OnPush,
197
- host: {
198
- class: 'mlv-editor-alignment',
199
- '[hidden]': '!_supported()',
200
- },
201
- }]
202
- }], ctorParameters: () => [], propDecorators: { _menu: [{ type: i0.ViewChild, args: ['_menu', { isSignal: true }] }], _trigger: [{ type: i0.ViewChild, args: [i0.forwardRef(() => MlvMenuTrigger), { isSignal: true }] }] } });
203
- //# sourceMappingURL=editor-alignment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor-alignment.js","sourceRoot":"","sources":["../../../../../../libs/editor/src/lib/toolbar/editor-alignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,UAAU,EACV,MAAM,EACN,iBAAiB,EACjB,SAAS,GACV,MAAM,eAAe,CAAC;AAE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n ViewEncapsulation,\n viewChild,\n} from '@angular/core';\nimport type { Editor } from '@tiptap/core';\nimport { LucideAlignLeft } 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/** Left, center, right, and justified paragraph alignment commands in a menu. */\n@Component({\n selector: 'mlv-editor-alignment',\n imports: [\n MlvButton,\n MlvButtonIcon,\n MlvTooltip,\n LucideAlignLeft,\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().alignment\"\n [mlvTooltip]=\"_label(_activeAlignment())\"\n (menuOpened)=\"_registerOverlay()\"\n (menuClosed)=\"_unregisterOverlay()\"\n >\n <svg mlvButtonIcon lucideAlignLeft aria-hidden=\"true\" />\n </button>\n <mlv-menu #_menu [label]=\"_copy().alignment\">\n @for (alignment of _alignments; track alignment) {\n <mlv-list-item\n mlvMenuItem\n [disabled]=\"_disabled(alignment)\"\n [attr.aria-current]=\"_isActive(alignment) ? 'true' : null\"\n (itemClick)=\"_run(alignment)\"\n >\n {{ _label(alignment) }}\n </mlv-list-item>\n }\n </mlv-menu>\n `,\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'mlv-editor-alignment',\n '[hidden]': '!_supported()',\n },\n})\nexport class MlvEditorAlignment {\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 Removes a pending or 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 Tears down the active panel registration. */\n private _unregister: (() => void) | undefined;\n\n /** @private Guards queued registration after a quick close or destroy. */\n private _menuOpen = false;\n\n /** @protected Supported alignments in visual order. */\n protected readonly _alignments = [\n 'left',\n 'center',\n 'right',\n 'justify',\n ] as const;\n\n /** @protected Resolved localized copy. */\n protected _copy(): {\n alignment: string;\n left: string;\n center: string;\n right: string;\n justify: string;\n } {\n const copy = this._i18n?.();\n return {\n alignment: copy?.alignment ?? 'Alignment',\n left: copy?.alignLeft ?? 'Align left',\n center: copy?.alignCenter ?? 'Align center',\n right: copy?.alignRight ?? 'Align right',\n justify: copy?.alignJustify ?? 'Justify',\n };\n }\n\n constructor() {\n this._destroyRef.onDestroy(() => this._unregisterOverlay());\n }\n\n /** @protected Resolves a translated alignment label. */\n protected _label(alignment: (typeof this._alignments)[number]): string {\n return this._copy()[alignment];\n }\n\n /** @protected Current alignment, with left as the semantic default. */\n protected _activeAlignment(): (typeof this._alignments)[number] {\n return (\n this._alignments.find((alignment) => this._isActive(alignment)) ?? 'left'\n );\n }\n\n /** @protected Whether the current selection has this alignment. */\n protected _isActive(alignment: (typeof this._alignments)[number]): boolean {\n return (\n this._context.isActive('paragraph', { textAlign: alignment }) ||\n this._context.isActive('heading', { textAlign: alignment })\n );\n }\n\n /** @protected Whether alignment is registered by the active extension set. */\n protected _supported(): boolean {\n this._revision();\n return this._context.editor()?.commands.setTextAlign !== undefined;\n }\n\n /** @protected Whether the menu 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 an alignment cannot be applied at the current selection. */\n protected _disabled(alignment: (typeof this._alignments)[number]): boolean {\n this._revision();\n return (\n this._triggerDisabled() || !this._context.can(this._canAlign(alignment))\n );\n }\n\n /** @private Checks whether alignment can be applied without changing focus or selection. */\n private _canAlign(\n alignment: (typeof this._alignments)[number],\n ): (editor: Editor) => boolean {\n return (editor) => editor.can().chain().setTextAlign(alignment).run();\n }\n\n /** @protected Alignment command factory. */\n protected _align(\n alignment: (typeof this._alignments)[number],\n ): (editor: Editor) => boolean {\n return (editor) => editor.chain().focus().setTextAlign(alignment).run();\n }\n\n /** @protected Runs a selection-restoring alignment command. */\n protected _run(alignment: (typeof this._alignments)[number]): void {\n const command = this._align(alignment);\n this._context.run(command);\n }\n\n /** @protected Registers the portaled panel as editor-owned focus. */\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,101 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, computed, inject, ViewEncapsulation, } from '@angular/core';
2
- import { LucideCode2, LucideMinus, LucideTextQuote } from '@lucide/angular';
3
- import { MLV_EDITOR_TOOLBAR_CONTEXT, MLV_EDITOR_TOOLBAR_REVISION, } from '../editor-toolbar-context';
4
- import { MLV_EDITOR_I18N } from '@malva-ui/i18n';
5
- import { MlvEditorCommandButton } from './editor-command-button';
6
- import { MlvButtonIcon } from '@malva-ui/core/button';
7
- import * as i0 from "@angular/core";
8
- /** Blockquote and code-block toggles plus horizontal-rule insertion. */
9
- export class MlvEditorBlockInsert {
10
- /** @protected Editor command state. */ _context = inject(MLV_EDITOR_TOOLBAR_CONTEXT);
11
- /** @private Triggers active-state refreshes after editor events. */ _revision = inject(MLV_EDITOR_TOOLBAR_REVISION);
12
- /** @private Optional localized copy. */ _i18n = inject(MLV_EDITOR_I18N, { optional: true });
13
- /** @protected Resolved labels. */ _copy = computed(() => ({
14
- blockquote: this._i18n?.().blockquote ?? 'Blockquote',
15
- codeBlock: this._i18n?.().codeBlock ?? 'Code block',
16
- horizontalRule: this._i18n?.().horizontalRule ?? 'Horizontal rule',
17
- }), /* @ts-ignore */
18
- ...(ngDevMode ? [{ debugName: "_copy" }] : /* istanbul ignore next */ []));
19
- /** @protected Registered blockquote command. */ _canBlockquote = (editor) => editor.commands.toggleBlockquote !== undefined;
20
- /** @protected Current blockquote command availability. */ _canBlockquoteNow = (editor) => editor.can().chain().toggleBlockquote().run();
21
- /** @protected Registered code-block command. */ _canCodeBlock = (editor) => editor.commands.toggleCodeBlock !== undefined;
22
- /** @protected Current code-block command availability. */ _canCodeBlockNow = (editor) => editor.can().chain().toggleCodeBlock().run();
23
- /** @protected Registered horizontal-rule command. */ _canHorizontalRule = (editor) => editor.commands.setHorizontalRule !== undefined;
24
- /** @protected Current horizontal-rule command availability. */ _canHorizontalRuleNow = (editor) => editor.can().chain().setHorizontalRule().run();
25
- /** @protected Blockquote command. */ _blockquote = (editor) => editor.chain().focus().toggleBlockquote().run();
26
- /** @protected Code-block command. */ _codeBlock = (editor) => editor.chain().focus().toggleCodeBlock().run();
27
- /** @protected Horizontal-rule command. */ _horizontalRule = (editor) => editor.chain().focus().setHorizontalRule().run();
28
- /** @protected Reads command state after the toolbar receives an editor update. */
29
- _isActive = (name) => {
30
- this._revision();
31
- return this._context.isActive(name);
32
- };
33
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MlvEditorBlockInsert, deps: [], target: i0.ɵɵFactoryTarget.Component });
34
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.7", type: MlvEditorBlockInsert, isStandalone: true, selector: "mlv-editor-block-insert", host: { attributes: { "role": "group" }, classAttribute: "mlv-editor-block-insert" }, ngImport: i0, template: `
35
- <mlv-editor-command-button
36
- [label]="_copy().blockquote"
37
- [pressed]="_isActive('blockquote')"
38
- [supports]="_canBlockquote"
39
- [canCommand]="_canBlockquoteNow"
40
- [command]="_blockquote"
41
- ><svg mlvButtonIcon lucideTextQuote
42
- /></mlv-editor-command-button>
43
- <mlv-editor-command-button
44
- [label]="_copy().codeBlock"
45
- [pressed]="_isActive('codeBlock')"
46
- [supports]="_canCodeBlock"
47
- [canCommand]="_canCodeBlockNow"
48
- [command]="_codeBlock"
49
- ><svg mlvButtonIcon lucideCode2
50
- /></mlv-editor-command-button>
51
- <mlv-editor-command-button
52
- [label]="_copy().horizontalRule"
53
- [supports]="_canHorizontalRule"
54
- [canCommand]="_canHorizontalRuleNow"
55
- [command]="_horizontalRule"
56
- ><svg mlvButtonIcon lucideMinus
57
- /></mlv-editor-command-button>
58
- `, isInline: true, dependencies: [{ kind: "component", type: MlvEditorCommandButton, selector: "mlv-editor-command-button", inputs: ["label", "supports", "command", "canCommand", "pressed"] }, { kind: "component", type: LucideCode2, selector: "svg[lucideCodeXml], svg[lucideCode2]" }, { kind: "component", type: LucideMinus, selector: "svg[lucideMinus]" }, { kind: "component", type: LucideTextQuote, selector: "svg[lucideTextQuote]" }, { kind: "directive", type: MlvButtonIcon, selector: "[mlvButtonIcon]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
59
- }
60
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MlvEditorBlockInsert, decorators: [{
61
- type: Component,
62
- args: [{
63
- selector: 'mlv-editor-block-insert',
64
- imports: [
65
- MlvEditorCommandButton,
66
- LucideCode2,
67
- LucideMinus,
68
- LucideTextQuote,
69
- MlvButtonIcon,
70
- ],
71
- template: `
72
- <mlv-editor-command-button
73
- [label]="_copy().blockquote"
74
- [pressed]="_isActive('blockquote')"
75
- [supports]="_canBlockquote"
76
- [canCommand]="_canBlockquoteNow"
77
- [command]="_blockquote"
78
- ><svg mlvButtonIcon lucideTextQuote
79
- /></mlv-editor-command-button>
80
- <mlv-editor-command-button
81
- [label]="_copy().codeBlock"
82
- [pressed]="_isActive('codeBlock')"
83
- [supports]="_canCodeBlock"
84
- [canCommand]="_canCodeBlockNow"
85
- [command]="_codeBlock"
86
- ><svg mlvButtonIcon lucideCode2
87
- /></mlv-editor-command-button>
88
- <mlv-editor-command-button
89
- [label]="_copy().horizontalRule"
90
- [supports]="_canHorizontalRule"
91
- [canCommand]="_canHorizontalRuleNow"
92
- [command]="_horizontalRule"
93
- ><svg mlvButtonIcon lucideMinus
94
- /></mlv-editor-command-button>
95
- `,
96
- encapsulation: ViewEncapsulation.None,
97
- changeDetection: ChangeDetectionStrategy.OnPush,
98
- host: { class: 'mlv-editor-block-insert', role: 'group' },
99
- }]
100
- }] });
101
- //# sourceMappingURL=editor-block-insert.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor-block-insert.js","sourceRoot":"","sources":["../../../../../../libs/editor/src/lib/toolbar/editor-block-insert.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,QAAQ,EACR,MAAM,EACN,iBAA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tB,WAAW,iFACX,WAAW,6DACX,eAAe,iEACf,aAAa;;2FA+BJ,oBAAoB;kBAtChC,SAAS;mBAAC;oBACT,QAAQ,EAAE,yBAAyB;oBACnC,OAAO,EAAE;wBACP,sBAAsB;wBACtB,WAAW;wBACX,WAAW;wBACX,eAAe;wBACf,aAAa;qBACd;oBACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;GAwBT;oBACD,aAAa,EAAE,iBAAiB,CAAC,IAAI;oBACrC,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,IAAI,EAAE,EAAE,KAAK,EAAE,yBAAyB,EAAE,IAAI,EAAE,OAAO,EAAE;iBAC1D","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n computed,\n inject,\n ViewEncapsulation,\n} from '@angular/core';\nimport type { Editor } from '@tiptap/core';\nimport { LucideCode2, LucideMinus, LucideTextQuote } from '@lucide/angular';\nimport {\n MLV_EDITOR_TOOLBAR_CONTEXT,\n MLV_EDITOR_TOOLBAR_REVISION,\n} from '../editor-toolbar-context';\nimport { MLV_EDITOR_I18N } from '@malva-ui/i18n';\nimport { MlvEditorCommandButton } from './editor-command-button';\nimport { MlvButtonIcon } from '@malva-ui/core/button';\n\n/** Blockquote and code-block toggles plus horizontal-rule insertion. */\n@Component({\n selector: 'mlv-editor-block-insert',\n imports: [\n MlvEditorCommandButton,\n LucideCode2,\n LucideMinus,\n LucideTextQuote,\n MlvButtonIcon,\n ],\n template: `\n <mlv-editor-command-button\n [label]=\"_copy().blockquote\"\n [pressed]=\"_isActive('blockquote')\"\n [supports]=\"_canBlockquote\"\n [canCommand]=\"_canBlockquoteNow\"\n [command]=\"_blockquote\"\n ><svg mlvButtonIcon lucideTextQuote\n /></mlv-editor-command-button>\n <mlv-editor-command-button\n [label]=\"_copy().codeBlock\"\n [pressed]=\"_isActive('codeBlock')\"\n [supports]=\"_canCodeBlock\"\n [canCommand]=\"_canCodeBlockNow\"\n [command]=\"_codeBlock\"\n ><svg mlvButtonIcon lucideCode2\n /></mlv-editor-command-button>\n <mlv-editor-command-button\n [label]=\"_copy().horizontalRule\"\n [supports]=\"_canHorizontalRule\"\n [canCommand]=\"_canHorizontalRuleNow\"\n [command]=\"_horizontalRule\"\n ><svg mlvButtonIcon lucideMinus\n /></mlv-editor-command-button>\n `,\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: { class: 'mlv-editor-block-insert', role: 'group' },\n})\nexport class MlvEditorBlockInsert {\n /** @protected Editor command state. */ protected readonly _context = inject(\n MLV_EDITOR_TOOLBAR_CONTEXT,\n );\n /** @private Triggers active-state refreshes after editor events. */ private readonly _revision =\n inject(MLV_EDITOR_TOOLBAR_REVISION);\n /** @private Optional localized copy. */ private readonly _i18n = inject(\n MLV_EDITOR_I18N,\n { optional: true },\n );\n /** @protected Resolved labels. */ protected readonly _copy = computed(\n () => ({\n blockquote: this._i18n?.().blockquote ?? 'Blockquote',\n codeBlock: this._i18n?.().codeBlock ?? 'Code block',\n horizontalRule: this._i18n?.().horizontalRule ?? 'Horizontal rule',\n }),\n );\n /** @protected Registered blockquote command. */ protected readonly _canBlockquote =\n (editor: Editor): boolean => editor.commands.toggleBlockquote !== undefined;\n /** @protected Current blockquote command availability. */ protected readonly _canBlockquoteNow =\n (editor: Editor): boolean => editor.can().chain().toggleBlockquote().run();\n /** @protected Registered code-block command. */ protected readonly _canCodeBlock =\n (editor: Editor): boolean => editor.commands.toggleCodeBlock !== undefined;\n /** @protected Current code-block command availability. */ protected readonly _canCodeBlockNow =\n (editor: Editor): boolean => editor.can().chain().toggleCodeBlock().run();\n /** @protected Registered horizontal-rule command. */ protected readonly _canHorizontalRule =\n (editor: Editor): boolean =>\n editor.commands.setHorizontalRule !== undefined;\n /** @protected Current horizontal-rule command availability. */ protected readonly _canHorizontalRuleNow =\n (editor: Editor): boolean => editor.can().chain().setHorizontalRule().run();\n /** @protected Blockquote command. */ protected readonly _blockquote = (\n editor: Editor,\n ): boolean => editor.chain().focus().toggleBlockquote().run();\n /** @protected Code-block command. */ protected readonly _codeBlock = (\n editor: Editor,\n ): boolean => editor.chain().focus().toggleCodeBlock().run();\n /** @protected Horizontal-rule command. */ protected readonly _horizontalRule =\n (editor: Editor): boolean =>\n editor.chain().focus().setHorizontalRule().run();\n\n /** @protected Reads command state after the toolbar receives an editor update. */\n protected readonly _isActive = (\n name: 'blockquote' | 'codeBlock',\n ): boolean => {\n this._revision();\n return this._context.isActive(name);\n };\n}\n"]}
@@ -1,71 +0,0 @@
1
- import { Directive, effect, inject, untracked, viewChild } from '@angular/core';
2
- import { MLV_EDITOR_OVERLAY_REGISTRY, MLV_EDITOR_TOOLBAR_CONTEXT, MLV_EDITOR_TOOLBAR_REVISION, MLV_EDITOR_TOOLBAR_ROVING, } from '../editor-toolbar-context';
3
- import * as i0 from "@angular/core";
4
- /** @internal Shared selection, roving, and overlay lifecycle for colour controls. */
5
- export class MlvEditorColorControl {
6
- /** @protected Editor-scoped command and state boundary. */
7
- _context = inject(MLV_EDITOR_TOOLBAR_CONTEXT);
8
- /** @protected Reactive toolbar invalidation state. */
9
- _revision = inject(MLV_EDITOR_TOOLBAR_REVISION, {
10
- optional: true,
11
- });
12
- /** @protected Public color-picker composition surface. */
13
- _picker = viewChild.required('picker', /* @ts-ignore */
14
- ...(ngDevMode ? [{ debugName: "_picker" }] : /* istanbul ignore next */ []));
15
- /** @private Editor toolbar roving-focus owner. */
16
- _roving = inject(MLV_EDITOR_TOOLBAR_ROVING);
17
- /** @private Editor composite detached-overlay owner. */
18
- _overlays = inject(MLV_EDITOR_OVERLAY_REGISTRY);
19
- /** @private ProseMirror selection retained while focus is inside the picker. */
20
- _selection = null;
21
- constructor() {
22
- effect((onCleanup) => {
23
- const trigger = this._picker().triggerElement();
24
- if (!trigger)
25
- return;
26
- const activate = () => this._roving.activate(trigger);
27
- trigger.addEventListener('focus', activate);
28
- trigger.addEventListener('pointerdown', activate);
29
- const unregister = untracked(() => this._roving.register(trigger));
30
- onCleanup(() => {
31
- unregister();
32
- trigger.removeEventListener('focus', activate);
33
- trigger.removeEventListener('pointerdown', activate);
34
- });
35
- });
36
- effect(() => {
37
- const trigger = this._picker().triggerElement();
38
- if (trigger)
39
- trigger.tabIndex = this._roving.isActive(trigger) ? 0 : -1;
40
- });
41
- effect((onCleanup) => {
42
- const panel = this._picker().panelElement();
43
- if (!panel)
44
- return;
45
- const unregister = this._overlays.register(panel, () => this._picker().opened.set(false));
46
- onCleanup(unregister);
47
- });
48
- }
49
- /** @protected Snapshots the document selection at open intent. */
50
- _onOpenedChange(opened) {
51
- if (!opened)
52
- return;
53
- const selection = this._context.editor()?.state.selection;
54
- this._selection = selection
55
- ? { from: selection.from, to: selection.to }
56
- : null;
57
- }
58
- /** @protected Restores the snapshot and delegates the distinct colour command. */
59
- _apply(color) {
60
- const selection = this._selection;
61
- if (!selection)
62
- return;
63
- this._context.run((editor) => this._run(editor, selection, color));
64
- }
65
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MlvEditorColorControl, deps: [], target: i0.ɵɵFactoryTarget.Directive });
66
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "22.0.7", type: MlvEditorColorControl, isStandalone: true, viewQueries: [{ propertyName: "_picker", first: true, predicate: ["picker"], descendants: true, isSignal: true }], ngImport: i0 });
67
- }
68
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MlvEditorColorControl, decorators: [{
69
- type: Directive
70
- }], ctorParameters: () => [], propDecorators: { _picker: [{ type: i0.ViewChild, args: ['picker', { isSignal: true }] }] } });
71
- //# sourceMappingURL=editor-color-control.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor-color-control.js","sourceRoot":"","sources":["../../../../../../libs/editor/src/lib/toolbar/editor-color-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE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,CAAC,SAAS;YAAE,OAAO;QACvB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IACrE,CAAC;uGAlEmB,qBAAqB;2FAArB,qBAAqB;;2FAArB,qBAAqB;kBAD1C,SAAS;+FAYkC,QAAQ","sourcesContent":["import { Directive, effect, inject, untracked, viewChild } from '@angular/core';\nimport type { Editor } from '@tiptap/core';\nimport type { MlvColorPickerPopup } from '@malva-ui/core/color-picker';\nimport {\n MLV_EDITOR_OVERLAY_REGISTRY,\n MLV_EDITOR_TOOLBAR_CONTEXT,\n MLV_EDITOR_TOOLBAR_REVISION,\n MLV_EDITOR_TOOLBAR_ROVING,\n} from '../editor-toolbar-context';\n\ninterface EditorSelectionRange {\n readonly from: number;\n readonly to: number;\n}\n\n/** @internal Shared selection, roving, and overlay lifecycle for colour controls. */\n@Directive()\nexport abstract class MlvEditorColorControl {\n /** @protected Editor-scoped command and state boundary. */\n protected readonly _context = inject(MLV_EDITOR_TOOLBAR_CONTEXT);\n\n /** @protected Reactive toolbar invalidation state. */\n protected readonly _revision = inject(MLV_EDITOR_TOOLBAR_REVISION, {\n optional: true,\n });\n\n /** @protected Public color-picker composition surface. */\n protected readonly _picker =\n viewChild.required<MlvColorPickerPopup>('picker');\n\n /** @private Editor toolbar roving-focus owner. */\n private readonly _roving = inject(MLV_EDITOR_TOOLBAR_ROVING);\n\n /** @private Editor composite detached-overlay owner. */\n private readonly _overlays = inject(MLV_EDITOR_OVERLAY_REGISTRY);\n\n /** @private ProseMirror selection retained while focus is inside the picker. */\n private _selection: EditorSelectionRange | null = null;\n\n constructor() {\n effect((onCleanup) => {\n const trigger = this._picker().triggerElement();\n if (!trigger) return;\n const activate = () => this._roving.activate(trigger);\n trigger.addEventListener('focus', activate);\n trigger.addEventListener('pointerdown', activate);\n const unregister = untracked(() => this._roving.register(trigger));\n onCleanup(() => {\n unregister();\n trigger.removeEventListener('focus', activate);\n trigger.removeEventListener('pointerdown', activate);\n });\n });\n\n effect(() => {\n const trigger = this._picker().triggerElement();\n if (trigger) trigger.tabIndex = this._roving.isActive(trigger) ? 0 : -1;\n });\n\n effect((onCleanup) => {\n const panel = this._picker().panelElement();\n if (!panel) return;\n const unregister = this._overlays.register(panel, () =>\n this._picker().opened.set(false),\n );\n onCleanup(unregister);\n });\n }\n\n /** @protected Snapshots the document selection at open intent. */\n protected _onOpenedChange(opened: boolean): void {\n if (!opened) return;\n const selection = this._context.editor()?.state.selection;\n this._selection = selection\n ? { from: selection.from, to: selection.to }\n : null;\n }\n\n /** @protected Restores the snapshot and delegates the distinct colour command. */\n protected _apply(color: string): void {\n const selection = this._selection;\n if (!selection) return;\n this._context.run((editor) => this._run(editor, selection, color));\n }\n\n /** @protected Distinct foreground/highlight command policy. */\n protected abstract _run(\n editor: Editor,\n selection: EditorSelectionRange,\n color: string,\n ): boolean;\n}\n"]}
@@ -1,115 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, computed, inject, input, ViewEncapsulation, } from '@angular/core';
2
- import { MlvButton, MlvButtonIcon } from '@malva-ui/core/button';
3
- import { MlvTooltip } from '@malva-ui/core/tooltip';
4
- import { MLV_EDITOR_TOOLBAR_CONTEXT, MLV_EDITOR_TOOLBAR_REVISION, } from '../editor-toolbar-context';
5
- import { MlvEditorToolbarWidget } from './editor-toolbar-widget';
6
- import * as i0 from "@angular/core";
7
- /** @internal Reusable selection-preserving command button for editor toolbar modules. */
8
- export class MlvEditorCommandButton {
9
- /** Accessible action label. */
10
- label = input.required(/* @ts-ignore */
11
- ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
12
- /** Evaluates whether the configured extension provides this action. */
13
- supports = input.required(/* @ts-ignore */
14
- ...(ngDevMode ? [{ debugName: "supports" }] : /* istanbul ignore next */ []));
15
- /** Executes the action through a focused editor command chain. */
16
- command = input.required(/* @ts-ignore */
17
- ...(ngDevMode ? [{ debugName: "command" }] : /* istanbul ignore next */ []));
18
- /** Checks whether the registered command can run at the current selection. */
19
- canCommand = input(undefined, /* @ts-ignore */
20
- ...(ngDevMode ? [{ debugName: "canCommand" }] : /* istanbul ignore next */ []));
21
- /** Optional current active state for toggle-like commands. */
22
- pressed = input(undefined, /* @ts-ignore */
23
- ...(ngDevMode ? [{ debugName: "pressed" }] : /* istanbul ignore next */ []));
24
- /** @private Editor-scoped command state. */
25
- _context = inject(MLV_EDITOR_TOOLBAR_CONTEXT);
26
- /** @private Per-editor state invalidation signal. */
27
- _revision = inject(MLV_EDITOR_TOOLBAR_REVISION);
28
- /** @protected Whether the current extension set supports this command. */
29
- supported = computed(() => {
30
- this._revision();
31
- const editor = this._context.editor();
32
- if (!editor)
33
- return false;
34
- try {
35
- return this.supports()(editor);
36
- }
37
- catch {
38
- return false;
39
- }
40
- }, /* @ts-ignore */
41
- ...(ngDevMode ? [{ debugName: "supported" }] : /* istanbul ignore next */ []));
42
- /** @protected Whether the command currently cannot mutate the editor. */
43
- _disabled() {
44
- this._revision();
45
- const canCommand = this.canCommand();
46
- return (!this.supported() ||
47
- this._context.disabled() ||
48
- this._context.readonly() ||
49
- !(canCommand ? this._context.can(canCommand) : true));
50
- }
51
- /** @protected Prevents the browser from moving the selection before the command chain restores content focus. */
52
- _preserveSelection(event) {
53
- if (!this._disabled())
54
- event.preventDefault();
55
- }
56
- /** @protected Executes only supported, enabled commands. */
57
- _run() {
58
- if (this._disabled())
59
- return;
60
- this._context.run(this.command());
61
- }
62
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MlvEditorCommandButton, deps: [], target: i0.ɵɵFactoryTarget.Component });
63
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.7", type: MlvEditorCommandButton, isStandalone: true, selector: "mlv-editor-command-button", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, supports: { classPropertyName: "supports", publicName: "supports", isSignal: true, isRequired: true, transformFunction: null }, command: { classPropertyName: "command", publicName: "command", isSignal: true, isRequired: true, transformFunction: null }, canCommand: { classPropertyName: "canCommand", publicName: "canCommand", isSignal: true, isRequired: false, transformFunction: null }, pressed: { classPropertyName: "pressed", publicName: "pressed", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "hidden": "!supported()" }, classAttribute: "mlv-editor-command-button" }, ngImport: i0, template: `
64
- <button
65
- mlvButton
66
- mlvEditorToolbarWidget
67
- type="button"
68
- shape="square"
69
- variant="transparent"
70
- [attr.aria-label]="label()"
71
- [attr.aria-pressed]="pressed() === undefined ? null : pressed()"
72
- [disabled]="_disabled()"
73
- [mlvTooltip]="label()"
74
- [tooltipDisabled]="_disabled()"
75
- mlvDensity="tight"
76
- (pointerdown)="_preserveSelection($event)"
77
- (click)="_run()"
78
- >
79
- <span mlvButtonIcon aria-hidden="true"><ng-content /></span>
80
- </button>
81
- `, 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: "directive", type: MlvEditorToolbarWidget, selector: "[mlvEditorToolbarWidget]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
82
- }
83
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: MlvEditorCommandButton, decorators: [{
84
- type: Component,
85
- args: [{
86
- selector: 'mlv-editor-command-button',
87
- imports: [MlvButton, MlvButtonIcon, MlvTooltip, MlvEditorToolbarWidget],
88
- template: `
89
- <button
90
- mlvButton
91
- mlvEditorToolbarWidget
92
- type="button"
93
- shape="square"
94
- variant="transparent"
95
- [attr.aria-label]="label()"
96
- [attr.aria-pressed]="pressed() === undefined ? null : pressed()"
97
- [disabled]="_disabled()"
98
- [mlvTooltip]="label()"
99
- [tooltipDisabled]="_disabled()"
100
- mlvDensity="tight"
101
- (pointerdown)="_preserveSelection($event)"
102
- (click)="_run()"
103
- >
104
- <span mlvButtonIcon aria-hidden="true"><ng-content /></span>
105
- </button>
106
- `,
107
- encapsulation: ViewEncapsulation.None,
108
- changeDetection: ChangeDetectionStrategy.OnPush,
109
- host: {
110
- class: 'mlv-editor-command-button',
111
- '[hidden]': '!supported()',
112
- },
113
- }]
114
- }], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], supports: [{ type: i0.Input, args: [{ isSignal: true, alias: "supports", required: true }] }], command: [{ type: i0.Input, args: [{ isSignal: true, alias: "command", required: true }] }], canCommand: [{ type: i0.Input, args: [{ isSignal: true, alias: "canCommand", required: false }] }], pressed: [{ type: i0.Input, args: [{ isSignal: true, alias: "pressed", required: false }] }] } });
115
- //# sourceMappingURL=editor-command-button.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor-command-button.js","sourceRoot":"","sources":["../../../../../../libs/editor/src/lib/toolbar/editor-command-button.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,QAAQ,EACR,MAAM,EACN,KAAK,EACL,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;;AAEjE,yFAAyF;AA8BzF,MAAM,OAAO,sBAAsB;IACjC,+BAA+B;IACtB,KAAK,GAAG,KAAK,CAA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C,KAAmB;QAC9C,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YAAE,KAAK,CAAC,cAAc,EAAE,CAAC;IAChD,CAAC;IAED,4DAA4D;IAClD,IAAI;QACZ,IAAI,IAAI,CAAC,SAAS,EAAE;YAAE,OAAO;QAC7B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACpC,CAAC;uGAzDU,sBAAsB;2FAAtB,sBAAsB,2zBA1BvB;;;;;;;;;;;;;;;;;;GAkBT,4DAnBS,SAAS,iIAAE,aAAa,4DAAE,UAAU,uKAAE,sBAAsB;;2FA2B3D,sBAAsB;kBA7BlC,SAAS;mBAAC;oBACT,QAAQ,EAAE,2BAA2B;oBACrC,OAAO,EAAE,CAAC,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,sBAAsB,CAAC;oBACvE,QAAQ,EAAE;;;;;;;;;;;;;;;;;;GAkBT;oBACD,aAAa,EAAE,iBAAiB,CAAC,IAAI;oBACrC,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,IAAI,EAAE;wBACJ,KAAK,EAAE,2BAA2B;wBAClC,UAAU,EAAE,cAAc;qBAC3B;iBACF","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n computed,\n inject,\n input,\n ViewEncapsulation,\n} from '@angular/core';\nimport type { Editor } from '@tiptap/core';\nimport { MlvButton, MlvButtonIcon } from '@malva-ui/core/button';\nimport { MlvTooltip } from '@malva-ui/core/tooltip';\nimport {\n MLV_EDITOR_TOOLBAR_CONTEXT,\n MLV_EDITOR_TOOLBAR_REVISION,\n} from '../editor-toolbar-context';\nimport { MlvEditorToolbarWidget } from './editor-toolbar-widget';\n\n/** @internal Reusable selection-preserving command button for editor toolbar modules. */\n@Component({\n selector: 'mlv-editor-command-button',\n imports: [MlvButton, MlvButtonIcon, MlvTooltip, MlvEditorToolbarWidget],\n template: `\n <button\n mlvButton\n mlvEditorToolbarWidget\n type=\"button\"\n shape=\"square\"\n variant=\"transparent\"\n [attr.aria-label]=\"label()\"\n [attr.aria-pressed]=\"pressed() === undefined ? null : pressed()\"\n [disabled]=\"_disabled()\"\n [mlvTooltip]=\"label()\"\n [tooltipDisabled]=\"_disabled()\"\n mlvDensity=\"tight\"\n (pointerdown)=\"_preserveSelection($event)\"\n (click)=\"_run()\"\n >\n <span mlvButtonIcon aria-hidden=\"true\"><ng-content /></span>\n </button>\n `,\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'mlv-editor-command-button',\n '[hidden]': '!supported()',\n },\n})\nexport class MlvEditorCommandButton {\n /** Accessible action label. */\n readonly label = input.required<string>();\n\n /** Evaluates whether the configured extension provides this action. */\n readonly supports = input.required<(editor: Editor) => boolean>();\n\n /** Executes the action through a focused editor command chain. */\n readonly command = input.required<(editor: Editor) => boolean>();\n\n /** Checks whether the registered command can run at the current selection. */\n readonly canCommand = input<((editor: Editor) => boolean) | undefined>(\n undefined,\n );\n\n /** Optional current active state for toggle-like commands. */\n readonly pressed = input<boolean | undefined>(undefined);\n\n /** @private Editor-scoped command state. */\n private 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 /** @protected Whether the current extension set supports this command. */\n protected readonly supported = computed(() => {\n this._revision();\n const editor = this._context.editor();\n if (!editor) return false;\n try {\n return this.supports()(editor);\n } catch {\n return false;\n }\n });\n\n /** @protected Whether the command currently cannot mutate the editor. */\n protected _disabled(): boolean {\n this._revision();\n const canCommand = this.canCommand();\n return (\n !this.supported() ||\n this._context.disabled() ||\n this._context.readonly() ||\n !(canCommand ? this._context.can(canCommand) : true)\n );\n }\n\n /** @protected Prevents the browser from moving the selection before the command chain restores content focus. */\n protected _preserveSelection(event: PointerEvent): void {\n if (!this._disabled()) event.preventDefault();\n }\n\n /** @protected Executes only supported, enabled commands. */\n protected _run(): void {\n if (this._disabled()) return;\n this._context.run(this.command());\n }\n}\n"]}