@nanahoshi/mona-ui 0.36.1 → 0.38.0
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/docs/api/common.md +1 -1
- package/docs/api/dropdown-list.md +2 -0
- package/docs/api/dropdown-tree.md +81 -0
- package/docs/api/dropdowns.md +34 -8
- package/docs/api/editor.md +67 -0
- package/docs/api/file-upload.md +1 -1
- package/docs/api/i18n.md +49 -4
- package/docs/api/list.md +1 -1
- package/docs/api/locales.md +14 -14
- package/docs/api/multi-select-tree.md +75 -0
- package/docs/api/multi-select.md +3 -1
- package/docs/api/popup.md +1 -1
- package/docs/api/tree-view.md +2 -2
- package/docs/auto-complete.md +2 -0
- package/docs/combo-box.md +2 -0
- package/docs/dropdown-list.md +52 -0
- package/docs/dropdown-tree.md +427 -0
- package/docs/editor.md +238 -9
- package/docs/multi-select-tree.md +353 -0
- package/docs/multi-select.md +6 -0
- package/dropdown-tree/package.json +4 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +40 -5
- package/fesm2022/nanahoshi-mona-ui-dropdown-tree.mjs +1061 -0
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +701 -60
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +1356 -192
- package/fesm2022/nanahoshi-mona-ui-file-upload.mjs +28 -94
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +63 -1
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +80 -37
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +83 -2
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +66 -1
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +30 -1
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +42 -1
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +42 -1
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +24 -1
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +42 -1
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +24 -1
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +24 -1
- package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +64 -1
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +42 -1
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +64 -1
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +24 -1
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +24 -1
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +24 -1
- package/fesm2022/nanahoshi-mona-ui-multi-select-tree.mjs +1179 -0
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +42 -7
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +3 -1
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +2 -1
- package/i18n/catalogs/en-US.messages.json +26 -1
- package/llms.txt +7 -3
- package/locales/ar-sa/ar-sa.messages.json +26 -1
- package/locales/de-de/de-de.messages.json +26 -1
- package/locales/es-es/es-es.messages.json +26 -1
- package/locales/fr-fr/fr-fr.messages.json +26 -1
- package/locales/id-id/id-id.messages.json +26 -1
- package/locales/it-it/it-it.messages.json +26 -1
- package/locales/ja-jp/ja-jp.messages.json +26 -1
- package/locales/ko-kr/ko-kr.messages.json +26 -1
- package/locales/pl-pl/pl-pl.messages.json +26 -1
- package/locales/pt-br/pt-br.messages.json +26 -1
- package/locales/ru-ru/ru-ru.messages.json +26 -1
- package/locales/tr-tr/tr-tr.messages.json +26 -1
- package/locales/zh-cn/zh-cn.messages.json +26 -1
- package/locales/zh-tw/zh-tw.messages.json +26 -1
- package/multi-select-tree/package.json +4 -0
- package/package.json +9 -1
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +33 -5
- package/types/nanahoshi-mona-ui-dropdown-tree.d.ts +414 -0
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +198 -8
- package/types/nanahoshi-mona-ui-editor.d.ts +124 -2
- package/types/nanahoshi-mona-ui-file-upload.d.ts +1 -0
- package/types/nanahoshi-mona-ui-i18n.d.ts +44 -0
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +36 -0
- package/types/nanahoshi-mona-ui-internal.d.ts +37 -0
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +25 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +25 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +25 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +25 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +25 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +25 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +25 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +25 -0
- package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +25 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +25 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +25 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +25 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +25 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +25 -0
- package/types/nanahoshi-mona-ui-multi-select-tree.d.ts +456 -0
- package/types/nanahoshi-mona-ui-multi-select.d.ts +43 -7
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { Component, DOCUMENT, DestroyRef, Directive, ElementRef, Injectable, Injector, afterEveryRender, afterNextRender, afterRenderEffect, booleanAttribute, computed, effect, inject, input, model, output, signal, untracked, viewChild } from "@angular/core";
|
|
2
|
+
import { Component, DOCUMENT, DestroyRef, Directive, ElementRef, Injectable, Injector, afterEveryRender, afterNextRender, afterRenderEffect, booleanAttribute, computed, effect, inject, input, isDevMode, model, output, signal, untracked, viewChild } from "@angular/core";
|
|
3
3
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
4
4
|
import { MonaI18nService, formatNumber, injectComponentDirection } from "@nanahoshi/mona-ui/i18n";
|
|
5
|
-
import { FIELD_ASSOCIATION_BOUNDARY, RovingToolbar, createElementControlId, injectEffectiveDisabled, injectLabelAssociation } from "@nanahoshi/mona-ui/internal";
|
|
5
|
+
import { FIELD_ASSOCIATION_BOUNDARY, RovingToolbar, createElementControlId, injectEffectiveDisabled, injectLabelAssociation, matchesAccept, parseAccept, runUpload, themeOverlaySurfaceClasses } from "@nanahoshi/mona-ui/internal";
|
|
6
|
+
import { injectLiveAnnouncer } from "@nanahoshi/mona-ui/internal/live-announcer";
|
|
7
|
+
import { Subject, catchError, debounceTime, from, fromEvent, isObservable, map, of, switchMap } from "rxjs";
|
|
6
8
|
import { twMerge } from "tailwind-merge";
|
|
9
|
+
import { DOCUMENT as DOCUMENT$1 } from "@angular/common";
|
|
10
|
+
import { FileUploadComponent, formatFileSize } from "@nanahoshi/mona-ui/file-upload";
|
|
11
|
+
import { Editor, Extension, Node, mergeAttributes } from "@tiptap/core";
|
|
12
|
+
import { AllSelection, NodeSelection, Plugin, PluginKey, TextSelection } from "@tiptap/pm/state";
|
|
13
|
+
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
14
|
+
import { cva } from "class-variance-authority";
|
|
7
15
|
import { ImmutableSet, List, any, range } from "@mirei/ts-collections";
|
|
8
|
-
import { Editor, Extension } from "@tiptap/core";
|
|
9
16
|
import { Highlight } from "@tiptap/extension-highlight";
|
|
10
17
|
import { TaskItem, TaskList } from "@tiptap/extension-list";
|
|
11
18
|
import { Subscript } from "@tiptap/extension-subscript";
|
|
@@ -14,10 +21,8 @@ import { Table, TableCell, TableHeader, TableRow } from "@tiptap/extension-table
|
|
|
14
21
|
import { TextAlign } from "@tiptap/extension-text-align";
|
|
15
22
|
import { Color, FontFamily, TextStyle } from "@tiptap/extension-text-style";
|
|
16
23
|
import { StarterKit } from "@tiptap/starter-kit";
|
|
17
|
-
import { Subject } from "rxjs";
|
|
18
24
|
import { Image } from "@tiptap/extension-image";
|
|
19
|
-
import {
|
|
20
|
-
import { cva } from "class-variance-authority";
|
|
25
|
+
import { PopupDataInjectionToken, PopupService } from "@nanahoshi/mona-ui/popup";
|
|
21
26
|
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
22
27
|
import { ButtonGroupComponent } from "@nanahoshi/mona-ui/button-group";
|
|
23
28
|
import { ColorPickerComponent, ColorPickerValueTemplateDirective } from "@nanahoshi/mona-ui/color-picker";
|
|
@@ -33,6 +38,10 @@ import { PopoverComponent } from "@nanahoshi/mona-ui/popover";
|
|
|
33
38
|
function localizeNumber(value, options) {
|
|
34
39
|
return formatNumber(value, "en-US", options);
|
|
35
40
|
}
|
|
41
|
+
const PLURAL_RULES = new Intl.PluralRules("en-US");
|
|
42
|
+
function plural(category, forms) {
|
|
43
|
+
return (forms[category] ?? forms.other)();
|
|
44
|
+
}
|
|
36
45
|
const EDITOR_DEFAULT_MESSAGES = {
|
|
37
46
|
addColumnAfter: "Add column after",
|
|
38
47
|
addColumnBefore: "Add column before",
|
|
@@ -50,6 +59,22 @@ const EDITOR_DEFAULT_MESSAGES = {
|
|
|
50
59
|
backgroundColor: "Background color",
|
|
51
60
|
bold: "Bold",
|
|
52
61
|
cancel: "Cancel",
|
|
62
|
+
characterCount: (count) => plural(PLURAL_RULES.select(count), {
|
|
63
|
+
one: () => `${localizeNumber(count)} character`,
|
|
64
|
+
other: () => `${localizeNumber(count)} characters`
|
|
65
|
+
}),
|
|
66
|
+
characterLimitHint: (limit) => `You can enter up to ${plural(PLURAL_RULES.select(limit), {
|
|
67
|
+
one: () => `${localizeNumber(limit)} character`,
|
|
68
|
+
other: () => `${localizeNumber(limit)} characters`
|
|
69
|
+
})}.`,
|
|
70
|
+
charactersLeft: (count) => plural(PLURAL_RULES.select(count), {
|
|
71
|
+
one: () => `${localizeNumber(count)} character left`,
|
|
72
|
+
other: () => `${localizeNumber(count)} characters left`
|
|
73
|
+
}),
|
|
74
|
+
charactersOver: (count) => plural(PLURAL_RULES.select(count), {
|
|
75
|
+
one: () => `${localizeNumber(count)} character too many`,
|
|
76
|
+
other: () => `${localizeNumber(count)} characters too many`
|
|
77
|
+
}),
|
|
53
78
|
codeBlock: "Code block",
|
|
54
79
|
color: "Color",
|
|
55
80
|
contentLabel: "Rich text editor",
|
|
@@ -57,6 +82,7 @@ const EDITOR_DEFAULT_MESSAGES = {
|
|
|
57
82
|
deleteColumn: "Delete column",
|
|
58
83
|
deleteRow: "Delete row",
|
|
59
84
|
deleteTable: "Delete table",
|
|
85
|
+
editImage: "Edit image",
|
|
60
86
|
editLink: "Edit link",
|
|
61
87
|
enterUrl: "Enter the URL",
|
|
62
88
|
fontSize: "Font size",
|
|
@@ -64,6 +90,11 @@ const EDITOR_DEFAULT_MESSAGES = {
|
|
|
64
90
|
heading: (level) => `Heading ${localizeNumber(level)}`,
|
|
65
91
|
heightPx: "Height (px)",
|
|
66
92
|
historyGroup: "History",
|
|
93
|
+
imageFile: "Image file",
|
|
94
|
+
imageInserted: (name) => `${name} inserted.`,
|
|
95
|
+
imageTooLarge: (name, size) => `${name} wasn't added. The file is larger than ${size}.`,
|
|
96
|
+
imageUploadFailed: (name) => `${name} couldn't be uploaded.`,
|
|
97
|
+
imageUploading: (name) => `Uploading ${name}`,
|
|
67
98
|
imageUrl: "Image URL",
|
|
68
99
|
indent: "Indent",
|
|
69
100
|
indentGroup: "Indentation",
|
|
@@ -79,12 +110,20 @@ const EDITOR_DEFAULT_MESSAGES = {
|
|
|
79
110
|
justify: "Justify",
|
|
80
111
|
linkGroup: "Link",
|
|
81
112
|
listGroup: "Lists",
|
|
113
|
+
mentionNoResults: "No matches",
|
|
114
|
+
mentionResults: (count) => plural(PLURAL_RULES.select(count), {
|
|
115
|
+
one: () => `${localizeNumber(count)} suggestion`,
|
|
116
|
+
other: () => `${localizeNumber(count)} suggestions`
|
|
117
|
+
}),
|
|
118
|
+
mentionSearching: "Searching…",
|
|
119
|
+
mentionSuggestions: "Suggestions",
|
|
82
120
|
mergeCells: "Merge selected cells",
|
|
83
121
|
outdent: "Outdent",
|
|
84
122
|
paragraph: "Paragraph",
|
|
85
123
|
quotation: "Quotation",
|
|
86
124
|
redo: "Redo",
|
|
87
125
|
removeLink: "Remove link",
|
|
126
|
+
save: "Save",
|
|
88
127
|
selectFontFamily: "Select font family",
|
|
89
128
|
selectFontSize: "Select font size",
|
|
90
129
|
splitCell: "Split cell",
|
|
@@ -98,8 +137,309 @@ const EDITOR_DEFAULT_MESSAGES = {
|
|
|
98
137
|
toolbar: "Formatting",
|
|
99
138
|
underline: "Underline",
|
|
100
139
|
undo: "Undo",
|
|
101
|
-
widthPx: "Width (px)"
|
|
140
|
+
widthPx: "Width (px)",
|
|
141
|
+
wordCount: (count) => plural(PLURAL_RULES.select(count), {
|
|
142
|
+
one: () => `${localizeNumber(count)} word`,
|
|
143
|
+
other: () => `${localizeNumber(count)} words`
|
|
144
|
+
})
|
|
102
145
|
};
|
|
146
|
+
const PLACEHOLDER_KEY = new PluginKey("monaImageUploadPlaceholders");
|
|
147
|
+
function insertionEnd(tr) {
|
|
148
|
+
let end = null;
|
|
149
|
+
tr.mapping.maps.at(-1)?.forEach((_from, _to, _newFrom, newTo) => {
|
|
150
|
+
end = newTo;
|
|
151
|
+
});
|
|
152
|
+
return end;
|
|
153
|
+
}
|
|
154
|
+
function filesOf(transfer) {
|
|
155
|
+
return transfer ? Array.from(transfer.files) : [];
|
|
156
|
+
}
|
|
157
|
+
function addImagePlaceholder(view, id, position, element) {
|
|
158
|
+
const action = { add: {
|
|
159
|
+
element,
|
|
160
|
+
id,
|
|
161
|
+
position
|
|
162
|
+
} };
|
|
163
|
+
view.dispatch(view.state.tr.setMeta(PLACEHOLDER_KEY, action).setMeta("addToHistory", false));
|
|
164
|
+
}
|
|
165
|
+
function findImagePlaceholder(state, id) {
|
|
166
|
+
return PLACEHOLDER_KEY.getState(state)?.find((placeholder) => placeholder.id === id)?.position ?? null;
|
|
167
|
+
}
|
|
168
|
+
function removeImagePlaceholder(view, id) {
|
|
169
|
+
const action = { remove: id };
|
|
170
|
+
view.dispatch(view.state.tr.setMeta(PLACEHOLDER_KEY, action).setMeta("addToHistory", false));
|
|
171
|
+
}
|
|
172
|
+
function imagePlaceholderRemoval(id) {
|
|
173
|
+
return {
|
|
174
|
+
key: PLACEHOLDER_KEY,
|
|
175
|
+
value: { remove: id }
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const ImageUpload = Extension.create({
|
|
179
|
+
name: "monaImageUpload",
|
|
180
|
+
addOptions() {
|
|
181
|
+
return {
|
|
182
|
+
accepted: () => [],
|
|
183
|
+
upload: () => void 0
|
|
184
|
+
};
|
|
185
|
+
},
|
|
186
|
+
addProseMirrorPlugins() {
|
|
187
|
+
const options = this.options;
|
|
188
|
+
return [new Plugin({
|
|
189
|
+
key: PLACEHOLDER_KEY,
|
|
190
|
+
state: {
|
|
191
|
+
init: () => [],
|
|
192
|
+
apply: (tr, placeholders) => {
|
|
193
|
+
const action = tr.getMeta(PLACEHOLDER_KEY);
|
|
194
|
+
const removedIndex = action && "remove" in action ? placeholders.findIndex((placeholder) => placeholder.id === action.remove) : -1;
|
|
195
|
+
const removed = removedIndex < 0 ? null : placeholders[removedIndex];
|
|
196
|
+
const end = removed && tr.docChanged ? insertionEnd(tr) : null;
|
|
197
|
+
let next = !tr.docChanged ? placeholders : placeholders.flatMap((placeholder, index) => {
|
|
198
|
+
if (end !== null && index > removedIndex && placeholder.position === removed?.position) return [{
|
|
199
|
+
...placeholder,
|
|
200
|
+
position: end
|
|
201
|
+
}];
|
|
202
|
+
const mapped = tr.mapping.mapResult(placeholder.position, -1);
|
|
203
|
+
return mapped.deletedAcross ? [] : [{
|
|
204
|
+
...placeholder,
|
|
205
|
+
position: mapped.pos
|
|
206
|
+
}];
|
|
207
|
+
});
|
|
208
|
+
if (action && "add" in action) next = [...next, action.add];
|
|
209
|
+
else if (action && "remove" in action) next = next.filter((placeholder) => placeholder.id !== action.remove);
|
|
210
|
+
return next;
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
props: {
|
|
214
|
+
decorations: (state) => {
|
|
215
|
+
const placeholders = PLACEHOLDER_KEY.getState(state) ?? [];
|
|
216
|
+
if (placeholders.length === 0) return null;
|
|
217
|
+
return DecorationSet.create(state.doc, placeholders.map(({ element, id, position }) => Decoration.widget(position, element, {
|
|
218
|
+
id,
|
|
219
|
+
key: id,
|
|
220
|
+
side: -1
|
|
221
|
+
})));
|
|
222
|
+
},
|
|
223
|
+
handleDrop: (view, event, _slice, moved) => {
|
|
224
|
+
if (moved) return false;
|
|
225
|
+
const files = options.accepted(filesOf(event.dataTransfer));
|
|
226
|
+
if (files.length === 0) return false;
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
const target = view.posAtCoords({
|
|
229
|
+
left: event.clientX,
|
|
230
|
+
top: event.clientY
|
|
231
|
+
});
|
|
232
|
+
options.upload(view, files, target?.pos ?? view.state.selection.from);
|
|
233
|
+
return true;
|
|
234
|
+
},
|
|
235
|
+
handlePaste: (view, event) => {
|
|
236
|
+
if (event.clipboardData?.getData("text/html")) return false;
|
|
237
|
+
const files = options.accepted(filesOf(event.clipboardData));
|
|
238
|
+
if (files.length === 0) return false;
|
|
239
|
+
event.preventDefault();
|
|
240
|
+
if (!view.state.selection.empty) view.dispatch(view.state.tr.deleteSelection());
|
|
241
|
+
options.upload(view, files, view.state.selection.from);
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
})];
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
const editorBaseThemeVariants = cva(`
|
|
249
|
+
flex flex-col
|
|
250
|
+
bg-surface text-foreground
|
|
251
|
+
border border-border
|
|
252
|
+
transition-[border-color,box-shadow] duration-150 ease-in
|
|
253
|
+
focus-within:border-focus-indicator
|
|
254
|
+
focus-within:ring-2 focus-within:ring-focus-indicator/35
|
|
255
|
+
|
|
256
|
+
data-[disabled='true']:cursor-not-allowed
|
|
257
|
+
data-[disabled='true']:border-disabled-border
|
|
258
|
+
data-[disabled='true']:text-disabled-foreground
|
|
259
|
+
data-[invalid='true']:border-error
|
|
260
|
+
data-[invalid='true']:ring-2 data-[invalid='true']:ring-error/35
|
|
261
|
+
data-[invalid='true']:focus-within:border-error
|
|
262
|
+
data-[invalid='true']:focus-within:ring-error/35
|
|
263
|
+
|
|
264
|
+
prose prose-neutral max-w-none
|
|
265
|
+
prose-headings:text-foreground prose-headings:font-bold
|
|
266
|
+
prose-headings:mt-1 prose-headings:mb-1
|
|
267
|
+
prose-p:text-foreground prose-p:my-1
|
|
268
|
+
prose-strong:text-inherit
|
|
269
|
+
[&_span[style*=color]_mark]:text-inherit
|
|
270
|
+
prose-a:text-[var(--mona-primary-text-color,var(--color-primary))]
|
|
271
|
+
|
|
272
|
+
[&_ol]:ps-8 [&_ul]:ps-8
|
|
273
|
+
|
|
274
|
+
[&_blockquote]:border-s-4
|
|
275
|
+
[&_blockquote]:border-s-solid
|
|
276
|
+
[&_blockquote]:border-s-border-control-hover
|
|
277
|
+
[&_blockquote]:px-4 [&_blockquote]:py-2
|
|
278
|
+
[&_blockquote]:ms-4
|
|
279
|
+
[&_blockquote]:bg-surface-muted
|
|
280
|
+
|
|
281
|
+
[&_hr]:my-1 [&_hr]:bg-border-subtle
|
|
282
|
+
[&_hr]:border [&_hr]:border-border-subtle
|
|
283
|
+
|
|
284
|
+
[&_ul[data-type='taskList']_li]:flex
|
|
285
|
+
[&_ul[data-type='taskList']_li]:py-0.5
|
|
286
|
+
[&_ul[data-type='taskList']_li>label]:grow-0
|
|
287
|
+
[&_ul[data-type='taskList']_li>label]:shrink-0
|
|
288
|
+
[&_ul[data-type='taskList']_li>label]:basis-auto
|
|
289
|
+
[&_ul[data-type='taskList']_li>div]:grow-1
|
|
290
|
+
[&_ul[data-type='taskList']_li>div]:shrink-1
|
|
291
|
+
[&_ul[data-type='taskList']_li>div]:basis-auto
|
|
292
|
+
[&_ul[data-type='taskList']_input[type='checkbox']]:me-2!
|
|
293
|
+
|
|
294
|
+
[&_img]:max-w-full
|
|
295
|
+
[&_img]:h-auto
|
|
296
|
+
[&_img.ProseMirror-selectednode]:outline-3
|
|
297
|
+
[&_img.ProseMirror-selectednode]:outline-focus-indicator
|
|
298
|
+
|
|
299
|
+
[&_span[data-type='mention']]:rounded-sm
|
|
300
|
+
[&_span[data-type='mention']]:bg-primary-subtle
|
|
301
|
+
[&_span[data-type='mention']]:px-0.5
|
|
302
|
+
[&_span[data-type='mention']]:font-medium
|
|
303
|
+
[&_span[data-type='mention']]:text-primary-subtle-foreground
|
|
304
|
+
[&_span[data-type='mention']]:[box-decoration-break:clone]
|
|
305
|
+
|
|
306
|
+
[&_pre]:bg-surface-muted
|
|
307
|
+
[&_pre]:border [&_pre]:border-border-subtle
|
|
308
|
+
[&_pre]:whitespace-pre-wrap
|
|
309
|
+
[&_pre]:font-mono
|
|
310
|
+
[&_pre_code]:p-0
|
|
311
|
+
[&_pre_code]:text-sm
|
|
312
|
+
[&_pre_code]:bg-none
|
|
313
|
+
|
|
314
|
+
[&.ProseMirror-gapcursor]:after:border-foreground!
|
|
315
|
+
|
|
316
|
+
[&_table]:border-collapse
|
|
317
|
+
[&_table]:m-0
|
|
318
|
+
[&_table]:overflow-hidden
|
|
319
|
+
[&_table]:table-fixed
|
|
320
|
+
[&_table]:w-full
|
|
321
|
+
[&_table_td]:border [&_table_td]:border-border-subtle
|
|
322
|
+
[&_table_td]:p-2 [&_table_td]:align-top [&_table_td]:relative
|
|
323
|
+
[&_table_th]:border [&_table_th]:border-border-subtle
|
|
324
|
+
[&_table_th]:p-2 [&_table_th]:align-top [&_table_th]:relative
|
|
325
|
+
|
|
326
|
+
[&_table_th]:bg-surface-muted [&_table_th]:text-foreground [&_table_th]:font-bold
|
|
327
|
+
|
|
328
|
+
[&_.selectedCell]:after:content-[''] [&_.selectedCell]:after:absolute [&_.selectedCell]:after:inset-0
|
|
329
|
+
[&_.selectedCell]:after:pointer-events-none
|
|
330
|
+
[&_.selectedCell]:after:z-2
|
|
331
|
+
[&_.selectedCell]:after:bg-active/70
|
|
332
|
+
|
|
333
|
+
[&_.column-resize-handle]:absolute
|
|
334
|
+
[&_.column-resize-handle]:bg-focus-indicator
|
|
335
|
+
[&_.column-resize-handle]:w-1
|
|
336
|
+
[&_.column-resize-handle]:pointer-events-none
|
|
337
|
+
[&_.column-resize-handle]:top-0
|
|
338
|
+
[&_.column-resize-handle]:-bottom-0.5
|
|
339
|
+
[&_.column-resize-handle]:-end-0.5
|
|
340
|
+
|
|
341
|
+
[&_.ProseMirror.resize-cursor]:cursor-ew-resize
|
|
342
|
+
|
|
343
|
+
`);
|
|
344
|
+
const editorContainerThemeVariants = cva(`
|
|
345
|
+
h-full w-full bg-surface
|
|
346
|
+
[&>.ProseMirror]:p-1.5
|
|
347
|
+
[&>.ProseMirror]:text-foreground
|
|
348
|
+
[&>.ProseMirror]:border-none
|
|
349
|
+
[&>.ProseMirror]:outline-none [&>.ProseMirror:focus-visible]:outline-hidden
|
|
350
|
+
[&>.ProseMirror]:w-full
|
|
351
|
+
[&>.ProseMirror]:h-full
|
|
352
|
+
[&>.ProseMirror]:overflow-auto
|
|
353
|
+
[&>.ProseMirror]:resize-none
|
|
354
|
+
[&>.ProseMirror]:[scrollbar-color:var(--color-scrollbar-thumb)_var(--color-scrollbar-track)]
|
|
355
|
+
[&>.ProseMirror]:[scrollbar-width:thin]
|
|
356
|
+
`, {
|
|
357
|
+
variants: { disabled: {
|
|
358
|
+
true: "bg-disabled-background [&>.ProseMirror]:text-disabled-foreground",
|
|
359
|
+
false: ""
|
|
360
|
+
} },
|
|
361
|
+
defaultVariants: { disabled: false }
|
|
362
|
+
});
|
|
363
|
+
const editorFontColorPreviewThemeVariants = cva(`
|
|
364
|
+
w-full flex h-[2px]
|
|
365
|
+
`);
|
|
366
|
+
const editorFontColorValueThemeVariants = cva(`
|
|
367
|
+
flex flex-col items-center justify-center
|
|
368
|
+
gap-0.5 ps-1.25 text-sm
|
|
369
|
+
`);
|
|
370
|
+
const editorFontFamilyDropdownListThemeVariants = cva(`
|
|
371
|
+
w-[12em]
|
|
372
|
+
`);
|
|
373
|
+
const editorFontHighlightPreviewThemeVariants = cva(`
|
|
374
|
+
w-full flex h-[2px]
|
|
375
|
+
`);
|
|
376
|
+
const editorFontHighlightValueThemeVariants = cva(`
|
|
377
|
+
flex flex-col items-center justify-center
|
|
378
|
+
gap-0.5 ps-1.25 text-sm
|
|
379
|
+
`);
|
|
380
|
+
const editorFontSizeDropdownListThemeVariants = cva(`
|
|
381
|
+
w-[8em]
|
|
382
|
+
`);
|
|
383
|
+
const editorHeadingsDropdownListThemeVariants = cva(`
|
|
384
|
+
w-[14em]
|
|
385
|
+
`);
|
|
386
|
+
const editorImageInserterActionsThemeVariants = cva(`
|
|
387
|
+
flex justify-end gap-1 px-2 py-1
|
|
388
|
+
bg-surface-muted
|
|
389
|
+
border-t border-t-border-subtle
|
|
390
|
+
`);
|
|
391
|
+
const editorImageInserterFormThemeVariants = cva(`
|
|
392
|
+
flex flex-col gap-1.5 pt-2
|
|
393
|
+
`);
|
|
394
|
+
const editorImageInserterRowLabelThemeVariants = cva(`
|
|
395
|
+
mb-0.5 ps-0.5 text-sm font-semibold
|
|
396
|
+
`);
|
|
397
|
+
const editorImageInserterRowThemeVariants = cva(`
|
|
398
|
+
flex flex-col justify-center px-2
|
|
399
|
+
`);
|
|
400
|
+
const editorPlaceholderThemeVariants = cva(`
|
|
401
|
+
pointer-events-none absolute top-0 start-0 px-1.5 py-2.5
|
|
402
|
+
text-muted-foreground select-none
|
|
403
|
+
`);
|
|
404
|
+
const editorTableCreatorThemeVariants = cva(`
|
|
405
|
+
grid grid-cols-8 gap-0.5 p-1
|
|
406
|
+
`);
|
|
407
|
+
const editorTableCreatorCellThemeVariants = cva(`
|
|
408
|
+
flex h-6 w-6 p-0 cursor-pointer
|
|
409
|
+
bg-surface-muted border border-input-border
|
|
410
|
+
data-[highlighted]:bg-primary data-[highlighted]:border-primary
|
|
411
|
+
focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-focus-indicator
|
|
412
|
+
`);
|
|
413
|
+
const editorToolbarThemeVariants = cva(`
|
|
414
|
+
flex flex-wrap items-center justify-start gap-1 p-1
|
|
415
|
+
bg-surface-muted text-foreground border-b border-b-border-subtle
|
|
416
|
+
`, {
|
|
417
|
+
variants: { disabled: {
|
|
418
|
+
true: "opacity-50",
|
|
419
|
+
false: ""
|
|
420
|
+
} },
|
|
421
|
+
defaultVariants: { disabled: false }
|
|
422
|
+
});
|
|
423
|
+
const EDITOR_IMAGE_UPLOAD_CLASSES = "relative flex w-fit max-w-full flex-col gap-1";
|
|
424
|
+
const EDITOR_IMAGE_UPLOAD_PREVIEW_CLASSES = "m-0! max-h-40 max-w-full opacity-60";
|
|
425
|
+
const EDITOR_IMAGE_UPLOAD_TRACK_CLASSES = "block h-1 w-full overflow-hidden rounded-full bg-surface-muted forced-colors:border forced-colors:border-[CanvasText]";
|
|
426
|
+
const EDITOR_IMAGE_UPLOAD_BAR_CLASSES = "block h-full bg-primary forced-colors:bg-[Highlight]";
|
|
427
|
+
const EDITOR_FOOTER_CLASSES = "not-prose flex flex-wrap justify-end gap-x-3 border-t border-border-subtle px-2 py-1 text-xs text-muted-foreground";
|
|
428
|
+
const EDITOR_COUNT_OVER_CLASSES = "font-medium text-error";
|
|
429
|
+
const EDITOR_MENTION_LIST_CLASSES = `
|
|
430
|
+
not-prose flex max-h-60 min-w-48 flex-col overflow-auto
|
|
431
|
+
rounded-md border border-border py-1 text-sm text-foreground shadow-(--shadow-overlay)
|
|
432
|
+
[scrollbar-color:var(--color-scrollbar-thumb)_var(--color-scrollbar-track)] [scrollbar-width:thin]
|
|
433
|
+
${themeOverlaySurfaceClasses}
|
|
434
|
+
`;
|
|
435
|
+
const EDITOR_MENTION_STATUS_CLASSES = "px-3 py-1 text-muted-foreground";
|
|
436
|
+
const editorMentionOptionThemeVariants = cva("flex cursor-pointer select-none items-center px-3 py-1 text-foreground hover:bg-hover", {
|
|
437
|
+
variants: { highlighted: {
|
|
438
|
+
true: "bg-hover inset-ring-2 inset-ring-focus-indicator forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]",
|
|
439
|
+
false: ""
|
|
440
|
+
} },
|
|
441
|
+
defaultVariants: { highlighted: false }
|
|
442
|
+
});
|
|
103
443
|
const ExtendedImage = Image.extend({
|
|
104
444
|
name: "extendedImage",
|
|
105
445
|
addAttributes() {
|
|
@@ -255,6 +595,122 @@ const Indent = Extension.create({
|
|
|
255
595
|
};
|
|
256
596
|
}
|
|
257
597
|
});
|
|
598
|
+
const MENTION_KEY = new PluginKey("monaMention");
|
|
599
|
+
const QUERY_PATTERN = /(?:^|[\s(])@([^\s@]{0,50})$/u;
|
|
600
|
+
function findQuery(state) {
|
|
601
|
+
const { selection } = state;
|
|
602
|
+
if (!selection.empty) return null;
|
|
603
|
+
const $from = selection.$from;
|
|
604
|
+
if (!$from.parent.isTextblock || $from.parent.type.spec.code) return null;
|
|
605
|
+
const code = state.schema.marks["code"];
|
|
606
|
+
if (code && $from.marks().some((mark) => mark.type === code)) return null;
|
|
607
|
+
const start = Math.max(0, $from.parentOffset - 60);
|
|
608
|
+
const textBefore = $from.parent.textBetween(start, $from.parentOffset, void 0, "");
|
|
609
|
+
const match = QUERY_PATTERN.exec(textBefore);
|
|
610
|
+
if (!match) return null;
|
|
611
|
+
const query = match[1] ?? "";
|
|
612
|
+
return {
|
|
613
|
+
from: $from.pos - query.length - 1,
|
|
614
|
+
query,
|
|
615
|
+
to: $from.pos
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
function sameQuery(a, b) {
|
|
619
|
+
return a?.from === b?.from && a?.query === b?.query && a?.to === b?.to;
|
|
620
|
+
}
|
|
621
|
+
const Mention = Node.create({
|
|
622
|
+
name: "mention",
|
|
623
|
+
group: "inline",
|
|
624
|
+
inline: true,
|
|
625
|
+
atom: true,
|
|
626
|
+
selectable: false,
|
|
627
|
+
addOptions() {
|
|
628
|
+
return {
|
|
629
|
+
enabled: () => false,
|
|
630
|
+
onKeyDown: () => false,
|
|
631
|
+
onQuery: () => void 0
|
|
632
|
+
};
|
|
633
|
+
},
|
|
634
|
+
addAttributes() {
|
|
635
|
+
return {
|
|
636
|
+
id: {
|
|
637
|
+
default: null,
|
|
638
|
+
parseHTML: (element) => element.getAttribute("data-id"),
|
|
639
|
+
renderHTML: (attributes) => attributes["id"] ? { "data-id": attributes["id"] } : {}
|
|
640
|
+
},
|
|
641
|
+
label: {
|
|
642
|
+
default: null,
|
|
643
|
+
parseHTML: (element) => element.getAttribute("data-label") ?? element.textContent?.replace(/^@/u, "") ?? null,
|
|
644
|
+
renderHTML: (attributes) => attributes["label"] ? { "data-label": attributes["label"] } : {}
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
},
|
|
648
|
+
parseHTML() {
|
|
649
|
+
return [{ tag: "span[data-type=\"mention\"]" }];
|
|
650
|
+
},
|
|
651
|
+
renderHTML({ HTMLAttributes: attributes, node }) {
|
|
652
|
+
const label = String(node.attrs["label"] ?? node.attrs["id"] ?? "");
|
|
653
|
+
return [
|
|
654
|
+
"span",
|
|
655
|
+
mergeAttributes({ "data-type": "mention" }, attributes),
|
|
656
|
+
`@${label}`
|
|
657
|
+
];
|
|
658
|
+
},
|
|
659
|
+
renderText({ node }) {
|
|
660
|
+
return `@${String(node.attrs["label"] ?? node.attrs["id"] ?? "")}`;
|
|
661
|
+
},
|
|
662
|
+
addProseMirrorPlugins() {
|
|
663
|
+
const options = this.options;
|
|
664
|
+
return [new Plugin({
|
|
665
|
+
key: MENTION_KEY,
|
|
666
|
+
state: {
|
|
667
|
+
init: () => ({
|
|
668
|
+
dismissed: null,
|
|
669
|
+
query: null
|
|
670
|
+
}),
|
|
671
|
+
apply: (tr, previous, _oldState, newState) => {
|
|
672
|
+
const dismissed = tr.getMeta(MENTION_KEY)?.dismiss ?? (previous.dismissed === null ? null : tr.mapping.map(previous.dismissed));
|
|
673
|
+
const query = options.enabled() ? findQuery(newState) : null;
|
|
674
|
+
if (query === null) return {
|
|
675
|
+
dismissed: null,
|
|
676
|
+
query: null
|
|
677
|
+
};
|
|
678
|
+
return {
|
|
679
|
+
dismissed,
|
|
680
|
+
query: query.from === dismissed ? null : query
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
},
|
|
684
|
+
view: (view) => {
|
|
685
|
+
let current = null;
|
|
686
|
+
return {
|
|
687
|
+
update: (updated) => {
|
|
688
|
+
const next = MENTION_KEY.getState(updated.state)?.query ?? null;
|
|
689
|
+
if (!sameQuery(current, next)) {
|
|
690
|
+
current = next;
|
|
691
|
+
options.onQuery(updated, next);
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
destroy: () => {
|
|
695
|
+
if (current !== null) {
|
|
696
|
+
current = null;
|
|
697
|
+
options.onQuery(view, null);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
},
|
|
702
|
+
props: { handleKeyDown: (view, event) => {
|
|
703
|
+
const query = MENTION_KEY.getState(view.state)?.query;
|
|
704
|
+
if (!query || event.isComposing) return false;
|
|
705
|
+
if (event.key === "Escape") {
|
|
706
|
+
view.dispatch(view.state.tr.setMeta(MENTION_KEY, { dismiss: query.from }));
|
|
707
|
+
return true;
|
|
708
|
+
}
|
|
709
|
+
return options.onKeyDown(event);
|
|
710
|
+
} }
|
|
711
|
+
})];
|
|
712
|
+
}
|
|
713
|
+
});
|
|
258
714
|
const DEFAULT_FONTS = [
|
|
259
715
|
"Arial",
|
|
260
716
|
"Comic Sans MS",
|
|
@@ -302,6 +758,7 @@ const DEFAULT_SETTINGS = {
|
|
|
302
758
|
italic: true,
|
|
303
759
|
link: true,
|
|
304
760
|
list: true,
|
|
761
|
+
mention: true,
|
|
305
762
|
strikethrough: true,
|
|
306
763
|
subscript: true,
|
|
307
764
|
superscript: true,
|
|
@@ -335,6 +792,8 @@ var EditorService = class EditorService {
|
|
|
335
792
|
this.settings = signal({}, ...ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []);
|
|
336
793
|
this.state = this.#state.asReadonly();
|
|
337
794
|
this.update$ = new Subject();
|
|
795
|
+
this.imageUploader = null;
|
|
796
|
+
this.mentionController = null;
|
|
338
797
|
}
|
|
339
798
|
#ready;
|
|
340
799
|
#state;
|
|
@@ -410,7 +869,18 @@ var EditorService = class EditorService {
|
|
|
410
869
|
if (settings.fontFamily) extensions.add(FontFamily);
|
|
411
870
|
if (settings.fontHighlight) extensions.add(Highlight.configure({ multicolor: true }));
|
|
412
871
|
if (settings.fontSize) extensions.add(FontSize);
|
|
413
|
-
if (settings.image)
|
|
872
|
+
if (settings.image) {
|
|
873
|
+
extensions.add(ExtendedImage);
|
|
874
|
+
extensions.add(ImageUpload.configure({
|
|
875
|
+
accepted: (files) => this.imageUploader?.accepted(files) ?? [],
|
|
876
|
+
upload: (view, files, position) => this.imageUploader?.upload(view, files, position)
|
|
877
|
+
}));
|
|
878
|
+
}
|
|
879
|
+
if (settings.mention) extensions.add(Mention.configure({
|
|
880
|
+
enabled: () => this.mentionController?.enabled() ?? false,
|
|
881
|
+
onKeyDown: (event) => this.mentionController?.onKeyDown(event) ?? false,
|
|
882
|
+
onQuery: (view, query) => this.mentionController?.onQuery(view, query)
|
|
883
|
+
}));
|
|
414
884
|
if (settings.indent) extensions.add(Indent);
|
|
415
885
|
if (settings.subscript) extensions.add(Subscript);
|
|
416
886
|
if (settings.superscript) extensions.add(Superscript);
|
|
@@ -477,174 +947,515 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
477
947
|
type: EditorService,
|
|
478
948
|
decorators: [{ type: Injectable }]
|
|
479
949
|
});
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
950
|
+
var EditorImageUploadService = class EditorImageUploadService {
|
|
951
|
+
#announcer;
|
|
952
|
+
#document;
|
|
953
|
+
#editorService;
|
|
954
|
+
#i18n;
|
|
955
|
+
#messages;
|
|
956
|
+
#uploads;
|
|
957
|
+
#nextId;
|
|
958
|
+
constructor() {
|
|
959
|
+
this.#announcer = injectLiveAnnouncer();
|
|
960
|
+
this.#document = inject(DOCUMENT$1);
|
|
961
|
+
this.#editorService = inject(EditorService);
|
|
962
|
+
this.#i18n = inject(MonaI18nService);
|
|
963
|
+
this.#messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
964
|
+
this.#uploads = /* @__PURE__ */ new Map();
|
|
965
|
+
this.#nextId = 0;
|
|
966
|
+
this.options = signal({
|
|
967
|
+
accept: "image/*",
|
|
968
|
+
handler: null,
|
|
969
|
+
maxFileSize: null
|
|
970
|
+
}, ...ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []);
|
|
971
|
+
this.#editorService.imageUploader = this;
|
|
972
|
+
inject(DestroyRef).onDestroy(() => {
|
|
973
|
+
for (const abort of [...this.#uploads.values()]) abort();
|
|
974
|
+
this.#uploads.clear();
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
accepted(files) {
|
|
978
|
+
const { accept, handler } = untracked(this.options);
|
|
979
|
+
if (handler == null) return [];
|
|
980
|
+
const tokens = parseAccept(accept);
|
|
981
|
+
return files.filter((file) => matchesAccept(file, tokens));
|
|
982
|
+
}
|
|
983
|
+
upload(view, files, position) {
|
|
984
|
+
for (const file of files) this.#upload(view, file, position);
|
|
985
|
+
}
|
|
986
|
+
#announce(message) {
|
|
987
|
+
this.#announcer.announce(message, "polite");
|
|
988
|
+
}
|
|
989
|
+
#placeholder(previewUrl, label) {
|
|
990
|
+
const element = this.#document.createElement("span");
|
|
991
|
+
element.className = EDITOR_IMAGE_UPLOAD_CLASSES;
|
|
992
|
+
element.contentEditable = "false";
|
|
993
|
+
element.setAttribute("role", "img");
|
|
994
|
+
element.setAttribute("aria-label", label);
|
|
995
|
+
const preview = this.#document.createElement("img");
|
|
996
|
+
preview.className = EDITOR_IMAGE_UPLOAD_PREVIEW_CLASSES;
|
|
997
|
+
preview.alt = "";
|
|
998
|
+
preview.src = previewUrl;
|
|
999
|
+
const track = this.#document.createElement("span");
|
|
1000
|
+
track.className = EDITOR_IMAGE_UPLOAD_TRACK_CLASSES;
|
|
1001
|
+
const bar = this.#document.createElement("span");
|
|
1002
|
+
bar.className = EDITOR_IMAGE_UPLOAD_BAR_CLASSES;
|
|
1003
|
+
bar.style.inlineSize = "0%";
|
|
1004
|
+
track.append(bar);
|
|
1005
|
+
element.append(preview, track);
|
|
1006
|
+
return {
|
|
1007
|
+
bar,
|
|
1008
|
+
element
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
#upload(view, file, position) {
|
|
1012
|
+
const { handler, maxFileSize } = untracked(this.options);
|
|
1013
|
+
if (handler == null) return;
|
|
1014
|
+
const messages = untracked(this.#messages);
|
|
1015
|
+
if (maxFileSize != null && file.size > maxFileSize) {
|
|
1016
|
+
const size = formatFileSize(maxFileSize, untracked(this.#i18n.localeId));
|
|
1017
|
+
this.#announce(messages.imageTooLarge(file.name, size));
|
|
1018
|
+
return;
|
|
1019
|
+
}
|
|
1020
|
+
const id = `mona-image-upload-${this.#nextId++}`;
|
|
1021
|
+
const previewUrl = URL.createObjectURL(file);
|
|
1022
|
+
const { bar, element } = this.#placeholder(previewUrl, messages.imageUploading(file.name));
|
|
1023
|
+
addImagePlaceholder(view, id, position, element);
|
|
1024
|
+
this.#announce(messages.imageUploading(file.name));
|
|
1025
|
+
const finish = () => {
|
|
1026
|
+
this.#uploads.delete(id);
|
|
1027
|
+
URL.revokeObjectURL(previewUrl);
|
|
1028
|
+
};
|
|
1029
|
+
const fail = () => {
|
|
1030
|
+
if (!view.isDestroyed) removeImagePlaceholder(view, id);
|
|
1031
|
+
this.#announce(untracked(this.#messages).imageUploadFailed(file.name));
|
|
1032
|
+
};
|
|
1033
|
+
let abort = null;
|
|
1034
|
+
this.#uploads.set(id, () => {
|
|
1035
|
+
abort?.();
|
|
1036
|
+
finish();
|
|
1037
|
+
});
|
|
1038
|
+
abort = runUpload(handler, file, {
|
|
1039
|
+
failure: () => {
|
|
1040
|
+
finish();
|
|
1041
|
+
fail();
|
|
1042
|
+
},
|
|
1043
|
+
progress: (fraction) => {
|
|
1044
|
+
bar.style.inlineSize = `${Math.round(fraction * 100)}%`;
|
|
1045
|
+
},
|
|
1046
|
+
success: (response) => {
|
|
1047
|
+
finish();
|
|
1048
|
+
if (typeof response !== "string" || response === "") {
|
|
1049
|
+
if (isDevMode()) console.warn("[Mona Editor] imageUpload should return the image's address as a string, but it returned:", response);
|
|
1050
|
+
fail();
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
this.#insert(view, id, response, file.name);
|
|
1054
|
+
}
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
#insert(view, id, src, name) {
|
|
1058
|
+
if (view.isDestroyed || !this.#editorService.ready() || this.#editorService.editor.view !== view) return;
|
|
1059
|
+
const position = findImagePlaceholder(view.state, id);
|
|
1060
|
+
if (position === null) return;
|
|
1061
|
+
const removal = imagePlaceholderRemoval(id);
|
|
1062
|
+
this.#editorService.editor.chain().command(({ tr }) => {
|
|
1063
|
+
tr.setMeta(removal.key, removal.value);
|
|
1064
|
+
return true;
|
|
1065
|
+
}).insertContentAt(position, {
|
|
1066
|
+
attrs: { src },
|
|
1067
|
+
type: "extendedImage"
|
|
1068
|
+
}, { updateSelection: false }).run();
|
|
1069
|
+
this.#announce(untracked(this.#messages).imageInserted(name));
|
|
1070
|
+
}
|
|
1071
|
+
static {
|
|
1072
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1073
|
+
minVersion: "12.0.0",
|
|
1074
|
+
version: "22.2.6",
|
|
1075
|
+
ngImport: i0,
|
|
1076
|
+
type: EditorImageUploadService,
|
|
1077
|
+
deps: [],
|
|
1078
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
static {
|
|
1082
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
1083
|
+
minVersion: "12.0.0",
|
|
1084
|
+
version: "22.2.6",
|
|
1085
|
+
ngImport: i0,
|
|
1086
|
+
type: EditorImageUploadService
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1091
|
+
minVersion: "12.0.0",
|
|
1092
|
+
version: "22.2.6",
|
|
1093
|
+
ngImport: i0,
|
|
1094
|
+
type: EditorImageUploadService,
|
|
1095
|
+
decorators: [{ type: Injectable }],
|
|
1096
|
+
ctorParameters: () => []
|
|
587
1097
|
});
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
const
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
1098
|
+
var EditorMentionListComponent = class EditorMentionListComponent {
|
|
1099
|
+
constructor() {
|
|
1100
|
+
this.#i18n = inject(MonaI18nService);
|
|
1101
|
+
this.listClass = EDITOR_MENTION_LIST_CLASSES;
|
|
1102
|
+
this.mention = inject(PopupDataInjectionToken);
|
|
1103
|
+
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1104
|
+
this.options = computed(() => {
|
|
1105
|
+
const highlighted = this.mention.highlightedIndex();
|
|
1106
|
+
return this.mention.items().map((item, index) => ({
|
|
1107
|
+
class: editorMentionOptionThemeVariants({ highlighted: index === highlighted }),
|
|
1108
|
+
highlighted: index === highlighted,
|
|
1109
|
+
id: this.mention.optionId(index),
|
|
1110
|
+
index,
|
|
1111
|
+
label: item.label
|
|
1112
|
+
}));
|
|
1113
|
+
}, ...ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []);
|
|
1114
|
+
this.statusClass = EDITOR_MENTION_STATUS_CLASSES;
|
|
1115
|
+
}
|
|
1116
|
+
#i18n;
|
|
1117
|
+
onOptionClick(index) {
|
|
1118
|
+
this.mention.select(index);
|
|
1119
|
+
}
|
|
1120
|
+
onOptionPointerDown(event) {
|
|
1121
|
+
event.preventDefault();
|
|
1122
|
+
}
|
|
1123
|
+
onOptionPointerEnter(index) {
|
|
1124
|
+
this.mention.highlightedIndex.set(index);
|
|
1125
|
+
}
|
|
1126
|
+
static {
|
|
1127
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1128
|
+
minVersion: "12.0.0",
|
|
1129
|
+
version: "22.2.6",
|
|
1130
|
+
ngImport: i0,
|
|
1131
|
+
type: EditorMentionListComponent,
|
|
1132
|
+
deps: [],
|
|
1133
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
static {
|
|
1137
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
1138
|
+
minVersion: "17.0.0",
|
|
1139
|
+
version: "22.2.6",
|
|
1140
|
+
type: EditorMentionListComponent,
|
|
1141
|
+
isStandalone: true,
|
|
1142
|
+
selector: "mona-editor-mention-list",
|
|
1143
|
+
ngImport: i0,
|
|
1144
|
+
template: "<div [class]=\"listClass\">\n @if (options().length > 0) {\n <ul\n role=\"listbox\"\n class=\"m-0 list-none p-0\"\n [id]=\"mention.listId\"\n [attr.aria-label]=\"messages().mentionSuggestions\">\n @for (option of options(); track option.id) {\n <li\n role=\"option\"\n [id]=\"option.id\"\n [class]=\"option.class\"\n [attr.aria-selected]=\"option.highlighted\"\n (click)=\"onOptionClick(option.index)\"\n (pointerdown)=\"onOptionPointerDown($event)\"\n (pointerenter)=\"onOptionPointerEnter(option.index)\">\n {{ option.label }}\n </li>\n }\n </ul>\n } @else if (mention.loading()) {\n <div [class]=\"statusClass\">{{ messages().mentionSearching }}</div>\n } @else {\n <div [class]=\"statusClass\">{{ messages().mentionNoResults }}</div>\n }\n</div>\n"
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
};
|
|
1148
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1149
|
+
minVersion: "12.0.0",
|
|
1150
|
+
version: "22.2.6",
|
|
1151
|
+
ngImport: i0,
|
|
1152
|
+
type: EditorMentionListComponent,
|
|
1153
|
+
decorators: [{
|
|
1154
|
+
type: Component,
|
|
1155
|
+
args: [{
|
|
1156
|
+
selector: "mona-editor-mention-list",
|
|
1157
|
+
template: "<div [class]=\"listClass\">\n @if (options().length > 0) {\n <ul\n role=\"listbox\"\n class=\"m-0 list-none p-0\"\n [id]=\"mention.listId\"\n [attr.aria-label]=\"messages().mentionSuggestions\">\n @for (option of options(); track option.id) {\n <li\n role=\"option\"\n [id]=\"option.id\"\n [class]=\"option.class\"\n [attr.aria-selected]=\"option.highlighted\"\n (click)=\"onOptionClick(option.index)\"\n (pointerdown)=\"onOptionPointerDown($event)\"\n (pointerenter)=\"onOptionPointerEnter(option.index)\">\n {{ option.label }}\n </li>\n }\n </ul>\n } @else if (mention.loading()) {\n <div [class]=\"statusClass\">{{ messages().mentionSearching }}</div>\n } @else {\n <div [class]=\"statusClass\">{{ messages().mentionNoResults }}</div>\n }\n</div>\n"
|
|
1158
|
+
}]
|
|
1159
|
+
}]
|
|
1160
|
+
});
|
|
1161
|
+
function toMentions(result) {
|
|
1162
|
+
if (isObservable(result)) return result.pipe(map((mentions) => Array.from(mentions)));
|
|
1163
|
+
if (typeof result.then === "function") return from(result).pipe(map((mentions) => Array.from(mentions)));
|
|
1164
|
+
return of(Array.from(result));
|
|
1165
|
+
}
|
|
1166
|
+
var EditorMentionService = class EditorMentionService {
|
|
1167
|
+
#announcer;
|
|
1168
|
+
#destroyRef;
|
|
1169
|
+
#document;
|
|
1170
|
+
#editorService;
|
|
1171
|
+
#i18n;
|
|
1172
|
+
#injector;
|
|
1173
|
+
#messages;
|
|
1174
|
+
#popupService;
|
|
1175
|
+
#searches;
|
|
1176
|
+
#popupRef;
|
|
1177
|
+
#query;
|
|
1178
|
+
#view;
|
|
1179
|
+
constructor() {
|
|
1180
|
+
this.#announcer = injectLiveAnnouncer();
|
|
1181
|
+
this.#destroyRef = inject(DestroyRef);
|
|
1182
|
+
this.#document = inject(DOCUMENT$1);
|
|
1183
|
+
this.#editorService = inject(EditorService);
|
|
1184
|
+
this.#i18n = inject(MonaI18nService);
|
|
1185
|
+
this.#injector = inject(Injector);
|
|
1186
|
+
this.#messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
1187
|
+
this.#popupService = inject(PopupService);
|
|
1188
|
+
this.#searches = new Subject();
|
|
1189
|
+
this.#popupRef = null;
|
|
1190
|
+
this.#query = null;
|
|
1191
|
+
this.#view = null;
|
|
1192
|
+
this.activeDescendant = computed(() => this.open() && this.items().length > 0 ? this.optionId(this.highlightedIndex()) : null, ...ngDevMode ? [{ debugName: "activeDescendant" }] : /* istanbul ignore next */ []);
|
|
1193
|
+
this.highlightedIndex = signal(0, ...ngDevMode ? [{ debugName: "highlightedIndex" }] : /* istanbul ignore next */ []);
|
|
1194
|
+
this.items = signal([], ...ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []);
|
|
1195
|
+
this.listId = createElementControlId();
|
|
1196
|
+
this.loading = signal(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
|
|
1197
|
+
this.open = signal(false, ...ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []);
|
|
1198
|
+
this.search = signal(null, ...ngDevMode ? [{ debugName: "search" }] : /* istanbul ignore next */ []);
|
|
1199
|
+
this.#editorService.mentionController = this;
|
|
1200
|
+
this.#searches.pipe(switchMap((query) => {
|
|
1201
|
+
const search = untracked(this.search);
|
|
1202
|
+
if (query === null || search === null) return of(null);
|
|
1203
|
+
this.loading.set(true);
|
|
1204
|
+
let result;
|
|
1205
|
+
try {
|
|
1206
|
+
result = search(query);
|
|
1207
|
+
} catch {
|
|
1208
|
+
return of([]);
|
|
1209
|
+
}
|
|
1210
|
+
return toMentions(result).pipe(catchError(() => of([])));
|
|
1211
|
+
}), takeUntilDestroyed(this.#destroyRef)).subscribe((items) => {
|
|
1212
|
+
this.loading.set(false);
|
|
1213
|
+
if (items === null) return;
|
|
1214
|
+
this.items.set(items);
|
|
1215
|
+
this.highlightedIndex.set(0);
|
|
1216
|
+
const messages = untracked(this.#messages);
|
|
1217
|
+
this.#announce(items.length > 0 ? messages.mentionResults(items.length) : messages.mentionNoResults);
|
|
1218
|
+
});
|
|
1219
|
+
this.#editorService.blur$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => this.#dismiss());
|
|
1220
|
+
fromEvent(this.#document, "scroll", {
|
|
1221
|
+
capture: true,
|
|
1222
|
+
passive: true
|
|
1223
|
+
}).pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => this.#reposition());
|
|
1224
|
+
this.#destroyRef.onDestroy(() => this.#close());
|
|
1225
|
+
}
|
|
1226
|
+
enabled() {
|
|
1227
|
+
return untracked(this.search) !== null;
|
|
1228
|
+
}
|
|
1229
|
+
highlight(index) {
|
|
1230
|
+
const count = this.items().length;
|
|
1231
|
+
if (count === 0) return;
|
|
1232
|
+
this.highlightedIndex.set((index % count + count) % count);
|
|
1233
|
+
this.#document.getElementById(this.optionId(this.highlightedIndex()))?.scrollIntoView({ block: "nearest" });
|
|
1234
|
+
}
|
|
1235
|
+
onKeyDown(event) {
|
|
1236
|
+
if (!this.open() || this.items().length === 0 || event.altKey || event.ctrlKey || event.metaKey) return false;
|
|
1237
|
+
switch (event.key) {
|
|
1238
|
+
case "ArrowDown":
|
|
1239
|
+
this.highlight(this.highlightedIndex() + 1);
|
|
1240
|
+
return true;
|
|
1241
|
+
case "ArrowUp":
|
|
1242
|
+
this.highlight(this.highlightedIndex() - 1);
|
|
1243
|
+
return true;
|
|
1244
|
+
case "Enter":
|
|
1245
|
+
case "Tab":
|
|
1246
|
+
if (event.shiftKey) return false;
|
|
1247
|
+
this.select(this.highlightedIndex());
|
|
1248
|
+
return true;
|
|
1249
|
+
default: return false;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
onQuery(view, query) {
|
|
1253
|
+
const previous = this.#query;
|
|
1254
|
+
this.#query = query;
|
|
1255
|
+
this.#view = query ? view : null;
|
|
1256
|
+
if (query === null) {
|
|
1257
|
+
this.#searches.next(null);
|
|
1258
|
+
this.#close();
|
|
1259
|
+
return;
|
|
1260
|
+
}
|
|
1261
|
+
if (previous?.query !== query.query || previous.from !== query.from) this.#searches.next(query.query);
|
|
1262
|
+
if (this.#popupRef === null) this.#openPopup(view, query);
|
|
1263
|
+
else this.#reposition();
|
|
1264
|
+
}
|
|
1265
|
+
optionId(index) {
|
|
1266
|
+
return `${this.listId}-${index}`;
|
|
1267
|
+
}
|
|
1268
|
+
select(index) {
|
|
1269
|
+
const item = this.items()[index];
|
|
1270
|
+
const query = this.#query;
|
|
1271
|
+
const view = this.#view;
|
|
1272
|
+
if (!item || !query || !view || view.isDestroyed || this.#editorService.editor.view !== view) return;
|
|
1273
|
+
this.#editorService.editor.chain().focus().insertContentAt({
|
|
1274
|
+
from: query.from,
|
|
1275
|
+
to: query.to
|
|
1276
|
+
}, [{
|
|
1277
|
+
attrs: {
|
|
1278
|
+
id: item.id,
|
|
1279
|
+
label: item.label
|
|
1280
|
+
},
|
|
1281
|
+
type: "mention"
|
|
1282
|
+
}, {
|
|
1283
|
+
text: " ",
|
|
1284
|
+
type: "text"
|
|
1285
|
+
}]).run();
|
|
1286
|
+
}
|
|
1287
|
+
#anchor(view, position) {
|
|
1288
|
+
const coords = view.coordsAtPos(position);
|
|
1289
|
+
return {
|
|
1290
|
+
height: coords.bottom - coords.top,
|
|
1291
|
+
width: 1,
|
|
1292
|
+
x: coords.left,
|
|
1293
|
+
y: coords.top
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
#announce(message) {
|
|
1297
|
+
this.#announcer.announce(message, "polite");
|
|
1298
|
+
}
|
|
1299
|
+
#close() {
|
|
1300
|
+
const popupRef = this.#popupRef;
|
|
1301
|
+
this.#popupRef = null;
|
|
1302
|
+
this.open.set(false);
|
|
1303
|
+
this.items.set([]);
|
|
1304
|
+
this.loading.set(false);
|
|
1305
|
+
popupRef?.close();
|
|
1306
|
+
}
|
|
1307
|
+
#dismiss() {
|
|
1308
|
+
const view = this.#view;
|
|
1309
|
+
const query = this.#query;
|
|
1310
|
+
if (view && query && !view.isDestroyed) view.dispatch(view.state.tr.setMeta(MENTION_KEY, { dismiss: query.from }));
|
|
1311
|
+
}
|
|
1312
|
+
#openPopup(view, query) {
|
|
1313
|
+
const popupRef = this.#popupService.create({
|
|
1314
|
+
anchor: this.#anchor(view, query.from),
|
|
1315
|
+
anchorConnectionPoint: "bottomleft",
|
|
1316
|
+
closeOnEscape: false,
|
|
1317
|
+
closeOnOutsideClick: false,
|
|
1318
|
+
content: EditorMentionListComponent,
|
|
1319
|
+
data: this,
|
|
1320
|
+
injector: this.#injector,
|
|
1321
|
+
offset: {
|
|
1322
|
+
horizontal: 0,
|
|
1323
|
+
vertical: 4
|
|
1324
|
+
},
|
|
1325
|
+
popupConnectionPoint: "topleft",
|
|
1326
|
+
restoreFocus: false,
|
|
1327
|
+
withPush: true,
|
|
1328
|
+
withScrollTracking: false
|
|
1329
|
+
});
|
|
1330
|
+
this.#popupRef = popupRef;
|
|
1331
|
+
this.open.set(true);
|
|
1332
|
+
popupRef.closed.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
1333
|
+
if (this.#popupRef === popupRef) {
|
|
1334
|
+
this.#popupRef = null;
|
|
1335
|
+
this.open.set(false);
|
|
1336
|
+
}
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
#reposition() {
|
|
1340
|
+
const popupRef = this.#popupRef;
|
|
1341
|
+
const view = this.#view;
|
|
1342
|
+
const query = this.#query;
|
|
1343
|
+
if (!popupRef || !view || !query || view.isDestroyed) return;
|
|
1344
|
+
popupRef.overlayRef.getConfig().positionStrategy?.setOrigin(this.#anchor(view, query.from));
|
|
1345
|
+
popupRef.overlayRef.updatePosition();
|
|
1346
|
+
}
|
|
1347
|
+
static {
|
|
1348
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1349
|
+
minVersion: "12.0.0",
|
|
1350
|
+
version: "22.2.6",
|
|
1351
|
+
ngImport: i0,
|
|
1352
|
+
type: EditorMentionService,
|
|
1353
|
+
deps: [],
|
|
1354
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
static {
|
|
1358
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
1359
|
+
minVersion: "12.0.0",
|
|
1360
|
+
version: "22.2.6",
|
|
1361
|
+
ngImport: i0,
|
|
1362
|
+
type: EditorMentionService
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
};
|
|
1366
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1367
|
+
minVersion: "12.0.0",
|
|
1368
|
+
version: "22.2.6",
|
|
1369
|
+
ngImport: i0,
|
|
1370
|
+
type: EditorMentionService,
|
|
1371
|
+
decorators: [{ type: Injectable }],
|
|
1372
|
+
ctorParameters: () => []
|
|
647
1373
|
});
|
|
1374
|
+
const BLOCK_ELEMENTS = /* @__PURE__ */ new Set([
|
|
1375
|
+
"ADDRESS",
|
|
1376
|
+
"ARTICLE",
|
|
1377
|
+
"ASIDE",
|
|
1378
|
+
"BLOCKQUOTE",
|
|
1379
|
+
"BR",
|
|
1380
|
+
"DD",
|
|
1381
|
+
"DIV",
|
|
1382
|
+
"DL",
|
|
1383
|
+
"DT",
|
|
1384
|
+
"FIGCAPTION",
|
|
1385
|
+
"FIGURE",
|
|
1386
|
+
"FOOTER",
|
|
1387
|
+
"H1",
|
|
1388
|
+
"H2",
|
|
1389
|
+
"H3",
|
|
1390
|
+
"H4",
|
|
1391
|
+
"H5",
|
|
1392
|
+
"H6",
|
|
1393
|
+
"HEADER",
|
|
1394
|
+
"HR",
|
|
1395
|
+
"LI",
|
|
1396
|
+
"OL",
|
|
1397
|
+
"P",
|
|
1398
|
+
"PRE",
|
|
1399
|
+
"SECTION",
|
|
1400
|
+
"TABLE",
|
|
1401
|
+
"TD",
|
|
1402
|
+
"TH",
|
|
1403
|
+
"TR",
|
|
1404
|
+
"UL"
|
|
1405
|
+
]);
|
|
1406
|
+
const segmenters = /* @__PURE__ */ new Map();
|
|
1407
|
+
function createSegmenter(locale, granularity) {
|
|
1408
|
+
try {
|
|
1409
|
+
return typeof Intl.Segmenter === "function" ? new Intl.Segmenter(locale, { granularity }) : null;
|
|
1410
|
+
} catch {
|
|
1411
|
+
return null;
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
function segmenter(locale, granularity) {
|
|
1415
|
+
const key = `${locale ?? ""}|${granularity}`;
|
|
1416
|
+
if (!segmenters.has(key)) segmenters.set(key, createSegmenter(locale, granularity));
|
|
1417
|
+
return segmenters.get(key) ?? null;
|
|
1418
|
+
}
|
|
1419
|
+
function countText(text, unit, locale) {
|
|
1420
|
+
if (unit === "characters") {
|
|
1421
|
+
const graphemes = segmenter(locale, "grapheme");
|
|
1422
|
+
if (!graphemes) return Array.from(text).length;
|
|
1423
|
+
let count = 0;
|
|
1424
|
+
for (const _ of graphemes.segment(text)) count++;
|
|
1425
|
+
return count;
|
|
1426
|
+
}
|
|
1427
|
+
const words = segmenter(locale, "word");
|
|
1428
|
+
if (!words) return text.split(/\s+/u).filter((word) => word.length > 0).length;
|
|
1429
|
+
let count = 0;
|
|
1430
|
+
for (const segment of words.segment(text)) if (segment.isWordLike) count++;
|
|
1431
|
+
return count;
|
|
1432
|
+
}
|
|
1433
|
+
function documentText(doc, unit) {
|
|
1434
|
+
const separator = unit === "words" ? "\n" : "";
|
|
1435
|
+
return doc.textBetween(0, doc.content.size, separator, (leaf) => {
|
|
1436
|
+
if (leaf.type.name === "mention") return `@${String(leaf.attrs["label"] ?? leaf.attrs["id"] ?? "")}`;
|
|
1437
|
+
return leaf.type.name === "hardBreak" ? separator : "";
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
function htmlText(html, separator) {
|
|
1441
|
+
if (typeof DOMParser === "undefined") return html.replace(/<[^>]*>/gu, separator);
|
|
1442
|
+
const body = new DOMParser().parseFromString(html, "text/html").body;
|
|
1443
|
+
let text = "";
|
|
1444
|
+
const walk = (node) => {
|
|
1445
|
+
if (node.nodeType === 3) {
|
|
1446
|
+
text += node.nodeValue ?? "";
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
if (node.nodeType !== 1) return;
|
|
1450
|
+
if (BLOCK_ELEMENTS.has(node.tagName)) text += separator;
|
|
1451
|
+
node.childNodes.forEach(walk);
|
|
1452
|
+
};
|
|
1453
|
+
body.childNodes.forEach(walk);
|
|
1454
|
+
return text;
|
|
1455
|
+
}
|
|
1456
|
+
function countEditorText(html, unit, locale) {
|
|
1457
|
+
return countText(htmlText(html, unit === "words" ? "\n" : ""), unit, locale);
|
|
1458
|
+
}
|
|
648
1459
|
var EditorPressedDirective = class EditorPressedDirective {
|
|
649
1460
|
#host;
|
|
650
1461
|
constructor() {
|
|
@@ -1191,6 +2002,8 @@ var EditorFontFamilyComponent = class EditorFontFamilyComponent {
|
|
|
1191
2002
|
type: DropdownListComponent,
|
|
1192
2003
|
selector: "mona-dropdown-list",
|
|
1193
2004
|
inputs: [
|
|
2005
|
+
"adaptiveMode",
|
|
2006
|
+
"adaptiveTitle",
|
|
1194
2007
|
"aria-describedby",
|
|
1195
2008
|
"aria-label",
|
|
1196
2009
|
"aria-labelledby",
|
|
@@ -1231,7 +2044,7 @@ var EditorFontFamilyComponent = class EditorFontFamilyComponent {
|
|
|
1231
2044
|
{
|
|
1232
2045
|
kind: "directive",
|
|
1233
2046
|
type: DropdownItemTemplateDirective,
|
|
1234
|
-
selector: " ng-template[monaDropDownItemTemplate], ng-template[monaAutoCompleteItemTemplate], ng-template[monaDropDownListItemTemplate], ng-template[monaComboBoxItemTemplate], ng-template[monaMultiSelectItemTemplate] "
|
|
2047
|
+
selector: " ng-template[monaDropDownItemTemplate], ng-template[monaAutoCompleteItemTemplate], ng-template[monaDropDownListItemTemplate], ng-template[monaDropDownTreeItemTemplate], ng-template[monaComboBoxItemTemplate], ng-template[monaMultiSelectItemTemplate], ng-template[monaMultiSelectTreeItemTemplate] "
|
|
1235
2048
|
}
|
|
1236
2049
|
]
|
|
1237
2050
|
});
|
|
@@ -1387,6 +2200,8 @@ var EditorFontSizeComponent = class EditorFontSizeComponent {
|
|
|
1387
2200
|
type: DropdownListComponent,
|
|
1388
2201
|
selector: "mona-dropdown-list",
|
|
1389
2202
|
inputs: [
|
|
2203
|
+
"adaptiveMode",
|
|
2204
|
+
"adaptiveTitle",
|
|
1390
2205
|
"aria-describedby",
|
|
1391
2206
|
"aria-label",
|
|
1392
2207
|
"aria-labelledby",
|
|
@@ -1508,6 +2323,8 @@ var EditorHeadingsComponent = class EditorHeadingsComponent {
|
|
|
1508
2323
|
type: DropdownListComponent,
|
|
1509
2324
|
selector: "mona-dropdown-list",
|
|
1510
2325
|
inputs: [
|
|
2326
|
+
"adaptiveMode",
|
|
2327
|
+
"adaptiveTitle",
|
|
1511
2328
|
"aria-describedby",
|
|
1512
2329
|
"aria-label",
|
|
1513
2330
|
"aria-labelledby",
|
|
@@ -1548,7 +2365,7 @@ var EditorHeadingsComponent = class EditorHeadingsComponent {
|
|
|
1548
2365
|
{
|
|
1549
2366
|
kind: "directive",
|
|
1550
2367
|
type: DropdownItemTemplateDirective,
|
|
1551
|
-
selector: " ng-template[monaDropDownItemTemplate], ng-template[monaAutoCompleteItemTemplate], ng-template[monaDropDownListItemTemplate], ng-template[monaComboBoxItemTemplate], ng-template[monaMultiSelectItemTemplate] "
|
|
2368
|
+
selector: " ng-template[monaDropDownItemTemplate], ng-template[monaAutoCompleteItemTemplate], ng-template[monaDropDownListItemTemplate], ng-template[monaDropDownTreeItemTemplate], ng-template[monaComboBoxItemTemplate], ng-template[monaMultiSelectItemTemplate], ng-template[monaMultiSelectTreeItemTemplate] "
|
|
1552
2369
|
}
|
|
1553
2370
|
]
|
|
1554
2371
|
});
|
|
@@ -1745,6 +2562,8 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1745
2562
|
}]
|
|
1746
2563
|
});
|
|
1747
2564
|
var EditorImageInserterComponent = class EditorImageInserterComponent {
|
|
2565
|
+
#i18n;
|
|
2566
|
+
#imageFormModel;
|
|
1748
2567
|
constructor() {
|
|
1749
2568
|
this.#i18n = inject(MonaI18nService);
|
|
1750
2569
|
this.#imageFormModel = signal({
|
|
@@ -1776,11 +2595,17 @@ var EditorImageInserterComponent = class EditorImageInserterComponent {
|
|
|
1776
2595
|
this.rowLabelClass = computed(() => {
|
|
1777
2596
|
return editorImageInserterRowLabelThemeVariants();
|
|
1778
2597
|
}, ...ngDevMode ? [{ debugName: "rowLabelClass" }] : /* istanbul ignore next */ []);
|
|
2598
|
+
this.accept = input("image/*", ...ngDevMode ? [{ debugName: "accept" }] : /* istanbul ignore next */ []);
|
|
2599
|
+
this.image = input(null, ...ngDevMode ? [{ debugName: "image" }] : /* istanbul ignore next */ []);
|
|
1779
2600
|
this.insert = output();
|
|
1780
2601
|
this.insertCancel = output();
|
|
2602
|
+
this.maxFileSize = input(null, ...ngDevMode ? [{ debugName: "maxFileSize" }] : /* istanbul ignore next */ []);
|
|
2603
|
+
this.upload = input(null, ...ngDevMode ? [{ debugName: "upload" }] : /* istanbul ignore next */ []);
|
|
2604
|
+
effect(() => {
|
|
2605
|
+
const image = this.image();
|
|
2606
|
+
if (image) untracked(() => this.#imageFormModel.set({ ...image }));
|
|
2607
|
+
});
|
|
1781
2608
|
}
|
|
1782
|
-
#i18n;
|
|
1783
|
-
#imageFormModel;
|
|
1784
2609
|
onCancel() {
|
|
1785
2610
|
this.insertCancel.emit();
|
|
1786
2611
|
}
|
|
@@ -1792,6 +2617,10 @@ var EditorImageInserterComponent = class EditorImageInserterComponent {
|
|
|
1792
2617
|
width: this.iForm.width().value()
|
|
1793
2618
|
});
|
|
1794
2619
|
}
|
|
2620
|
+
onUploadSuccess(item) {
|
|
2621
|
+
if (typeof item.response === "string" && item.response !== "") this.iForm.link().value.set(item.response);
|
|
2622
|
+
else if (isDevMode()) console.warn("[Mona Editor] imageUpload should return the image's address as a string, but it returned:", item.response);
|
|
2623
|
+
}
|
|
1795
2624
|
static {
|
|
1796
2625
|
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1797
2626
|
minVersion: "12.0.0",
|
|
@@ -1804,17 +2633,47 @@ var EditorImageInserterComponent = class EditorImageInserterComponent {
|
|
|
1804
2633
|
}
|
|
1805
2634
|
static {
|
|
1806
2635
|
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
1807
|
-
minVersion: "
|
|
2636
|
+
minVersion: "17.0.0",
|
|
1808
2637
|
version: "22.2.6",
|
|
1809
2638
|
type: EditorImageInserterComponent,
|
|
1810
2639
|
isStandalone: true,
|
|
1811
2640
|
selector: "mona-editor-image-inserter",
|
|
2641
|
+
inputs: {
|
|
2642
|
+
accept: {
|
|
2643
|
+
classPropertyName: "accept",
|
|
2644
|
+
publicName: "accept",
|
|
2645
|
+
isSignal: true,
|
|
2646
|
+
isRequired: false,
|
|
2647
|
+
transformFunction: null
|
|
2648
|
+
},
|
|
2649
|
+
image: {
|
|
2650
|
+
classPropertyName: "image",
|
|
2651
|
+
publicName: "image",
|
|
2652
|
+
isSignal: true,
|
|
2653
|
+
isRequired: false,
|
|
2654
|
+
transformFunction: null
|
|
2655
|
+
},
|
|
2656
|
+
maxFileSize: {
|
|
2657
|
+
classPropertyName: "maxFileSize",
|
|
2658
|
+
publicName: "maxFileSize",
|
|
2659
|
+
isSignal: true,
|
|
2660
|
+
isRequired: false,
|
|
2661
|
+
transformFunction: null
|
|
2662
|
+
},
|
|
2663
|
+
upload: {
|
|
2664
|
+
classPropertyName: "upload",
|
|
2665
|
+
publicName: "upload",
|
|
2666
|
+
isSignal: true,
|
|
2667
|
+
isRequired: false,
|
|
2668
|
+
transformFunction: null
|
|
2669
|
+
}
|
|
2670
|
+
},
|
|
1812
2671
|
outputs: {
|
|
1813
2672
|
insert: "insert",
|
|
1814
2673
|
insertCancel: "insertCancel"
|
|
1815
2674
|
},
|
|
1816
2675
|
ngImport: i0,
|
|
1817
|
-
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",
|
|
2676
|
+
template: "<form [formRoot]=\"iForm\" [class]=\"formClass()\">\n @if (upload()) {\n <div [class]=\"rowClass()\">\n <mona-file-upload\n [accept]=\"accept()\"\n [aria-label]=\"messages().imageFile\"\n [maxFileSize]=\"maxFileSize()\"\n [multiple]=\"false\"\n [upload]=\"upload()\"\n (uploadSuccess)=\"onUploadSuccess($event)\"></mona-file-upload>\n </div>\n }\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 {{ image() ? messages().save : messages().insert }}\n </button>\n <button monaButton [size]=\"'small'\" [look]=\"'secondary'\" (click)=\"onCancel()\">{{ messages().cancel }}</button>\n </div>\n</form>\n",
|
|
1818
2677
|
dependencies: [
|
|
1819
2678
|
{
|
|
1820
2679
|
kind: "component",
|
|
@@ -1872,6 +2731,38 @@ var EditorImageInserterComponent = class EditorImageInserterComponent {
|
|
|
1872
2731
|
],
|
|
1873
2732
|
outputs: ["lookChange", "selectedChange"]
|
|
1874
2733
|
},
|
|
2734
|
+
{
|
|
2735
|
+
kind: "component",
|
|
2736
|
+
type: FileUploadComponent,
|
|
2737
|
+
selector: "mona-file-upload",
|
|
2738
|
+
inputs: [
|
|
2739
|
+
"accept",
|
|
2740
|
+
"aria-describedby",
|
|
2741
|
+
"aria-label",
|
|
2742
|
+
"aria-labelledby",
|
|
2743
|
+
"autoUpload",
|
|
2744
|
+
"disabled",
|
|
2745
|
+
"invalid",
|
|
2746
|
+
"maxFileSize",
|
|
2747
|
+
"maxFiles",
|
|
2748
|
+
"minFileSize",
|
|
2749
|
+
"multiple",
|
|
2750
|
+
"readonly",
|
|
2751
|
+
"required",
|
|
2752
|
+
"touched",
|
|
2753
|
+
"upload",
|
|
2754
|
+
"class",
|
|
2755
|
+
"value"
|
|
2756
|
+
],
|
|
2757
|
+
outputs: [
|
|
2758
|
+
"remove",
|
|
2759
|
+
"touch",
|
|
2760
|
+
"uploadError",
|
|
2761
|
+
"uploadSuccess",
|
|
2762
|
+
"valueChange"
|
|
2763
|
+
],
|
|
2764
|
+
exportAs: ["monaFileUpload"]
|
|
2765
|
+
},
|
|
1875
2766
|
{
|
|
1876
2767
|
kind: "component",
|
|
1877
2768
|
type: NumericTextBoxComponent,
|
|
@@ -1914,14 +2805,32 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1914
2805
|
imports: [
|
|
1915
2806
|
TextBoxComponent,
|
|
1916
2807
|
ButtonDirective,
|
|
2808
|
+
FileUploadComponent,
|
|
1917
2809
|
NumericTextBoxComponent,
|
|
1918
2810
|
FormRoot,
|
|
1919
2811
|
FormField
|
|
1920
2812
|
],
|
|
1921
|
-
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"
|
|
2813
|
+
template: "<form [formRoot]=\"iForm\" [class]=\"formClass()\">\n @if (upload()) {\n <div [class]=\"rowClass()\">\n <mona-file-upload\n [accept]=\"accept()\"\n [aria-label]=\"messages().imageFile\"\n [maxFileSize]=\"maxFileSize()\"\n [multiple]=\"false\"\n [upload]=\"upload()\"\n (uploadSuccess)=\"onUploadSuccess($event)\"></mona-file-upload>\n </div>\n }\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 {{ image() ? messages().save : messages().insert }}\n </button>\n <button monaButton [size]=\"'small'\" [look]=\"'secondary'\" (click)=\"onCancel()\">{{ messages().cancel }}</button>\n </div>\n</form>\n"
|
|
1922
2814
|
}]
|
|
1923
2815
|
}],
|
|
2816
|
+
ctorParameters: () => [],
|
|
1924
2817
|
propDecorators: {
|
|
2818
|
+
accept: [{
|
|
2819
|
+
type: i0.Input,
|
|
2820
|
+
args: [{
|
|
2821
|
+
isSignal: true,
|
|
2822
|
+
alias: "accept",
|
|
2823
|
+
required: false
|
|
2824
|
+
}]
|
|
2825
|
+
}],
|
|
2826
|
+
image: [{
|
|
2827
|
+
type: i0.Input,
|
|
2828
|
+
args: [{
|
|
2829
|
+
isSignal: true,
|
|
2830
|
+
alias: "image",
|
|
2831
|
+
required: false
|
|
2832
|
+
}]
|
|
2833
|
+
}],
|
|
1925
2834
|
insert: [{
|
|
1926
2835
|
type: i0.Output,
|
|
1927
2836
|
args: ["insert"]
|
|
@@ -1929,19 +2838,55 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1929
2838
|
insertCancel: [{
|
|
1930
2839
|
type: i0.Output,
|
|
1931
2840
|
args: ["insertCancel"]
|
|
2841
|
+
}],
|
|
2842
|
+
maxFileSize: [{
|
|
2843
|
+
type: i0.Input,
|
|
2844
|
+
args: [{
|
|
2845
|
+
isSignal: true,
|
|
2846
|
+
alias: "maxFileSize",
|
|
2847
|
+
required: false
|
|
2848
|
+
}]
|
|
2849
|
+
}],
|
|
2850
|
+
upload: [{
|
|
2851
|
+
type: i0.Input,
|
|
2852
|
+
args: [{
|
|
2853
|
+
isSignal: true,
|
|
2854
|
+
alias: "upload",
|
|
2855
|
+
required: false
|
|
2856
|
+
}]
|
|
1932
2857
|
}]
|
|
1933
2858
|
}
|
|
1934
2859
|
});
|
|
2860
|
+
function pixels(value) {
|
|
2861
|
+
const number = Number(value);
|
|
2862
|
+
return value == null || value === "" || !Number.isFinite(number) ? null : number;
|
|
2863
|
+
}
|
|
1935
2864
|
var EditorImageComponent = class EditorImageComponent {
|
|
1936
2865
|
constructor() {
|
|
1937
2866
|
this.#editorService = inject(EditorService);
|
|
1938
2867
|
this.#i18n = inject(MonaI18nService);
|
|
2868
|
+
this.#selectedImage = computed(() => {
|
|
2869
|
+
const selection = this.#editorService.state()?.selection;
|
|
2870
|
+
if (!(selection instanceof NodeSelection) || selection.node.type.name !== "extendedImage") return null;
|
|
2871
|
+
const attributes = selection.node.attrs;
|
|
2872
|
+
return {
|
|
2873
|
+
alt: String(attributes["alt"] ?? ""),
|
|
2874
|
+
height: pixels(attributes["height"]),
|
|
2875
|
+
link: String(attributes["src"] ?? ""),
|
|
2876
|
+
width: pixels(attributes["width"])
|
|
2877
|
+
};
|
|
2878
|
+
}, ...ngDevMode ? [{ debugName: "#selectedImage" }] : /* istanbul ignore next */ []);
|
|
2879
|
+
this.editedImage = signal(null, ...ngDevMode ? [{ debugName: "editedImage" }] : /* istanbul ignore next */ []);
|
|
1939
2880
|
this.inserterVisible = signal(false, ...ngDevMode ? [{ debugName: "inserterVisible" }] : /* istanbul ignore next */ []);
|
|
2881
|
+
this.label = computed(() => this.#selectedImage() ? this.messages().editImage : this.messages().insertImage, ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
|
|
1940
2882
|
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
2883
|
+
this.upload = inject(EditorImageUploadService).options;
|
|
1941
2884
|
}
|
|
1942
2885
|
#editorService;
|
|
1943
2886
|
#i18n;
|
|
2887
|
+
#selectedImage;
|
|
1944
2888
|
onDisplayInserterClick() {
|
|
2889
|
+
this.editedImage.set(this.#selectedImage());
|
|
1945
2890
|
this.inserterVisible.set(true);
|
|
1946
2891
|
}
|
|
1947
2892
|
onImageInsert(event) {
|
|
@@ -1958,7 +2903,18 @@ var EditorImageComponent = class EditorImageComponent {
|
|
|
1958
2903
|
this.inserterVisible.set(false);
|
|
1959
2904
|
}
|
|
1960
2905
|
insertImage(event) {
|
|
1961
|
-
this.#editorService.editor.chain().focus()
|
|
2906
|
+
const chain = this.#editorService.editor.chain().focus();
|
|
2907
|
+
if (this.editedImage() && this.#selectedImage()) {
|
|
2908
|
+
chain.updateAttributes("extendedImage", {
|
|
2909
|
+
alt: event.alt,
|
|
2910
|
+
height: event.height,
|
|
2911
|
+
src: event.link,
|
|
2912
|
+
title: event.alt,
|
|
2913
|
+
width: event.width
|
|
2914
|
+
}).run();
|
|
2915
|
+
return;
|
|
2916
|
+
}
|
|
2917
|
+
chain.setImage({
|
|
1962
2918
|
alt: event.alt,
|
|
1963
2919
|
height: event.height ?? void 0,
|
|
1964
2920
|
src: event.link,
|
|
@@ -1984,7 +2940,7 @@ var EditorImageComponent = class EditorImageComponent {
|
|
|
1984
2940
|
isStandalone: true,
|
|
1985
2941
|
selector: "mona-editor-image",
|
|
1986
2942
|
ngImport: i0,
|
|
1987
|
-
template: "<button
|
|
2943
|
+
template: "<button monaButton [size]=\"'small'\" aria-haspopup=\"dialog\" (click)=\"onDisplayInserterClick()\" [title]=\"label()\">\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]=\"editedImage() ? messages().editImage : messages().insertImage\"\n [minimizable]=\"false\"\n [maximizable]=\"false\"\n (close)=\"onInserterClose()\">\n <ng-template monaWindowContentTemplate>\n <mona-editor-image-inserter\n [accept]=\"upload().accept\"\n [image]=\"editedImage()\"\n [maxFileSize]=\"upload().maxFileSize\"\n [upload]=\"upload().handler\"\n (insert)=\"onImageInsert($event)\"\n (insertCancel)=\"onInsertCancel()\"></mona-editor-image-inserter>\n </ng-template>\n </mona-window>\n}\n",
|
|
1988
2944
|
dependencies: [
|
|
1989
2945
|
{
|
|
1990
2946
|
kind: "component",
|
|
@@ -2028,6 +2984,12 @@ var EditorImageComponent = class EditorImageComponent {
|
|
|
2028
2984
|
kind: "component",
|
|
2029
2985
|
type: EditorImageInserterComponent,
|
|
2030
2986
|
selector: "mona-editor-image-inserter",
|
|
2987
|
+
inputs: [
|
|
2988
|
+
"accept",
|
|
2989
|
+
"image",
|
|
2990
|
+
"maxFileSize",
|
|
2991
|
+
"upload"
|
|
2992
|
+
],
|
|
2031
2993
|
outputs: ["insert", "insertCancel"]
|
|
2032
2994
|
},
|
|
2033
2995
|
{
|
|
@@ -2075,7 +3037,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2075
3037
|
ButtonDirective,
|
|
2076
3038
|
WindowContentTemplateDirective
|
|
2077
3039
|
],
|
|
2078
|
-
template: "<button
|
|
3040
|
+
template: "<button monaButton [size]=\"'small'\" aria-haspopup=\"dialog\" (click)=\"onDisplayInserterClick()\" [title]=\"label()\">\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]=\"editedImage() ? messages().editImage : messages().insertImage\"\n [minimizable]=\"false\"\n [maximizable]=\"false\"\n (close)=\"onInserterClose()\">\n <ng-template monaWindowContentTemplate>\n <mona-editor-image-inserter\n [accept]=\"upload().accept\"\n [image]=\"editedImage()\"\n [maxFileSize]=\"upload().maxFileSize\"\n [upload]=\"upload().handler\"\n (insert)=\"onImageInsert($event)\"\n (insertCancel)=\"onInsertCancel()\"></mona-editor-image-inserter>\n </ng-template>\n </mona-window>\n}\n"
|
|
2079
3041
|
}]
|
|
2080
3042
|
}]
|
|
2081
3043
|
});
|
|
@@ -3179,18 +4141,29 @@ const EMPTY_DOCUMENT = {
|
|
|
3179
4141
|
content: []
|
|
3180
4142
|
};
|
|
3181
4143
|
var EditorComponent = class EditorComponent {
|
|
4144
|
+
#announcer;
|
|
4145
|
+
#characters;
|
|
3182
4146
|
#contentAttributes;
|
|
3183
4147
|
#destroyRef;
|
|
3184
4148
|
#direction;
|
|
3185
4149
|
#editable;
|
|
3186
4150
|
#i18n;
|
|
4151
|
+
#imageUpload;
|
|
3187
4152
|
#label;
|
|
4153
|
+
#mention;
|
|
3188
4154
|
#rendered;
|
|
3189
4155
|
#toolbar;
|
|
4156
|
+
#words;
|
|
3190
4157
|
#appliedContent;
|
|
3191
4158
|
#lastValue;
|
|
3192
4159
|
#tabLeaves;
|
|
3193
4160
|
constructor() {
|
|
4161
|
+
this.#announcer = injectLiveAnnouncer();
|
|
4162
|
+
this.#characters = computed(() => {
|
|
4163
|
+
const state = this.editorService.state();
|
|
4164
|
+
if (state === null || this.characterLimit() === null && !this.showCharacterCount()) return null;
|
|
4165
|
+
return countText(documentText(state.doc, "characters"), "characters", this.#i18n.localeId() ?? void 0);
|
|
4166
|
+
}, ...ngDevMode ? [{ debugName: "#characters" }] : /* istanbul ignore next */ []);
|
|
3194
4167
|
this.#contentAttributes = computed(() => {
|
|
3195
4168
|
const attributes = {
|
|
3196
4169
|
"aria-multiline": "true",
|
|
@@ -3200,8 +4173,14 @@ var EditorComponent = class EditorComponent {
|
|
|
3200
4173
|
const ariaLabelledBy = this.#label.labelledBy();
|
|
3201
4174
|
if (ariaLabelledBy) attributes["aria-labelledby"] = ariaLabelledBy;
|
|
3202
4175
|
else attributes["aria-label"] = this.ariaLabel() || this.messages().contentLabel;
|
|
3203
|
-
const
|
|
3204
|
-
if (
|
|
4176
|
+
const describedBy = [this.#label.describedBy(), this.characterLimit() === null ? "" : this.limitHintId].filter((id) => !!id).join(" ");
|
|
4177
|
+
if (describedBy) attributes["aria-describedby"] = describedBy;
|
|
4178
|
+
const activeDescendant = this.#mention.activeDescendant();
|
|
4179
|
+
if (activeDescendant) {
|
|
4180
|
+
attributes["aria-activedescendant"] = activeDescendant;
|
|
4181
|
+
attributes["aria-autocomplete"] = "list";
|
|
4182
|
+
attributes["aria-controls"] = this.#mention.listId;
|
|
4183
|
+
}
|
|
3205
4184
|
if (this.placeholder()) attributes["aria-placeholder"] = this.placeholder();
|
|
3206
4185
|
if (this.effectiveDisabled()) attributes["aria-disabled"] = "true";
|
|
3207
4186
|
if (this.readonly()) attributes["aria-readonly"] = "true";
|
|
@@ -3213,6 +4192,7 @@ var EditorComponent = class EditorComponent {
|
|
|
3213
4192
|
this.#direction = injectComponentDirection();
|
|
3214
4193
|
this.#editable = computed(() => !this.effectiveDisabled() && !this.readonly(), ...ngDevMode ? [{ debugName: "#editable" }] : /* istanbul ignore next */ []);
|
|
3215
4194
|
this.#i18n = inject(MonaI18nService);
|
|
4195
|
+
this.#imageUpload = inject(EditorImageUploadService);
|
|
3216
4196
|
this.#label = injectLabelAssociation({
|
|
3217
4197
|
activate: () => this.focus(),
|
|
3218
4198
|
ariaDescribedBy: () => this.ariaDescribedBy(),
|
|
@@ -3220,8 +4200,14 @@ var EditorComponent = class EditorComponent {
|
|
|
3220
4200
|
ariaLabelledBy: () => this.ariaLabelledBy(),
|
|
3221
4201
|
focus: () => this.focus()
|
|
3222
4202
|
});
|
|
4203
|
+
this.#mention = inject(EditorMentionService);
|
|
3223
4204
|
this.#rendered = signal(false, ...ngDevMode ? [{ debugName: "#rendered" }] : /* istanbul ignore next */ []);
|
|
3224
4205
|
this.#toolbar = new RovingToolbar(() => this.toolbarElement()?.nativeElement);
|
|
4206
|
+
this.#words = computed(() => {
|
|
4207
|
+
const state = this.editorService.state();
|
|
4208
|
+
if (state === null || !this.showWordCount()) return null;
|
|
4209
|
+
return countText(documentText(state.doc, "words"), "words", this.#i18n.localeId() ?? void 0);
|
|
4210
|
+
}, ...ngDevMode ? [{ debugName: "#words" }] : /* istanbul ignore next */ []);
|
|
3225
4211
|
this.#appliedContent = void 0;
|
|
3226
4212
|
this.#lastValue = null;
|
|
3227
4213
|
this.#tabLeaves = false;
|
|
@@ -3233,11 +4219,49 @@ var EditorComponent = class EditorComponent {
|
|
|
3233
4219
|
this.containerClass = computed(() => {
|
|
3234
4220
|
return editorContainerThemeVariants({ disabled: this.effectiveDisabled() });
|
|
3235
4221
|
}, ...ngDevMode ? [{ debugName: "containerClass" }] : /* istanbul ignore next */ []);
|
|
4222
|
+
this.countParts = computed(() => {
|
|
4223
|
+
const messages = this.messages();
|
|
4224
|
+
const parts = [];
|
|
4225
|
+
const words = this.#words();
|
|
4226
|
+
if (words !== null) parts.push({
|
|
4227
|
+
class: "",
|
|
4228
|
+
text: messages.wordCount(words)
|
|
4229
|
+
});
|
|
4230
|
+
const limitMessage = this.limitMessage();
|
|
4231
|
+
const characters = this.#characters();
|
|
4232
|
+
if (limitMessage !== null) parts.push({
|
|
4233
|
+
class: this.overLimit() ? EDITOR_COUNT_OVER_CLASSES : "",
|
|
4234
|
+
text: limitMessage
|
|
4235
|
+
});
|
|
4236
|
+
else if (characters !== null) parts.push({
|
|
4237
|
+
class: "",
|
|
4238
|
+
text: messages.characterCount(characters)
|
|
4239
|
+
});
|
|
4240
|
+
return parts;
|
|
4241
|
+
}, ...ngDevMode ? [{ debugName: "countParts" }] : /* istanbul ignore next */ []);
|
|
3236
4242
|
this.editorContainer = viewChild.required("editorContainer", ...ngDevMode ? [{ debugName: "editorContainer" }] : /* istanbul ignore next */ []);
|
|
3237
4243
|
this.editorService = inject(EditorService);
|
|
3238
4244
|
this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
|
|
3239
|
-
this.
|
|
4245
|
+
this.footerClass = EDITOR_FOOTER_CLASSES;
|
|
4246
|
+
this.invalidState = computed(() => this.touched() && (this.invalid() || this.required() && !this.value()) || this.overLimit(), ...ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []);
|
|
4247
|
+
this.limitHint = computed(() => {
|
|
4248
|
+
const limit = this.characterLimit();
|
|
4249
|
+
return limit === null ? "" : this.messages().characterLimitHint(limit);
|
|
4250
|
+
}, ...ngDevMode ? [{ debugName: "limitHint" }] : /* istanbul ignore next */ []);
|
|
4251
|
+
this.limitHintId = createElementControlId();
|
|
4252
|
+
this.limitMessage = computed(() => {
|
|
4253
|
+
const limit = this.characterLimit();
|
|
4254
|
+
const characters = this.#characters();
|
|
4255
|
+
if (limit === null || characters === null) return null;
|
|
4256
|
+
const messages = this.messages();
|
|
4257
|
+
return characters <= limit ? messages.charactersLeft(limit - characters) : messages.charactersOver(characters - limit);
|
|
4258
|
+
}, ...ngDevMode ? [{ debugName: "limitMessage" }] : /* istanbul ignore next */ []);
|
|
3240
4259
|
this.messages = this.#i18n.componentMessages("editor", EDITOR_DEFAULT_MESSAGES);
|
|
4260
|
+
this.overLimit = computed(() => {
|
|
4261
|
+
const limit = this.characterLimit();
|
|
4262
|
+
const characters = this.#characters();
|
|
4263
|
+
return limit !== null && characters !== null && characters > limit;
|
|
4264
|
+
}, ...ngDevMode ? [{ debugName: "overLimit" }] : /* istanbul ignore next */ []);
|
|
3241
4265
|
this.placeholderClass = computed(() => editorPlaceholderThemeVariants(), ...ngDevMode ? [{ debugName: "placeholderClass" }] : /* istanbul ignore next */ []);
|
|
3242
4266
|
this.toolbarClass = computed(() => {
|
|
3243
4267
|
return editorToolbarThemeVariants({ disabled: this.effectiveDisabled() });
|
|
@@ -3256,6 +4280,7 @@ var EditorComponent = class EditorComponent {
|
|
|
3256
4280
|
alias: "aria-labelledby"
|
|
3257
4281
|
});
|
|
3258
4282
|
this.blur = output();
|
|
4283
|
+
this.characterLimit = input(null, ...ngDevMode ? [{ debugName: "characterLimit" }] : /* istanbul ignore next */ []);
|
|
3259
4284
|
this.content = input(...ngDevMode ? [void 0, { debugName: "content" }] : /* istanbul ignore next */ []);
|
|
3260
4285
|
this.create = output();
|
|
3261
4286
|
this.disabled = input(false, {
|
|
@@ -3264,10 +4289,14 @@ var EditorComponent = class EditorComponent {
|
|
|
3264
4289
|
});
|
|
3265
4290
|
this.editorBlur = output();
|
|
3266
4291
|
this.editorFocus = output();
|
|
4292
|
+
this.imageAccept = input("image/*", ...ngDevMode ? [{ debugName: "imageAccept" }] : /* istanbul ignore next */ []);
|
|
4293
|
+
this.imageMaxFileSize = input(null, ...ngDevMode ? [{ debugName: "imageMaxFileSize" }] : /* istanbul ignore next */ []);
|
|
4294
|
+
this.imageUpload = input(null, ...ngDevMode ? [{ debugName: "imageUpload" }] : /* istanbul ignore next */ []);
|
|
3267
4295
|
this.invalid = input(false, {
|
|
3268
4296
|
...ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {},
|
|
3269
4297
|
transform: booleanAttribute
|
|
3270
4298
|
});
|
|
4299
|
+
this.mentionSearch = input(null, ...ngDevMode ? [{ debugName: "mentionSearch" }] : /* istanbul ignore next */ []);
|
|
3271
4300
|
this.placeholder = input("", ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
|
|
3272
4301
|
this.readonly = input(false, {
|
|
3273
4302
|
...ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {},
|
|
@@ -3279,6 +4308,14 @@ var EditorComponent = class EditorComponent {
|
|
|
3279
4308
|
});
|
|
3280
4309
|
this.selectionUpdate = output();
|
|
3281
4310
|
this.settings = input({}, ...ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []);
|
|
4311
|
+
this.showCharacterCount = input(false, {
|
|
4312
|
+
...ngDevMode ? { debugName: "showCharacterCount" } : /* istanbul ignore next */ {},
|
|
4313
|
+
transform: booleanAttribute
|
|
4314
|
+
});
|
|
4315
|
+
this.showWordCount = input(false, {
|
|
4316
|
+
...ngDevMode ? { debugName: "showWordCount" } : /* istanbul ignore next */ {},
|
|
4317
|
+
transform: booleanAttribute
|
|
4318
|
+
});
|
|
3282
4319
|
this.touch = output();
|
|
3283
4320
|
this.touched = input(false, {
|
|
3284
4321
|
...ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {},
|
|
@@ -3310,6 +4347,16 @@ var EditorComponent = class EditorComponent {
|
|
|
3310
4347
|
if (!this.editorService.ready()) return;
|
|
3311
4348
|
untracked(() => this.#applyContent(content));
|
|
3312
4349
|
});
|
|
4350
|
+
effect(() => {
|
|
4351
|
+
this.#imageUpload.options.set({
|
|
4352
|
+
accept: this.imageAccept(),
|
|
4353
|
+
handler: this.imageUpload(),
|
|
4354
|
+
maxFileSize: this.imageMaxFileSize()
|
|
4355
|
+
});
|
|
4356
|
+
});
|
|
4357
|
+
effect(() => {
|
|
4358
|
+
this.#mention.search.set(this.mentionSearch());
|
|
4359
|
+
});
|
|
3313
4360
|
effect(() => {
|
|
3314
4361
|
const editable = this.#editable();
|
|
3315
4362
|
const attributes = this.#contentAttributes();
|
|
@@ -3394,6 +4441,10 @@ var EditorComponent = class EditorComponent {
|
|
|
3394
4441
|
this.editorService.selectionUpdate$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
3395
4442
|
this.selectionUpdate.emit();
|
|
3396
4443
|
});
|
|
4444
|
+
this.editorService.update$.pipe(debounceTime(1e3), takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
4445
|
+
const message = untracked(this.limitMessage);
|
|
4446
|
+
if (message !== null && this.editorService.ready() && this.editorService.editor.isFocused) this.#announcer.announce(message, "polite");
|
|
4447
|
+
});
|
|
3397
4448
|
this.editorService.update$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
3398
4449
|
const value = this.#currentValue();
|
|
3399
4450
|
this.#lastValue = value;
|
|
@@ -3443,6 +4494,13 @@ var EditorComponent = class EditorComponent {
|
|
|
3443
4494
|
isRequired: false,
|
|
3444
4495
|
transformFunction: null
|
|
3445
4496
|
},
|
|
4497
|
+
characterLimit: {
|
|
4498
|
+
classPropertyName: "characterLimit",
|
|
4499
|
+
publicName: "characterLimit",
|
|
4500
|
+
isSignal: true,
|
|
4501
|
+
isRequired: false,
|
|
4502
|
+
transformFunction: null
|
|
4503
|
+
},
|
|
3446
4504
|
content: {
|
|
3447
4505
|
classPropertyName: "content",
|
|
3448
4506
|
publicName: "content",
|
|
@@ -3457,6 +4515,27 @@ var EditorComponent = class EditorComponent {
|
|
|
3457
4515
|
isRequired: false,
|
|
3458
4516
|
transformFunction: null
|
|
3459
4517
|
},
|
|
4518
|
+
imageAccept: {
|
|
4519
|
+
classPropertyName: "imageAccept",
|
|
4520
|
+
publicName: "imageAccept",
|
|
4521
|
+
isSignal: true,
|
|
4522
|
+
isRequired: false,
|
|
4523
|
+
transformFunction: null
|
|
4524
|
+
},
|
|
4525
|
+
imageMaxFileSize: {
|
|
4526
|
+
classPropertyName: "imageMaxFileSize",
|
|
4527
|
+
publicName: "imageMaxFileSize",
|
|
4528
|
+
isSignal: true,
|
|
4529
|
+
isRequired: false,
|
|
4530
|
+
transformFunction: null
|
|
4531
|
+
},
|
|
4532
|
+
imageUpload: {
|
|
4533
|
+
classPropertyName: "imageUpload",
|
|
4534
|
+
publicName: "imageUpload",
|
|
4535
|
+
isSignal: true,
|
|
4536
|
+
isRequired: false,
|
|
4537
|
+
transformFunction: null
|
|
4538
|
+
},
|
|
3460
4539
|
invalid: {
|
|
3461
4540
|
classPropertyName: "invalid",
|
|
3462
4541
|
publicName: "invalid",
|
|
@@ -3464,6 +4543,13 @@ var EditorComponent = class EditorComponent {
|
|
|
3464
4543
|
isRequired: false,
|
|
3465
4544
|
transformFunction: null
|
|
3466
4545
|
},
|
|
4546
|
+
mentionSearch: {
|
|
4547
|
+
classPropertyName: "mentionSearch",
|
|
4548
|
+
publicName: "mentionSearch",
|
|
4549
|
+
isSignal: true,
|
|
4550
|
+
isRequired: false,
|
|
4551
|
+
transformFunction: null
|
|
4552
|
+
},
|
|
3467
4553
|
placeholder: {
|
|
3468
4554
|
classPropertyName: "placeholder",
|
|
3469
4555
|
publicName: "placeholder",
|
|
@@ -3492,6 +4578,20 @@ var EditorComponent = class EditorComponent {
|
|
|
3492
4578
|
isRequired: false,
|
|
3493
4579
|
transformFunction: null
|
|
3494
4580
|
},
|
|
4581
|
+
showCharacterCount: {
|
|
4582
|
+
classPropertyName: "showCharacterCount",
|
|
4583
|
+
publicName: "showCharacterCount",
|
|
4584
|
+
isSignal: true,
|
|
4585
|
+
isRequired: false,
|
|
4586
|
+
transformFunction: null
|
|
4587
|
+
},
|
|
4588
|
+
showWordCount: {
|
|
4589
|
+
classPropertyName: "showWordCount",
|
|
4590
|
+
publicName: "showWordCount",
|
|
4591
|
+
isSignal: true,
|
|
4592
|
+
isRequired: false,
|
|
4593
|
+
transformFunction: null
|
|
4594
|
+
},
|
|
3495
4595
|
touched: {
|
|
3496
4596
|
classPropertyName: "touched",
|
|
3497
4597
|
publicName: "touched",
|
|
@@ -3534,7 +4634,11 @@ var EditorComponent = class EditorComponent {
|
|
|
3534
4634
|
"attr.data-readonly": "readonly() || null",
|
|
3535
4635
|
"attr.data-required": "required() || null"
|
|
3536
4636
|
} },
|
|
3537
|
-
providers: [
|
|
4637
|
+
providers: [
|
|
4638
|
+
EditorService,
|
|
4639
|
+
EditorImageUploadService,
|
|
4640
|
+
EditorMentionService
|
|
4641
|
+
],
|
|
3538
4642
|
viewQueries: [{
|
|
3539
4643
|
propertyName: "editorContainer",
|
|
3540
4644
|
first: true,
|
|
@@ -3549,7 +4653,7 @@ var EditorComponent = class EditorComponent {
|
|
|
3549
4653
|
isSignal: true
|
|
3550
4654
|
}],
|
|
3551
4655
|
ngImport: i0,
|
|
3552
|
-
template: "@if (editorService.ready() && !readonly()) {\n <div\n role=\"toolbar\"\n [class]=\"toolbarClass()\"\n [attr.aria-label]=\"messages().toolbar\"\n [attr.inert]=\"effectiveDisabled() || 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",
|
|
4656
|
+
template: "@if (editorService.ready() && !readonly()) {\n <div\n role=\"toolbar\"\n [class]=\"toolbarClass()\"\n [attr.aria-label]=\"messages().toolbar\"\n [attr.inert]=\"effectiveDisabled() || 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@if (countParts().length > 0) {\n <div [class]=\"footerClass\">\n @for (part of countParts(); track $index) {\n <span [class]=\"part.class\">{{ part.text }}</span>\n }\n </div>\n}\n@if (limitHint()) {\n <span class=\"sr-only\" [id]=\"limitHintId\">{{ limitHint() }}</span>\n}\n",
|
|
3553
4657
|
dependencies: [
|
|
3554
4658
|
{
|
|
3555
4659
|
kind: "component",
|
|
@@ -3669,7 +4773,11 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3669
4773
|
EditorTableComponent,
|
|
3670
4774
|
EditorCodeBlockComponent
|
|
3671
4775
|
],
|
|
3672
|
-
providers: [
|
|
4776
|
+
providers: [
|
|
4777
|
+
EditorService,
|
|
4778
|
+
EditorImageUploadService,
|
|
4779
|
+
EditorMentionService
|
|
4780
|
+
],
|
|
3673
4781
|
viewProviders: [...FIELD_ASSOCIATION_BOUNDARY],
|
|
3674
4782
|
host: {
|
|
3675
4783
|
"[class]": "baseClass()",
|
|
@@ -3681,7 +4789,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3681
4789
|
"[attr.data-readonly]": "readonly() || null",
|
|
3682
4790
|
"[attr.data-required]": "required() || null"
|
|
3683
4791
|
},
|
|
3684
|
-
template: "@if (editorService.ready() && !readonly()) {\n <div\n role=\"toolbar\"\n [class]=\"toolbarClass()\"\n [attr.aria-label]=\"messages().toolbar\"\n [attr.inert]=\"effectiveDisabled() || 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"
|
|
4792
|
+
template: "@if (editorService.ready() && !readonly()) {\n <div\n role=\"toolbar\"\n [class]=\"toolbarClass()\"\n [attr.aria-label]=\"messages().toolbar\"\n [attr.inert]=\"effectiveDisabled() || 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@if (countParts().length > 0) {\n <div [class]=\"footerClass\">\n @for (part of countParts(); track $index) {\n <span [class]=\"part.class\">{{ part.text }}</span>\n }\n </div>\n}\n@if (limitHint()) {\n <span class=\"sr-only\" [id]=\"limitHintId\">{{ limitHint() }}</span>\n}\n"
|
|
3685
4793
|
}]
|
|
3686
4794
|
}],
|
|
3687
4795
|
ctorParameters: () => [],
|
|
@@ -3722,6 +4830,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3722
4830
|
type: i0.Output,
|
|
3723
4831
|
args: ["blur"]
|
|
3724
4832
|
}],
|
|
4833
|
+
characterLimit: [{
|
|
4834
|
+
type: i0.Input,
|
|
4835
|
+
args: [{
|
|
4836
|
+
isSignal: true,
|
|
4837
|
+
alias: "characterLimit",
|
|
4838
|
+
required: false
|
|
4839
|
+
}]
|
|
4840
|
+
}],
|
|
3725
4841
|
content: [{
|
|
3726
4842
|
type: i0.Input,
|
|
3727
4843
|
args: [{
|
|
@@ -3750,6 +4866,30 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3750
4866
|
type: i0.Output,
|
|
3751
4867
|
args: ["editorFocus"]
|
|
3752
4868
|
}],
|
|
4869
|
+
imageAccept: [{
|
|
4870
|
+
type: i0.Input,
|
|
4871
|
+
args: [{
|
|
4872
|
+
isSignal: true,
|
|
4873
|
+
alias: "imageAccept",
|
|
4874
|
+
required: false
|
|
4875
|
+
}]
|
|
4876
|
+
}],
|
|
4877
|
+
imageMaxFileSize: [{
|
|
4878
|
+
type: i0.Input,
|
|
4879
|
+
args: [{
|
|
4880
|
+
isSignal: true,
|
|
4881
|
+
alias: "imageMaxFileSize",
|
|
4882
|
+
required: false
|
|
4883
|
+
}]
|
|
4884
|
+
}],
|
|
4885
|
+
imageUpload: [{
|
|
4886
|
+
type: i0.Input,
|
|
4887
|
+
args: [{
|
|
4888
|
+
isSignal: true,
|
|
4889
|
+
alias: "imageUpload",
|
|
4890
|
+
required: false
|
|
4891
|
+
}]
|
|
4892
|
+
}],
|
|
3753
4893
|
invalid: [{
|
|
3754
4894
|
type: i0.Input,
|
|
3755
4895
|
args: [{
|
|
@@ -3758,6 +4898,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3758
4898
|
required: false
|
|
3759
4899
|
}]
|
|
3760
4900
|
}],
|
|
4901
|
+
mentionSearch: [{
|
|
4902
|
+
type: i0.Input,
|
|
4903
|
+
args: [{
|
|
4904
|
+
isSignal: true,
|
|
4905
|
+
alias: "mentionSearch",
|
|
4906
|
+
required: false
|
|
4907
|
+
}]
|
|
4908
|
+
}],
|
|
3761
4909
|
placeholder: [{
|
|
3762
4910
|
type: i0.Input,
|
|
3763
4911
|
args: [{
|
|
@@ -3794,6 +4942,22 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3794
4942
|
required: false
|
|
3795
4943
|
}]
|
|
3796
4944
|
}],
|
|
4945
|
+
showCharacterCount: [{
|
|
4946
|
+
type: i0.Input,
|
|
4947
|
+
args: [{
|
|
4948
|
+
isSignal: true,
|
|
4949
|
+
alias: "showCharacterCount",
|
|
4950
|
+
required: false
|
|
4951
|
+
}]
|
|
4952
|
+
}],
|
|
4953
|
+
showWordCount: [{
|
|
4954
|
+
type: i0.Input,
|
|
4955
|
+
args: [{
|
|
4956
|
+
isSignal: true,
|
|
4957
|
+
alias: "showWordCount",
|
|
4958
|
+
required: false
|
|
4959
|
+
}]
|
|
4960
|
+
}],
|
|
3797
4961
|
touch: [{
|
|
3798
4962
|
type: i0.Output,
|
|
3799
4963
|
args: ["touch"]
|
|
@@ -3831,6 +4995,6 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3831
4995
|
}]
|
|
3832
4996
|
}
|
|
3833
4997
|
});
|
|
3834
|
-
export { EDITOR_DEFAULT_MESSAGES, EditorComponent };
|
|
4998
|
+
export { EDITOR_DEFAULT_MESSAGES, EditorComponent, countEditorText };
|
|
3835
4999
|
|
|
3836
5000
|
//# sourceMappingURL=nanahoshi-mona-ui-editor.mjs.map
|