@nanahoshi/mona-ui 0.24.8 → 0.24.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +37 -9
- package/fesm2022/nanahoshi-mona-ui-button.mjs +8 -2
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +4 -3
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +101 -47
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +342 -102
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +119 -69
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +1054 -452
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-DdyHnUIr.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DhKLnW06.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-B6gq7Hu3.mjs → nanahoshi-mona-ui-grid-grid-list.component-voGbKOiB.mjs} +4 -4
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-DdUY3I7P.mjs → nanahoshi-mona-ui-grid-grid-row.component-HQ1Kv6R9.mjs} +2 -3
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-DG8Bu4Dy.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-PNLJFcuH.mjs} +4 -4
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CVqpbMcb.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-BO19AVwC.mjs} +9 -9
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +23 -0
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +567 -33
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +20 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +127 -133
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +473 -240
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +202 -90
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +609 -256
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +45 -10
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +102 -58
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +286 -443
- package/fesm2022/nanahoshi-mona-ui-window.mjs +594 -311
- package/i18n/catalogs/en-US.messages.json +24 -4
- package/locales/ar-sa/ar-sa.messages.json +20 -0
- package/locales/de-de/de-de.messages.json +20 -0
- package/locales/es-es/es-es.messages.json +20 -0
- package/locales/fr-fr/fr-fr.messages.json +20 -0
- package/locales/id-id/id-id.messages.json +20 -0
- package/locales/it-it/it-it.messages.json +20 -0
- package/locales/ja-jp/ja-jp.messages.json +20 -0
- package/locales/ko-kr/ko-kr.messages.json +20 -0
- package/locales/pt-br/pt-br.messages.json +20 -0
- package/locales/ru-ru/ru-ru.messages.json +20 -0
- package/locales/tr-tr/tr-tr.messages.json +20 -0
- package/locales/zh-cn/zh-cn.messages.json +20 -0
- package/locales/zh-tw/zh-tw.messages.json +20 -0
- package/package.json +1 -1
- package/types/nanahoshi-mona-ui-button-group.d.ts +13 -3
- package/types/nanahoshi-mona-ui-button.d.ts +20 -3
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -6
- package/types/nanahoshi-mona-ui-dialog.d.ts +131 -20
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +75 -56
- package/types/nanahoshi-mona-ui-editor.d.ts +118 -21
- package/types/nanahoshi-mona-ui-i18n.d.ts +37 -0
- package/types/nanahoshi-mona-ui-internal.d.ts +142 -16
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +20 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +20 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +65 -62
- package/types/nanahoshi-mona-ui-notification.d.ts +76 -16
- package/types/nanahoshi-mona-ui-popover.d.ts +44 -17
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +110 -32
- package/types/nanahoshi-mona-ui-popup.d.ts +2 -0
- package/types/nanahoshi-mona-ui-sheet.d.ts +16 -5
- package/types/nanahoshi-mona-ui-split-button.d.ts +29 -7
- package/types/nanahoshi-mona-ui-tooltip.d.ts +43 -20
- package/types/nanahoshi-mona-ui-window.d.ts +103 -14
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { signal, computed, Injectable, inject, ElementRef, input, afterRenderEffect, Directive, Component, DOCUMENT, output, Injector, viewChild, DestroyRef, booleanAttribute, model, afterNextRender, afterEveryRender, effect, untracked } from '@angular/core';
|
|
3
3
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
|
-
import {
|
|
4
|
+
import { formatNumber, MonaI18nService, injectComponentDirection } from '@nanahoshi/mona-ui/i18n';
|
|
5
|
+
import { createElementControlId, RovingToolbar } from '@nanahoshi/mona-ui/internal';
|
|
5
6
|
import { twMerge } from 'tailwind-merge';
|
|
6
7
|
import { ImmutableSet, any, List, range } from '@mirei/ts-collections';
|
|
7
|
-
import { formatNumber, MonaI18nService } from '@nanahoshi/mona-ui/i18n';
|
|
8
8
|
import { Extension, Editor } from '@tiptap/core';
|
|
9
9
|
import { Color } from '@tiptap/extension-color';
|
|
10
10
|
import { FontFamily } from '@tiptap/extension-font-family';
|
|
11
11
|
import { Highlight } from '@tiptap/extension-highlight';
|
|
12
|
-
import { Link } from '@tiptap/extension-link';
|
|
13
12
|
import { Subscript } from '@tiptap/extension-subscript';
|
|
14
13
|
import { Superscript } from '@tiptap/extension-superscript';
|
|
15
14
|
import { Table } from '@tiptap/extension-table';
|
|
@@ -20,7 +19,6 @@ import { TaskItem } from '@tiptap/extension-task-item';
|
|
|
20
19
|
import { TaskList } from '@tiptap/extension-task-list';
|
|
21
20
|
import { TextAlign } from '@tiptap/extension-text-align';
|
|
22
21
|
import { TextStyle } from '@tiptap/extension-text-style';
|
|
23
|
-
import { Underline } from '@tiptap/extension-underline';
|
|
24
22
|
import { StarterKit } from '@tiptap/starter-kit';
|
|
25
23
|
import { Subject } from 'rxjs';
|
|
26
24
|
import { Image } from '@tiptap/extension-image';
|
|
@@ -29,19 +27,98 @@ import { cva } from 'class-variance-authority';
|
|
|
29
27
|
import { ButtonDirective } from '@nanahoshi/mona-ui/button';
|
|
30
28
|
import { ButtonGroupComponent } from '@nanahoshi/mona-ui/button-group';
|
|
31
29
|
import { ColorPickerComponent, ColorPickerValueTemplateDirective } from '@nanahoshi/mona-ui/color-picker';
|
|
30
|
+
import { FormsModule } from '@angular/forms';
|
|
32
31
|
import { DropdownListComponent } from '@nanahoshi/mona-ui/dropdown-list';
|
|
33
32
|
import { DropdownItemTemplateDirective } from '@nanahoshi/mona-ui/dropdowns';
|
|
34
33
|
import { WindowComponent, WindowContentTemplateDirective } from '@nanahoshi/mona-ui/window';
|
|
35
34
|
import { form, required, maxLength, FormRoot, FormField } from '@angular/forms/signals';
|
|
36
35
|
import { NumericTextBoxComponent } from '@nanahoshi/mona-ui/numeric-text-box';
|
|
37
36
|
import { TextBoxComponent } from '@nanahoshi/mona-ui/text-box';
|
|
38
|
-
import { DialogService } from '@nanahoshi/mona-ui/dialog';
|
|
37
|
+
import { DIALOG_DATA, DialogService } from '@nanahoshi/mona-ui/dialog';
|
|
39
38
|
import { PopoverComponent } from '@nanahoshi/mona-ui/popover';
|
|
40
39
|
|
|
40
|
+
// Generated from i18n/catalogs/en-US.messages.json by scripts/generate-locale-catalogs.ts. Do not edit.
|
|
41
|
+
// Edit the JSON file and run `npm run generate:locale-catalogs`.
|
|
42
|
+
function localizeNumber(value, options) {
|
|
43
|
+
return formatNumber(value, "en-US", options);
|
|
44
|
+
}
|
|
45
|
+
const EDITOR_DEFAULT_MESSAGES = {
|
|
46
|
+
addColumnAfter: "Add column after",
|
|
47
|
+
addColumnBefore: "Add column before",
|
|
48
|
+
addHorizontalLine: "Add horizontal line",
|
|
49
|
+
addRowAfter: "Add row after",
|
|
50
|
+
addRowBefore: "Add row before",
|
|
51
|
+
alignCenter: "Center text",
|
|
52
|
+
alignEnd: "Align text to the end",
|
|
53
|
+
alignLeft: "Align text left",
|
|
54
|
+
alignRight: "Align text right",
|
|
55
|
+
alignStart: "Align text to the start",
|
|
56
|
+
alignmentGroup: "Alignment",
|
|
57
|
+
altText: "Alt text",
|
|
58
|
+
apply: "Apply",
|
|
59
|
+
backgroundColor: "Background color",
|
|
60
|
+
bold: "Bold",
|
|
61
|
+
cancel: "Cancel",
|
|
62
|
+
codeBlock: "Code block",
|
|
63
|
+
color: "Color",
|
|
64
|
+
contentLabel: "Rich text editor",
|
|
65
|
+
defaultFontFamily: "Default font",
|
|
66
|
+
deleteColumn: "Delete column",
|
|
67
|
+
deleteRow: "Delete row",
|
|
68
|
+
deleteTable: "Delete table",
|
|
69
|
+
editLink: "Edit link",
|
|
70
|
+
enterUrl: "Enter the URL",
|
|
71
|
+
fontSize: "Font size",
|
|
72
|
+
format: "Format",
|
|
73
|
+
heading: (level) => `Heading ${localizeNumber(level)}`,
|
|
74
|
+
heightPx: "Height (px)",
|
|
75
|
+
historyGroup: "History",
|
|
76
|
+
imageUrl: "Image URL",
|
|
77
|
+
indent: "Indent",
|
|
78
|
+
indentGroup: "Indentation",
|
|
79
|
+
insert: "Insert",
|
|
80
|
+
insertImage: "Insert image",
|
|
81
|
+
insertLink: "Insert link",
|
|
82
|
+
insertOrderedList: "Insert ordered list",
|
|
83
|
+
insertTable: "Insert table",
|
|
84
|
+
insertTaskList: "Insert task list",
|
|
85
|
+
insertUnorderedList: "Insert unordered list",
|
|
86
|
+
invalidUrl: "Enter a web address, a mailto: or tel: link, or a relative path.",
|
|
87
|
+
italic: "Italic",
|
|
88
|
+
justify: "Justify",
|
|
89
|
+
linkGroup: "Link",
|
|
90
|
+
listGroup: "Lists",
|
|
91
|
+
mergeCells: "Merge selected cells",
|
|
92
|
+
outdent: "Outdent",
|
|
93
|
+
paragraph: "Paragraph",
|
|
94
|
+
quotation: "Quotation",
|
|
95
|
+
redo: "Redo",
|
|
96
|
+
removeLink: "Remove link",
|
|
97
|
+
selectFontFamily: "Select font family",
|
|
98
|
+
selectFontSize: "Select font size",
|
|
99
|
+
splitCell: "Split cell",
|
|
100
|
+
strikethrough: "Strikethrough",
|
|
101
|
+
subscript: "Subscript",
|
|
102
|
+
superscript: "Superscript",
|
|
103
|
+
tableGroup: "Table",
|
|
104
|
+
tableSize: (rows, columns) => `Rows: ${localizeNumber(rows)}, columns: ${localizeNumber(columns)}`,
|
|
105
|
+
textStyleGroup: "Text style",
|
|
106
|
+
toggleHeaderRow: "Toggle header row",
|
|
107
|
+
toolbar: "Formatting",
|
|
108
|
+
underline: "Underline",
|
|
109
|
+
undo: "Undo",
|
|
110
|
+
widthPx: "Width (px)"
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The image node with `width` and `height` kept as attributes, on top of the base `src`, `alt` and `title`.
|
|
115
|
+
*/
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Tiptap extensions are named in PascalCase.
|
|
41
117
|
const ExtendedImage = Image.extend({
|
|
42
118
|
name: "extendedImage",
|
|
43
119
|
addAttributes() {
|
|
44
120
|
return {
|
|
121
|
+
...this.parent?.(),
|
|
45
122
|
width: {
|
|
46
123
|
default: null,
|
|
47
124
|
parseHTML: (element) => element.getAttribute("width"),
|
|
@@ -56,6 +133,7 @@ const ExtendedImage = Image.extend({
|
|
|
56
133
|
}
|
|
57
134
|
});
|
|
58
135
|
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Tiptap extensions are named in PascalCase.
|
|
59
137
|
const FontSize = Extension.create({
|
|
60
138
|
name: "fontSize",
|
|
61
139
|
addOptions() {
|
|
@@ -73,7 +151,7 @@ const FontSize = Extension.create({
|
|
|
73
151
|
attributes: {
|
|
74
152
|
fontSize: {
|
|
75
153
|
default: null,
|
|
76
|
-
parseHTML: element => element.style.fontSize.replace(/['"]+/g, ""),
|
|
154
|
+
parseHTML: element => element.style.fontSize.replace(/['"]+/g, "") || null,
|
|
77
155
|
renderHTML: attributes => {
|
|
78
156
|
if (!attributes["fontSize"]) {
|
|
79
157
|
return {};
|
|
@@ -103,20 +181,13 @@ const FontSize = Extension.create({
|
|
|
103
181
|
* Indent extension for Tiptap v3
|
|
104
182
|
* Port of the well-known v2 example, updated for @tiptap/core@3 and @tiptap/pm.
|
|
105
183
|
*/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return
|
|
184
|
+
/**
|
|
185
|
+
* The level after `current` in `direction`, or `current` when there is none.
|
|
186
|
+
*/
|
|
187
|
+
const stepIndentLevel = (current, direction, levels) => {
|
|
188
|
+
const sorted = [...levels].sort((a, b) => (a - b) * direction);
|
|
189
|
+
return sorted.find(level => (level - current) * direction > 0) ?? current;
|
|
112
190
|
};
|
|
113
|
-
var IndentProps;
|
|
114
|
-
(function (IndentProps) {
|
|
115
|
-
IndentProps[IndentProps["min"] = 0] = "min";
|
|
116
|
-
IndentProps[IndentProps["max"] = 210] = "max";
|
|
117
|
-
IndentProps[IndentProps["more"] = 30] = "more";
|
|
118
|
-
IndentProps[IndentProps["less"] = -30] = "less";
|
|
119
|
-
})(IndentProps || (IndentProps = {}));
|
|
120
191
|
/**
|
|
121
192
|
* Helpers for list detection (kept simple here).
|
|
122
193
|
* If you want to support more list types, extend these.
|
|
@@ -126,19 +197,18 @@ const isOrderedListNode = (name) => name === "orderedList" || name === "ordered_
|
|
|
126
197
|
const isTaskListNode = (name) => name === "taskList" || name === "task_list";
|
|
127
198
|
const isListNodeName = (name) => isBulletListNode(name) || isOrderedListNode(name) || isTaskListNode(name);
|
|
128
199
|
/**
|
|
129
|
-
*
|
|
200
|
+
* Move the `indent` attribute of the node at `pos` one level in `direction`.
|
|
130
201
|
*/
|
|
131
|
-
const setNodeIndentMarkup = (tr, pos,
|
|
202
|
+
const setNodeIndentMarkup = (tr, pos, direction, options) => {
|
|
132
203
|
const doc = tr.doc;
|
|
133
204
|
if (!doc)
|
|
134
205
|
return tr;
|
|
135
206
|
const node = doc.nodeAt(pos);
|
|
136
207
|
if (!node)
|
|
137
208
|
return tr;
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
const indent = clamp(currentIndent + delta, minIndent, maxIndent);
|
|
209
|
+
const attrs = node.attrs;
|
|
210
|
+
const currentIndent = attrs.indent ?? 0;
|
|
211
|
+
const indent = stepIndentLevel(currentIndent, direction, options.indentLevels);
|
|
142
212
|
if (indent === currentIndent)
|
|
143
213
|
return tr;
|
|
144
214
|
const nodeAttrs = {
|
|
@@ -148,9 +218,9 @@ const setNodeIndentMarkup = (tr, pos, delta) => {
|
|
|
148
218
|
return tr.setNodeMarkup(pos, node.type, nodeAttrs, node.marks);
|
|
149
219
|
};
|
|
150
220
|
/**
|
|
151
|
-
*
|
|
221
|
+
* Move all matching blocks in the current selection one level in `direction`.
|
|
152
222
|
*/
|
|
153
|
-
const updateIndentLevel = (tr,
|
|
223
|
+
const updateIndentLevel = (tr, direction, options) => {
|
|
154
224
|
const { doc, selection } = tr;
|
|
155
225
|
if (!doc || !selection)
|
|
156
226
|
return tr;
|
|
@@ -162,7 +232,7 @@ const updateIndentLevel = (tr, delta, options) => {
|
|
|
162
232
|
const nodeName = node.type.name;
|
|
163
233
|
// Only apply to configured types (typically paragraph + heading)
|
|
164
234
|
if (options.types.includes(nodeName)) {
|
|
165
|
-
tr = setNodeIndentMarkup(tr, pos,
|
|
235
|
+
tr = setNodeIndentMarkup(tr, pos, direction, options);
|
|
166
236
|
return false;
|
|
167
237
|
}
|
|
168
238
|
// Don’t traverse into lists (you might want to handle list indentation differently)
|
|
@@ -173,6 +243,7 @@ const updateIndentLevel = (tr, delta, options) => {
|
|
|
173
243
|
});
|
|
174
244
|
return tr;
|
|
175
245
|
};
|
|
246
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Tiptap extensions are named in PascalCase.
|
|
176
247
|
const Indent = Extension.create({
|
|
177
248
|
name: "indent",
|
|
178
249
|
/**
|
|
@@ -180,9 +251,9 @@ const Indent = Extension.create({
|
|
|
180
251
|
*/
|
|
181
252
|
addOptions() {
|
|
182
253
|
return {
|
|
183
|
-
|
|
254
|
+
defaultIndentLevel: 0,
|
|
184
255
|
indentLevels: [0, 30, 60, 90, 120, 150, 180, 210],
|
|
185
|
-
|
|
256
|
+
types: ["paragraph", "heading"]
|
|
186
257
|
};
|
|
187
258
|
},
|
|
188
259
|
/**
|
|
@@ -222,208 +293,222 @@ const Indent = Extension.create({
|
|
|
222
293
|
const { selection } = state;
|
|
223
294
|
// Keep current selection intact
|
|
224
295
|
tr = tr.setSelection(selection);
|
|
225
|
-
tr = updateIndentLevel(tr,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return
|
|
296
|
+
tr = updateIndentLevel(tr, 1, this.options);
|
|
297
|
+
// `can()` runs commands without `dispatch`: it only asks whether they would change anything.
|
|
298
|
+
if (!tr.docChanged) {
|
|
299
|
+
return false;
|
|
229
300
|
}
|
|
230
|
-
|
|
301
|
+
dispatch?.(tr);
|
|
302
|
+
return true;
|
|
231
303
|
},
|
|
232
304
|
outdent: () => ({ tr, state, dispatch }) => {
|
|
233
305
|
const { selection } = state;
|
|
234
306
|
tr = tr.setSelection(selection);
|
|
235
|
-
tr = updateIndentLevel(tr,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
return
|
|
307
|
+
tr = updateIndentLevel(tr, -1, this.options);
|
|
308
|
+
// `can()` runs commands without `dispatch`: it only asks whether they would change anything.
|
|
309
|
+
if (!tr.docChanged) {
|
|
310
|
+
return false;
|
|
239
311
|
}
|
|
240
|
-
|
|
312
|
+
dispatch?.(tr);
|
|
313
|
+
return true;
|
|
241
314
|
}
|
|
242
315
|
};
|
|
243
316
|
},
|
|
244
317
|
/**
|
|
245
|
-
*
|
|
246
|
-
* -
|
|
247
|
-
* -
|
|
318
|
+
* Keyboard shortcuts:
|
|
319
|
+
* - Mod-] → indent()
|
|
320
|
+
* - Mod-[ → outdent()
|
|
321
|
+
*
|
|
322
|
+
* Tab is left to lists (where it nests the item) and to the browser, so the keyboard can leave the editor.
|
|
248
323
|
*/
|
|
249
324
|
addKeyboardShortcuts() {
|
|
250
325
|
const indentCommand = () => this.editor.commands.indent();
|
|
251
326
|
const outdentCommand = () => this.editor.commands.outdent();
|
|
252
327
|
return {
|
|
253
|
-
|
|
254
|
-
"
|
|
328
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- ProseMirror key names.
|
|
329
|
+
"Mod-]": indentCommand,
|
|
330
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- ProseMirror key names.
|
|
331
|
+
"Mod-[": outdentCommand
|
|
255
332
|
};
|
|
256
333
|
}
|
|
257
334
|
});
|
|
258
335
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
underline:
|
|
312
|
-
undo: "Undo",
|
|
313
|
-
widthPx: "Width (px)"
|
|
336
|
+
const DEFAULT_FONTS = [
|
|
337
|
+
"Arial",
|
|
338
|
+
"Comic Sans MS",
|
|
339
|
+
"Courier New",
|
|
340
|
+
"Georgia",
|
|
341
|
+
"Impact",
|
|
342
|
+
"Lucida Console",
|
|
343
|
+
"Lucida Sans Unicode",
|
|
344
|
+
"Palatino Linotype",
|
|
345
|
+
"Tahoma",
|
|
346
|
+
"Times New Roman",
|
|
347
|
+
"Trebuchet MS",
|
|
348
|
+
"Verdana"
|
|
349
|
+
];
|
|
350
|
+
const DEFAULT_FONT_SIZES = [
|
|
351
|
+
"10px",
|
|
352
|
+
"12px",
|
|
353
|
+
"14px",
|
|
354
|
+
"16px",
|
|
355
|
+
"18px",
|
|
356
|
+
"20px",
|
|
357
|
+
"24px",
|
|
358
|
+
"32px",
|
|
359
|
+
"36px",
|
|
360
|
+
"48px",
|
|
361
|
+
"60px",
|
|
362
|
+
"72px"
|
|
363
|
+
];
|
|
364
|
+
const DEFAULT_SETTINGS = {
|
|
365
|
+
alignment: true,
|
|
366
|
+
blockquote: true,
|
|
367
|
+
bold: true,
|
|
368
|
+
code: true,
|
|
369
|
+
fontColor: true,
|
|
370
|
+
fontFamily: true,
|
|
371
|
+
fontHighlight: true,
|
|
372
|
+
fontList: [],
|
|
373
|
+
fontSize: true,
|
|
374
|
+
fontSizeList: [],
|
|
375
|
+
headings: true,
|
|
376
|
+
history: true,
|
|
377
|
+
horizontalRule: true,
|
|
378
|
+
image: true,
|
|
379
|
+
indent: true,
|
|
380
|
+
italic: true,
|
|
381
|
+
link: true,
|
|
382
|
+
list: true,
|
|
383
|
+
strikethrough: true,
|
|
384
|
+
subscript: true,
|
|
385
|
+
superscript: true,
|
|
386
|
+
table: true,
|
|
387
|
+
taskList: true,
|
|
388
|
+
underline: true
|
|
314
389
|
};
|
|
315
|
-
|
|
390
|
+
/**
|
|
391
|
+
* Wraps a single block node in a document; a document is used as it is.
|
|
392
|
+
*/
|
|
393
|
+
function toDocumentContent(content) {
|
|
394
|
+
if (typeof content === "string" || content.type === "doc") {
|
|
395
|
+
return content;
|
|
396
|
+
}
|
|
397
|
+
return { type: "doc", content: [content] };
|
|
398
|
+
}
|
|
316
399
|
class EditorService {
|
|
317
400
|
constructor() {
|
|
318
|
-
this.#
|
|
319
|
-
|
|
320
|
-
this.#
|
|
321
|
-
alignment: true,
|
|
322
|
-
blockquote: true,
|
|
323
|
-
bold: true,
|
|
324
|
-
code: true,
|
|
325
|
-
fontColor: true,
|
|
326
|
-
fontFamily: true,
|
|
327
|
-
fontHighlight: true,
|
|
328
|
-
fontList: [],
|
|
329
|
-
fontSize: true,
|
|
330
|
-
headings: true,
|
|
331
|
-
history: true,
|
|
332
|
-
horizontalRule: true,
|
|
333
|
-
image: true,
|
|
334
|
-
indent: true,
|
|
335
|
-
italic: true,
|
|
336
|
-
link: true,
|
|
337
|
-
list: true,
|
|
338
|
-
strikethrough: true,
|
|
339
|
-
subscript: true,
|
|
340
|
-
superscript: true,
|
|
341
|
-
table: true,
|
|
342
|
-
taskList: true,
|
|
343
|
-
underline: true
|
|
344
|
-
};
|
|
345
|
-
this.#state = signal({}, /* @ts-ignore */
|
|
401
|
+
this.#ready = signal(false, /* @ts-ignore */
|
|
402
|
+
...(ngDevMode ? [{ debugName: "#ready" }] : /* istanbul ignore next */ []));
|
|
403
|
+
this.#state = signal(null, /* @ts-ignore */
|
|
346
404
|
...(ngDevMode ? [{ debugName: "#state" }] : /* istanbul ignore next */ []));
|
|
405
|
+
this.#editor = null;
|
|
347
406
|
this.blur$ = new Subject();
|
|
348
407
|
this.create$ = new Subject();
|
|
349
408
|
this.focus$ = new Subject();
|
|
350
|
-
this.fontSizes = signal(ImmutableSet.create(
|
|
351
|
-
"10px",
|
|
352
|
-
"12px",
|
|
353
|
-
"14px",
|
|
354
|
-
"16px",
|
|
355
|
-
"18px",
|
|
356
|
-
"20px",
|
|
357
|
-
"24px",
|
|
358
|
-
"32px",
|
|
359
|
-
"36px",
|
|
360
|
-
"48px",
|
|
361
|
-
"60px",
|
|
362
|
-
"72px"
|
|
363
|
-
]), /* @ts-ignore */
|
|
409
|
+
this.fontSizes = signal(ImmutableSet.create(DEFAULT_FONT_SIZES), /* @ts-ignore */
|
|
364
410
|
...(ngDevMode ? [{ debugName: "fontSizes" }] : /* istanbul ignore next */ []));
|
|
365
|
-
this.fonts = signal(ImmutableSet.create(
|
|
366
|
-
"Arial",
|
|
367
|
-
"Comic Sans MS",
|
|
368
|
-
"Courier New",
|
|
369
|
-
"Georgia",
|
|
370
|
-
"Impact",
|
|
371
|
-
"Lucida Console",
|
|
372
|
-
"Lucida Sans Unicode",
|
|
373
|
-
"Palatino Linotype",
|
|
374
|
-
"Tahoma",
|
|
375
|
-
"Times New Roman",
|
|
376
|
-
"Trebuchet MS",
|
|
377
|
-
"Verdana"
|
|
378
|
-
]), /* @ts-ignore */
|
|
411
|
+
this.fonts = signal(ImmutableSet.create(DEFAULT_FONTS), /* @ts-ignore */
|
|
379
412
|
...(ngDevMode ? [{ debugName: "fonts" }] : /* istanbul ignore next */ []));
|
|
380
|
-
|
|
413
|
+
/**
|
|
414
|
+
* True while the document has no content; false before the editor exists too, so nothing shows over it.
|
|
415
|
+
*/
|
|
416
|
+
this.isEmpty = computed(() => {
|
|
417
|
+
this.#state();
|
|
418
|
+
return this.#editor?.isEmpty ?? false;
|
|
419
|
+
}, /* @ts-ignore */
|
|
420
|
+
...(ngDevMode ? [{ debugName: "isEmpty" }] : /* istanbul ignore next */ []));
|
|
421
|
+
/**
|
|
422
|
+
* True while an editor exists. The toolbar renders only then, so its components can use {@link editor}.
|
|
423
|
+
*/
|
|
424
|
+
this.ready = this.#ready.asReadonly();
|
|
381
425
|
this.selectionUpdate$ = new Subject();
|
|
426
|
+
/**
|
|
427
|
+
* The resolved settings of the current editor. Set before the editor is created, so the toolbar never renders a
|
|
428
|
+
* feature the editor doesn't have.
|
|
429
|
+
*/
|
|
382
430
|
this.settings = signal({}, /* @ts-ignore */
|
|
383
431
|
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
432
|
+
this.state = this.#state.asReadonly();
|
|
384
433
|
this.update$ = new Subject();
|
|
385
434
|
}
|
|
386
|
-
#
|
|
387
|
-
#defaultSettings;
|
|
435
|
+
#ready;
|
|
388
436
|
#state;
|
|
389
437
|
#editor;
|
|
390
438
|
destroy() {
|
|
391
|
-
this.#editor
|
|
439
|
+
this.#editor?.destroy();
|
|
440
|
+
this.#editor = null;
|
|
441
|
+
this.#ready.set(false);
|
|
442
|
+
this.blur$.complete();
|
|
443
|
+
this.create$.complete();
|
|
444
|
+
this.focus$.complete();
|
|
445
|
+
this.selectionUpdate$.complete();
|
|
446
|
+
this.update$.complete();
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Replaces the document without emitting an update, as for a value set from outside.
|
|
450
|
+
*/
|
|
451
|
+
setContent(content) {
|
|
452
|
+
this.#editor?.commands.setContent(toDocumentContent(content), { emitUpdate: false });
|
|
392
453
|
}
|
|
393
|
-
|
|
394
|
-
if (this.#editor) {
|
|
395
|
-
|
|
454
|
+
setEditable(editable, attributes) {
|
|
455
|
+
if (!this.#editor) {
|
|
456
|
+
return;
|
|
396
457
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
this.fonts.set(ImmutableSet.create(editorSettings.fontList));
|
|
458
|
+
if (this.#editor.isEditable !== editable) {
|
|
459
|
+
this.#editor.setEditable(editable, false);
|
|
400
460
|
}
|
|
401
|
-
this.#editor
|
|
461
|
+
this.#editor.setOptions({ editorProps: { attributes } });
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Creates the editor, or rebuilds it for new settings. A rebuilt editor keeps its document: it is carried over as
|
|
465
|
+
* HTML, so content that a removed feature can't hold falls back to plain text instead of being lost.
|
|
466
|
+
*/
|
|
467
|
+
setupEditor(element, settings, options) {
|
|
468
|
+
const content = this.#editor ? this.#editor.getHTML() : toDocumentContent(options.content);
|
|
469
|
+
this.#editor?.destroy();
|
|
470
|
+
this.#editor = null;
|
|
471
|
+
const editorSettings = { ...DEFAULT_SETTINGS, ...settings };
|
|
472
|
+
const fontList = editorSettings.fontList;
|
|
473
|
+
const fontSizeList = editorSettings.fontSizeList;
|
|
474
|
+
this.fonts.set(ImmutableSet.create(any(fontList) ? fontList : DEFAULT_FONTS));
|
|
475
|
+
this.fontSizes.set(ImmutableSet.create(any(fontSizeList) ? fontSizeList : DEFAULT_FONT_SIZES));
|
|
476
|
+
this.settings.set(editorSettings);
|
|
477
|
+
const editor = new Editor({
|
|
478
|
+
content,
|
|
479
|
+
editable: options.editable,
|
|
480
|
+
editorProps: { attributes: options.attributes },
|
|
402
481
|
element,
|
|
403
|
-
extensions: this
|
|
404
|
-
content: ``,
|
|
482
|
+
extensions: this.#getExtensions(editorSettings),
|
|
405
483
|
onBlur: () => this.blur$.next(),
|
|
406
|
-
onCreate: (
|
|
407
|
-
this.#state.set(editor.state);
|
|
408
|
-
this.settings.set(editorSettings);
|
|
409
|
-
this.create$.next();
|
|
410
|
-
},
|
|
484
|
+
onCreate: () => this.create$.next(),
|
|
411
485
|
onFocus: () => this.focus$.next(),
|
|
412
486
|
onSelectionUpdate: () => this.selectionUpdate$.next(),
|
|
413
|
-
onTransaction:
|
|
487
|
+
onTransaction: ({ editor: transactionEditor }) => this.#state.set(transactionEditor.state),
|
|
414
488
|
onUpdate: () => this.update$.next()
|
|
415
489
|
});
|
|
490
|
+
this.#editor = editor;
|
|
491
|
+
this.#state.set(editor.state);
|
|
492
|
+
this.#ready.set(true);
|
|
416
493
|
}
|
|
494
|
+
/**
|
|
495
|
+
* The Tiptap editor. Available while {@link ready} is true.
|
|
496
|
+
*/
|
|
417
497
|
get editor() {
|
|
498
|
+
if (!this.#editor) {
|
|
499
|
+
throw new Error("The editor has not been created yet.");
|
|
500
|
+
}
|
|
418
501
|
return this.#editor;
|
|
419
502
|
}
|
|
420
|
-
|
|
503
|
+
#getExtensions(settings) {
|
|
421
504
|
const extensions = new List();
|
|
422
505
|
extensions.add(TextStyle);
|
|
423
|
-
|
|
424
|
-
extensions.add(customizedStarterKit);
|
|
506
|
+
extensions.add(StarterKit.configure(this.#getStarterKitOptions(settings)));
|
|
425
507
|
if (settings.alignment) {
|
|
426
508
|
extensions.add(TextAlign.configure({
|
|
509
|
+
// start and end follow the text direction; left and right are kept so older HTML keeps its
|
|
510
|
+
// alignment.
|
|
511
|
+
alignments: ["start", "center", "end", "justify", "left", "right"],
|
|
427
512
|
types: ["paragraph", "heading"]
|
|
428
513
|
}));
|
|
429
514
|
}
|
|
@@ -445,21 +530,12 @@ class EditorService {
|
|
|
445
530
|
if (settings.indent) {
|
|
446
531
|
extensions.add(Indent);
|
|
447
532
|
}
|
|
448
|
-
if (settings.link) {
|
|
449
|
-
extensions.add(Link.configure({
|
|
450
|
-
openOnClick: "whenNotEditable",
|
|
451
|
-
autolink: true
|
|
452
|
-
}));
|
|
453
|
-
}
|
|
454
533
|
if (settings.subscript) {
|
|
455
534
|
extensions.add(Subscript);
|
|
456
535
|
}
|
|
457
536
|
if (settings.superscript) {
|
|
458
537
|
extensions.add(Superscript);
|
|
459
538
|
}
|
|
460
|
-
if (settings.underline) {
|
|
461
|
-
extensions.add(Underline);
|
|
462
|
-
}
|
|
463
539
|
if (settings.table) {
|
|
464
540
|
extensions.add(Table.configure({
|
|
465
541
|
resizable: true
|
|
@@ -476,36 +552,48 @@ class EditorService {
|
|
|
476
552
|
}
|
|
477
553
|
return extensions.toArray();
|
|
478
554
|
}
|
|
479
|
-
|
|
480
|
-
|
|
555
|
+
/**
|
|
556
|
+
* StarterKit 3 includes Link and Underline, so they are configured here rather than registered a second time.
|
|
557
|
+
*/
|
|
558
|
+
#getStarterKitOptions(settings) {
|
|
559
|
+
const options = {
|
|
560
|
+
link: settings.link ? { autolink: true, openOnClick: "whenNotEditable" } : false
|
|
561
|
+
};
|
|
562
|
+
if (!settings.blockquote) {
|
|
563
|
+
options.blockquote = false;
|
|
564
|
+
}
|
|
481
565
|
if (!settings.bold) {
|
|
482
|
-
|
|
566
|
+
options.bold = false;
|
|
483
567
|
}
|
|
484
|
-
if (!settings.
|
|
485
|
-
|
|
568
|
+
if (!settings.code) {
|
|
569
|
+
options.code = false;
|
|
570
|
+
options.codeBlock = false;
|
|
486
571
|
}
|
|
487
|
-
if (!settings.
|
|
488
|
-
|
|
572
|
+
if (!settings.headings) {
|
|
573
|
+
options.heading = false;
|
|
489
574
|
}
|
|
490
575
|
if (!settings.history) {
|
|
491
|
-
|
|
576
|
+
options.undoRedo = false;
|
|
492
577
|
}
|
|
493
|
-
if (!settings.
|
|
494
|
-
|
|
578
|
+
if (!settings.horizontalRule) {
|
|
579
|
+
options.horizontalRule = false;
|
|
495
580
|
}
|
|
496
|
-
if (!settings.
|
|
497
|
-
|
|
581
|
+
if (!settings.italic) {
|
|
582
|
+
options.italic = false;
|
|
498
583
|
}
|
|
499
|
-
if (!settings.
|
|
500
|
-
|
|
584
|
+
if (!settings.list) {
|
|
585
|
+
options.bulletList = false;
|
|
586
|
+
options.listItem = false;
|
|
587
|
+
options.listKeymap = false;
|
|
588
|
+
options.orderedList = false;
|
|
501
589
|
}
|
|
502
|
-
if (!settings.
|
|
503
|
-
|
|
590
|
+
if (!settings.strikethrough) {
|
|
591
|
+
options.strike = false;
|
|
504
592
|
}
|
|
505
|
-
if (!settings.
|
|
506
|
-
|
|
593
|
+
if (!settings.underline) {
|
|
594
|
+
options.underline = false;
|
|
507
595
|
}
|
|
508
|
-
return
|
|
596
|
+
return options;
|
|
509
597
|
}
|
|
510
598
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
511
599
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorService }); }
|
|
@@ -522,11 +610,20 @@ const editorBaseThemeVariants = cva(`
|
|
|
522
610
|
focus-within:border-focus-indicator
|
|
523
611
|
focus-within:ring-2 focus-within:ring-focus-indicator/35
|
|
524
612
|
|
|
613
|
+
data-[disabled='true']:cursor-not-allowed
|
|
614
|
+
data-[disabled='true']:border-disabled-border
|
|
615
|
+
data-[disabled='true']:text-disabled-foreground
|
|
616
|
+
data-[invalid='true']:border-error
|
|
617
|
+
data-[invalid='true']:ring-2 data-[invalid='true']:ring-error/35
|
|
618
|
+
data-[invalid='true']:focus-within:border-error
|
|
619
|
+
data-[invalid='true']:focus-within:ring-error/35
|
|
620
|
+
|
|
525
621
|
prose prose-neutral max-w-none
|
|
526
622
|
prose-headings:text-foreground prose-headings:font-bold
|
|
527
623
|
prose-headings:mt-1 prose-headings:mb-1
|
|
528
624
|
prose-p:text-foreground prose-p:my-1
|
|
529
|
-
prose-strong:text-
|
|
625
|
+
prose-strong:text-inherit
|
|
626
|
+
[&_span[style*=color]_mark]:text-inherit
|
|
530
627
|
prose-a:text-primary
|
|
531
628
|
|
|
532
629
|
[&_ol]:ps-8 [&_ul]:ps-8
|
|
@@ -596,17 +693,27 @@ const editorBaseThemeVariants = cva(`
|
|
|
596
693
|
`);
|
|
597
694
|
const editorContainerThemeVariants = cva(`
|
|
598
695
|
h-full w-full bg-surface
|
|
599
|
-
[
|
|
600
|
-
[
|
|
601
|
-
[
|
|
602
|
-
[
|
|
603
|
-
[
|
|
604
|
-
[
|
|
605
|
-
[
|
|
606
|
-
[
|
|
607
|
-
[
|
|
608
|
-
[
|
|
609
|
-
|
|
696
|
+
[&>.ProseMirror]:p-1.5
|
|
697
|
+
[&>.ProseMirror]:text-foreground
|
|
698
|
+
[&>.ProseMirror]:border-none
|
|
699
|
+
[&>.ProseMirror]:outline-none
|
|
700
|
+
[&>.ProseMirror]:w-full
|
|
701
|
+
[&>.ProseMirror]:h-full
|
|
702
|
+
[&>.ProseMirror]:overflow-auto
|
|
703
|
+
[&>.ProseMirror]:resize-none
|
|
704
|
+
[&>.ProseMirror]:[scrollbar-color:var(--color-scrollbar-thumb)_var(--color-scrollbar-track)]
|
|
705
|
+
[&>.ProseMirror]:[scrollbar-width:thin]
|
|
706
|
+
`, {
|
|
707
|
+
variants: {
|
|
708
|
+
disabled: {
|
|
709
|
+
true: "bg-disabled-background [&>.ProseMirror]:text-disabled-foreground",
|
|
710
|
+
false: ""
|
|
711
|
+
}
|
|
712
|
+
},
|
|
713
|
+
defaultVariants: {
|
|
714
|
+
disabled: false
|
|
715
|
+
}
|
|
716
|
+
});
|
|
610
717
|
const editorFontColorPreviewThemeVariants = cva(`
|
|
611
718
|
w-full flex h-[2px]
|
|
612
719
|
`);
|
|
@@ -644,22 +751,61 @@ const editorImageInserterRowLabelThemeVariants = cva(`
|
|
|
644
751
|
const editorImageInserterRowThemeVariants = cva(`
|
|
645
752
|
flex flex-col justify-center px-2
|
|
646
753
|
`);
|
|
754
|
+
const editorPlaceholderThemeVariants = cva(`
|
|
755
|
+
pointer-events-none absolute top-0 start-0 px-1.5 py-2.5
|
|
756
|
+
text-muted-foreground select-none
|
|
757
|
+
`);
|
|
647
758
|
const editorTableCreatorThemeVariants = cva(`
|
|
648
759
|
grid grid-cols-8 gap-0.5 p-1
|
|
649
760
|
`);
|
|
650
761
|
const editorTableCreatorCellThemeVariants = cva(`
|
|
651
|
-
flex h-6 w-6
|
|
652
|
-
bg-
|
|
762
|
+
flex h-6 w-6 p-0 cursor-pointer
|
|
763
|
+
bg-surface-muted border border-input-border
|
|
764
|
+
data-[highlighted]:bg-primary data-[highlighted]:border-primary
|
|
765
|
+
focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-focus-indicator
|
|
653
766
|
`);
|
|
654
767
|
const editorToolbarThemeVariants = cva(`
|
|
655
768
|
flex flex-wrap items-center justify-start gap-1 p-1
|
|
656
769
|
bg-surface-muted text-foreground border-b border-b-border-subtle
|
|
657
|
-
|
|
770
|
+
`, {
|
|
771
|
+
variants: {
|
|
772
|
+
disabled: {
|
|
773
|
+
true: "opacity-50",
|
|
774
|
+
false: ""
|
|
775
|
+
}
|
|
776
|
+
},
|
|
777
|
+
defaultVariants: {
|
|
778
|
+
disabled: false
|
|
779
|
+
}
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* @internal Sets `aria-pressed` on a toolbar toggle from the editor's state. The button stays `[toggleable]="false"`,
|
|
784
|
+
* so a click never flips it on its own when the command does nothing. It is written after render, because the
|
|
785
|
+
* button's own host binding clears `aria-pressed` on its first render.
|
|
786
|
+
*/
|
|
787
|
+
class EditorPressedDirective {
|
|
788
|
+
#host;
|
|
789
|
+
constructor() {
|
|
790
|
+
this.#host = inject(ElementRef);
|
|
791
|
+
this.pressed = input.required({ ...(ngDevMode ? { debugName: "pressed" } : /* istanbul ignore next */ {}), alias: "monaEditorPressed" });
|
|
792
|
+
afterRenderEffect({
|
|
793
|
+
write: () => this.#host.nativeElement.setAttribute("aria-pressed", this.pressed() ? "true" : "false")
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorPressedDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
797
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: EditorPressedDirective, isStandalone: true, selector: "button[monaEditorPressed]", inputs: { pressed: { classPropertyName: "pressed", publicName: "monaEditorPressed", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 }); }
|
|
798
|
+
}
|
|
799
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorPressedDirective, decorators: [{
|
|
800
|
+
type: Directive,
|
|
801
|
+
args: [{
|
|
802
|
+
selector: "button[monaEditorPressed]"
|
|
803
|
+
}]
|
|
804
|
+
}], ctorParameters: () => [], propDecorators: { pressed: [{ type: i0.Input, args: [{ isSignal: true, alias: "monaEditorPressed", required: true }] }] } });
|
|
658
805
|
|
|
659
806
|
class EditorBasicTextStylesComponent {
|
|
660
807
|
constructor() {
|
|
661
808
|
this.#i18n = inject(MonaI18nService);
|
|
662
|
-
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
663
809
|
this.anyToolVisible = computed(() => {
|
|
664
810
|
return (this.boldVisible() ||
|
|
665
811
|
this.italicVisible() ||
|
|
@@ -688,6 +834,7 @@ class EditorBasicTextStylesComponent {
|
|
|
688
834
|
return this.editorService.settings().italic;
|
|
689
835
|
}, /* @ts-ignore */
|
|
690
836
|
...(ngDevMode ? [{ debugName: "italicVisible" }] : /* istanbul ignore next */ []));
|
|
837
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
691
838
|
this.strikeThroughSelected = computed(() => {
|
|
692
839
|
this.editorService.state();
|
|
693
840
|
return this.editorService.editor.isActive("strike");
|
|
@@ -775,23 +922,23 @@ class EditorBasicTextStylesComponent {
|
|
|
775
922
|
}
|
|
776
923
|
}
|
|
777
924
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorBasicTextStylesComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
778
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: EditorBasicTextStylesComponent, isStandalone: true, selector: "mona-editor-basic-text-styles", ngImport: i0, template: "@if (anyToolVisible()) {\n <mona-button-group selection=\"multiple\" [size]=\"'small'\">\n @if (boldVisible()) {\n <button\n monaButton\n [selected]=\"boldSelected()\"\n [toggleable]=\"false\"\n (click)=\"onBoldToggle()\"\n [title]=\"messages().bold\">\n <i class=\"ri-bold\"></i>\n </button>\n }\n @if (italicVisible()) {\n <button\n monaButton\n [selected]=\"italicSelected()\"\n [toggleable]=\"false\"\n (click)=\"onItalicToggle()\"\n [title]=\"messages().italic\">\n <i class=\"ri-italic\"></i>\n </button>\n }\n @if (underlineVisible()) {\n <button\n monaButton\n [selected]=\"underlineSelected()\"\n [toggleable]=\"false\"\n (click)=\"onUnderlineToggle()\"\n [title]=\"messages().underline\">\n <i class=\"ri-underline\"></i>\n </button>\n }\n @if (strikeThroughVisible()) {\n <button\n monaButton\n [selected]=\"strikeThroughSelected()\"\n [toggleable]=\"false\"\n (click)=\"onStrikeThroughToggle()\"\n [title]=\"messages().strikethrough\">\n <i class=\"ri-strikethrough\"></i>\n </button>\n }\n @if (subscriptVisible()) {\n <button\n monaButton\n [selected]=\"subscriptSelected()\"\n [toggleable]=\"false\"\n (click)=\"onSubscriptToggle()\"\n [title]=\"messages().subscript\">\n <i class=\"ri-subscript\"></i>\n </button>\n }\n @if (superscriptVisible()) {\n <button\n monaButton\n [selected]=\"superscriptSelected()\"\n [toggleable]=\"false\"\n (click)=\"onSuperscriptToggle()\"\n [title]=\"messages().superscript\">\n <i class=\"ri-superscript\"></i>\n </button>\n }\n </mona-button-group>\n}\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }, { kind: "component", type: ButtonGroupComponent, selector: "mona-button-group", inputs: ["allowEmpty", "aria-label", "disabled", "look", "rounded", "selection", "size", "class"], outputs: ["buttonClick", "disabledChange", "selectionChange"] }] }); }
|
|
925
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: EditorBasicTextStylesComponent, isStandalone: true, selector: "mona-editor-basic-text-styles", ngImport: i0, template: "@if (anyToolVisible()) {\n <mona-button-group selection=\"multiple\" [size]=\"'small'\" [aria-label]=\"messages().textStyleGroup\">\n @if (boldVisible()) {\n <button\n monaButton\n [selected]=\"boldSelected()\"\n [monaEditorPressed]=\"boldSelected()\"\n [toggleable]=\"false\"\n (click)=\"onBoldToggle()\"\n [title]=\"messages().bold\">\n <i class=\"ri-bold\"></i>\n </button>\n }\n @if (italicVisible()) {\n <button\n monaButton\n [selected]=\"italicSelected()\"\n [monaEditorPressed]=\"italicSelected()\"\n [toggleable]=\"false\"\n (click)=\"onItalicToggle()\"\n [title]=\"messages().italic\">\n <i class=\"ri-italic\"></i>\n </button>\n }\n @if (underlineVisible()) {\n <button\n monaButton\n [selected]=\"underlineSelected()\"\n [monaEditorPressed]=\"underlineSelected()\"\n [toggleable]=\"false\"\n (click)=\"onUnderlineToggle()\"\n [title]=\"messages().underline\">\n <i class=\"ri-underline\"></i>\n </button>\n }\n @if (strikeThroughVisible()) {\n <button\n monaButton\n [selected]=\"strikeThroughSelected()\"\n [monaEditorPressed]=\"strikeThroughSelected()\"\n [toggleable]=\"false\"\n (click)=\"onStrikeThroughToggle()\"\n [title]=\"messages().strikethrough\">\n <i class=\"ri-strikethrough\"></i>\n </button>\n }\n @if (subscriptVisible()) {\n <button\n monaButton\n [selected]=\"subscriptSelected()\"\n [monaEditorPressed]=\"subscriptSelected()\"\n [toggleable]=\"false\"\n (click)=\"onSubscriptToggle()\"\n [title]=\"messages().subscript\">\n <i class=\"ri-subscript\"></i>\n </button>\n }\n @if (superscriptVisible()) {\n <button\n monaButton\n [selected]=\"superscriptSelected()\"\n [monaEditorPressed]=\"superscriptSelected()\"\n [toggleable]=\"false\"\n (click)=\"onSuperscriptToggle()\"\n [title]=\"messages().superscript\">\n <i class=\"ri-superscript\"></i>\n </button>\n }\n </mona-button-group>\n}\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }, { kind: "component", type: ButtonGroupComponent, selector: "mona-button-group", inputs: ["allowEmpty", "aria-label", "disabled", "look", "rounded", "selection", "size", "class"], outputs: ["buttonClick", "disabledChange", "selectionChange"] }, { kind: "directive", type: EditorPressedDirective, selector: "button[monaEditorPressed]", inputs: ["monaEditorPressed"] }] }); }
|
|
779
926
|
}
|
|
780
927
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorBasicTextStylesComponent, decorators: [{
|
|
781
928
|
type: Component,
|
|
782
|
-
args: [{ selector: "mona-editor-basic-text-styles", imports: [ButtonDirective, ButtonGroupComponent], template: "@if (anyToolVisible()) {\n <mona-button-group selection=\"multiple\" [size]=\"'small'\">\n @if (boldVisible()) {\n <button\n monaButton\n [selected]=\"boldSelected()\"\n [toggleable]=\"false\"\n (click)=\"onBoldToggle()\"\n [title]=\"messages().bold\">\n <i class=\"ri-bold\"></i>\n </button>\n }\n @if (italicVisible()) {\n <button\n monaButton\n [selected]=\"italicSelected()\"\n [toggleable]=\"false\"\n (click)=\"onItalicToggle()\"\n [title]=\"messages().italic\">\n <i class=\"ri-italic\"></i>\n </button>\n }\n @if (underlineVisible()) {\n <button\n monaButton\n [selected]=\"underlineSelected()\"\n [toggleable]=\"false\"\n (click)=\"onUnderlineToggle()\"\n [title]=\"messages().underline\">\n <i class=\"ri-underline\"></i>\n </button>\n }\n @if (strikeThroughVisible()) {\n <button\n monaButton\n [selected]=\"strikeThroughSelected()\"\n [toggleable]=\"false\"\n (click)=\"onStrikeThroughToggle()\"\n [title]=\"messages().strikethrough\">\n <i class=\"ri-strikethrough\"></i>\n </button>\n }\n @if (subscriptVisible()) {\n <button\n monaButton\n [selected]=\"subscriptSelected()\"\n [toggleable]=\"false\"\n (click)=\"onSubscriptToggle()\"\n [title]=\"messages().subscript\">\n <i class=\"ri-subscript\"></i>\n </button>\n }\n @if (superscriptVisible()) {\n <button\n monaButton\n [selected]=\"superscriptSelected()\"\n [toggleable]=\"false\"\n (click)=\"onSuperscriptToggle()\"\n [title]=\"messages().superscript\">\n <i class=\"ri-superscript\"></i>\n </button>\n }\n </mona-button-group>\n}\n" }]
|
|
929
|
+
args: [{ selector: "mona-editor-basic-text-styles", imports: [ButtonDirective, ButtonGroupComponent, EditorPressedDirective], template: "@if (anyToolVisible()) {\n <mona-button-group selection=\"multiple\" [size]=\"'small'\" [aria-label]=\"messages().textStyleGroup\">\n @if (boldVisible()) {\n <button\n monaButton\n [selected]=\"boldSelected()\"\n [monaEditorPressed]=\"boldSelected()\"\n [toggleable]=\"false\"\n (click)=\"onBoldToggle()\"\n [title]=\"messages().bold\">\n <i class=\"ri-bold\"></i>\n </button>\n }\n @if (italicVisible()) {\n <button\n monaButton\n [selected]=\"italicSelected()\"\n [monaEditorPressed]=\"italicSelected()\"\n [toggleable]=\"false\"\n (click)=\"onItalicToggle()\"\n [title]=\"messages().italic\">\n <i class=\"ri-italic\"></i>\n </button>\n }\n @if (underlineVisible()) {\n <button\n monaButton\n [selected]=\"underlineSelected()\"\n [monaEditorPressed]=\"underlineSelected()\"\n [toggleable]=\"false\"\n (click)=\"onUnderlineToggle()\"\n [title]=\"messages().underline\">\n <i class=\"ri-underline\"></i>\n </button>\n }\n @if (strikeThroughVisible()) {\n <button\n monaButton\n [selected]=\"strikeThroughSelected()\"\n [monaEditorPressed]=\"strikeThroughSelected()\"\n [toggleable]=\"false\"\n (click)=\"onStrikeThroughToggle()\"\n [title]=\"messages().strikethrough\">\n <i class=\"ri-strikethrough\"></i>\n </button>\n }\n @if (subscriptVisible()) {\n <button\n monaButton\n [selected]=\"subscriptSelected()\"\n [monaEditorPressed]=\"subscriptSelected()\"\n [toggleable]=\"false\"\n (click)=\"onSubscriptToggle()\"\n [title]=\"messages().subscript\">\n <i class=\"ri-subscript\"></i>\n </button>\n }\n @if (superscriptVisible()) {\n <button\n monaButton\n [selected]=\"superscriptSelected()\"\n [monaEditorPressed]=\"superscriptSelected()\"\n [toggleable]=\"false\"\n (click)=\"onSuperscriptToggle()\"\n [title]=\"messages().superscript\">\n <i class=\"ri-superscript\"></i>\n </button>\n }\n </mona-button-group>\n}\n" }]
|
|
783
930
|
}] });
|
|
784
931
|
|
|
785
932
|
class EditorBlockquoteComponent {
|
|
786
933
|
constructor() {
|
|
787
934
|
this.#editorService = inject(EditorService);
|
|
788
935
|
this.#i18n = inject(MonaI18nService);
|
|
789
|
-
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
790
936
|
this.blockquoteSelected = computed(() => {
|
|
791
937
|
this.#editorService.state();
|
|
792
938
|
return this.#editorService.editor.isActive("blockquote");
|
|
793
939
|
}, /* @ts-ignore */
|
|
794
940
|
...(ngDevMode ? [{ debugName: "blockquoteSelected" }] : /* istanbul ignore next */ []));
|
|
941
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
795
942
|
}
|
|
796
943
|
#editorService;
|
|
797
944
|
#i18n;
|
|
@@ -804,54 +951,87 @@ class EditorBlockquoteComponent {
|
|
|
804
951
|
}
|
|
805
952
|
}
|
|
806
953
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorBlockquoteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
807
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorBlockquoteComponent, isStandalone: true, selector: "mona-editor-blockquote", ngImport: i0, template: "<button monaButton [size]=\"'small'\" [selected]=\"blockquoteSelected()\" (click)=\"onBlockquoteToggle()\" [title]=\"messages().quotation\">\n <i class=\"ri-double-quotes-r\"></i>\n</button>\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }] }); }
|
|
954
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorBlockquoteComponent, isStandalone: true, selector: "mona-editor-blockquote", ngImport: i0, template: "<button monaButton [size]=\"'small'\" [selected]=\"blockquoteSelected()\" [monaEditorPressed]=\"blockquoteSelected()\" (click)=\"onBlockquoteToggle()\" [title]=\"messages().quotation\">\n <i class=\"ri-double-quotes-r\"></i>\n</button>\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }, { kind: "directive", type: EditorPressedDirective, selector: "button[monaEditorPressed]", inputs: ["monaEditorPressed"] }] }); }
|
|
808
955
|
}
|
|
809
956
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorBlockquoteComponent, decorators: [{
|
|
810
957
|
type: Component,
|
|
811
|
-
args: [{ selector: "mona-editor-blockquote", imports: [ButtonDirective], template: "<button monaButton [size]=\"'small'\" [selected]=\"blockquoteSelected()\" (click)=\"onBlockquoteToggle()\" [title]=\"messages().quotation\">\n <i class=\"ri-double-quotes-r\"></i>\n</button>\n" }]
|
|
958
|
+
args: [{ selector: "mona-editor-blockquote", imports: [ButtonDirective, EditorPressedDirective], template: "<button monaButton [size]=\"'small'\" [selected]=\"blockquoteSelected()\" [monaEditorPressed]=\"blockquoteSelected()\" (click)=\"onBlockquoteToggle()\" [title]=\"messages().quotation\">\n <i class=\"ri-double-quotes-r\"></i>\n</button>\n" }]
|
|
812
959
|
}] });
|
|
813
960
|
|
|
814
961
|
class EditorCodeBlockComponent {
|
|
815
962
|
constructor() {
|
|
816
963
|
this.#editorService = inject(EditorService);
|
|
817
964
|
this.#i18n = inject(MonaI18nService);
|
|
818
|
-
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
819
965
|
this.codeBlockSelected = computed(() => {
|
|
820
966
|
this.#editorService.state();
|
|
821
967
|
return this.#editorService.editor.isActive("codeBlock");
|
|
822
968
|
}, /* @ts-ignore */
|
|
823
969
|
...(ngDevMode ? [{ debugName: "codeBlockSelected" }] : /* istanbul ignore next */ []));
|
|
970
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
824
971
|
}
|
|
825
972
|
#editorService;
|
|
826
973
|
#i18n;
|
|
827
974
|
onCodeBlockClick() {
|
|
828
|
-
this.#editorService.editor.chain().toggleCodeBlock().run();
|
|
975
|
+
this.#editorService.editor.chain().focus().toggleCodeBlock().run();
|
|
829
976
|
}
|
|
830
977
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorCodeBlockComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
831
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorCodeBlockComponent, isStandalone: true, selector: "mona-editor-code-block", ngImport: i0, template: "<button monaButton [size]=\"'small'\" [selected]=\"codeBlockSelected()\" (click)=\"onCodeBlockClick()\" [title]=\"messages().codeBlock\">\n <i class=\"ri-code-s-slash-line\"></i>\n</button>\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }] }); }
|
|
978
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorCodeBlockComponent, isStandalone: true, selector: "mona-editor-code-block", ngImport: i0, template: "<button monaButton [size]=\"'small'\" [selected]=\"codeBlockSelected()\" [monaEditorPressed]=\"codeBlockSelected()\" (click)=\"onCodeBlockClick()\" [title]=\"messages().codeBlock\">\n <i class=\"ri-code-s-slash-line\"></i>\n</button>\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }, { kind: "directive", type: EditorPressedDirective, selector: "button[monaEditorPressed]", inputs: ["monaEditorPressed"] }] }); }
|
|
832
979
|
}
|
|
833
980
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorCodeBlockComponent, decorators: [{
|
|
834
981
|
type: Component,
|
|
835
|
-
args: [{ selector: "mona-editor-code-block", imports: [ButtonDirective], template: "<button monaButton [size]=\"'small'\" [selected]=\"codeBlockSelected()\" (click)=\"onCodeBlockClick()\" [title]=\"messages().codeBlock\">\n <i class=\"ri-code-s-slash-line\"></i>\n</button>\n" }]
|
|
982
|
+
args: [{ selector: "mona-editor-code-block", imports: [ButtonDirective, EditorPressedDirective], template: "<button monaButton [size]=\"'small'\" [selected]=\"codeBlockSelected()\" [monaEditorPressed]=\"codeBlockSelected()\" (click)=\"onCodeBlockClick()\" [title]=\"messages().codeBlock\">\n <i class=\"ri-code-s-slash-line\"></i>\n</button>\n" }]
|
|
836
983
|
}] });
|
|
837
984
|
|
|
985
|
+
const CONTEXTS = new WeakMap();
|
|
986
|
+
/**
|
|
987
|
+
* Converts any CSS color to the form a canvas reports (`#rrggbb`, or `rgba(…)` with transparency). One canvas per
|
|
988
|
+
* document is kept for it, since the toolbar asks on every selection change.
|
|
989
|
+
*/
|
|
838
990
|
const htmlColorCode = (name, document) => {
|
|
839
|
-
|
|
840
|
-
|
|
991
|
+
let context = CONTEXTS.get(document);
|
|
992
|
+
if (context === undefined) {
|
|
993
|
+
context = document.createElement("canvas").getContext("2d");
|
|
994
|
+
CONTEXTS.set(document, context);
|
|
995
|
+
}
|
|
841
996
|
if (!context) {
|
|
842
997
|
return "";
|
|
843
998
|
}
|
|
999
|
+
// Reset first, so a color the canvas can't read doesn't report the previous one.
|
|
1000
|
+
context.fillStyle = "#000000";
|
|
844
1001
|
context.fillStyle = name;
|
|
845
1002
|
return context.fillStyle;
|
|
846
1003
|
};
|
|
847
1004
|
|
|
1005
|
+
/**
|
|
1006
|
+
* Reads an attribute of a mark across the selection. It returns the value only when all the selected text shares it,
|
|
1007
|
+
* and `null` when any of it lacks the mark or has another value, so that a color picker has something to change.
|
|
1008
|
+
* With only a cursor, it reads the marks the next typed text would get.
|
|
1009
|
+
*/
|
|
1010
|
+
const selectionMarkAttribute = (state, markName, attribute) => {
|
|
1011
|
+
const read = (marks) => {
|
|
1012
|
+
const value = marks.find(mark => mark.type.name === markName)?.attrs[attribute];
|
|
1013
|
+
return typeof value === "string" && value ? value : null;
|
|
1014
|
+
};
|
|
1015
|
+
if (state.selection.empty) {
|
|
1016
|
+
return read(state.storedMarks ?? state.selection.$from.marks());
|
|
1017
|
+
}
|
|
1018
|
+
let common;
|
|
1019
|
+
for (const { $from, $to } of state.selection.ranges) {
|
|
1020
|
+
state.doc.nodesBetween($from.pos, $to.pos, node => {
|
|
1021
|
+
if (node.isText) {
|
|
1022
|
+
const value = read(node.marks);
|
|
1023
|
+
common = common === undefined || common === value ? value : null;
|
|
1024
|
+
}
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
return common ?? null;
|
|
1028
|
+
};
|
|
1029
|
+
|
|
848
1030
|
class EditorFontColorComponent {
|
|
849
1031
|
constructor() {
|
|
850
1032
|
this.#document = inject(DOCUMENT);
|
|
851
1033
|
this.#editorService = inject(EditorService);
|
|
852
1034
|
this.#i18n = inject(MonaI18nService);
|
|
853
|
-
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
854
|
-
this.#lastColor = "";
|
|
855
1035
|
this.colorPreviewClass = computed(() => {
|
|
856
1036
|
return editorFontColorPreviewThemeVariants();
|
|
857
1037
|
}, /* @ts-ignore */
|
|
@@ -860,44 +1040,42 @@ class EditorFontColorComponent {
|
|
|
860
1040
|
return editorFontColorValueThemeVariants();
|
|
861
1041
|
}, /* @ts-ignore */
|
|
862
1042
|
...(ngDevMode ? [{ debugName: "colorValueClass" }] : /* istanbul ignore next */ []));
|
|
1043
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
863
1044
|
this.selectedColor = computed(() => {
|
|
864
|
-
this.#editorService.state();
|
|
865
|
-
const
|
|
866
|
-
|
|
867
|
-
return htmlColorCode(color, this.#document);
|
|
1045
|
+
const state = this.#editorService.state();
|
|
1046
|
+
const color = state ? selectionMarkAttribute(state, "textStyle", "color") : null;
|
|
1047
|
+
return color ? htmlColorCode(color, this.#document) : null;
|
|
868
1048
|
}, /* @ts-ignore */
|
|
869
1049
|
...(ngDevMode ? [{ debugName: "selectedColor" }] : /* istanbul ignore next */ []));
|
|
870
1050
|
}
|
|
871
1051
|
#document;
|
|
872
1052
|
#editorService;
|
|
873
1053
|
#i18n;
|
|
874
|
-
#lastColor;
|
|
875
1054
|
onColorChange(color) {
|
|
876
1055
|
if (color) {
|
|
877
1056
|
this.#editorService.editor.chain().focus().setColor(color).run();
|
|
878
|
-
this.#lastColor = color;
|
|
879
1057
|
}
|
|
880
1058
|
else {
|
|
881
1059
|
this.#editorService.editor.chain().focus().unsetColor().run();
|
|
882
1060
|
}
|
|
883
1061
|
}
|
|
884
1062
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorFontColorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
885
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorFontColorComponent, isStandalone: true, selector: "mona-editor-font-color", ngImport: i0, template: "<mona-color-picker\n view=\"gradient\"\n [size]=\"'small'\"\n [value]=\"selectedColor()\"\n (valueChange)=\"onColorChange($event)\"\n [title]=\"messages().color\">\n <ng-template monaColorPickerValueTemplate let-color>\n <div [class]=\"colorValueClass()\">\n <i class=\"ri-font-family\"></i>\n <span [class]=\"colorPreviewClass()\" [style.background-color]=\"color\"></span>\n </div>\n </ng-template>\n</mona-color-picker>\n", dependencies: [{ kind: "component", type: ColorPickerComponent, selector: "mona-color-picker", inputs: ["aria-label", "closeOnSelect", "columns", "disabled", "invalid", "opacity", "palette", "readonly", "required", "rounded", "showClearButton", "size", "touched", "value", "view"], outputs: ["touch", "valueChange"] }, { kind: "directive", type: ColorPickerValueTemplateDirective, selector: "ng-template[monaColorPickerValueTemplate]" }] }); }
|
|
1063
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorFontColorComponent, isStandalone: true, selector: "mona-editor-font-color", ngImport: i0, template: "<mona-color-picker\n view=\"gradient\"\n [size]=\"'small'\"\n [value]=\"selectedColor()\"\n (valueChange)=\"onColorChange($event)\"\n [aria-label]=\"messages().color\"\n [title]=\"messages().color\">\n <ng-template monaColorPickerValueTemplate let-color>\n <div [class]=\"colorValueClass()\">\n <i class=\"ri-font-family\"></i>\n <span [class]=\"colorPreviewClass()\" [style.background-color]=\"color || 'currentColor'\"></span>\n </div>\n </ng-template>\n</mona-color-picker>\n", dependencies: [{ kind: "component", type: ColorPickerComponent, selector: "mona-color-picker", inputs: ["aria-label", "closeOnSelect", "columns", "disabled", "invalid", "opacity", "palette", "readonly", "required", "rounded", "showClearButton", "size", "touched", "value", "view"], outputs: ["touch", "valueChange"] }, { kind: "directive", type: ColorPickerValueTemplateDirective, selector: "ng-template[monaColorPickerValueTemplate]" }] }); }
|
|
886
1064
|
}
|
|
887
1065
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorFontColorComponent, decorators: [{
|
|
888
1066
|
type: Component,
|
|
889
|
-
args: [{ selector: "mona-editor-font-color", imports: [ColorPickerComponent, ColorPickerValueTemplateDirective], template: "<mona-color-picker\n view=\"gradient\"\n [size]=\"'small'\"\n [value]=\"selectedColor()\"\n (valueChange)=\"onColorChange($event)\"\n [title]=\"messages().color\">\n <ng-template monaColorPickerValueTemplate let-color>\n <div [class]=\"colorValueClass()\">\n <i class=\"ri-font-family\"></i>\n <span [class]=\"colorPreviewClass()\" [style.background-color]=\"color\"></span>\n </div>\n </ng-template>\n</mona-color-picker>\n" }]
|
|
1067
|
+
args: [{ selector: "mona-editor-font-color", imports: [ColorPickerComponent, ColorPickerValueTemplateDirective], template: "<mona-color-picker\n view=\"gradient\"\n [size]=\"'small'\"\n [value]=\"selectedColor()\"\n (valueChange)=\"onColorChange($event)\"\n [aria-label]=\"messages().color\"\n [title]=\"messages().color\">\n <ng-template monaColorPickerValueTemplate let-color>\n <div [class]=\"colorValueClass()\">\n <i class=\"ri-font-family\"></i>\n <span [class]=\"colorPreviewClass()\" [style.background-color]=\"color || 'currentColor'\"></span>\n </div>\n </ng-template>\n</mona-color-picker>\n" }]
|
|
890
1068
|
}] });
|
|
891
1069
|
|
|
892
1070
|
class EditorFontFamilyComponent {
|
|
893
1071
|
constructor() {
|
|
894
1072
|
this.#i18n = inject(MonaI18nService);
|
|
895
|
-
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
896
1073
|
this.dropdownListClass = computed(() => {
|
|
897
1074
|
return editorFontFamilyDropdownListThemeVariants();
|
|
898
1075
|
}, /* @ts-ignore */
|
|
899
1076
|
...(ngDevMode ? [{ debugName: "dropdownListClass" }] : /* istanbul ignore next */ []));
|
|
900
1077
|
this.editorService = inject(EditorService);
|
|
1078
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
901
1079
|
this.selectedFontFamily = computed(() => {
|
|
902
1080
|
this.editorService.state();
|
|
903
1081
|
return (this.editorService
|
|
@@ -907,10 +1085,6 @@ class EditorFontFamilyComponent {
|
|
|
907
1085
|
...(ngDevMode ? [{ debugName: "selectedFontFamily" }] : /* istanbul ignore next */ []));
|
|
908
1086
|
}
|
|
909
1087
|
#i18n;
|
|
910
|
-
ngOnInit() {
|
|
911
|
-
const defaultFontFamily = this.editorService.fonts().first();
|
|
912
|
-
this.editorService.editor.chain().focus().setFontFamily(defaultFontFamily).run();
|
|
913
|
-
}
|
|
914
1088
|
onFontFamilyChange(fontFamily) {
|
|
915
1089
|
if (!fontFamily) {
|
|
916
1090
|
return;
|
|
@@ -918,19 +1092,17 @@ class EditorFontFamilyComponent {
|
|
|
918
1092
|
this.editorService.editor.chain().focus().setFontFamily(fontFamily).run();
|
|
919
1093
|
}
|
|
920
1094
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorFontFamilyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
921
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorFontFamilyComponent, isStandalone: true, selector: "mona-editor-font-family", ngImport: i0, template: "<mona-dropdown-list\n [data]=\"editorService.fonts()\"\n [value]=\"selectedFontFamily()\"\n (valueChange)=\"onFontFamilyChange($event)\"\n [size]=\"'small'\"\n [class]=\"dropdownListClass()\"\n [title]=\"messages().selectFontFamily\">\n <ng-template monaDropDownListItemTemplate let-font>\n <span [style.font-family]=\"font\">{{ font }}</span>\n </ng-template>\n</mona-dropdown-list>\n", dependencies: [{ kind: "component", type: DropdownListComponent, selector: "mona-dropdown-list", inputs: ["aria-describedby", "aria-label", "aria-labelledby", "data", "disabled", "invalid", "itemDisabled", "loading", "placeholder", "popupClass", "popupHeight", "popupWidth", "readonly", "required", "rounded", "showClearButton", "size", "textField", "touched", "class", "value", "valueField", "valuePrimitive"], outputs: ["close", "closed", "open", "opened", "touch", "valueChange"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: DropdownItemTemplateDirective, selector: " ng-template[monaDropDownItemTemplate], ng-template[monaAutoCompleteItemTemplate], ng-template[monaDropDownListItemTemplate], ng-template[monaComboBoxItemTemplate], ng-template[monaMultiSelectItemTemplate] " }] }); }
|
|
1095
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorFontFamilyComponent, isStandalone: true, selector: "mona-editor-font-family", ngImport: i0, template: "<mona-dropdown-list\n [data]=\"editorService.fonts()\"\n [value]=\"selectedFontFamily()\"\n (valueChange)=\"onFontFamilyChange($event)\"\n [size]=\"'small'\"\n [class]=\"dropdownListClass()\"\n [aria-label]=\"messages().selectFontFamily\"\n [placeholder]=\"messages().defaultFontFamily\"\n [title]=\"messages().selectFontFamily\">\n <ng-template monaDropDownListItemTemplate let-font>\n <span [style.font-family]=\"font\">{{ font }}</span>\n </ng-template>\n</mona-dropdown-list>\n", dependencies: [{ kind: "component", type: DropdownListComponent, selector: "mona-dropdown-list", inputs: ["aria-describedby", "aria-label", "aria-labelledby", "data", "disabled", "invalid", "itemDisabled", "loading", "placeholder", "popupClass", "popupHeight", "popupWidth", "readonly", "required", "rounded", "showClearButton", "size", "textField", "touched", "class", "value", "valueField", "valuePrimitive"], outputs: ["close", "closed", "open", "opened", "touch", "valueChange"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: DropdownItemTemplateDirective, selector: " ng-template[monaDropDownItemTemplate], ng-template[monaAutoCompleteItemTemplate], ng-template[monaDropDownListItemTemplate], ng-template[monaComboBoxItemTemplate], ng-template[monaMultiSelectItemTemplate] " }] }); }
|
|
922
1096
|
}
|
|
923
1097
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorFontFamilyComponent, decorators: [{
|
|
924
1098
|
type: Component,
|
|
925
|
-
args: [{ selector: "mona-editor-font-family", imports: [DropdownListComponent, FormsModule, DropdownItemTemplateDirective], template: "<mona-dropdown-list\n [data]=\"editorService.fonts()\"\n [value]=\"selectedFontFamily()\"\n (valueChange)=\"onFontFamilyChange($event)\"\n [size]=\"'small'\"\n [class]=\"dropdownListClass()\"\n [title]=\"messages().selectFontFamily\">\n <ng-template monaDropDownListItemTemplate let-font>\n <span [style.font-family]=\"font\">{{ font }}</span>\n </ng-template>\n</mona-dropdown-list>\n" }]
|
|
1099
|
+
args: [{ selector: "mona-editor-font-family", imports: [DropdownListComponent, FormsModule, DropdownItemTemplateDirective], template: "<mona-dropdown-list\n [data]=\"editorService.fonts()\"\n [value]=\"selectedFontFamily()\"\n (valueChange)=\"onFontFamilyChange($event)\"\n [size]=\"'small'\"\n [class]=\"dropdownListClass()\"\n [aria-label]=\"messages().selectFontFamily\"\n [placeholder]=\"messages().defaultFontFamily\"\n [title]=\"messages().selectFontFamily\">\n <ng-template monaDropDownListItemTemplate let-font>\n <span [style.font-family]=\"font\">{{ font }}</span>\n </ng-template>\n</mona-dropdown-list>\n" }]
|
|
926
1100
|
}] });
|
|
927
1101
|
|
|
928
1102
|
class EditorFontHighlightComponent {
|
|
929
1103
|
constructor() {
|
|
930
1104
|
this.#editorService = inject(EditorService);
|
|
931
1105
|
this.#i18n = inject(MonaI18nService);
|
|
932
|
-
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
933
|
-
this.#lastColor = "";
|
|
934
1106
|
this.highlightPreviewClass = computed(() => {
|
|
935
1107
|
return editorFontHighlightPreviewThemeVariants();
|
|
936
1108
|
}, /* @ts-ignore */
|
|
@@ -939,53 +1111,40 @@ class EditorFontHighlightComponent {
|
|
|
939
1111
|
return editorFontHighlightValueThemeVariants();
|
|
940
1112
|
}, /* @ts-ignore */
|
|
941
1113
|
...(ngDevMode ? [{ debugName: "highlightValueClass" }] : /* istanbul ignore next */ []));
|
|
1114
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
942
1115
|
this.selectedColor = computed(() => {
|
|
943
1116
|
const state = this.#editorService.state();
|
|
944
|
-
|
|
945
|
-
const marks = state.storedMarks || state.selection.$from.marks();
|
|
946
|
-
const highlightMark = marks.find(mark => mark.type.name === "highlight");
|
|
947
|
-
return highlightMark ? highlightMark.attrs["color"] : this.#lastColor;
|
|
948
|
-
}
|
|
949
|
-
else {
|
|
950
|
-
const node = state.doc.nodeAt(state.selection.from);
|
|
951
|
-
if (node) {
|
|
952
|
-
const highlightMark = node.marks.find(mark => mark.type.name === "highlight");
|
|
953
|
-
return highlightMark ? highlightMark.attrs["color"] : this.#lastColor;
|
|
954
|
-
}
|
|
955
|
-
return "";
|
|
956
|
-
}
|
|
1117
|
+
return state ? selectionMarkAttribute(state, "highlight", "color") : null;
|
|
957
1118
|
}, /* @ts-ignore */
|
|
958
1119
|
...(ngDevMode ? [{ debugName: "selectedColor" }] : /* istanbul ignore next */ []));
|
|
959
1120
|
}
|
|
960
1121
|
#editorService;
|
|
961
1122
|
#i18n;
|
|
962
|
-
#lastColor;
|
|
963
1123
|
onColorChange(color) {
|
|
964
1124
|
if (color) {
|
|
965
1125
|
this.#editorService.editor.chain().focus().setHighlight({ color }).run();
|
|
966
|
-
this.#lastColor = color;
|
|
967
1126
|
}
|
|
968
1127
|
else {
|
|
969
1128
|
this.#editorService.editor.chain().focus().unsetHighlight().run();
|
|
970
1129
|
}
|
|
971
1130
|
}
|
|
972
1131
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorFontHighlightComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
973
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: EditorFontHighlightComponent, isStandalone: true, selector: "mona-editor-font-highlight", ngImport: i0, template: "<mona-color-picker\n view=\"gradient\"\n [value]=\"selectedColor()\"\n (valueChange)=\"onColorChange($event)\"\n [size]=\"'small'\"\n [title]=\"messages().backgroundColor\">\n <ng-template monaColorPickerValueTemplate let-color>\n <div [class]=\"highlightValueClass()\">\n <i class=\"ri-drop-fill\"></i>\n @if (color) {\n <span [class]=\"highlightPreviewClass()\" [style.background-color]=\"color\"></span>\n }\n </div>\n </ng-template>\n</mona-color-picker>\n", dependencies: [{ kind: "component", type: ColorPickerComponent, selector: "mona-color-picker", inputs: ["aria-label", "closeOnSelect", "columns", "disabled", "invalid", "opacity", "palette", "readonly", "required", "rounded", "showClearButton", "size", "touched", "value", "view"], outputs: ["touch", "valueChange"] }, { kind: "directive", type: ColorPickerValueTemplateDirective, selector: "ng-template[monaColorPickerValueTemplate]" }] }); }
|
|
1132
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: EditorFontHighlightComponent, isStandalone: true, selector: "mona-editor-font-highlight", ngImport: i0, template: "<mona-color-picker\n view=\"gradient\"\n [value]=\"selectedColor()\"\n (valueChange)=\"onColorChange($event)\"\n [size]=\"'small'\"\n [aria-label]=\"messages().backgroundColor\"\n [title]=\"messages().backgroundColor\">\n <ng-template monaColorPickerValueTemplate let-color>\n <div [class]=\"highlightValueClass()\">\n <i class=\"ri-drop-fill\"></i>\n @if (color) {\n <span [class]=\"highlightPreviewClass()\" [style.background-color]=\"color\"></span>\n }\n </div>\n </ng-template>\n</mona-color-picker>\n", dependencies: [{ kind: "component", type: ColorPickerComponent, selector: "mona-color-picker", inputs: ["aria-label", "closeOnSelect", "columns", "disabled", "invalid", "opacity", "palette", "readonly", "required", "rounded", "showClearButton", "size", "touched", "value", "view"], outputs: ["touch", "valueChange"] }, { kind: "directive", type: ColorPickerValueTemplateDirective, selector: "ng-template[monaColorPickerValueTemplate]" }] }); }
|
|
974
1133
|
}
|
|
975
1134
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorFontHighlightComponent, decorators: [{
|
|
976
1135
|
type: Component,
|
|
977
|
-
args: [{ selector: "mona-editor-font-highlight", imports: [ColorPickerComponent, ColorPickerValueTemplateDirective], template: "<mona-color-picker\n view=\"gradient\"\n [value]=\"selectedColor()\"\n (valueChange)=\"onColorChange($event)\"\n [size]=\"'small'\"\n [title]=\"messages().backgroundColor\">\n <ng-template monaColorPickerValueTemplate let-color>\n <div [class]=\"highlightValueClass()\">\n <i class=\"ri-drop-fill\"></i>\n @if (color) {\n <span [class]=\"highlightPreviewClass()\" [style.background-color]=\"color\"></span>\n }\n </div>\n </ng-template>\n</mona-color-picker>\n" }]
|
|
1136
|
+
args: [{ selector: "mona-editor-font-highlight", imports: [ColorPickerComponent, ColorPickerValueTemplateDirective], template: "<mona-color-picker\n view=\"gradient\"\n [value]=\"selectedColor()\"\n (valueChange)=\"onColorChange($event)\"\n [size]=\"'small'\"\n [aria-label]=\"messages().backgroundColor\"\n [title]=\"messages().backgroundColor\">\n <ng-template monaColorPickerValueTemplate let-color>\n <div [class]=\"highlightValueClass()\">\n <i class=\"ri-drop-fill\"></i>\n @if (color) {\n <span [class]=\"highlightPreviewClass()\" [style.background-color]=\"color\"></span>\n }\n </div>\n </ng-template>\n</mona-color-picker>\n" }]
|
|
978
1137
|
}] });
|
|
979
1138
|
|
|
980
1139
|
class EditorFontSizeComponent {
|
|
981
1140
|
constructor() {
|
|
982
1141
|
this.#i18n = inject(MonaI18nService);
|
|
983
|
-
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
984
|
-
this.editorService = inject(EditorService);
|
|
985
1142
|
this.dropdownListClass = computed(() => {
|
|
986
1143
|
return editorFontSizeDropdownListThemeVariants();
|
|
987
1144
|
}, /* @ts-ignore */
|
|
988
1145
|
...(ngDevMode ? [{ debugName: "dropdownListClass" }] : /* istanbul ignore next */ []));
|
|
1146
|
+
this.editorService = inject(EditorService);
|
|
1147
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
989
1148
|
this.selectedFontSize = computed(() => {
|
|
990
1149
|
this.editorService.state();
|
|
991
1150
|
return (this.editorService
|
|
@@ -1002,11 +1161,11 @@ class EditorFontSizeComponent {
|
|
|
1002
1161
|
this.editorService.editor.chain().focus().setFontSize(fontSize).run();
|
|
1003
1162
|
}
|
|
1004
1163
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorFontSizeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1005
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorFontSizeComponent, isStandalone: true, selector: "mona-editor-font-size", ngImport: i0, template: "<mona-dropdown-list\n [data]=\"editorService.fontSizes()\"\n [placeholder]=\"messages().fontSize\"\n [value]=\"selectedFontSize()\"\n (valueChange)=\"onFontSizeChange($event)\"\n [size]=\"'small'\"\n [class]=\"dropdownListClass()\"\n [title]=\"messages().selectFontSize\"></mona-dropdown-list>\n", dependencies: [{ kind: "component", type: DropdownListComponent, selector: "mona-dropdown-list", inputs: ["aria-describedby", "aria-label", "aria-labelledby", "data", "disabled", "invalid", "itemDisabled", "loading", "placeholder", "popupClass", "popupHeight", "popupWidth", "readonly", "required", "rounded", "showClearButton", "size", "textField", "touched", "class", "value", "valueField", "valuePrimitive"], outputs: ["close", "closed", "open", "opened", "touch", "valueChange"] }, { kind: "ngmodule", type: FormsModule }] }); }
|
|
1164
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorFontSizeComponent, isStandalone: true, selector: "mona-editor-font-size", ngImport: i0, template: "<mona-dropdown-list\n [data]=\"editorService.fontSizes()\"\n [placeholder]=\"messages().fontSize\"\n [aria-label]=\"messages().selectFontSize\"\n [value]=\"selectedFontSize()\"\n (valueChange)=\"onFontSizeChange($event)\"\n [size]=\"'small'\"\n [class]=\"dropdownListClass()\"\n [title]=\"messages().selectFontSize\"></mona-dropdown-list>\n", dependencies: [{ kind: "component", type: DropdownListComponent, selector: "mona-dropdown-list", inputs: ["aria-describedby", "aria-label", "aria-labelledby", "data", "disabled", "invalid", "itemDisabled", "loading", "placeholder", "popupClass", "popupHeight", "popupWidth", "readonly", "required", "rounded", "showClearButton", "size", "textField", "touched", "class", "value", "valueField", "valuePrimitive"], outputs: ["close", "closed", "open", "opened", "touch", "valueChange"] }, { kind: "ngmodule", type: FormsModule }] }); }
|
|
1006
1165
|
}
|
|
1007
1166
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorFontSizeComponent, decorators: [{
|
|
1008
1167
|
type: Component,
|
|
1009
|
-
args: [{ selector: "mona-editor-font-size", imports: [DropdownListComponent, FormsModule], template: "<mona-dropdown-list\n [data]=\"editorService.fontSizes()\"\n [placeholder]=\"messages().fontSize\"\n [value]=\"selectedFontSize()\"\n (valueChange)=\"onFontSizeChange($event)\"\n [size]=\"'small'\"\n [class]=\"dropdownListClass()\"\n [title]=\"messages().selectFontSize\"></mona-dropdown-list>\n" }]
|
|
1168
|
+
args: [{ selector: "mona-editor-font-size", imports: [DropdownListComponent, FormsModule], template: "<mona-dropdown-list\n [data]=\"editorService.fontSizes()\"\n [placeholder]=\"messages().fontSize\"\n [aria-label]=\"messages().selectFontSize\"\n [value]=\"selectedFontSize()\"\n (valueChange)=\"onFontSizeChange($event)\"\n [size]=\"'small'\"\n [class]=\"dropdownListClass()\"\n [title]=\"messages().selectFontSize\"></mona-dropdown-list>\n" }]
|
|
1010
1169
|
}] });
|
|
1011
1170
|
|
|
1012
1171
|
var HeadingType;
|
|
@@ -1024,12 +1183,11 @@ class EditorHeadingsComponent {
|
|
|
1024
1183
|
constructor() {
|
|
1025
1184
|
this.#editorService = inject(EditorService);
|
|
1026
1185
|
this.#i18n = inject(MonaI18nService);
|
|
1027
|
-
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1028
|
-
this.HeadingType = HeadingType;
|
|
1029
1186
|
this.dropdownListClass = computed(() => {
|
|
1030
1187
|
return editorHeadingsDropdownListThemeVariants();
|
|
1031
1188
|
}, /* @ts-ignore */
|
|
1032
1189
|
...(ngDevMode ? [{ debugName: "dropdownListClass" }] : /* istanbul ignore next */ []));
|
|
1190
|
+
this.headingType = HeadingType;
|
|
1033
1191
|
this.headingsDropdownListData = computed(() => {
|
|
1034
1192
|
const msgs = this.messages();
|
|
1035
1193
|
return [
|
|
@@ -1043,9 +1201,10 @@ class EditorHeadingsComponent {
|
|
|
1043
1201
|
];
|
|
1044
1202
|
}, /* @ts-ignore */
|
|
1045
1203
|
...(ngDevMode ? [{ debugName: "headingsDropdownListData" }] : /* istanbul ignore next */ []));
|
|
1204
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1046
1205
|
this.selectedHeadingsDropdownItem = computed(() => {
|
|
1047
1206
|
const state = this.#editorService.state();
|
|
1048
|
-
const node = state
|
|
1207
|
+
const node = state?.selection.$from.node();
|
|
1049
1208
|
const data = this.headingsDropdownListData();
|
|
1050
1209
|
if (node && node.type.name === "heading") {
|
|
1051
1210
|
return data.find(item => item.value === node.attrs["level"]);
|
|
@@ -1068,11 +1227,11 @@ class EditorHeadingsComponent {
|
|
|
1068
1227
|
}
|
|
1069
1228
|
}
|
|
1070
1229
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorHeadingsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1071
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: EditorHeadingsComponent, isStandalone: true, selector: "mona-editor-headings", ngImport: i0, template: "<mona-dropdown-list\n [data]=\"headingsDropdownListData()\"\n [value]=\"selectedHeadingsDropdownItem()\"\n (valueChange)=\"onFormatChange($event)\"\n [size]=\"'small'\"\n [class]=\"dropdownListClass()\"\n textField=\"text\"\n valueField=\"value\"\n [title]=\"messages().format\">\n <ng-template monaDropDownListItemTemplate let-dataItem>\n @switch (dataItem.value) {\n @case (
|
|
1230
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: EditorHeadingsComponent, isStandalone: true, selector: "mona-editor-headings", ngImport: i0, template: "<mona-dropdown-list\n [data]=\"headingsDropdownListData()\"\n [value]=\"selectedHeadingsDropdownItem()\"\n (valueChange)=\"onFormatChange($event)\"\n [size]=\"'small'\"\n [class]=\"dropdownListClass()\"\n textField=\"text\"\n valueField=\"value\"\n [aria-label]=\"messages().format\"\n [title]=\"messages().format\">\n <ng-template monaDropDownListItemTemplate let-dataItem>\n @switch (dataItem.value) {\n @case (headingType.Heading1) {\n <h1 class=\"m-0 text-2xl font-bold\">{{ dataItem.text }}</h1>\n }\n @case (headingType.Heading2) {\n <h2 class=\"m-0 text-xl font-bold\">{{ dataItem.text }}</h2>\n }\n @case (headingType.Heading3) {\n <h3 class=\"m-0 text-lg font-bold\">{{ dataItem.text }}</h3>\n }\n @case (headingType.Heading4) {\n <h4 class=\"m-0 text-base font-bold\">{{ dataItem.text }}</h4>\n }\n @case (headingType.Heading5) {\n <h5 class=\"m-0 text-sm font-bold\">{{ dataItem.text }}</h5>\n }\n @case (headingType.Heading6) {\n <h6 class=\"m-0 text-xs font-bold\">{{ dataItem.text }}</h6>\n }\n @case (headingType.Paragraph) {\n <p class=\"m-0 text-sm\">{{ dataItem.text }}</p>\n }\n @default {\n <p class=\"m-0 text-sm\">{{ dataItem.text }}</p>\n }\n }\n </ng-template>\n</mona-dropdown-list>\n", dependencies: [{ kind: "component", type: DropdownListComponent, selector: "mona-dropdown-list", inputs: ["aria-describedby", "aria-label", "aria-labelledby", "data", "disabled", "invalid", "itemDisabled", "loading", "placeholder", "popupClass", "popupHeight", "popupWidth", "readonly", "required", "rounded", "showClearButton", "size", "textField", "touched", "class", "value", "valueField", "valuePrimitive"], outputs: ["close", "closed", "open", "opened", "touch", "valueChange"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: DropdownItemTemplateDirective, selector: " ng-template[monaDropDownItemTemplate], ng-template[monaAutoCompleteItemTemplate], ng-template[monaDropDownListItemTemplate], ng-template[monaComboBoxItemTemplate], ng-template[monaMultiSelectItemTemplate] " }] }); }
|
|
1072
1231
|
}
|
|
1073
1232
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorHeadingsComponent, decorators: [{
|
|
1074
1233
|
type: Component,
|
|
1075
|
-
args: [{ selector: "mona-editor-headings", imports: [DropdownListComponent, FormsModule, DropdownItemTemplateDirective], template: "<mona-dropdown-list\n [data]=\"headingsDropdownListData()\"\n [value]=\"selectedHeadingsDropdownItem()\"\n (valueChange)=\"onFormatChange($event)\"\n [size]=\"'small'\"\n [class]=\"dropdownListClass()\"\n textField=\"text\"\n valueField=\"value\"\n [title]=\"messages().format\">\n <ng-template monaDropDownListItemTemplate let-dataItem>\n @switch (dataItem.value) {\n @case (
|
|
1234
|
+
args: [{ selector: "mona-editor-headings", imports: [DropdownListComponent, FormsModule, DropdownItemTemplateDirective], template: "<mona-dropdown-list\n [data]=\"headingsDropdownListData()\"\n [value]=\"selectedHeadingsDropdownItem()\"\n (valueChange)=\"onFormatChange($event)\"\n [size]=\"'small'\"\n [class]=\"dropdownListClass()\"\n textField=\"text\"\n valueField=\"value\"\n [aria-label]=\"messages().format\"\n [title]=\"messages().format\">\n <ng-template monaDropDownListItemTemplate let-dataItem>\n @switch (dataItem.value) {\n @case (headingType.Heading1) {\n <h1 class=\"m-0 text-2xl font-bold\">{{ dataItem.text }}</h1>\n }\n @case (headingType.Heading2) {\n <h2 class=\"m-0 text-xl font-bold\">{{ dataItem.text }}</h2>\n }\n @case (headingType.Heading3) {\n <h3 class=\"m-0 text-lg font-bold\">{{ dataItem.text }}</h3>\n }\n @case (headingType.Heading4) {\n <h4 class=\"m-0 text-base font-bold\">{{ dataItem.text }}</h4>\n }\n @case (headingType.Heading5) {\n <h5 class=\"m-0 text-sm font-bold\">{{ dataItem.text }}</h5>\n }\n @case (headingType.Heading6) {\n <h6 class=\"m-0 text-xs font-bold\">{{ dataItem.text }}</h6>\n }\n @case (headingType.Paragraph) {\n <p class=\"m-0 text-sm\">{{ dataItem.text }}</p>\n }\n @default {\n <p class=\"m-0 text-sm\">{{ dataItem.text }}</p>\n }\n }\n </ng-template>\n</mona-dropdown-list>\n" }]
|
|
1076
1235
|
}] });
|
|
1077
1236
|
|
|
1078
1237
|
class EditorHistoryComponent {
|
|
@@ -1100,11 +1259,11 @@ class EditorHistoryComponent {
|
|
|
1100
1259
|
this.#editorService.editor.chain().focus().undo().run();
|
|
1101
1260
|
}
|
|
1102
1261
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorHistoryComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1103
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorHistoryComponent, isStandalone: true, selector: "mona-editor-history", ngImport: i0, template: "<mona-button-group selection=\"single\" [size]=\"'small'\">\n <button
|
|
1262
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorHistoryComponent, isStandalone: true, selector: "mona-editor-history", ngImport: i0, template: "<mona-button-group selection=\"single\" [size]=\"'small'\" [aria-label]=\"messages().historyGroup\">\n <button\n monaButton\n [toggleable]=\"false\"\n [disabled]=\"undoDisabled()\"\n (click)=\"onUndoClick()\"\n [title]=\"messages().undo\">\n <i class=\"ri-arrow-go-back-line\"></i>\n </button>\n <button\n monaButton\n [toggleable]=\"false\"\n [disabled]=\"redoDisabled()\"\n (click)=\"onRedoClick()\"\n [title]=\"messages().redo\">\n <i class=\"ri-arrow-go-forward-line\"></i>\n </button>\n</mona-button-group>\n", dependencies: [{ kind: "component", type: ButtonGroupComponent, selector: "mona-button-group", inputs: ["allowEmpty", "aria-label", "disabled", "look", "rounded", "selection", "size", "class"], outputs: ["buttonClick", "disabledChange", "selectionChange"] }, { kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }] }); }
|
|
1104
1263
|
}
|
|
1105
1264
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorHistoryComponent, decorators: [{
|
|
1106
1265
|
type: Component,
|
|
1107
|
-
args: [{ selector: "mona-editor-history", imports: [ButtonGroupComponent, ButtonDirective], template: "<mona-button-group selection=\"single\" [size]=\"'small'\">\n <button
|
|
1266
|
+
args: [{ selector: "mona-editor-history", imports: [ButtonGroupComponent, ButtonDirective], template: "<mona-button-group selection=\"single\" [size]=\"'small'\" [aria-label]=\"messages().historyGroup\">\n <button\n monaButton\n [toggleable]=\"false\"\n [disabled]=\"undoDisabled()\"\n (click)=\"onUndoClick()\"\n [title]=\"messages().undo\">\n <i class=\"ri-arrow-go-back-line\"></i>\n </button>\n <button\n monaButton\n [toggleable]=\"false\"\n [disabled]=\"redoDisabled()\"\n (click)=\"onRedoClick()\"\n [title]=\"messages().redo\">\n <i class=\"ri-arrow-go-forward-line\"></i>\n </button>\n</mona-button-group>\n" }]
|
|
1108
1267
|
}] });
|
|
1109
1268
|
|
|
1110
1269
|
class EditorHorizontalRuleComponent {
|
|
@@ -1129,7 +1288,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
1129
1288
|
class EditorImageInserterComponent {
|
|
1130
1289
|
constructor() {
|
|
1131
1290
|
this.#i18n = inject(MonaI18nService);
|
|
1132
|
-
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1133
1291
|
this.#imageFormModel = signal({
|
|
1134
1292
|
alt: "",
|
|
1135
1293
|
height: null,
|
|
@@ -1149,6 +1307,13 @@ class EditorImageInserterComponent {
|
|
|
1149
1307
|
required(schema.link);
|
|
1150
1308
|
maxLength(schema.link, 2048);
|
|
1151
1309
|
});
|
|
1310
|
+
this.labelIds = {
|
|
1311
|
+
alt: createElementControlId(),
|
|
1312
|
+
height: createElementControlId(),
|
|
1313
|
+
link: createElementControlId(),
|
|
1314
|
+
width: createElementControlId()
|
|
1315
|
+
};
|
|
1316
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1152
1317
|
this.rowClass = computed(() => {
|
|
1153
1318
|
return editorImageInserterRowThemeVariants();
|
|
1154
1319
|
}, /* @ts-ignore */
|
|
@@ -1157,13 +1322,13 @@ class EditorImageInserterComponent {
|
|
|
1157
1322
|
return editorImageInserterRowLabelThemeVariants();
|
|
1158
1323
|
}, /* @ts-ignore */
|
|
1159
1324
|
...(ngDevMode ? [{ debugName: "rowLabelClass" }] : /* istanbul ignore next */ []));
|
|
1160
|
-
this.cancel = output();
|
|
1161
1325
|
this.insert = output();
|
|
1326
|
+
this.insertCancel = output();
|
|
1162
1327
|
}
|
|
1163
1328
|
#i18n;
|
|
1164
1329
|
#imageFormModel;
|
|
1165
1330
|
onCancel() {
|
|
1166
|
-
this.
|
|
1331
|
+
this.insertCancel.emit();
|
|
1167
1332
|
}
|
|
1168
1333
|
onImageInsert() {
|
|
1169
1334
|
this.insert.emit({
|
|
@@ -1174,20 +1339,20 @@ class EditorImageInserterComponent {
|
|
|
1174
1339
|
});
|
|
1175
1340
|
}
|
|
1176
1341
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorImageInserterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1177
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorImageInserterComponent, isStandalone: true, selector: "mona-editor-image-inserter", outputs: {
|
|
1342
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorImageInserterComponent, isStandalone: true, selector: "mona-editor-image-inserter", outputs: { insert: "insert", insertCancel: "insertCancel" }, ngImport: i0, template: "<form [formRoot]=\"iForm\" [class]=\"formClass()\">\n <div [class]=\"rowClass()\">\n <label [class]=\"rowLabelClass()\" [id]=\"labelIds.link\">{{ messages().imageUrl }}</label>\n <mona-text-box [size]=\"'small'\" [formField]=\"iForm.link\" [aria-labelledby]=\"labelIds.link\"></mona-text-box>\n </div>\n <div [class]=\"rowClass()\">\n <label [class]=\"rowLabelClass()\" [id]=\"labelIds.alt\">{{ messages().altText }}</label>\n <mona-text-box [size]=\"'small'\" [formField]=\"iForm.alt\" [aria-labelledby]=\"labelIds.alt\"></mona-text-box>\n </div>\n <div class=\"flex gap-2\">\n <div [class]=\"rowClass()\">\n <label [class]=\"rowLabelClass()\" [id]=\"labelIds.width\">{{ messages().widthPx }}</label>\n <mona-numeric-text-box\n [size]=\"'small'\"\n [formField]=\"iForm.width\"\n [aria-labelledby]=\"labelIds.width\"></mona-numeric-text-box>\n </div>\n <div [class]=\"rowClass()\">\n <label [class]=\"rowLabelClass()\" [id]=\"labelIds.height\">{{ messages().heightPx }}</label>\n <mona-numeric-text-box\n [size]=\"'small'\"\n [formField]=\"iForm.height\"\n [aria-labelledby]=\"labelIds.height\"></mona-numeric-text-box>\n </div>\n </div>\n <div [class]=\"actionsClass()\">\n <button monaButton [size]=\"'small'\" [disabled]=\"!iForm().valid()\" look=\"primary\" (click)=\"onImageInsert()\">\n {{ messages().insert }}\n </button>\n <button monaButton [size]=\"'small'\" [look]=\"'secondary'\" (click)=\"onCancel()\">{{ messages().cancel }}</button>\n </div>\n</form>\n", dependencies: [{ kind: "component", type: TextBoxComponent, selector: "mona-text-box", inputs: ["aria-describedby", "aria-label", "aria-labelledby", "clearButton", "disabled", "inputAttributes", "inputClass", "inputId", "inputStyle", "invalid", "maxLength", "minLength", "name", "placeholder", "readonly", "required", "rounded", "size", "touched", "type", "class", "value"], outputs: ["inputBlur", "inputFocus", "touch", "valueChange"] }, { kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }, { kind: "component", type: NumericTextBoxComponent, selector: "mona-numeric-text-box", inputs: ["formatter", "maxValue", "minValue", "step", "value"], outputs: ["valueChange"] }, { kind: "directive", type: FormRoot, selector: "form[formRoot]", inputs: ["formRoot"] }, { kind: "directive", type: FormField, selector: "[formField]", inputs: ["formField"], exportAs: ["formField"] }] }); }
|
|
1178
1343
|
}
|
|
1179
1344
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorImageInserterComponent, decorators: [{
|
|
1180
1345
|
type: Component,
|
|
1181
|
-
args: [{ selector: "mona-editor-image-inserter", imports: [TextBoxComponent, ButtonDirective, NumericTextBoxComponent, FormRoot, FormField], template: "<form [formRoot]=\"iForm\" [class]=\"formClass()\">\n <div [class]=\"rowClass()\">\n <
|
|
1182
|
-
}], propDecorators: {
|
|
1346
|
+
args: [{ selector: "mona-editor-image-inserter", imports: [TextBoxComponent, ButtonDirective, NumericTextBoxComponent, FormRoot, FormField], template: "<form [formRoot]=\"iForm\" [class]=\"formClass()\">\n <div [class]=\"rowClass()\">\n <label [class]=\"rowLabelClass()\" [id]=\"labelIds.link\">{{ messages().imageUrl }}</label>\n <mona-text-box [size]=\"'small'\" [formField]=\"iForm.link\" [aria-labelledby]=\"labelIds.link\"></mona-text-box>\n </div>\n <div [class]=\"rowClass()\">\n <label [class]=\"rowLabelClass()\" [id]=\"labelIds.alt\">{{ messages().altText }}</label>\n <mona-text-box [size]=\"'small'\" [formField]=\"iForm.alt\" [aria-labelledby]=\"labelIds.alt\"></mona-text-box>\n </div>\n <div class=\"flex gap-2\">\n <div [class]=\"rowClass()\">\n <label [class]=\"rowLabelClass()\" [id]=\"labelIds.width\">{{ messages().widthPx }}</label>\n <mona-numeric-text-box\n [size]=\"'small'\"\n [formField]=\"iForm.width\"\n [aria-labelledby]=\"labelIds.width\"></mona-numeric-text-box>\n </div>\n <div [class]=\"rowClass()\">\n <label [class]=\"rowLabelClass()\" [id]=\"labelIds.height\">{{ messages().heightPx }}</label>\n <mona-numeric-text-box\n [size]=\"'small'\"\n [formField]=\"iForm.height\"\n [aria-labelledby]=\"labelIds.height\"></mona-numeric-text-box>\n </div>\n </div>\n <div [class]=\"actionsClass()\">\n <button monaButton [size]=\"'small'\" [disabled]=\"!iForm().valid()\" look=\"primary\" (click)=\"onImageInsert()\">\n {{ messages().insert }}\n </button>\n <button monaButton [size]=\"'small'\" [look]=\"'secondary'\" (click)=\"onCancel()\">{{ messages().cancel }}</button>\n </div>\n</form>\n" }]
|
|
1347
|
+
}], propDecorators: { insert: [{ type: i0.Output, args: ["insert"] }], insertCancel: [{ type: i0.Output, args: ["insertCancel"] }] } });
|
|
1183
1348
|
|
|
1184
1349
|
class EditorImageComponent {
|
|
1185
1350
|
constructor() {
|
|
1186
1351
|
this.#editorService = inject(EditorService);
|
|
1187
1352
|
this.#i18n = inject(MonaI18nService);
|
|
1188
|
-
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1189
1353
|
this.inserterVisible = signal(false, /* @ts-ignore */
|
|
1190
1354
|
...(ngDevMode ? [{ debugName: "inserterVisible" }] : /* istanbul ignore next */ []));
|
|
1355
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1191
1356
|
}
|
|
1192
1357
|
#editorService;
|
|
1193
1358
|
#i18n;
|
|
@@ -1210,35 +1375,34 @@ class EditorImageComponent {
|
|
|
1210
1375
|
insertImage(event) {
|
|
1211
1376
|
this.#editorService.editor
|
|
1212
1377
|
.chain()
|
|
1378
|
+
.focus()
|
|
1213
1379
|
.setImage({
|
|
1214
|
-
src: event.link,
|
|
1215
1380
|
alt: event.alt,
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
.
|
|
1219
|
-
width: event.width
|
|
1220
|
-
height: event.height
|
|
1381
|
+
height: event.height ?? undefined,
|
|
1382
|
+
src: event.link,
|
|
1383
|
+
title: event.alt,
|
|
1384
|
+
width: event.width ?? undefined
|
|
1221
1385
|
})
|
|
1222
1386
|
.run();
|
|
1223
1387
|
}
|
|
1224
1388
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorImageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1225
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: EditorImageComponent, isStandalone: true, selector: "mona-editor-image", ngImport: i0, template: "<button
|
|
1389
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: EditorImageComponent, isStandalone: true, selector: "mona-editor-image", ngImport: i0, template: "<button\n monaButton\n [size]=\"'small'\"\n aria-haspopup=\"dialog\"\n (click)=\"onDisplayInserterClick()\"\n [title]=\"messages().insertImage\">\n <i class=\"ri-image-add-line\"></i>\n</button>\n\n@if (inserterVisible()) {\n <mona-window\n [width]=\"400\"\n [modal]=\"true\"\n [title]=\"messages().insertImage\"\n [minimizable]=\"false\"\n [maximizable]=\"false\"\n (close)=\"onInserterClose()\">\n <ng-template monaWindowContentTemplate>\n <mona-editor-image-inserter\n (insert)=\"onImageInsert($event)\"\n (insertCancel)=\"onInsertCancel()\"></mona-editor-image-inserter>\n </ng-template>\n </mona-window>\n}\n", dependencies: [{ kind: "component", type: WindowComponent, selector: "mona-window", inputs: ["ariaLabel", "closable", "closeOnEscape", "draggable", "focusedElement", "height", "left", "look", "maxHeight", "maxWidth", "maximizable", "messages", "minHeight", "minWidth", "minimizable", "modal", "resizable", "rounded", "title", "top", "width"], outputs: ["close", "closed", "dragEnd", "dragStart", "heightChange", "leftChange", "topChange", "widthChange"] }, { kind: "component", type: EditorImageInserterComponent, selector: "mona-editor-image-inserter", outputs: ["insert", "insertCancel"] }, { kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }, { kind: "directive", type: WindowContentTemplateDirective, selector: "ng-template[monaWindowContentTemplate]" }] }); }
|
|
1226
1390
|
}
|
|
1227
1391
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorImageComponent, decorators: [{
|
|
1228
1392
|
type: Component,
|
|
1229
|
-
args: [{ selector: "mona-editor-image", imports: [WindowComponent, EditorImageInserterComponent, ButtonDirective, WindowContentTemplateDirective], template: "<button
|
|
1393
|
+
args: [{ selector: "mona-editor-image", imports: [WindowComponent, EditorImageInserterComponent, ButtonDirective, WindowContentTemplateDirective], template: "<button\n monaButton\n [size]=\"'small'\"\n aria-haspopup=\"dialog\"\n (click)=\"onDisplayInserterClick()\"\n [title]=\"messages().insertImage\">\n <i class=\"ri-image-add-line\"></i>\n</button>\n\n@if (inserterVisible()) {\n <mona-window\n [width]=\"400\"\n [modal]=\"true\"\n [title]=\"messages().insertImage\"\n [minimizable]=\"false\"\n [maximizable]=\"false\"\n (close)=\"onInserterClose()\">\n <ng-template monaWindowContentTemplate>\n <mona-editor-image-inserter\n (insert)=\"onImageInsert($event)\"\n (insertCancel)=\"onInsertCancel()\"></mona-editor-image-inserter>\n </ng-template>\n </mona-window>\n}\n" }]
|
|
1230
1394
|
}] });
|
|
1231
1395
|
|
|
1232
1396
|
class EditorIndentComponent {
|
|
1233
1397
|
constructor() {
|
|
1234
1398
|
this.#editorService = inject(EditorService);
|
|
1235
1399
|
this.#i18n = inject(MonaI18nService);
|
|
1236
|
-
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1237
1400
|
this.indentDisabled = computed(() => {
|
|
1238
1401
|
this.#editorService.state();
|
|
1239
1402
|
return !this.#editorService.editor.can().indent();
|
|
1240
1403
|
}, /* @ts-ignore */
|
|
1241
1404
|
...(ngDevMode ? [{ debugName: "indentDisabled" }] : /* istanbul ignore next */ []));
|
|
1405
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1242
1406
|
this.outdentDisabled = computed(() => {
|
|
1243
1407
|
this.#editorService.state();
|
|
1244
1408
|
return !this.#editorService.editor.can().outdent();
|
|
@@ -1254,11 +1418,101 @@ class EditorIndentComponent {
|
|
|
1254
1418
|
this.#editorService.editor.chain().focus().outdent().run();
|
|
1255
1419
|
}
|
|
1256
1420
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorIndentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1257
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorIndentComponent, isStandalone: true, selector: "mona-editor-indent", ngImport: i0, template: "<mona-button-group selection=\"single\" [size]=\"'small'\">\n <button
|
|
1421
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorIndentComponent, isStandalone: true, selector: "mona-editor-indent", ngImport: i0, template: "<mona-button-group selection=\"single\" [size]=\"'small'\" [aria-label]=\"messages().indentGroup\">\n <button\n monaButton\n [toggleable]=\"false\"\n [disabled]=\"indentDisabled()\"\n (click)=\"onIndentClick()\"\n [title]=\"messages().indent\">\n <i class=\"ri-indent-increase\"></i>\n </button>\n <button\n monaButton\n [toggleable]=\"false\"\n [disabled]=\"outdentDisabled()\"\n (click)=\"onOutdentClick()\"\n [title]=\"messages().outdent\">\n <i class=\"ri-indent-decrease\"></i>\n </button>\n</mona-button-group>\n", dependencies: [{ kind: "component", type: ButtonGroupComponent, selector: "mona-button-group", inputs: ["allowEmpty", "aria-label", "disabled", "look", "rounded", "selection", "size", "class"], outputs: ["buttonClick", "disabledChange", "selectionChange"] }, { kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }] }); }
|
|
1258
1422
|
}
|
|
1259
1423
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorIndentComponent, decorators: [{
|
|
1260
1424
|
type: Component,
|
|
1261
|
-
args: [{ selector: "mona-editor-indent", imports: [ButtonGroupComponent, ButtonDirective], template: "<mona-button-group selection=\"single\" [size]=\"'small'\">\n <button
|
|
1425
|
+
args: [{ selector: "mona-editor-indent", imports: [ButtonGroupComponent, ButtonDirective], template: "<mona-button-group selection=\"single\" [size]=\"'small'\" [aria-label]=\"messages().indentGroup\">\n <button\n monaButton\n [toggleable]=\"false\"\n [disabled]=\"indentDisabled()\"\n (click)=\"onIndentClick()\"\n [title]=\"messages().indent\">\n <i class=\"ri-indent-increase\"></i>\n </button>\n <button\n monaButton\n [toggleable]=\"false\"\n [disabled]=\"outdentDisabled()\"\n (click)=\"onOutdentClick()\"\n [title]=\"messages().outdent\">\n <i class=\"ri-indent-decrease\"></i>\n </button>\n</mona-button-group>\n" }]
|
|
1426
|
+
}] });
|
|
1427
|
+
|
|
1428
|
+
const ALLOWED_SCHEME = /^(?:https?|mailto|tel):/i;
|
|
1429
|
+
const ANY_SCHEME = /^[a-z][a-z\d+.-]*:/i;
|
|
1430
|
+
const RELATIVE = /^(?:\/|#|\?|\.\.?\/)/;
|
|
1431
|
+
const BARE_HOST = /^[^\s/?#]+\.[^\s/?#]+/;
|
|
1432
|
+
/**
|
|
1433
|
+
* Checks a link typed by the user and returns the URL to store, or `null` when it can't be used.
|
|
1434
|
+
*
|
|
1435
|
+
* - `http:`, `https:`, `mailto:` and `tel:` URLs are kept.
|
|
1436
|
+
* - Relative URLs (`/path`, `#anchor`, `?query`, `./file`) are kept.
|
|
1437
|
+
* - A bare host such as `example.com/page` gets `https://`.
|
|
1438
|
+
* - Any other scheme (`javascript:`, `data:`, `ftp:` …) and text with spaces is refused.
|
|
1439
|
+
*/
|
|
1440
|
+
function normalizeLinkUrl(value) {
|
|
1441
|
+
const url = value.trim();
|
|
1442
|
+
if (!url || /\s/.test(url)) {
|
|
1443
|
+
return null;
|
|
1444
|
+
}
|
|
1445
|
+
if (ALLOWED_SCHEME.test(url) || RELATIVE.test(url)) {
|
|
1446
|
+
return url;
|
|
1447
|
+
}
|
|
1448
|
+
if (ANY_SCHEME.test(url)) {
|
|
1449
|
+
return null;
|
|
1450
|
+
}
|
|
1451
|
+
return BARE_HOST.test(url) ? `https://${url}` : null;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
/**
|
|
1455
|
+
* @internal The content of the link dialog: one URL field. The dialog's own actions apply, remove or cancel; Enter in
|
|
1456
|
+
* the field applies.
|
|
1457
|
+
*/
|
|
1458
|
+
class EditorLinkDialogComponent {
|
|
1459
|
+
constructor() {
|
|
1460
|
+
this.#i18n = inject(MonaI18nService);
|
|
1461
|
+
this.errorId = createElementControlId();
|
|
1462
|
+
this.invalid = signal(false, /* @ts-ignore */
|
|
1463
|
+
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
1464
|
+
this.labelId = createElementControlId();
|
|
1465
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1466
|
+
this.url = signal(inject(DIALOG_DATA).href, /* @ts-ignore */
|
|
1467
|
+
...(ngDevMode ? [{ debugName: "url" }] : /* istanbul ignore next */ []));
|
|
1468
|
+
}
|
|
1469
|
+
#i18n;
|
|
1470
|
+
/**
|
|
1471
|
+
* Returns the URL to store, or `null` after showing why the typed one can't be used.
|
|
1472
|
+
*/
|
|
1473
|
+
validate() {
|
|
1474
|
+
const href = normalizeLinkUrl(this.url());
|
|
1475
|
+
this.invalid.set(href === null);
|
|
1476
|
+
return href;
|
|
1477
|
+
}
|
|
1478
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorLinkDialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1479
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: EditorLinkDialogComponent, isStandalone: true, selector: "mona-editor-link-dialog", ngImport: i0, template: `
|
|
1480
|
+
<div class="flex flex-col gap-1 p-2">
|
|
1481
|
+
<label class="ps-0.5 text-sm font-semibold" [id]="labelId">{{ messages().enterUrl }}</label>
|
|
1482
|
+
<mona-text-box
|
|
1483
|
+
size="small"
|
|
1484
|
+
[(value)]="url"
|
|
1485
|
+
[aria-labelledby]="labelId"
|
|
1486
|
+
[aria-describedby]="invalid() ? errorId : ''"
|
|
1487
|
+
[invalid]="invalid()"
|
|
1488
|
+
[touched]="invalid()"></mona-text-box>
|
|
1489
|
+
@if (invalid()) {
|
|
1490
|
+
<p class="m-0 ps-0.5 text-sm text-error" [id]="errorId">{{ messages().invalidUrl }}</p>
|
|
1491
|
+
}
|
|
1492
|
+
</div>
|
|
1493
|
+
`, isInline: true, dependencies: [{ kind: "component", type: TextBoxComponent, selector: "mona-text-box", inputs: ["aria-describedby", "aria-label", "aria-labelledby", "clearButton", "disabled", "inputAttributes", "inputClass", "inputId", "inputStyle", "invalid", "maxLength", "minLength", "name", "placeholder", "readonly", "required", "rounded", "size", "touched", "type", "class", "value"], outputs: ["inputBlur", "inputFocus", "touch", "valueChange"] }] }); }
|
|
1494
|
+
}
|
|
1495
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorLinkDialogComponent, decorators: [{
|
|
1496
|
+
type: Component,
|
|
1497
|
+
args: [{
|
|
1498
|
+
selector: "mona-editor-link-dialog",
|
|
1499
|
+
imports: [TextBoxComponent],
|
|
1500
|
+
template: `
|
|
1501
|
+
<div class="flex flex-col gap-1 p-2">
|
|
1502
|
+
<label class="ps-0.5 text-sm font-semibold" [id]="labelId">{{ messages().enterUrl }}</label>
|
|
1503
|
+
<mona-text-box
|
|
1504
|
+
size="small"
|
|
1505
|
+
[(value)]="url"
|
|
1506
|
+
[aria-labelledby]="labelId"
|
|
1507
|
+
[aria-describedby]="invalid() ? errorId : ''"
|
|
1508
|
+
[invalid]="invalid()"
|
|
1509
|
+
[touched]="invalid()"></mona-text-box>
|
|
1510
|
+
@if (invalid()) {
|
|
1511
|
+
<p class="m-0 ps-0.5 text-sm text-error" [id]="errorId">{{ messages().invalidUrl }}</p>
|
|
1512
|
+
}
|
|
1513
|
+
</div>
|
|
1514
|
+
`
|
|
1515
|
+
}]
|
|
1262
1516
|
}] });
|
|
1263
1517
|
|
|
1264
1518
|
class EditorLinkComponent {
|
|
@@ -1266,48 +1520,90 @@ class EditorLinkComponent {
|
|
|
1266
1520
|
this.#dialogService = inject(DialogService);
|
|
1267
1521
|
this.#editorService = inject(EditorService);
|
|
1268
1522
|
this.#i18n = inject(MonaI18nService);
|
|
1269
|
-
this
|
|
1523
|
+
this.#injector = inject(Injector);
|
|
1270
1524
|
this.linkSelected = computed(() => {
|
|
1271
1525
|
this.#editorService.state();
|
|
1272
1526
|
return this.#editorService.editor.isActive("link");
|
|
1273
1527
|
}, /* @ts-ignore */
|
|
1274
1528
|
...(ngDevMode ? [{ debugName: "linkSelected" }] : /* istanbul ignore next */ []));
|
|
1275
|
-
this.
|
|
1276
|
-
|
|
1277
|
-
return !this.#editorService.editor.isActive("link");
|
|
1278
|
-
}, /* @ts-ignore */
|
|
1529
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1530
|
+
this.unlinkDisabled = computed(() => !this.linkSelected(), /* @ts-ignore */
|
|
1279
1531
|
...(ngDevMode ? [{ debugName: "unlinkDisabled" }] : /* istanbul ignore next */ []));
|
|
1280
1532
|
}
|
|
1281
1533
|
#dialogService;
|
|
1282
1534
|
#editorService;
|
|
1283
1535
|
#i18n;
|
|
1536
|
+
#injector;
|
|
1537
|
+
/**
|
|
1538
|
+
* Opens the link dialog for the selection: Apply sets the link (extending it over the whole link when the
|
|
1539
|
+
* selection is inside one), Remove takes it off, Cancel and Escape change nothing.
|
|
1540
|
+
*/
|
|
1284
1541
|
onLinkDialogDisplay() {
|
|
1285
|
-
const
|
|
1542
|
+
const editor = this.#editorService.editor;
|
|
1543
|
+
const editing = editor.isActive("link");
|
|
1544
|
+
const href = editor.getAttributes("link")["href"] ?? "";
|
|
1545
|
+
const messages = this.messages();
|
|
1546
|
+
const actions = [{ data: "cancel", text: messages.cancel }];
|
|
1547
|
+
if (editing) {
|
|
1548
|
+
actions.push({ data: "remove", text: messages.removeLink });
|
|
1549
|
+
}
|
|
1550
|
+
actions.push({ data: "apply", default: true, look: "primary", text: messages.apply });
|
|
1286
1551
|
const dialogRef = this.#dialogService.show({
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1552
|
+
actions,
|
|
1553
|
+
content: EditorLinkDialogComponent,
|
|
1554
|
+
data: { href },
|
|
1555
|
+
focusedElement: "mona-editor-link-dialog input",
|
|
1556
|
+
injector: this.#injector,
|
|
1557
|
+
title: editing ? messages.editLink : messages.insertLink,
|
|
1558
|
+
width: 420
|
|
1559
|
+
});
|
|
1560
|
+
let url = null;
|
|
1561
|
+
dialogRef.action$.subscribe(event => {
|
|
1562
|
+
if (event.action.data !== "apply") {
|
|
1563
|
+
return;
|
|
1564
|
+
}
|
|
1565
|
+
url = dialogRef.component?.instance?.validate() ?? null;
|
|
1566
|
+
if (url === null) {
|
|
1567
|
+
event.preventDefault();
|
|
1568
|
+
}
|
|
1569
|
+
});
|
|
1570
|
+
dialogRef.result.subscribe(result => {
|
|
1571
|
+
if (result.viaClose) {
|
|
1572
|
+
return;
|
|
1573
|
+
}
|
|
1574
|
+
if (result.action.data === "remove") {
|
|
1575
|
+
this.#editorService.editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
1576
|
+
}
|
|
1577
|
+
else if (result.action.data === "apply" && url !== null) {
|
|
1578
|
+
this.#setLink(url, editing);
|
|
1579
|
+
}
|
|
1292
1580
|
});
|
|
1293
|
-
// dialogRef.result.pipe(take(1)).subscribe(result => this.setLink(result.value as string));
|
|
1294
1581
|
}
|
|
1295
1582
|
onUnlinkClick() {
|
|
1296
|
-
this.#editorService.editor.chain().focus().unsetLink().run();
|
|
1583
|
+
this.#editorService.editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
1297
1584
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1585
|
+
/**
|
|
1586
|
+
* Links the selection, or the whole link the cursor is in. With nothing selected outside a link, the URL itself
|
|
1587
|
+
* is inserted as the link's text.
|
|
1588
|
+
*/
|
|
1589
|
+
#setLink(href, editing) {
|
|
1590
|
+
const editor = this.#editorService.editor;
|
|
1591
|
+
if (!editing && editor.state.selection.empty) {
|
|
1592
|
+
editor
|
|
1593
|
+
.chain()
|
|
1594
|
+
.focus()
|
|
1595
|
+
.insertContent({ marks: [{ attrs: { href }, type: "link" }], text: href, type: "text" })
|
|
1596
|
+
.run();
|
|
1301
1597
|
return;
|
|
1302
1598
|
}
|
|
1303
|
-
|
|
1599
|
+
editor.chain().focus().extendMarkRange("link").setLink({ href }).run();
|
|
1304
1600
|
}
|
|
1305
1601
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorLinkComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1306
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorLinkComponent, isStandalone: true, selector: "mona-editor-link", ngImport: i0, template: "<mona-button-group selection=\"single\" [size]=\"'small'\">\n <button\n monaButton\n [selected]=\"linkSelected()\"\n [toggleable]=\"false\"\n (click)=\"onLinkDialogDisplay()\"\n [title]=\"messages().insertLink\">\n <i class=\"ri-link-m\"></i>\n </button>\n <button
|
|
1602
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorLinkComponent, isStandalone: true, selector: "mona-editor-link", ngImport: i0, template: "<mona-button-group selection=\"single\" [size]=\"'small'\" [aria-label]=\"messages().linkGroup\">\n <button\n monaButton\n [selected]=\"linkSelected()\"\n [toggleable]=\"false\"\n aria-haspopup=\"dialog\"\n (click)=\"onLinkDialogDisplay()\"\n [title]=\"messages().insertLink\">\n <i class=\"ri-link-m\"></i>\n </button>\n <button\n monaButton\n [toggleable]=\"false\"\n [disabled]=\"unlinkDisabled()\"\n (click)=\"onUnlinkClick()\"\n [title]=\"messages().removeLink\">\n <i class=\"ri-link-unlink-m\"></i>\n </button>\n</mona-button-group>\n", dependencies: [{ kind: "component", type: ButtonGroupComponent, selector: "mona-button-group", inputs: ["allowEmpty", "aria-label", "disabled", "look", "rounded", "selection", "size", "class"], outputs: ["buttonClick", "disabledChange", "selectionChange"] }, { kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }] }); }
|
|
1307
1603
|
}
|
|
1308
1604
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorLinkComponent, decorators: [{
|
|
1309
1605
|
type: Component,
|
|
1310
|
-
args: [{ selector: "mona-editor-link", imports: [ButtonGroupComponent, ButtonDirective], template: "<mona-button-group selection=\"single\" [size]=\"'small'\">\n <button\n monaButton\n [selected]=\"linkSelected()\"\n [toggleable]=\"false\"\n (click)=\"onLinkDialogDisplay()\"\n [title]=\"messages().insertLink\">\n <i class=\"ri-link-m\"></i>\n </button>\n <button
|
|
1606
|
+
args: [{ selector: "mona-editor-link", imports: [ButtonGroupComponent, ButtonDirective], template: "<mona-button-group selection=\"single\" [size]=\"'small'\" [aria-label]=\"messages().linkGroup\">\n <button\n monaButton\n [selected]=\"linkSelected()\"\n [toggleable]=\"false\"\n aria-haspopup=\"dialog\"\n (click)=\"onLinkDialogDisplay()\"\n [title]=\"messages().insertLink\">\n <i class=\"ri-link-m\"></i>\n </button>\n <button\n monaButton\n [toggleable]=\"false\"\n [disabled]=\"unlinkDisabled()\"\n (click)=\"onUnlinkClick()\"\n [title]=\"messages().removeLink\">\n <i class=\"ri-link-unlink-m\"></i>\n </button>\n</mona-button-group>\n" }]
|
|
1311
1607
|
}] });
|
|
1312
1608
|
|
|
1313
1609
|
class EditorListComponent {
|
|
@@ -1335,16 +1631,30 @@ class EditorListComponent {
|
|
|
1335
1631
|
this.#editorService.editor.chain().focus().toggleBulletList().run();
|
|
1336
1632
|
}
|
|
1337
1633
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1338
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorListComponent, isStandalone: true, selector: "mona-editor-list", ngImport: i0, template: "<mona-button-group selection=\"single\" [size]=\"'small'\">\n <button\n monaButton\n [selected]=\"unorderedListSelected()\"\n [toggleable]=\"false\"\n (click)=\"onUnorderedListToggle()\"\n [title]=\"messages().insertUnorderedList\">\n <i class=\"ri-list-unordered\"></i>\n </button>\n <button\n monaButton\n [selected]=\"orderedListSelected()\"\n [toggleable]=\"false\"\n (click)=\"onOrderedListToggle()\"\n [title]=\"messages().insertOrderedList\">\n <i class=\"ri-list-ordered-2\"></i>\n </button>\n</mona-button-group>\n", dependencies: [{ kind: "component", type: ButtonGroupComponent, selector: "mona-button-group", inputs: ["allowEmpty", "aria-label", "disabled", "look", "rounded", "selection", "size", "class"], outputs: ["buttonClick", "disabledChange", "selectionChange"] }, { kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }] }); }
|
|
1634
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorListComponent, isStandalone: true, selector: "mona-editor-list", ngImport: i0, template: "<mona-button-group selection=\"single\" [size]=\"'small'\" [aria-label]=\"messages().listGroup\">\n <button\n monaButton\n [selected]=\"unorderedListSelected()\"\n [monaEditorPressed]=\"unorderedListSelected()\"\n [toggleable]=\"false\"\n (click)=\"onUnorderedListToggle()\"\n [title]=\"messages().insertUnorderedList\">\n <i class=\"ri-list-unordered\"></i>\n </button>\n <button\n monaButton\n [selected]=\"orderedListSelected()\"\n [monaEditorPressed]=\"orderedListSelected()\"\n [toggleable]=\"false\"\n (click)=\"onOrderedListToggle()\"\n [title]=\"messages().insertOrderedList\">\n <i class=\"ri-list-ordered-2\"></i>\n </button>\n</mona-button-group>\n", dependencies: [{ kind: "component", type: ButtonGroupComponent, selector: "mona-button-group", inputs: ["allowEmpty", "aria-label", "disabled", "look", "rounded", "selection", "size", "class"], outputs: ["buttonClick", "disabledChange", "selectionChange"] }, { kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }, { kind: "directive", type: EditorPressedDirective, selector: "button[monaEditorPressed]", inputs: ["monaEditorPressed"] }] }); }
|
|
1339
1635
|
}
|
|
1340
1636
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorListComponent, decorators: [{
|
|
1341
1637
|
type: Component,
|
|
1342
|
-
args: [{ selector: "mona-editor-list", imports: [ButtonGroupComponent, ButtonDirective], template: "<mona-button-group selection=\"single\" [size]=\"'small'\">\n <button\n monaButton\n [selected]=\"unorderedListSelected()\"\n [toggleable]=\"false\"\n (click)=\"onUnorderedListToggle()\"\n [title]=\"messages().insertUnorderedList\">\n <i class=\"ri-list-unordered\"></i>\n </button>\n <button\n monaButton\n [selected]=\"orderedListSelected()\"\n [toggleable]=\"false\"\n (click)=\"onOrderedListToggle()\"\n [title]=\"messages().insertOrderedList\">\n <i class=\"ri-list-ordered-2\"></i>\n </button>\n</mona-button-group>\n" }]
|
|
1638
|
+
args: [{ selector: "mona-editor-list", imports: [ButtonGroupComponent, ButtonDirective, EditorPressedDirective], template: "<mona-button-group selection=\"single\" [size]=\"'small'\" [aria-label]=\"messages().listGroup\">\n <button\n monaButton\n [selected]=\"unorderedListSelected()\"\n [monaEditorPressed]=\"unorderedListSelected()\"\n [toggleable]=\"false\"\n (click)=\"onUnorderedListToggle()\"\n [title]=\"messages().insertUnorderedList\">\n <i class=\"ri-list-unordered\"></i>\n </button>\n <button\n monaButton\n [selected]=\"orderedListSelected()\"\n [monaEditorPressed]=\"orderedListSelected()\"\n [toggleable]=\"false\"\n (click)=\"onOrderedListToggle()\"\n [title]=\"messages().insertOrderedList\">\n <i class=\"ri-list-ordered-2\"></i>\n </button>\n</mona-button-group>\n" }]
|
|
1343
1639
|
}] });
|
|
1344
1640
|
|
|
1641
|
+
const SIZE = 8;
|
|
1642
|
+
/**
|
|
1643
|
+
* The table size picker: an 8 × 8 grid of buttons, one Tab stop. The arrows (mirrored in right-to-left text), Home
|
|
1644
|
+
* and End move the size, Enter or Space inserts it, and the size is read out below the grid.
|
|
1645
|
+
*/
|
|
1345
1646
|
class EditorTableCreatorComponent {
|
|
1346
1647
|
constructor() {
|
|
1347
|
-
this
|
|
1648
|
+
this.#direction = injectComponentDirection();
|
|
1649
|
+
this.#host = inject(ElementRef);
|
|
1650
|
+
this.#i18n = inject(MonaI18nService);
|
|
1651
|
+
this.cells = Array.from({ length: SIZE * SIZE }, (_, index) => ({
|
|
1652
|
+
col: (index % SIZE) + 1,
|
|
1653
|
+
row: Math.floor(index / SIZE) + 1
|
|
1654
|
+
}));
|
|
1655
|
+
this.highlighted = signal({ col: 1, row: 1 }, /* @ts-ignore */
|
|
1656
|
+
...(ngDevMode ? [{ debugName: "highlighted" }] : /* istanbul ignore next */ []));
|
|
1657
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1348
1658
|
this.tableCreatorCellClass = computed(() => {
|
|
1349
1659
|
return editorTableCreatorCellThemeVariants();
|
|
1350
1660
|
}, /* @ts-ignore */
|
|
@@ -1355,36 +1665,73 @@ class EditorTableCreatorComponent {
|
|
|
1355
1665
|
...(ngDevMode ? [{ debugName: "tableCreatorClass" }] : /* istanbul ignore next */ []));
|
|
1356
1666
|
this.insert = output();
|
|
1357
1667
|
}
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1668
|
+
#direction;
|
|
1669
|
+
#host;
|
|
1670
|
+
#i18n;
|
|
1671
|
+
isHighlighted(cell) {
|
|
1672
|
+
const highlighted = this.highlighted();
|
|
1673
|
+
return cell.row <= highlighted.row && cell.col <= highlighted.col;
|
|
1674
|
+
}
|
|
1675
|
+
isTabStop(cell) {
|
|
1676
|
+
const highlighted = this.highlighted();
|
|
1677
|
+
return cell.row === highlighted.row && cell.col === highlighted.col;
|
|
1678
|
+
}
|
|
1679
|
+
onCellClick(cell) {
|
|
1680
|
+
this.insert.emit({ col: cell.col, row: cell.row });
|
|
1681
|
+
}
|
|
1682
|
+
onCellFocus(cell) {
|
|
1683
|
+
this.highlighted.set(cell);
|
|
1684
|
+
}
|
|
1685
|
+
onCellPointerEnter(cell) {
|
|
1686
|
+
this.highlighted.set(cell);
|
|
1687
|
+
}
|
|
1688
|
+
onKeydown(event) {
|
|
1689
|
+
const { col, row } = this.highlighted();
|
|
1690
|
+
const forward = this.#direction() === "rtl" ? -1 : 1;
|
|
1691
|
+
let next;
|
|
1692
|
+
switch (event.key) {
|
|
1693
|
+
case "ArrowDown":
|
|
1694
|
+
next = { col, row: row + 1 };
|
|
1695
|
+
break;
|
|
1696
|
+
case "ArrowUp":
|
|
1697
|
+
next = { col, row: row - 1 };
|
|
1698
|
+
break;
|
|
1699
|
+
case "ArrowRight":
|
|
1700
|
+
next = { col: col + forward, row };
|
|
1701
|
+
break;
|
|
1702
|
+
case "ArrowLeft":
|
|
1703
|
+
next = { col: col - forward, row };
|
|
1704
|
+
break;
|
|
1705
|
+
case "Home":
|
|
1706
|
+
next = { col: 1, row: event.ctrlKey ? 1 : row };
|
|
1707
|
+
break;
|
|
1708
|
+
case "End":
|
|
1709
|
+
next = { col: SIZE, row: event.ctrlKey ? SIZE : row };
|
|
1710
|
+
break;
|
|
1711
|
+
default:
|
|
1712
|
+
return;
|
|
1713
|
+
}
|
|
1714
|
+
event.preventDefault();
|
|
1715
|
+
const clamped = {
|
|
1716
|
+
col: Math.min(Math.max(next.col, 1), SIZE),
|
|
1717
|
+
row: Math.min(Math.max(next.row, 1), SIZE)
|
|
1718
|
+
};
|
|
1719
|
+
this.highlighted.set(clamped);
|
|
1720
|
+
const index = (clamped.row - 1) * SIZE + (clamped.col - 1);
|
|
1721
|
+
this.#host.nativeElement.querySelectorAll("button").item(index)?.focus();
|
|
1367
1722
|
}
|
|
1368
1723
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorTableCreatorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1369
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: EditorTableCreatorComponent, isStandalone: true, selector: "mona-editor-table-creator", outputs: { insert: "insert" }, ngImport: i0, template: "<div [
|
|
1724
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: EditorTableCreatorComponent, isStandalone: true, selector: "mona-editor-table-creator", outputs: { insert: "insert" }, ngImport: i0, template: "<div role=\"group\" [attr.aria-label]=\"messages().insertTable\" (keydown)=\"onKeydown($event)\">\n <div [class]=\"tableCreatorClass()\">\n @for (cell of cells; track $index) {\n <button\n type=\"button\"\n [class]=\"tableCreatorCellClass()\"\n [attr.data-highlighted]=\"isHighlighted(cell) || null\"\n [attr.tabindex]=\"isTabStop(cell) ? 0 : -1\"\n [attr.aria-label]=\"messages().tableSize(cell.row, cell.col)\"\n (click)=\"onCellClick(cell)\"\n (focus)=\"onCellFocus(cell)\"\n (pointerenter)=\"onCellPointerEnter(cell)\"></button>\n }\n </div>\n <p class=\"m-0 px-1 pb-1 text-center text-sm\" aria-live=\"polite\">\n {{ messages().tableSize(highlighted().row, highlighted().col) }}\n </p>\n</div>\n" }); }
|
|
1370
1725
|
}
|
|
1371
1726
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorTableCreatorComponent, decorators: [{
|
|
1372
1727
|
type: Component,
|
|
1373
|
-
args: [{ selector: "mona-editor-table-creator", template: "<div [
|
|
1728
|
+
args: [{ selector: "mona-editor-table-creator", template: "<div role=\"group\" [attr.aria-label]=\"messages().insertTable\" (keydown)=\"onKeydown($event)\">\n <div [class]=\"tableCreatorClass()\">\n @for (cell of cells; track $index) {\n <button\n type=\"button\"\n [class]=\"tableCreatorCellClass()\"\n [attr.data-highlighted]=\"isHighlighted(cell) || null\"\n [attr.tabindex]=\"isTabStop(cell) ? 0 : -1\"\n [attr.aria-label]=\"messages().tableSize(cell.row, cell.col)\"\n (click)=\"onCellClick(cell)\"\n (focus)=\"onCellFocus(cell)\"\n (pointerenter)=\"onCellPointerEnter(cell)\"></button>\n }\n </div>\n <p class=\"m-0 px-1 pb-1 text-center text-sm\" aria-live=\"polite\">\n {{ messages().tableSize(highlighted().row, highlighted().col) }}\n </p>\n</div>\n" }]
|
|
1374
1729
|
}], propDecorators: { insert: [{ type: i0.Output, args: ["insert"] }] } });
|
|
1375
1730
|
|
|
1376
1731
|
class EditorTableComponent {
|
|
1377
1732
|
constructor() {
|
|
1378
1733
|
this.#editorService = inject(EditorService);
|
|
1379
1734
|
this.#i18n = inject(MonaI18nService);
|
|
1380
|
-
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1381
|
-
this.addColumnBeforeDisabled = computed(() => {
|
|
1382
|
-
this.#editorService.state();
|
|
1383
|
-
const isTable = this.#editorService.editor.isActive("table");
|
|
1384
|
-
const canAddColumnBefore = this.#editorService.editor.can().addColumnBefore();
|
|
1385
|
-
return !isTable || !canAddColumnBefore;
|
|
1386
|
-
}, /* @ts-ignore */
|
|
1387
|
-
...(ngDevMode ? [{ debugName: "addColumnBeforeDisabled" }] : /* istanbul ignore next */ []));
|
|
1388
1735
|
this.addColumnAfterDisabled = computed(() => {
|
|
1389
1736
|
this.#editorService.state();
|
|
1390
1737
|
const isTable = this.#editorService.editor.isActive("table");
|
|
@@ -1392,13 +1739,13 @@ class EditorTableComponent {
|
|
|
1392
1739
|
return !isTable || !canAddColumnAfter;
|
|
1393
1740
|
}, /* @ts-ignore */
|
|
1394
1741
|
...(ngDevMode ? [{ debugName: "addColumnAfterDisabled" }] : /* istanbul ignore next */ []));
|
|
1395
|
-
this.
|
|
1742
|
+
this.addColumnBeforeDisabled = computed(() => {
|
|
1396
1743
|
this.#editorService.state();
|
|
1397
1744
|
const isTable = this.#editorService.editor.isActive("table");
|
|
1398
|
-
const
|
|
1399
|
-
return !isTable || !
|
|
1745
|
+
const canAddColumnBefore = this.#editorService.editor.can().addColumnBefore();
|
|
1746
|
+
return !isTable || !canAddColumnBefore;
|
|
1400
1747
|
}, /* @ts-ignore */
|
|
1401
|
-
...(ngDevMode ? [{ debugName: "
|
|
1748
|
+
...(ngDevMode ? [{ debugName: "addColumnBeforeDisabled" }] : /* istanbul ignore next */ []));
|
|
1402
1749
|
this.addRowAfterDisabled = computed(() => {
|
|
1403
1750
|
this.#editorService.state();
|
|
1404
1751
|
const isTable = this.#editorService.editor.isActive("table");
|
|
@@ -1406,6 +1753,13 @@ class EditorTableComponent {
|
|
|
1406
1753
|
return !isTable || !canAddRowAfter;
|
|
1407
1754
|
}, /* @ts-ignore */
|
|
1408
1755
|
...(ngDevMode ? [{ debugName: "addRowAfterDisabled" }] : /* istanbul ignore next */ []));
|
|
1756
|
+
this.addRowBeforeDisabled = computed(() => {
|
|
1757
|
+
this.#editorService.state();
|
|
1758
|
+
const isTable = this.#editorService.editor.isActive("table");
|
|
1759
|
+
const canAddRowBefore = this.#editorService.editor.can().addRowBefore();
|
|
1760
|
+
return !isTable || !canAddRowBefore;
|
|
1761
|
+
}, /* @ts-ignore */
|
|
1762
|
+
...(ngDevMode ? [{ debugName: "addRowBeforeDisabled" }] : /* istanbul ignore next */ []));
|
|
1409
1763
|
this.deleteColumnDisabled = computed(() => {
|
|
1410
1764
|
this.#editorService.state();
|
|
1411
1765
|
const isTable = this.#editorService.editor.isActive("table");
|
|
@@ -1434,6 +1788,7 @@ class EditorTableComponent {
|
|
|
1434
1788
|
return !isTable || !canMergeCells;
|
|
1435
1789
|
}, /* @ts-ignore */
|
|
1436
1790
|
...(ngDevMode ? [{ debugName: "mergeCellsDisabled" }] : /* istanbul ignore next */ []));
|
|
1791
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1437
1792
|
this.popover = viewChild("popoverComponent", /* @ts-ignore */
|
|
1438
1793
|
...(ngDevMode ? [{ debugName: "popover" }] : /* istanbul ignore next */ []));
|
|
1439
1794
|
this.splitCellDisabled = computed(() => {
|
|
@@ -1453,18 +1808,18 @@ class EditorTableComponent {
|
|
|
1453
1808
|
}
|
|
1454
1809
|
#editorService;
|
|
1455
1810
|
#i18n;
|
|
1456
|
-
onAddColumnBeforeClick() {
|
|
1457
|
-
this.#editorService.editor.chain().focus().addColumnBefore().run();
|
|
1458
|
-
}
|
|
1459
1811
|
onAddColumnAfterClick() {
|
|
1460
1812
|
this.#editorService.editor.chain().focus().addColumnAfter().run();
|
|
1461
1813
|
}
|
|
1462
|
-
|
|
1463
|
-
this.#editorService.editor.chain().focus().
|
|
1814
|
+
onAddColumnBeforeClick() {
|
|
1815
|
+
this.#editorService.editor.chain().focus().addColumnBefore().run();
|
|
1464
1816
|
}
|
|
1465
1817
|
onAddRowAfterClick() {
|
|
1466
1818
|
this.#editorService.editor.chain().focus().addRowAfter().run();
|
|
1467
1819
|
}
|
|
1820
|
+
onAddRowBeforeClick() {
|
|
1821
|
+
this.#editorService.editor.chain().focus().addRowBefore().run();
|
|
1822
|
+
}
|
|
1468
1823
|
onDeleteColumnClick() {
|
|
1469
1824
|
this.#editorService.editor.chain().focus().deleteColumn().run();
|
|
1470
1825
|
}
|
|
@@ -1482,20 +1837,24 @@ class EditorTableComponent {
|
|
|
1482
1837
|
}
|
|
1483
1838
|
onTableInsert(event) {
|
|
1484
1839
|
this.popover()?.close();
|
|
1485
|
-
this.#editorService.editor
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1840
|
+
this.#editorService.editor
|
|
1841
|
+
.chain()
|
|
1842
|
+
.focus()
|
|
1843
|
+
.insertTable({
|
|
1844
|
+
cols: event.col,
|
|
1845
|
+
rows: event.row
|
|
1846
|
+
})
|
|
1847
|
+
.run();
|
|
1489
1848
|
}
|
|
1490
1849
|
onToggleHeaderRow() {
|
|
1491
1850
|
this.#editorService.editor.chain().focus().toggleHeaderRow().run();
|
|
1492
1851
|
}
|
|
1493
1852
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1494
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.6", type: EditorTableComponent, isStandalone: true, selector: "mona-editor-table", viewQueries: [{ propertyName: "popover", first: true, predicate: ["popoverComponent"], descendants: true, isSignal: true }], ngImport: i0, template: "<mona-button-group selection=\"single\" [size]=\"'small'\">\n <button monaButton [title]=\"messages().insertTable\" #insertTableButton>\n <i class=\"ri-grid-line\"></i>\n </button>\n <button\n monaButton\n [disabled]=\"addColumnBeforeDisabled()\"\n (click)=\"onAddColumnBeforeClick()\"\n [title]=\"messages().addColumnBefore\">\n <i class=\"ri-insert-column-left\"></i>\n </button>\n <button monaButton [disabled]=\"addColumnAfterDisabled()\" (click)=\"onAddColumnAfterClick()\" [title]=\"messages().addColumnAfter\">\n <i class=\"ri-insert-column-right\"></i>\n </button>\n <button monaButton [disabled]=\"addRowBeforeDisabled()\" (click)=\"onAddRowBeforeClick()\" [title]=\"messages().addRowBefore\">\n <i class=\"ri-insert-row-top\"></i>\n </button>\n <button monaButton [disabled]=\"addRowAfterDisabled()\" (click)=\"onAddRowAfterClick()\" [title]=\"messages().addRowAfter\">\n <i class=\"ri-insert-row-bottom\"></i>\n </button>\n <button monaButton [disabled]=\"deleteColumnDisabled()\" (click)=\"onDeleteColumnClick()\" [title]=\"messages().deleteColumn\">\n <i class=\"ri-delete-column\"></i>\n </button>\n <button monaButton [disabled]=\"deleteRowDisabled()\" (click)=\"onDeleteRowClick()\" [title]=\"messages().deleteRow\">\n <i class=\"ri-delete-row\"></i>\n </button>\n <button monaButton [disabled]=\"mergeCellsDisabled()\" (click)=\"onMergeCellsClick()\" [title]=\"messages().mergeCells\">\n <i class=\"ri-merge-cells-horizontal\"></i>\n </button>\n <button monaButton [disabled]=\"splitCellDisabled()\" (click)=\"onSplitCellClick()\" [title]=\"messages().splitCell\">\n <i class=\"ri-split-cells-horizontal\"></i>\n </button>\n <button monaButton [disabled]=\"toggleHeaderRowDisabled()\" (click)=\"onToggleHeaderRow()\" [title]=\"messages().toggleHeaderRow\">\n <i class=\"ri-table-line\"></i>\n </button>\n <button monaButton [disabled]=\"deleteTableDisabled()\" (click)=\"onDeleteTableClick()\" [title]=\"messages().deleteTable\">\n <i class=\"ri-close-large-line\"></i>\n </button>\n</mona-button-group>\n\n<mona-popover [target]=\"insertTableButton\" position=\"bottom\" #popoverComponent>\n <mona-editor-table-creator (insert)=\"onTableInsert($event)\"></mona-editor-table-creator>\n</mona-popover>\n", dependencies: [{ kind: "component", type: ButtonGroupComponent, selector: "mona-button-group", inputs: ["allowEmpty", "aria-label", "disabled", "look", "rounded", "selection", "size", "class"], outputs: ["buttonClick", "disabledChange", "selectionChange"] }, { kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }, { kind: "component", type: PopoverComponent, selector: "mona-popover", inputs: ["displayArrow", "position", "rounded", "target", "title", "trigger"], outputs: ["
|
|
1853
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.6", type: EditorTableComponent, isStandalone: true, selector: "mona-editor-table", viewQueries: [{ propertyName: "popover", first: true, predicate: ["popoverComponent"], descendants: true, isSignal: true }], ngImport: i0, template: "<mona-button-group selection=\"single\" [size]=\"'small'\" [aria-label]=\"messages().tableGroup\">\n <button monaButton [toggleable]=\"false\" [title]=\"messages().insertTable\" #insertTableButton>\n <i class=\"ri-grid-line\"></i>\n </button>\n <button\n monaButton\n [toggleable]=\"false\"\n [disabled]=\"addColumnBeforeDisabled()\"\n (click)=\"onAddColumnBeforeClick()\"\n [title]=\"messages().addColumnBefore\">\n <i class=\"ri-insert-column-left\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"addColumnAfterDisabled()\" (click)=\"onAddColumnAfterClick()\" [title]=\"messages().addColumnAfter\">\n <i class=\"ri-insert-column-right\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"addRowBeforeDisabled()\" (click)=\"onAddRowBeforeClick()\" [title]=\"messages().addRowBefore\">\n <i class=\"ri-insert-row-top\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"addRowAfterDisabled()\" (click)=\"onAddRowAfterClick()\" [title]=\"messages().addRowAfter\">\n <i class=\"ri-insert-row-bottom\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"deleteColumnDisabled()\" (click)=\"onDeleteColumnClick()\" [title]=\"messages().deleteColumn\">\n <i class=\"ri-delete-column\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"deleteRowDisabled()\" (click)=\"onDeleteRowClick()\" [title]=\"messages().deleteRow\">\n <i class=\"ri-delete-row\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"mergeCellsDisabled()\" (click)=\"onMergeCellsClick()\" [title]=\"messages().mergeCells\">\n <i class=\"ri-merge-cells-horizontal\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"splitCellDisabled()\" (click)=\"onSplitCellClick()\" [title]=\"messages().splitCell\">\n <i class=\"ri-split-cells-horizontal\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"toggleHeaderRowDisabled()\" (click)=\"onToggleHeaderRow()\" [title]=\"messages().toggleHeaderRow\">\n <i class=\"ri-table-line\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"deleteTableDisabled()\" (click)=\"onDeleteTableClick()\" [title]=\"messages().deleteTable\">\n <i class=\"ri-close-large-line\"></i>\n </button>\n</mona-button-group>\n\n<mona-popover [target]=\"insertTableButton\" position=\"bottom\" #popoverComponent>\n <mona-editor-table-creator (insert)=\"onTableInsert($event)\"></mona-editor-table-creator>\n</mona-popover>\n", dependencies: [{ kind: "component", type: ButtonGroupComponent, selector: "mona-button-group", inputs: ["allowEmpty", "aria-label", "disabled", "look", "rounded", "selection", "size", "class"], outputs: ["buttonClick", "disabledChange", "selectionChange"] }, { kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }, { kind: "component", type: PopoverComponent, selector: "mona-popover", inputs: ["ariaLabel", "autoFocus", "closeOnEscape", "closeOnOutsideClick", "displayArrow", "position", "rounded", "target", "title", "trigger"], outputs: ["hidden", "hide", "show", "shown"], exportAs: ["monaPopover"] }, { kind: "component", type: EditorTableCreatorComponent, selector: "mona-editor-table-creator", outputs: ["insert"] }] }); }
|
|
1495
1854
|
}
|
|
1496
1855
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorTableComponent, decorators: [{
|
|
1497
1856
|
type: Component,
|
|
1498
|
-
args: [{ selector: "mona-editor-table", imports: [ButtonGroupComponent, ButtonDirective, PopoverComponent, EditorTableCreatorComponent], template: "<mona-button-group selection=\"single\" [size]=\"'small'\">\n <button monaButton [title]=\"messages().insertTable\" #insertTableButton>\n <i class=\"ri-grid-line\"></i>\n </button>\n <button\n monaButton\n [disabled]=\"addColumnBeforeDisabled()\"\n (click)=\"onAddColumnBeforeClick()\"\n [title]=\"messages().addColumnBefore\">\n <i class=\"ri-insert-column-left\"></i>\n </button>\n <button monaButton [disabled]=\"addColumnAfterDisabled()\" (click)=\"onAddColumnAfterClick()\" [title]=\"messages().addColumnAfter\">\n <i class=\"ri-insert-column-right\"></i>\n </button>\n <button monaButton [disabled]=\"addRowBeforeDisabled()\" (click)=\"onAddRowBeforeClick()\" [title]=\"messages().addRowBefore\">\n <i class=\"ri-insert-row-top\"></i>\n </button>\n <button monaButton [disabled]=\"addRowAfterDisabled()\" (click)=\"onAddRowAfterClick()\" [title]=\"messages().addRowAfter\">\n <i class=\"ri-insert-row-bottom\"></i>\n </button>\n <button monaButton [disabled]=\"deleteColumnDisabled()\" (click)=\"onDeleteColumnClick()\" [title]=\"messages().deleteColumn\">\n <i class=\"ri-delete-column\"></i>\n </button>\n <button monaButton [disabled]=\"deleteRowDisabled()\" (click)=\"onDeleteRowClick()\" [title]=\"messages().deleteRow\">\n <i class=\"ri-delete-row\"></i>\n </button>\n <button monaButton [disabled]=\"mergeCellsDisabled()\" (click)=\"onMergeCellsClick()\" [title]=\"messages().mergeCells\">\n <i class=\"ri-merge-cells-horizontal\"></i>\n </button>\n <button monaButton [disabled]=\"splitCellDisabled()\" (click)=\"onSplitCellClick()\" [title]=\"messages().splitCell\">\n <i class=\"ri-split-cells-horizontal\"></i>\n </button>\n <button monaButton [disabled]=\"toggleHeaderRowDisabled()\" (click)=\"onToggleHeaderRow()\" [title]=\"messages().toggleHeaderRow\">\n <i class=\"ri-table-line\"></i>\n </button>\n <button monaButton [disabled]=\"deleteTableDisabled()\" (click)=\"onDeleteTableClick()\" [title]=\"messages().deleteTable\">\n <i class=\"ri-close-large-line\"></i>\n </button>\n</mona-button-group>\n\n<mona-popover [target]=\"insertTableButton\" position=\"bottom\" #popoverComponent>\n <mona-editor-table-creator (insert)=\"onTableInsert($event)\"></mona-editor-table-creator>\n</mona-popover>\n" }]
|
|
1857
|
+
args: [{ selector: "mona-editor-table", imports: [ButtonGroupComponent, ButtonDirective, PopoverComponent, EditorTableCreatorComponent], template: "<mona-button-group selection=\"single\" [size]=\"'small'\" [aria-label]=\"messages().tableGroup\">\n <button monaButton [toggleable]=\"false\" [title]=\"messages().insertTable\" #insertTableButton>\n <i class=\"ri-grid-line\"></i>\n </button>\n <button\n monaButton\n [toggleable]=\"false\"\n [disabled]=\"addColumnBeforeDisabled()\"\n (click)=\"onAddColumnBeforeClick()\"\n [title]=\"messages().addColumnBefore\">\n <i class=\"ri-insert-column-left\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"addColumnAfterDisabled()\" (click)=\"onAddColumnAfterClick()\" [title]=\"messages().addColumnAfter\">\n <i class=\"ri-insert-column-right\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"addRowBeforeDisabled()\" (click)=\"onAddRowBeforeClick()\" [title]=\"messages().addRowBefore\">\n <i class=\"ri-insert-row-top\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"addRowAfterDisabled()\" (click)=\"onAddRowAfterClick()\" [title]=\"messages().addRowAfter\">\n <i class=\"ri-insert-row-bottom\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"deleteColumnDisabled()\" (click)=\"onDeleteColumnClick()\" [title]=\"messages().deleteColumn\">\n <i class=\"ri-delete-column\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"deleteRowDisabled()\" (click)=\"onDeleteRowClick()\" [title]=\"messages().deleteRow\">\n <i class=\"ri-delete-row\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"mergeCellsDisabled()\" (click)=\"onMergeCellsClick()\" [title]=\"messages().mergeCells\">\n <i class=\"ri-merge-cells-horizontal\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"splitCellDisabled()\" (click)=\"onSplitCellClick()\" [title]=\"messages().splitCell\">\n <i class=\"ri-split-cells-horizontal\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"toggleHeaderRowDisabled()\" (click)=\"onToggleHeaderRow()\" [title]=\"messages().toggleHeaderRow\">\n <i class=\"ri-table-line\"></i>\n </button>\n <button monaButton [toggleable]=\"false\" [disabled]=\"deleteTableDisabled()\" (click)=\"onDeleteTableClick()\" [title]=\"messages().deleteTable\">\n <i class=\"ri-close-large-line\"></i>\n </button>\n</mona-button-group>\n\n<mona-popover [target]=\"insertTableButton\" position=\"bottom\" #popoverComponent>\n <mona-editor-table-creator (insert)=\"onTableInsert($event)\"></mona-editor-table-creator>\n</mona-popover>\n" }]
|
|
1499
1858
|
}], propDecorators: { popover: [{ type: i0.ViewChild, args: ["popoverComponent", { isSignal: true }] }] } });
|
|
1500
1859
|
|
|
1501
1860
|
class EditorTaskListComponent {
|
|
@@ -1515,85 +1874,154 @@ class EditorTaskListComponent {
|
|
|
1515
1874
|
this.#editorService.editor.chain().focus().toggleTaskList().run();
|
|
1516
1875
|
}
|
|
1517
1876
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorTaskListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1518
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorTaskListComponent, isStandalone: true, selector: "mona-editor-task-list", ngImport: i0, template: "<button monaButton [selected]=\"taskSelected()\" [size]=\"'small'\" (click)=\"onTaskToggle()\" [title]=\"messages().insertTaskList\">\n <i class=\"ri-checkbox-fill\"></i>\n</button>\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }] }); }
|
|
1877
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorTaskListComponent, isStandalone: true, selector: "mona-editor-task-list", ngImport: i0, template: "<button monaButton [selected]=\"taskSelected()\" [monaEditorPressed]=\"taskSelected()\" [size]=\"'small'\" (click)=\"onTaskToggle()\" [title]=\"messages().insertTaskList\">\n <i class=\"ri-checkbox-fill\"></i>\n</button>\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }, { kind: "directive", type: EditorPressedDirective, selector: "button[monaEditorPressed]", inputs: ["monaEditorPressed"] }] }); }
|
|
1519
1878
|
}
|
|
1520
1879
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorTaskListComponent, decorators: [{
|
|
1521
1880
|
type: Component,
|
|
1522
|
-
args: [{ selector: "mona-editor-task-list", imports: [ButtonDirective], template: "<button monaButton [selected]=\"taskSelected()\" [size]=\"'small'\" (click)=\"onTaskToggle()\" [title]=\"messages().insertTaskList\">\n <i class=\"ri-checkbox-fill\"></i>\n</button>\n" }]
|
|
1881
|
+
args: [{ selector: "mona-editor-task-list", imports: [ButtonDirective, EditorPressedDirective], template: "<button monaButton [selected]=\"taskSelected()\" [monaEditorPressed]=\"taskSelected()\" [size]=\"'small'\" (click)=\"onTaskToggle()\" [title]=\"messages().insertTaskList\">\n <i class=\"ri-checkbox-fill\"></i>\n</button>\n" }]
|
|
1523
1882
|
}] });
|
|
1524
1883
|
|
|
1884
|
+
/**
|
|
1885
|
+
* Aligns paragraphs and headings to the start or end of the line, so the buttons mean the same in right-to-left text.
|
|
1886
|
+
* Content with a physical `left` or `right` alignment (from older HTML) shows as start or end in the current
|
|
1887
|
+
* direction.
|
|
1888
|
+
*/
|
|
1525
1889
|
class EditorTextAlignmentsComponent {
|
|
1526
1890
|
constructor() {
|
|
1527
|
-
this.#
|
|
1528
|
-
this.#i18n = inject(MonaI18nService);
|
|
1529
|
-
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1530
|
-
this.alignCenterSelected = computed(() => {
|
|
1891
|
+
this.#alignment = computed(() => {
|
|
1531
1892
|
this.#editorService.state();
|
|
1532
|
-
|
|
1893
|
+
const editor = this.#editorService.editor;
|
|
1894
|
+
const rtl = this.#direction() === "rtl";
|
|
1895
|
+
if (editor.isActive({ textAlign: "center" })) {
|
|
1896
|
+
return "center";
|
|
1897
|
+
}
|
|
1898
|
+
if (editor.isActive({ textAlign: "justify" })) {
|
|
1899
|
+
return "justify";
|
|
1900
|
+
}
|
|
1901
|
+
if (editor.isActive({ textAlign: "start" }) || editor.isActive({ textAlign: rtl ? "right" : "left" })) {
|
|
1902
|
+
return "start";
|
|
1903
|
+
}
|
|
1904
|
+
if (editor.isActive({ textAlign: "end" }) || editor.isActive({ textAlign: rtl ? "left" : "right" })) {
|
|
1905
|
+
return "end";
|
|
1906
|
+
}
|
|
1907
|
+
return null;
|
|
1533
1908
|
}, /* @ts-ignore */
|
|
1909
|
+
...(ngDevMode ? [{ debugName: "#alignment" }] : /* istanbul ignore next */ []));
|
|
1910
|
+
this.#direction = injectComponentDirection();
|
|
1911
|
+
this.#editorService = inject(EditorService);
|
|
1912
|
+
this.#i18n = inject(MonaI18nService);
|
|
1913
|
+
this.alignCenterSelected = computed(() => this.#alignment() === "center", /* @ts-ignore */
|
|
1534
1914
|
...(ngDevMode ? [{ debugName: "alignCenterSelected" }] : /* istanbul ignore next */ []));
|
|
1535
|
-
this.
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
}, /* @ts-ignore */
|
|
1915
|
+
this.alignEndSelected = computed(() => this.#alignment() === "end", /* @ts-ignore */
|
|
1916
|
+
...(ngDevMode ? [{ debugName: "alignEndSelected" }] : /* istanbul ignore next */ []));
|
|
1917
|
+
this.alignJustifySelected = computed(() => this.#alignment() === "justify", /* @ts-ignore */
|
|
1539
1918
|
...(ngDevMode ? [{ debugName: "alignJustifySelected" }] : /* istanbul ignore next */ []));
|
|
1540
|
-
this.
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
this.
|
|
1546
|
-
|
|
1547
|
-
return this.#editorService.editor.isActive({ textAlign: "right" });
|
|
1548
|
-
}, /* @ts-ignore */
|
|
1549
|
-
...(ngDevMode ? [{ debugName: "alignRightSelected" }] : /* istanbul ignore next */ []));
|
|
1919
|
+
this.alignStartSelected = computed(() => this.#alignment() === "start", /* @ts-ignore */
|
|
1920
|
+
...(ngDevMode ? [{ debugName: "alignStartSelected" }] : /* istanbul ignore next */ []));
|
|
1921
|
+
this.endIcon = computed(() => (this.#direction() === "rtl" ? "ri-align-left" : "ri-align-right"), /* @ts-ignore */
|
|
1922
|
+
...(ngDevMode ? [{ debugName: "endIcon" }] : /* istanbul ignore next */ []));
|
|
1923
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1924
|
+
this.startIcon = computed(() => (this.#direction() === "rtl" ? "ri-align-right" : "ri-align-left"), /* @ts-ignore */
|
|
1925
|
+
...(ngDevMode ? [{ debugName: "startIcon" }] : /* istanbul ignore next */ []));
|
|
1550
1926
|
}
|
|
1927
|
+
#alignment;
|
|
1928
|
+
#direction;
|
|
1551
1929
|
#editorService;
|
|
1552
1930
|
#i18n;
|
|
1553
1931
|
onAlignCenter() {
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
this.#editorService.editor.chain().focus().setTextAlign("center").run();
|
|
1559
|
-
}
|
|
1932
|
+
this.#toggle("center");
|
|
1933
|
+
}
|
|
1934
|
+
onAlignEnd() {
|
|
1935
|
+
this.#toggle("end");
|
|
1560
1936
|
}
|
|
1561
1937
|
onAlignJustify() {
|
|
1562
|
-
|
|
1563
|
-
this.#editorService.editor.chain().focus().unsetTextAlign().run();
|
|
1564
|
-
}
|
|
1565
|
-
else {
|
|
1566
|
-
this.#editorService.editor.chain().focus().setTextAlign("justify").run();
|
|
1567
|
-
}
|
|
1938
|
+
this.#toggle("justify");
|
|
1568
1939
|
}
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
this.#editorService.editor.chain().focus().unsetTextAlign().run();
|
|
1572
|
-
}
|
|
1573
|
-
else {
|
|
1574
|
-
this.#editorService.editor.chain().focus().setTextAlign("left").run();
|
|
1575
|
-
}
|
|
1940
|
+
onAlignStart() {
|
|
1941
|
+
this.#toggle("start");
|
|
1576
1942
|
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1943
|
+
#toggle(alignment) {
|
|
1944
|
+
const chain = this.#editorService.editor.chain().focus();
|
|
1945
|
+
if (this.#alignment() === alignment) {
|
|
1946
|
+
chain.unsetTextAlign().run();
|
|
1580
1947
|
}
|
|
1581
1948
|
else {
|
|
1582
|
-
|
|
1949
|
+
chain.setTextAlign(alignment).run();
|
|
1583
1950
|
}
|
|
1584
1951
|
}
|
|
1585
1952
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorTextAlignmentsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1586
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorTextAlignmentsComponent, isStandalone: true, selector: "mona-editor-text-alignments", ngImport: i0, template: "<mona-button-group selection=\"single\" [size]=\"'small'\">\n <button\n monaButton\n [selected]=\"
|
|
1953
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: EditorTextAlignmentsComponent, isStandalone: true, selector: "mona-editor-text-alignments", ngImport: i0, template: "<mona-button-group selection=\"single\" [size]=\"'small'\" [aria-label]=\"messages().alignmentGroup\">\n <button\n monaButton\n [selected]=\"alignStartSelected()\"\n [monaEditorPressed]=\"alignStartSelected()\"\n [toggleable]=\"false\"\n (click)=\"onAlignStart()\"\n [title]=\"messages().alignStart\">\n <i [class]=\"startIcon()\"></i>\n </button>\n <button\n monaButton\n [selected]=\"alignCenterSelected()\"\n [monaEditorPressed]=\"alignCenterSelected()\"\n [toggleable]=\"false\"\n (click)=\"onAlignCenter()\"\n [title]=\"messages().alignCenter\">\n <i class=\"ri-align-center\"></i>\n </button>\n <button\n monaButton\n [selected]=\"alignEndSelected()\"\n [monaEditorPressed]=\"alignEndSelected()\"\n [toggleable]=\"false\"\n (click)=\"onAlignEnd()\"\n [title]=\"messages().alignEnd\">\n <i [class]=\"endIcon()\"></i>\n </button>\n <button\n monaButton\n [selected]=\"alignJustifySelected()\"\n [monaEditorPressed]=\"alignJustifySelected()\"\n [toggleable]=\"false\"\n (click)=\"onAlignJustify()\"\n [title]=\"messages().justify\">\n <i class=\"ri-align-justify\"></i>\n </button>\n</mona-button-group>\n", dependencies: [{ kind: "component", type: ButtonGroupComponent, selector: "mona-button-group", inputs: ["allowEmpty", "aria-label", "disabled", "look", "rounded", "selection", "size", "class"], outputs: ["buttonClick", "disabledChange", "selectionChange"] }, { kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class"], outputs: ["lookChange", "selectedChange"] }, { kind: "directive", type: EditorPressedDirective, selector: "button[monaEditorPressed]", inputs: ["monaEditorPressed"] }] }); }
|
|
1587
1954
|
}
|
|
1588
1955
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorTextAlignmentsComponent, decorators: [{
|
|
1589
1956
|
type: Component,
|
|
1590
|
-
args: [{ selector: "mona-editor-text-alignments", imports: [ButtonGroupComponent, ButtonDirective], template: "<mona-button-group selection=\"single\" [size]=\"'small'\">\n <button\n monaButton\n [selected]=\"
|
|
1957
|
+
args: [{ selector: "mona-editor-text-alignments", imports: [ButtonGroupComponent, ButtonDirective, EditorPressedDirective], template: "<mona-button-group selection=\"single\" [size]=\"'small'\" [aria-label]=\"messages().alignmentGroup\">\n <button\n monaButton\n [selected]=\"alignStartSelected()\"\n [monaEditorPressed]=\"alignStartSelected()\"\n [toggleable]=\"false\"\n (click)=\"onAlignStart()\"\n [title]=\"messages().alignStart\">\n <i [class]=\"startIcon()\"></i>\n </button>\n <button\n monaButton\n [selected]=\"alignCenterSelected()\"\n [monaEditorPressed]=\"alignCenterSelected()\"\n [toggleable]=\"false\"\n (click)=\"onAlignCenter()\"\n [title]=\"messages().alignCenter\">\n <i class=\"ri-align-center\"></i>\n </button>\n <button\n monaButton\n [selected]=\"alignEndSelected()\"\n [monaEditorPressed]=\"alignEndSelected()\"\n [toggleable]=\"false\"\n (click)=\"onAlignEnd()\"\n [title]=\"messages().alignEnd\">\n <i [class]=\"endIcon()\"></i>\n </button>\n <button\n monaButton\n [selected]=\"alignJustifySelected()\"\n [monaEditorPressed]=\"alignJustifySelected()\"\n [toggleable]=\"false\"\n (click)=\"onAlignJustify()\"\n [title]=\"messages().justify\">\n <i class=\"ri-align-justify\"></i>\n </button>\n</mona-button-group>\n" }]
|
|
1591
1958
|
}] });
|
|
1592
1959
|
|
|
1960
|
+
const EMPTY_DOCUMENT = { type: "doc", content: [] };
|
|
1593
1961
|
class EditorComponent {
|
|
1962
|
+
#contentAttributes;
|
|
1594
1963
|
#destroyRef;
|
|
1964
|
+
#direction;
|
|
1965
|
+
#editable;
|
|
1966
|
+
#i18n;
|
|
1967
|
+
#rendered;
|
|
1968
|
+
#toolbar;
|
|
1969
|
+
/** The last `content` applied, so a binding that echoes the editor's own output isn't applied again. */
|
|
1970
|
+
#appliedContent;
|
|
1971
|
+
/** The last value the editor emitted or was given, so a value echoed back isn't applied again. */
|
|
1972
|
+
#lastValue;
|
|
1973
|
+
/** Set by Escape in the content: the next Tab leaves the editor instead of nesting a list item. */
|
|
1974
|
+
#tabLeaves;
|
|
1595
1975
|
constructor() {
|
|
1976
|
+
this.#contentAttributes = computed(() => {
|
|
1977
|
+
// Tiptap adds the role when it creates the view, but later attribute updates replace the whole set.
|
|
1978
|
+
const attributes = {
|
|
1979
|
+
"aria-multiline": "true",
|
|
1980
|
+
dir: this.#direction(),
|
|
1981
|
+
role: "textbox"
|
|
1982
|
+
};
|
|
1983
|
+
const ariaLabelledBy = this.ariaLabelledBy();
|
|
1984
|
+
if (ariaLabelledBy) {
|
|
1985
|
+
attributes["aria-labelledby"] = ariaLabelledBy;
|
|
1986
|
+
}
|
|
1987
|
+
else {
|
|
1988
|
+
attributes["aria-label"] = this.ariaLabel() || this.messages().contentLabel;
|
|
1989
|
+
}
|
|
1990
|
+
if (this.ariaDescribedBy()) {
|
|
1991
|
+
attributes["aria-describedby"] = this.ariaDescribedBy();
|
|
1992
|
+
}
|
|
1993
|
+
if (this.placeholder()) {
|
|
1994
|
+
attributes["aria-placeholder"] = this.placeholder();
|
|
1995
|
+
}
|
|
1996
|
+
if (this.disabled()) {
|
|
1997
|
+
attributes["aria-disabled"] = "true";
|
|
1998
|
+
}
|
|
1999
|
+
if (this.readonly()) {
|
|
2000
|
+
attributes["aria-readonly"] = "true";
|
|
2001
|
+
}
|
|
2002
|
+
if (this.required()) {
|
|
2003
|
+
attributes["aria-required"] = "true";
|
|
2004
|
+
}
|
|
2005
|
+
if (this.invalidState()) {
|
|
2006
|
+
attributes["aria-invalid"] = "true";
|
|
2007
|
+
}
|
|
2008
|
+
return attributes;
|
|
2009
|
+
}, /* @ts-ignore */
|
|
2010
|
+
...(ngDevMode ? [{ debugName: "#contentAttributes" }] : /* istanbul ignore next */ []));
|
|
1596
2011
|
this.#destroyRef = inject(DestroyRef);
|
|
2012
|
+
this.#direction = injectComponentDirection();
|
|
2013
|
+
this.#editable = computed(() => !this.disabled() && !this.readonly(), /* @ts-ignore */
|
|
2014
|
+
...(ngDevMode ? [{ debugName: "#editable" }] : /* istanbul ignore next */ []));
|
|
2015
|
+
this.#i18n = inject(MonaI18nService);
|
|
2016
|
+
this.#rendered = signal(false, /* @ts-ignore */
|
|
2017
|
+
...(ngDevMode ? [{ debugName: "#rendered" }] : /* istanbul ignore next */ []));
|
|
2018
|
+
this.#toolbar = new RovingToolbar(() => this.toolbarElement()?.nativeElement);
|
|
2019
|
+
/** The last `content` applied, so a binding that echoes the editor's own output isn't applied again. */
|
|
2020
|
+
this.#appliedContent = undefined;
|
|
2021
|
+
/** The last value the editor emitted or was given, so a value echoed back isn't applied again. */
|
|
2022
|
+
this.#lastValue = null;
|
|
2023
|
+
/** Set by Escape in the content: the next Tab leaves the editor instead of nesting a list item. */
|
|
2024
|
+
this.#tabLeaves = false;
|
|
1597
2025
|
this.baseClass = computed(() => {
|
|
1598
2026
|
const userClass = this.userClass();
|
|
1599
2027
|
const variantClass = editorBaseThemeVariants();
|
|
@@ -1601,116 +2029,283 @@ class EditorComponent {
|
|
|
1601
2029
|
}, /* @ts-ignore */
|
|
1602
2030
|
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
1603
2031
|
this.containerClass = computed(() => {
|
|
1604
|
-
return editorContainerThemeVariants();
|
|
2032
|
+
return editorContainerThemeVariants({ disabled: this.disabled() });
|
|
1605
2033
|
}, /* @ts-ignore */
|
|
1606
2034
|
...(ngDevMode ? [{ debugName: "containerClass" }] : /* istanbul ignore next */ []));
|
|
1607
2035
|
this.editorContainer = viewChild.required("editorContainer", /* @ts-ignore */
|
|
1608
2036
|
...(ngDevMode ? [{ debugName: "editorContainer" }] : /* istanbul ignore next */ []));
|
|
1609
2037
|
this.editorService = inject(EditorService);
|
|
2038
|
+
this.invalidState = computed(() => this.touched() && (this.invalid() || (this.required() && !this.value())), /* @ts-ignore */
|
|
2039
|
+
...(ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []));
|
|
2040
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
2041
|
+
this.placeholderClass = computed(() => editorPlaceholderThemeVariants(), /* @ts-ignore */
|
|
2042
|
+
...(ngDevMode ? [{ debugName: "placeholderClass" }] : /* istanbul ignore next */ []));
|
|
1610
2043
|
this.toolbarClass = computed(() => {
|
|
1611
|
-
return editorToolbarThemeVariants();
|
|
2044
|
+
return editorToolbarThemeVariants({ disabled: this.disabled() });
|
|
1612
2045
|
}, /* @ts-ignore */
|
|
1613
2046
|
...(ngDevMode ? [{ debugName: "toolbarClass" }] : /* istanbul ignore next */ []));
|
|
2047
|
+
this.toolbarElement = viewChild("toolbar", /* @ts-ignore */
|
|
2048
|
+
...(ngDevMode ? [{ debugName: "toolbarElement" }] : /* istanbul ignore next */ []));
|
|
2049
|
+
/**
|
|
2050
|
+
* @description The id of an element that describes the content, such as a hint or an error message.
|
|
2051
|
+
*/
|
|
2052
|
+
this.ariaDescribedBy = input("", { ...(ngDevMode ? { debugName: "ariaDescribedBy" } : /* istanbul ignore next */ {}), alias: "aria-describedby" });
|
|
2053
|
+
/**
|
|
2054
|
+
* @description The accessible name of the content. Without it or `aria-labelledby`, the content is named "Rich
|
|
2055
|
+
* text editor" (translated).
|
|
2056
|
+
*/
|
|
2057
|
+
this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
2058
|
+
/**
|
|
2059
|
+
* @description The id of a visible label for the content, such as a `<label>` next to the editor.
|
|
2060
|
+
*/
|
|
2061
|
+
this.ariaLabelledBy = input("", { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
|
|
1614
2062
|
/**
|
|
1615
2063
|
* @description Emits when the editor loses focus.
|
|
2064
|
+
* @deprecated Use `editorBlur`.
|
|
1616
2065
|
*/
|
|
2066
|
+
// eslint-disable-next-line @angular-eslint/no-output-native -- Kept for compatibility; `editorBlur` replaces it.
|
|
1617
2067
|
this.blur = output();
|
|
1618
2068
|
/**
|
|
1619
|
-
* @description
|
|
2069
|
+
* @description The initial content of the editor, as HTML or a {@link JSONContent} document. A later change
|
|
2070
|
+
* replaces the document, unless it is the content the editor already has.
|
|
2071
|
+
* @deprecated Use `value` (HTML), or `[formField]` with a signal form. To read the JSON, use the `update` event or
|
|
2072
|
+
* the `json` property.
|
|
2073
|
+
*/
|
|
2074
|
+
this.content = input(/* @ts-ignore */
|
|
2075
|
+
...(ngDevMode ? [undefined, { debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2076
|
+
/**
|
|
2077
|
+
* @description Emits when the editor is created and ready to be used, and again when it is rebuilt for new
|
|
2078
|
+
* `settings`.
|
|
1620
2079
|
*/
|
|
1621
2080
|
this.create = output();
|
|
2081
|
+
/**
|
|
2082
|
+
* @description Disables the editor: the content can't be edited or focused for editing, and the toolbar is inert.
|
|
2083
|
+
* When bound to a signal form field via `[formField]`, the form sets it.
|
|
2084
|
+
*/
|
|
2085
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2086
|
+
/**
|
|
2087
|
+
* @description Emits when the editor loses focus.
|
|
2088
|
+
*/
|
|
2089
|
+
this.editorBlur = output();
|
|
1622
2090
|
/**
|
|
1623
2091
|
* @description Emits when the editor gains focus.
|
|
1624
2092
|
*/
|
|
1625
|
-
this.
|
|
2093
|
+
this.editorFocus = output();
|
|
1626
2094
|
/**
|
|
1627
|
-
* @description
|
|
2095
|
+
* @description Marks the editor as invalid once it has been touched. When bound to a signal form field via
|
|
2096
|
+
* `[formField]`, the form sets it.
|
|
1628
2097
|
*/
|
|
1629
|
-
this.
|
|
2098
|
+
this.invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
1630
2099
|
/**
|
|
1631
|
-
* @description
|
|
2100
|
+
* @description Text shown in the empty editor, and given to assistive technology as `aria-placeholder`. It is not
|
|
2101
|
+
* a name: use a label or `aria-label` too.
|
|
1632
2102
|
*/
|
|
1633
|
-
this.
|
|
2103
|
+
this.placeholder = input("", /* @ts-ignore */
|
|
2104
|
+
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
1634
2105
|
/**
|
|
1635
|
-
* @description
|
|
2106
|
+
* @description Makes the content read-only and hides the toolbar. When bound to a signal form field via
|
|
2107
|
+
* `[formField]`, the form sets it.
|
|
1636
2108
|
*/
|
|
1637
|
-
this.
|
|
1638
|
-
|
|
2109
|
+
this.readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2110
|
+
/**
|
|
2111
|
+
* @description Marks the editor as required: once touched, an empty editor is invalid.
|
|
2112
|
+
*/
|
|
2113
|
+
this.required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
1639
2114
|
/**
|
|
1640
|
-
* @description
|
|
2115
|
+
* @description Emits when the selection of the editor changes.
|
|
2116
|
+
*/
|
|
2117
|
+
this.selectionUpdate = output();
|
|
2118
|
+
/**
|
|
2119
|
+
* @description The settings of the editor. Changing them rebuilds the editor and keeps its document.
|
|
1641
2120
|
*/
|
|
1642
2121
|
this.settings = input({}, /* @ts-ignore */
|
|
1643
2122
|
...(ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []));
|
|
2123
|
+
/**
|
|
2124
|
+
* @description Emits when the editor loses focus.
|
|
2125
|
+
* Form directives (`[formField]`, `ngModel`, `formControl`) listen to this to mark the field as touched.
|
|
2126
|
+
*/
|
|
2127
|
+
this.touch = output();
|
|
2128
|
+
/**
|
|
2129
|
+
* @description Sets the touched state. When bound to a signal form field via `[formField]`, the form sets it.
|
|
2130
|
+
*/
|
|
2131
|
+
this.touched = input(false, { ...(ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2132
|
+
/**
|
|
2133
|
+
* @description Emits when the user changes the content. It isn't emitted when `value` or `content` is set from
|
|
2134
|
+
* outside.
|
|
2135
|
+
*/
|
|
2136
|
+
this.update = output();
|
|
1644
2137
|
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
|
|
2138
|
+
/**
|
|
2139
|
+
* @description The content of the editor as HTML. An empty editor has the value `""`. Use `[(value)]`, or
|
|
2140
|
+
* `[formField]` with a signal form.
|
|
2141
|
+
*/
|
|
2142
|
+
this.value = model("", /* @ts-ignore */
|
|
2143
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
2144
|
+
afterNextRender({
|
|
2145
|
+
write: () => {
|
|
2146
|
+
this.#listenForEscapeThenTab();
|
|
2147
|
+
this.#rendered.set(true);
|
|
2148
|
+
}
|
|
2149
|
+
});
|
|
2150
|
+
// Every render: toolbar controls that settings or state add later join its single Tab stop.
|
|
2151
|
+
afterEveryRender({
|
|
2152
|
+
write: () => this.#toolbar.sync()
|
|
2153
|
+
});
|
|
1645
2154
|
effect(() => {
|
|
1646
2155
|
const settings = this.settings();
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
}
|
|
2156
|
+
if (!this.#rendered()) {
|
|
2157
|
+
return;
|
|
2158
|
+
}
|
|
2159
|
+
untracked(() => this.#setupEditor(settings));
|
|
1650
2160
|
});
|
|
1651
2161
|
effect(() => {
|
|
1652
|
-
const
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
}
|
|
2162
|
+
const value = this.value();
|
|
2163
|
+
if (!this.editorService.ready()) {
|
|
2164
|
+
return;
|
|
2165
|
+
}
|
|
2166
|
+
untracked(() => this.#applyValue(value));
|
|
1656
2167
|
});
|
|
1657
|
-
|
|
1658
|
-
|
|
2168
|
+
effect(() => {
|
|
2169
|
+
const content = this.content();
|
|
2170
|
+
if (!this.editorService.ready()) {
|
|
2171
|
+
return;
|
|
2172
|
+
}
|
|
2173
|
+
untracked(() => this.#applyContent(content));
|
|
2174
|
+
});
|
|
2175
|
+
effect(() => {
|
|
2176
|
+
const editable = this.#editable();
|
|
2177
|
+
const attributes = this.#contentAttributes();
|
|
2178
|
+
if (!this.editorService.ready()) {
|
|
2179
|
+
return;
|
|
2180
|
+
}
|
|
2181
|
+
untracked(() => this.editorService.setEditable(editable, attributes));
|
|
1659
2182
|
});
|
|
2183
|
+
this.#subscribe();
|
|
1660
2184
|
this.#destroyRef.onDestroy(() => this.editorService.destroy());
|
|
1661
2185
|
}
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
2186
|
+
/**
|
|
2187
|
+
* Returns the HTML content of the editor, or `""` before the editor is created.
|
|
2188
|
+
* It can be used to save the content of the editor in a database and restore it later.
|
|
2189
|
+
*/
|
|
2190
|
+
get html() {
|
|
2191
|
+
return this.editorService.ready() ? this.editorService.editor.getHTML() : "";
|
|
2192
|
+
}
|
|
2193
|
+
/**
|
|
2194
|
+
* Returns the JSON content of the editor in the {@link JSONContent} format, or an empty document before the editor
|
|
2195
|
+
* is created.
|
|
2196
|
+
* It can be used to save the content of the editor in a database and restore it later.
|
|
2197
|
+
*/
|
|
2198
|
+
get json() {
|
|
2199
|
+
return this.editorService.ready() ? this.editorService.editor.getJSON() : EMPTY_DOCUMENT;
|
|
2200
|
+
}
|
|
2201
|
+
/**
|
|
2202
|
+
* Moves focus into the editor, keeping the selection it had.
|
|
2203
|
+
*/
|
|
2204
|
+
focus(options) {
|
|
2205
|
+
if (this.editorService.ready()) {
|
|
2206
|
+
this.editorService.editor.commands.focus(null, { scrollIntoView: !options?.preventScroll });
|
|
1665
2207
|
}
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
2208
|
+
}
|
|
2209
|
+
onToolbarFocusIn(event) {
|
|
2210
|
+
this.#toolbar.onFocusIn(event);
|
|
2211
|
+
}
|
|
2212
|
+
onToolbarKeydown(event) {
|
|
2213
|
+
this.#toolbar.onKeydown(event);
|
|
2214
|
+
}
|
|
2215
|
+
#applyContent(content) {
|
|
2216
|
+
if (content === this.#appliedContent) {
|
|
2217
|
+
return;
|
|
2218
|
+
}
|
|
2219
|
+
this.#appliedContent = content;
|
|
2220
|
+
if (content === undefined || this.#hasContent(content)) {
|
|
2221
|
+
return;
|
|
2222
|
+
}
|
|
2223
|
+
this.editorService.setContent(content);
|
|
2224
|
+
}
|
|
2225
|
+
#applyValue(value) {
|
|
2226
|
+
if (value === this.#lastValue) {
|
|
2227
|
+
return;
|
|
2228
|
+
}
|
|
2229
|
+
this.#lastValue = value;
|
|
2230
|
+
if (value === this.#currentValue()) {
|
|
2231
|
+
return;
|
|
2232
|
+
}
|
|
2233
|
+
this.editorService.setContent(value);
|
|
2234
|
+
}
|
|
2235
|
+
#currentValue() {
|
|
2236
|
+
const editor = this.editorService.editor;
|
|
2237
|
+
return editor.isEmpty ? "" : editor.getHTML();
|
|
2238
|
+
}
|
|
2239
|
+
#hasContent(content) {
|
|
2240
|
+
const editor = this.editorService.editor;
|
|
2241
|
+
if (typeof content === "string") {
|
|
2242
|
+
return content === editor.getHTML() || content === this.#currentValue();
|
|
1671
2243
|
}
|
|
2244
|
+
return JSON.stringify(content) === JSON.stringify(editor.getJSON());
|
|
2245
|
+
}
|
|
2246
|
+
/**
|
|
2247
|
+
* Tab inside a list nests the item, so the keyboard could be stuck in a long list. Escape, then Tab, leaves the
|
|
2248
|
+
* editor: the Tab is kept from ProseMirror and the browser moves focus.
|
|
2249
|
+
*/
|
|
2250
|
+
#listenForEscapeThenTab() {
|
|
2251
|
+
const container = this.editorContainer().nativeElement;
|
|
2252
|
+
const listener = (event) => {
|
|
2253
|
+
if (event.key === "Escape") {
|
|
2254
|
+
this.#tabLeaves = true;
|
|
2255
|
+
return;
|
|
2256
|
+
}
|
|
2257
|
+
if (event.key === "Tab" && this.#tabLeaves) {
|
|
2258
|
+
event.stopPropagation();
|
|
2259
|
+
}
|
|
2260
|
+
if (event.key !== "Shift") {
|
|
2261
|
+
this.#tabLeaves = false;
|
|
2262
|
+
}
|
|
2263
|
+
};
|
|
2264
|
+
container.addEventListener("keydown", listener, { capture: true });
|
|
2265
|
+
this.#destroyRef.onDestroy(() => container.removeEventListener("keydown", listener, { capture: true }));
|
|
2266
|
+
}
|
|
2267
|
+
#setupEditor(settings) {
|
|
2268
|
+
const value = this.value();
|
|
2269
|
+
const content = this.content();
|
|
2270
|
+
this.#lastValue = value;
|
|
2271
|
+
this.#appliedContent = content;
|
|
2272
|
+
this.editorService.setupEditor(this.editorContainer().nativeElement, settings, {
|
|
2273
|
+
attributes: this.#contentAttributes(),
|
|
2274
|
+
content: value || (content ?? ""),
|
|
2275
|
+
editable: this.#editable()
|
|
2276
|
+
});
|
|
1672
2277
|
}
|
|
1673
|
-
|
|
2278
|
+
#subscribe() {
|
|
1674
2279
|
this.editorService.blur$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
2280
|
+
this.touch.emit();
|
|
2281
|
+
this.editorBlur.emit();
|
|
1675
2282
|
this.blur.emit();
|
|
1676
2283
|
});
|
|
1677
2284
|
this.editorService.create$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
1678
2285
|
this.create.emit();
|
|
1679
2286
|
});
|
|
1680
2287
|
this.editorService.focus$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
1681
|
-
this.
|
|
2288
|
+
this.editorFocus.emit();
|
|
1682
2289
|
});
|
|
1683
2290
|
this.editorService.selectionUpdate$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
1684
2291
|
this.selectionUpdate.emit();
|
|
1685
2292
|
});
|
|
1686
2293
|
this.editorService.update$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
2294
|
+
const value = this.#currentValue();
|
|
2295
|
+
this.#lastValue = value;
|
|
2296
|
+
this.value.set(value);
|
|
1687
2297
|
this.update.emit({
|
|
1688
2298
|
html: this.html,
|
|
1689
2299
|
json: this.json
|
|
1690
2300
|
});
|
|
1691
2301
|
});
|
|
1692
2302
|
}
|
|
1693
|
-
/**
|
|
1694
|
-
* Returns the HTML content of the editor.
|
|
1695
|
-
* It can be used to save the content of the editor in a database and restore it later.
|
|
1696
|
-
*/
|
|
1697
|
-
get html() {
|
|
1698
|
-
return this.editorService.editor.getHTML();
|
|
1699
|
-
}
|
|
1700
|
-
/**
|
|
1701
|
-
* Returns the JSON content of the editor in the {@link JSONContent} format.
|
|
1702
|
-
* It can be used to save the content of the editor in a database and restore it later.
|
|
1703
|
-
*/
|
|
1704
|
-
get json() {
|
|
1705
|
-
return this.editorService.editor.getJSON();
|
|
1706
|
-
}
|
|
1707
2303
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1708
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: EditorComponent, isStandalone: true, selector: "mona-editor", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { blur: "blur", create: "create",
|
|
2304
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: EditorComponent, isStandalone: true, selector: "mona-editor", inputs: { ariaDescribedBy: { classPropertyName: "ariaDescribedBy", publicName: "aria-describedby", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, settings: { classPropertyName: "settings", publicName: "settings", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { blur: "blur", create: "create", editorBlur: "editorBlur", editorFocus: "editorFocus", selectionUpdate: "selectionUpdate", touch: "touch", update: "update", value: "valueChange" }, host: { properties: { "class": "baseClass()", "attr.aria-describedby": "null", "attr.aria-label": "null", "attr.aria-labelledby": "null", "attr.data-disabled": "disabled() || null", "attr.data-invalid": "invalidState() || null", "attr.data-readonly": "readonly() || null", "attr.data-required": "required() || null" } }, providers: [EditorService], viewQueries: [{ propertyName: "editorContainer", first: true, predicate: ["editorContainer"], descendants: true, isSignal: true }, { propertyName: "toolbarElement", first: true, predicate: ["toolbar"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (editorService.ready() && !readonly()) {\n <div\n role=\"toolbar\"\n [class]=\"toolbarClass()\"\n [attr.aria-label]=\"messages().toolbar\"\n [attr.inert]=\"disabled() || null\"\n (focusin)=\"onToolbarFocusIn($event)\"\n (keydown)=\"onToolbarKeydown($event)\"\n #toolbar>\n <mona-editor-basic-text-styles></mona-editor-basic-text-styles>\n @if (editorService.settings().headings) {\n <mona-editor-headings></mona-editor-headings>\n }\n @if (editorService.settings().alignment) {\n <mona-editor-text-alignments></mona-editor-text-alignments>\n }\n @if (editorService.settings().fontSize) {\n <mona-editor-font-size></mona-editor-font-size>\n }\n @if (editorService.settings().fontFamily) {\n <mona-editor-font-family></mona-editor-font-family>\n }\n @if (editorService.settings().fontColor) {\n <mona-editor-font-color></mona-editor-font-color>\n }\n @if (editorService.settings().fontHighlight) {\n <mona-editor-font-highlight></mona-editor-font-highlight>\n }\n @if (editorService.settings().blockquote) {\n <mona-editor-blockquote></mona-editor-blockquote>\n }\n @if (editorService.settings().code) {\n <mona-editor-code-block></mona-editor-code-block>\n }\n @if (editorService.settings().link) {\n <mona-editor-link></mona-editor-link>\n }\n @if (editorService.settings().list) {\n <mona-editor-list></mona-editor-list>\n }\n @if (editorService.settings().taskList) {\n <mona-editor-task-list></mona-editor-task-list>\n }\n @if (editorService.settings().indent) {\n <mona-editor-indent></mona-editor-indent>\n }\n @if (editorService.settings().history) {\n <mona-editor-history></mona-editor-history>\n }\n @if (editorService.settings().horizontalRule) {\n <mona-editor-horizontal-rule></mona-editor-horizontal-rule>\n }\n @if (editorService.settings().image) {\n <mona-editor-image></mona-editor-image>\n }\n @if (editorService.settings().table) {\n <mona-editor-table></mona-editor-table>\n }\n </div>\n}\n<div class=\"relative min-h-0 w-full flex-1\">\n <div [class]=\"containerClass()\" #editorContainer></div>\n @if (placeholder() && editorService.isEmpty()) {\n <div [class]=\"placeholderClass()\" aria-hidden=\"true\">{{ placeholder() }}</div>\n }\n</div>\n", dependencies: [{ kind: "component", type: EditorBasicTextStylesComponent, selector: "mona-editor-basic-text-styles" }, { kind: "component", type: EditorHeadingsComponent, selector: "mona-editor-headings" }, { kind: "component", type: EditorTextAlignmentsComponent, selector: "mona-editor-text-alignments" }, { kind: "component", type: EditorFontSizeComponent, selector: "mona-editor-font-size" }, { kind: "component", type: EditorFontColorComponent, selector: "mona-editor-font-color" }, { kind: "component", type: EditorFontHighlightComponent, selector: "mona-editor-font-highlight" }, { kind: "component", type: EditorBlockquoteComponent, selector: "mona-editor-blockquote" }, { kind: "component", type: EditorLinkComponent, selector: "mona-editor-link" }, { kind: "component", type: EditorListComponent, selector: "mona-editor-list" }, { kind: "component", type: EditorIndentComponent, selector: "mona-editor-indent" }, { kind: "component", type: EditorHistoryComponent, selector: "mona-editor-history" }, { kind: "component", type: EditorFontFamilyComponent, selector: "mona-editor-font-family" }, { kind: "component", type: EditorHorizontalRuleComponent, selector: "mona-editor-horizontal-rule" }, { kind: "component", type: EditorTaskListComponent, selector: "mona-editor-task-list" }, { kind: "component", type: EditorImageComponent, selector: "mona-editor-image" }, { kind: "component", type: EditorTableComponent, selector: "mona-editor-table" }, { kind: "component", type: EditorCodeBlockComponent, selector: "mona-editor-code-block" }] }); }
|
|
1709
2305
|
}
|
|
1710
2306
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: EditorComponent, decorators: [{
|
|
1711
2307
|
type: Component,
|
|
1712
2308
|
args: [{ selector: "mona-editor", imports: [
|
|
1713
|
-
FormsModule,
|
|
1714
2309
|
EditorBasicTextStylesComponent,
|
|
1715
2310
|
EditorHeadingsComponent,
|
|
1716
2311
|
EditorTextAlignmentsComponent,
|
|
@@ -1729,9 +2324,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
1729
2324
|
EditorTableComponent,
|
|
1730
2325
|
EditorCodeBlockComponent
|
|
1731
2326
|
], providers: [EditorService], host: {
|
|
1732
|
-
"[class]": "baseClass()"
|
|
1733
|
-
|
|
1734
|
-
|
|
2327
|
+
"[class]": "baseClass()",
|
|
2328
|
+
"[attr.aria-describedby]": "null",
|
|
2329
|
+
"[attr.aria-label]": "null",
|
|
2330
|
+
"[attr.aria-labelledby]": "null",
|
|
2331
|
+
"[attr.data-disabled]": "disabled() || null",
|
|
2332
|
+
"[attr.data-invalid]": "invalidState() || null",
|
|
2333
|
+
"[attr.data-readonly]": "readonly() || null",
|
|
2334
|
+
"[attr.data-required]": "required() || null"
|
|
2335
|
+
}, template: "@if (editorService.ready() && !readonly()) {\n <div\n role=\"toolbar\"\n [class]=\"toolbarClass()\"\n [attr.aria-label]=\"messages().toolbar\"\n [attr.inert]=\"disabled() || null\"\n (focusin)=\"onToolbarFocusIn($event)\"\n (keydown)=\"onToolbarKeydown($event)\"\n #toolbar>\n <mona-editor-basic-text-styles></mona-editor-basic-text-styles>\n @if (editorService.settings().headings) {\n <mona-editor-headings></mona-editor-headings>\n }\n @if (editorService.settings().alignment) {\n <mona-editor-text-alignments></mona-editor-text-alignments>\n }\n @if (editorService.settings().fontSize) {\n <mona-editor-font-size></mona-editor-font-size>\n }\n @if (editorService.settings().fontFamily) {\n <mona-editor-font-family></mona-editor-font-family>\n }\n @if (editorService.settings().fontColor) {\n <mona-editor-font-color></mona-editor-font-color>\n }\n @if (editorService.settings().fontHighlight) {\n <mona-editor-font-highlight></mona-editor-font-highlight>\n }\n @if (editorService.settings().blockquote) {\n <mona-editor-blockquote></mona-editor-blockquote>\n }\n @if (editorService.settings().code) {\n <mona-editor-code-block></mona-editor-code-block>\n }\n @if (editorService.settings().link) {\n <mona-editor-link></mona-editor-link>\n }\n @if (editorService.settings().list) {\n <mona-editor-list></mona-editor-list>\n }\n @if (editorService.settings().taskList) {\n <mona-editor-task-list></mona-editor-task-list>\n }\n @if (editorService.settings().indent) {\n <mona-editor-indent></mona-editor-indent>\n }\n @if (editorService.settings().history) {\n <mona-editor-history></mona-editor-history>\n }\n @if (editorService.settings().horizontalRule) {\n <mona-editor-horizontal-rule></mona-editor-horizontal-rule>\n }\n @if (editorService.settings().image) {\n <mona-editor-image></mona-editor-image>\n }\n @if (editorService.settings().table) {\n <mona-editor-table></mona-editor-table>\n }\n </div>\n}\n<div class=\"relative min-h-0 w-full flex-1\">\n <div [class]=\"containerClass()\" #editorContainer></div>\n @if (placeholder() && editorService.isEmpty()) {\n <div [class]=\"placeholderClass()\" aria-hidden=\"true\">{{ placeholder() }}</div>\n }\n</div>\n" }]
|
|
2336
|
+
}], ctorParameters: () => [], propDecorators: { editorContainer: [{ type: i0.ViewChild, args: ["editorContainer", { isSignal: true }] }], toolbarElement: [{ type: i0.ViewChild, args: ["toolbar", { isSignal: true }] }], ariaDescribedBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-describedby", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], blur: [{ type: i0.Output, args: ["blur"] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], create: [{ type: i0.Output, args: ["create"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], editorBlur: [{ type: i0.Output, args: ["editorBlur"] }], editorFocus: [{ type: i0.Output, args: ["editorFocus"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], selectionUpdate: [{ type: i0.Output, args: ["selectionUpdate"] }], settings: [{ type: i0.Input, args: [{ isSignal: true, alias: "settings", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], update: [{ type: i0.Output, args: ["update"] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
|
|
1735
2337
|
|
|
1736
2338
|
/*
|
|
1737
2339
|
* Public API Surface of @nanahoshi/mona-ui/editor
|