@nanahoshi/mona-ui 0.36.1 → 0.37.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.
Files changed (58) hide show
  1. package/docs/api/editor.md +67 -0
  2. package/docs/api/file-upload.md +1 -1
  3. package/docs/api/i18n.md +16 -0
  4. package/docs/api/locales.md +14 -14
  5. package/docs/editor.md +238 -9
  6. package/fesm2022/nanahoshi-mona-ui-editor.mjs +1348 -190
  7. package/fesm2022/nanahoshi-mona-ui-file-upload.mjs +28 -94
  8. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +50 -1
  9. package/fesm2022/nanahoshi-mona-ui-internal.mjs +83 -2
  10. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +59 -1
  11. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +23 -1
  12. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +35 -1
  13. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +35 -1
  14. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +17 -1
  15. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +35 -1
  16. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +17 -1
  17. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +17 -1
  18. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +47 -1
  19. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +35 -1
  20. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +47 -1
  21. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +17 -1
  22. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +17 -1
  23. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +17 -1
  24. package/i18n/catalogs/en-US.messages.json +17 -1
  25. package/llms.txt +1 -1
  26. package/locales/ar-sa/ar-sa.messages.json +17 -1
  27. package/locales/de-de/de-de.messages.json +17 -1
  28. package/locales/es-es/es-es.messages.json +17 -1
  29. package/locales/fr-fr/fr-fr.messages.json +17 -1
  30. package/locales/id-id/id-id.messages.json +17 -1
  31. package/locales/it-it/it-it.messages.json +17 -1
  32. package/locales/ja-jp/ja-jp.messages.json +17 -1
  33. package/locales/ko-kr/ko-kr.messages.json +17 -1
  34. package/locales/pl-pl/pl-pl.messages.json +17 -1
  35. package/locales/pt-br/pt-br.messages.json +17 -1
  36. package/locales/ru-ru/ru-ru.messages.json +17 -1
  37. package/locales/tr-tr/tr-tr.messages.json +17 -1
  38. package/locales/zh-cn/zh-cn.messages.json +17 -1
  39. package/locales/zh-tw/zh-tw.messages.json +17 -1
  40. package/package.json +1 -1
  41. package/types/nanahoshi-mona-ui-editor.d.ts +124 -2
  42. package/types/nanahoshi-mona-ui-file-upload.d.ts +1 -0
  43. package/types/nanahoshi-mona-ui-i18n.d.ts +32 -0
  44. package/types/nanahoshi-mona-ui-internal.d.ts +37 -0
  45. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +16 -0
  46. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +16 -0
  47. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +16 -0
  48. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +16 -0
  49. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +16 -0
  50. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +16 -0
  51. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +16 -0
  52. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +16 -0
  53. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +16 -0
  54. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +16 -0
  55. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +16 -0
  56. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +16 -0
  57. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +16 -0
  58. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +16 -0
@@ -232,6 +232,10 @@
232
232
  "backgroundColor": "Цвет фона",
233
233
  "bold": "Полужирный",
234
234
  "cancel": "Отмена",
235
+ "characterCount": "{count, plural, one {# символ} few {# символа} many {# символов} other {# символа}}",
236
+ "characterLimitHint": "Можно ввести не более {limit, plural, one {# символа} few {# символов} many {# символов} other {# символа}}.",
237
+ "charactersLeft": "{count, plural, one {Остался # символ} few {Осталось # символа} many {Осталось # символов} other {Осталось # символа}}",
238
+ "charactersOver": "{count, plural, one {# символ сверх лимита} few {# символа сверх лимита} many {# символов сверх лимита} other {# символа сверх лимита}}",
235
239
  "codeBlock": "Блок кода",
236
240
  "color": "Цвет",
237
241
  "contentLabel": "Редактор форматированного текста",
@@ -239,6 +243,7 @@
239
243
  "deleteColumn": "Удалить столбец",
240
244
  "deleteRow": "Удалить строку",
241
245
  "deleteTable": "Удалить таблицу",
246
+ "editImage": "Изменить изображение",
242
247
  "editLink": "Изменить ссылку",
243
248
  "enterUrl": "Введите URL",
244
249
  "fontSize": "Размер шрифта",
@@ -246,6 +251,11 @@
246
251
  "heading": "Заголовок {level}",
247
252
  "heightPx": "Высота (px)",
248
253
  "historyGroup": "История",
254
+ "imageFile": "Файл изображения",
255
+ "imageInserted": "Изображение {name} вставлено.",
256
+ "imageTooLarge": "Файл {name} не добавлен. Его размер больше {size}.",
257
+ "imageUploadFailed": "Не удалось загрузить {name}.",
258
+ "imageUploading": "Загрузка {name}",
249
259
  "imageUrl": "URL изображения",
250
260
  "indent": "Увеличить отступ",
251
261
  "indentGroup": "Отступ",
@@ -261,12 +271,17 @@
261
271
  "justify": "Выровнять по ширине",
262
272
  "linkGroup": "Ссылка",
263
273
  "listGroup": "Списки",
274
+ "mentionNoResults": "Совпадений нет",
275
+ "mentionResults": "{count, plural, one {# вариант} few {# варианта} many {# вариантов} other {# варианта}}",
276
+ "mentionSearching": "Поиск…",
277
+ "mentionSuggestions": "Варианты",
264
278
  "mergeCells": "Объединить выбранные ячейки",
265
279
  "outdent": "Уменьшить отступ",
266
280
  "paragraph": "Абзац",
267
281
  "quotation": "Цитата",
268
282
  "redo": "Повторить",
269
283
  "removeLink": "Удалить ссылку",
284
+ "save": "Сохранить",
270
285
  "selectFontFamily": "Выбрать шрифт",
271
286
  "selectFontSize": "Выбрать размер шрифта",
272
287
  "splitCell": "Разделить ячейку",
@@ -280,7 +295,8 @@
280
295
  "toolbar": "Форматирование",
281
296
  "underline": "Подчёркнутый",
282
297
  "undo": "Отменить",
283
- "widthPx": "Ширина (px)"
298
+ "widthPx": "Ширина (px)",
299
+ "wordCount": "{count, plural, one {# слово} few {# слова} many {# слов} other {# слова}}"
284
300
  },
285
301
  "fileUpload": {
286
302
  "browse": "Выбрать файлы",
@@ -232,6 +232,10 @@
232
232
  "backgroundColor": "Arka plan rengi",
233
233
  "bold": "Kalın",
234
234
  "cancel": "İptal",
235
+ "characterCount": "{count} karakter",
236
+ "characterLimitHint": "En fazla {limit} karakter girebilirsiniz.",
237
+ "charactersLeft": "{count} karakter kaldı",
238
+ "charactersOver": "{count} karakter fazla",
235
239
  "codeBlock": "Kod bloğu",
236
240
  "color": "Renk",
237
241
  "contentLabel": "Zengin metin düzenleyici",
@@ -239,6 +243,7 @@
239
243
  "deleteColumn": "Sütunu sil",
240
244
  "deleteRow": "Satırı sil",
241
245
  "deleteTable": "Tabloyu sil",
246
+ "editImage": "Görseli düzenle",
242
247
  "editLink": "Bağlantıyı düzenle",
243
248
  "enterUrl": "URL'yi gir",
244
249
  "fontSize": "Yazı tipi boyutu",
@@ -246,6 +251,11 @@
246
251
  "heading": "Başlık {level}",
247
252
  "heightPx": "Yükseklik (px)",
248
253
  "historyGroup": "Geçmiş",
254
+ "imageFile": "Görsel dosyası",
255
+ "imageInserted": "{name} eklendi.",
256
+ "imageTooLarge": "{name} eklenmedi. Dosya {size} boyutundan büyük.",
257
+ "imageUploadFailed": "{name} yüklenemedi.",
258
+ "imageUploading": "{name} yükleniyor",
249
259
  "imageUrl": "Görsel URL'si",
250
260
  "indent": "Girintiyi artır",
251
261
  "indentGroup": "Girinti",
@@ -261,12 +271,17 @@
261
271
  "justify": "İki yana yasla",
262
272
  "linkGroup": "Bağlantı",
263
273
  "listGroup": "Listeler",
274
+ "mentionNoResults": "Eşleşme yok",
275
+ "mentionResults": "{count} öneri",
276
+ "mentionSearching": "Aranıyor…",
277
+ "mentionSuggestions": "Öneriler",
264
278
  "mergeCells": "Seçili hücreleri birleştir",
265
279
  "outdent": "Girintiyi azalt",
266
280
  "paragraph": "Paragraf",
267
281
  "quotation": "Alıntı",
268
282
  "redo": "Yinele",
269
283
  "removeLink": "Bağlantıyı kaldır",
284
+ "save": "Kaydet",
270
285
  "selectFontFamily": "Yazı tipi ailesini seç",
271
286
  "selectFontSize": "Yazı tipi boyutunu seç",
272
287
  "splitCell": "Hücreyi böl",
@@ -280,7 +295,8 @@
280
295
  "toolbar": "Biçimlendirme",
281
296
  "underline": "Altı çizili",
282
297
  "undo": "Geri al",
283
- "widthPx": "Genişlik (px)"
298
+ "widthPx": "Genişlik (px)",
299
+ "wordCount": "{count} kelime"
284
300
  },
285
301
  "fileUpload": {
286
302
  "browse": "Dosyalara göz at",
@@ -232,6 +232,10 @@
232
232
  "backgroundColor": "背景颜色",
233
233
  "bold": "粗体",
234
234
  "cancel": "取消",
235
+ "characterCount": "{count} 个字符",
236
+ "characterLimitHint": "最多可输入 {limit} 个字符。",
237
+ "charactersLeft": "还可输入 {count} 个字符",
238
+ "charactersOver": "超出 {count} 个字符",
235
239
  "codeBlock": "代码块",
236
240
  "color": "颜色",
237
241
  "contentLabel": "富文本编辑器",
@@ -239,6 +243,7 @@
239
243
  "deleteColumn": "删除列",
240
244
  "deleteRow": "删除行",
241
245
  "deleteTable": "删除表格",
246
+ "editImage": "编辑图片",
242
247
  "editLink": "编辑链接",
243
248
  "enterUrl": "输入 URL",
244
249
  "fontSize": "字号",
@@ -246,6 +251,11 @@
246
251
  "heading": "标题 {level}",
247
252
  "heightPx": "高度 (px)",
248
253
  "historyGroup": "历史记录",
254
+ "imageFile": "图片文件",
255
+ "imageInserted": "已插入 {name}。",
256
+ "imageTooLarge": "未添加 {name}。文件大于 {size}。",
257
+ "imageUploadFailed": "无法上传 {name}。",
258
+ "imageUploading": "正在上传 {name}",
249
259
  "imageUrl": "图片 URL",
250
260
  "indent": "增加缩进",
251
261
  "indentGroup": "缩进",
@@ -261,12 +271,17 @@
261
271
  "justify": "两端对齐",
262
272
  "linkGroup": "链接",
263
273
  "listGroup": "列表",
274
+ "mentionNoResults": "没有匹配项",
275
+ "mentionResults": "{count} 条建议",
276
+ "mentionSearching": "正在搜索…",
277
+ "mentionSuggestions": "建议",
264
278
  "mergeCells": "合并所选单元格",
265
279
  "outdent": "减少缩进",
266
280
  "paragraph": "段落",
267
281
  "quotation": "引用",
268
282
  "redo": "重做",
269
283
  "removeLink": "移除链接",
284
+ "save": "保存",
270
285
  "selectFontFamily": "选择字体",
271
286
  "selectFontSize": "选择字号",
272
287
  "splitCell": "拆分单元格",
@@ -280,7 +295,8 @@
280
295
  "toolbar": "格式",
281
296
  "underline": "下划线",
282
297
  "undo": "撤销",
283
- "widthPx": "宽度 (px)"
298
+ "widthPx": "宽度 (px)",
299
+ "wordCount": "{count} 个词"
284
300
  },
285
301
  "fileUpload": {
286
302
  "browse": "浏览文件",
@@ -232,6 +232,10 @@
232
232
  "backgroundColor": "背景顏色",
233
233
  "bold": "粗體",
234
234
  "cancel": "取消",
235
+ "characterCount": "{count} 個字元",
236
+ "characterLimitHint": "最多可輸入 {limit} 個字元。",
237
+ "charactersLeft": "還可輸入 {count} 個字元",
238
+ "charactersOver": "超出 {count} 個字元",
235
239
  "codeBlock": "程式碼區塊",
236
240
  "color": "顏色",
237
241
  "contentLabel": "富文字編輯器",
@@ -239,6 +243,7 @@
239
243
  "deleteColumn": "刪除欄",
240
244
  "deleteRow": "刪除列",
241
245
  "deleteTable": "刪除表格",
246
+ "editImage": "編輯圖片",
242
247
  "editLink": "編輯連結",
243
248
  "enterUrl": "輸入 URL",
244
249
  "fontSize": "字型大小",
@@ -246,6 +251,11 @@
246
251
  "heading": "標題 {level}",
247
252
  "heightPx": "高度 (px)",
248
253
  "historyGroup": "歷程記錄",
254
+ "imageFile": "圖片檔案",
255
+ "imageInserted": "已插入 {name}。",
256
+ "imageTooLarge": "未新增 {name}。檔案大於 {size}。",
257
+ "imageUploadFailed": "無法上傳 {name}。",
258
+ "imageUploading": "正在上傳 {name}",
249
259
  "imageUrl": "圖片 URL",
250
260
  "indent": "增加縮排",
251
261
  "indentGroup": "縮排",
@@ -261,12 +271,17 @@
261
271
  "justify": "左右對齊",
262
272
  "linkGroup": "連結",
263
273
  "listGroup": "清單",
274
+ "mentionNoResults": "沒有相符的項目",
275
+ "mentionResults": "{count} 個建議",
276
+ "mentionSearching": "正在搜尋…",
277
+ "mentionSuggestions": "建議",
264
278
  "mergeCells": "合併選取的儲存格",
265
279
  "outdent": "減少縮排",
266
280
  "paragraph": "段落",
267
281
  "quotation": "引用",
268
282
  "redo": "重做",
269
283
  "removeLink": "移除連結",
284
+ "save": "儲存",
270
285
  "selectFontFamily": "選取字型",
271
286
  "selectFontSize": "選取字型大小",
272
287
  "splitCell": "分割儲存格",
@@ -280,7 +295,8 @@
280
295
  "toolbar": "格式設定",
281
296
  "underline": "底線",
282
297
  "undo": "復原",
283
- "widthPx": "寬度 (px)"
298
+ "widthPx": "寬度 (px)",
299
+ "wordCount": "{count} 個字詞"
284
300
  },
285
301
  "fileUpload": {
286
302
  "browse": "瀏覽檔案",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanahoshi/mona-ui",
3
- "version": "0.36.1",
3
+ "version": "0.37.0",
4
4
  "description": "A very light Angular UI framework",
5
5
  "author": "Nanahoshi",
6
6
  "repository": {
@@ -1,11 +1,13 @@
1
1
  import * as i0 from "@angular/core";
2
2
  import { ElementRef } from "@angular/core";
3
3
  import { FormValueControl } from "@angular/forms/signals";
4
+ import { FileUploadHandler } from "@nanahoshi/mona-ui/file-upload";
4
5
  import { Editor, JSONContent } from "@tiptap/core";
6
+ import { Observable, Subject } from "rxjs";
5
7
  import { ImmutableSet } from "@mirei/ts-collections";
6
8
  import { EditorState } from "@tiptap/pm/state";
7
- import { Subject } from "rxjs";
8
9
  import { MonaEditorMessages } from "@nanahoshi/mona-ui/i18n";
10
+ import "@tiptap/pm/model";
9
11
  /** The content of the editor after a user change, emitted by `EditorComponent.update`. */
10
12
  interface ContentChangeEvent {
11
13
  /** The content as HTML, the same as the editor's `html` property. */
@@ -13,6 +15,22 @@ interface ContentChangeEvent {
13
15
  /** The content as a `JSONContent` document, the same as the editor's `json` property. */
14
16
  json: JSONContent;
15
17
  }
18
+ /**
19
+ * Someone, or something, the content can mention. A mention keeps both: the content shows `@label`, and the HTML
20
+ * keeps the id in `data-id` for the page to read, such as to notify the person.
21
+ */
22
+ interface EditorMention {
23
+ /** What the mention refers to, such as a user id. */
24
+ readonly id: string;
25
+ /** What the mention shows after the `@`, such as a name. */
26
+ readonly label: string;
27
+ }
28
+ /**
29
+ * Finds the mentions to offer for the text typed after `@`, which is empty right after the `@`. It returns them, or a
30
+ * promise or an observable of them; a new search replaces one still running, so an observable can be HttpClient's
31
+ * request. Return a few, such as the first ten matches: the list doesn't page.
32
+ */
33
+ type EditorMentionSearch = (query: string) => Iterable<EditorMention> | Observable<Iterable<EditorMention>> | Promise<Iterable<EditorMention>>;
16
34
  /**
17
35
  * The features of an editor. Every feature is on unless it is set to `false`. Turning one off removes its toolbar
18
36
  * control, and the editor no longer keeps that kind of content.
@@ -57,6 +75,11 @@ interface EditorSettings {
57
75
  link: boolean;
58
76
  /** Whether the toolbar shows the numbered and bulleted list buttons and the editor keeps those lists. */
59
77
  list: boolean;
78
+ /**
79
+ * Whether the editor keeps mentions, and offers them as `@` is typed when it has a `mentionSearch`. It has no
80
+ * toolbar control. Optional, unlike the others, so settings written before it still compile.
81
+ */
82
+ mention?: boolean;
60
83
  /** Whether the toolbar shows the strikethrough button and the editor keeps struck-through text. */
61
84
  strikethrough: boolean;
62
85
  /** Whether the toolbar shows the subscript button and the editor keeps subscript text. */
@@ -93,6 +116,10 @@ declare class EditorService {
93
116
  readonly settings: import("@angular/core").WritableSignal<Partial<EditorSettings>>;
94
117
  readonly state: import("@angular/core").Signal<EditorState | null>;
95
118
  readonly update$: Subject<void>;
119
+ /** Set by the image upload service, which uploads pasted and dropped images. */
120
+ imageUploader: EditorImageUploader | null;
121
+ /** Set by the mention service, which offers mentions as `@` is typed. */
122
+ mentionController: EditorMentionController | null;
96
123
  destroy(): void;
97
124
  /**
98
125
  * Replaces the document without emitting an update, as for a value set from outside.
@@ -115,11 +142,24 @@ export declare class EditorComponent implements FormValueControl<string> {
115
142
  #private;
116
143
  protected readonly baseClass: import("@angular/core").Signal<string>;
117
144
  protected readonly containerClass: import("@angular/core").Signal<string>;
145
+ /** The counts under the content: the words, then the characters or the characters left. */
146
+ protected readonly countParts: import("@angular/core").Signal<{
147
+ readonly class: string;
148
+ readonly text: string;
149
+ }[]>;
118
150
  protected readonly editorContainer: import("@angular/core").Signal<ElementRef<HTMLDivElement>>;
119
151
  protected readonly editorService: EditorService;
120
152
  protected readonly effectiveDisabled: import("@angular/core").Signal<boolean>;
153
+ protected readonly footerClass = "not-prose flex flex-wrap justify-end gap-x-3 border-t border-border-subtle px-2 py-1 text-xs text-muted-foreground";
121
154
  protected readonly invalidState: import("@angular/core").Signal<boolean>;
155
+ /** Says how many characters the content can have, for assistive technology. */
156
+ protected readonly limitHint: import("@angular/core").Signal<string>;
157
+ protected readonly limitHintId: string;
158
+ /** How many characters are left, or how many are over the limit. Null without a limit. */
159
+ protected readonly limitMessage: import("@angular/core").Signal<string | null>;
122
160
  protected readonly messages: import("@angular/core").Signal<import("@nanahoshi/mona-ui/i18n").MonaEditorMessages>;
161
+ /** Whether the content has more characters than its limit. */
162
+ protected readonly overLimit: import("@angular/core").Signal<boolean>;
123
163
  protected readonly placeholderClass: import("@angular/core").Signal<string>;
124
164
  protected readonly toolbarClass: import("@angular/core").Signal<string>;
125
165
  protected readonly toolbarElement: import("@angular/core").Signal<ElementRef<HTMLDivElement> | undefined>;
@@ -141,6 +181,13 @@ export declare class EditorComponent implements FormValueControl<string> {
141
181
  * @deprecated Use `editorBlur`.
142
182
  */
143
183
  readonly blur: import("@angular/core").OutputEmitterRef<void>;
184
+ /**
185
+ * @description How many characters the content should fit, counted as people see them: the text without the
186
+ * markup, where an emoji or a letter with an accent counts once. Under the content, a count says how many are
187
+ * left. Typing past the limit isn't blocked, so nothing pasted is lost: the count turns into how many are over,
188
+ * and the editor shows as invalid. For a form, validate the value with `countEditorText`.
189
+ */
190
+ readonly characterLimit: import("@angular/core").InputSignal<number | null>;
144
191
  /**
145
192
  * @description The initial content of the editor, as HTML or a {@link JSONContent} document. A later change
146
193
  * replaces the document, unless it is the content the editor already has.
@@ -166,11 +213,30 @@ export declare class EditorComponent implements FormValueControl<string> {
166
213
  * @description Emits when the editor gains focus.
167
214
  */
168
215
  readonly editorFocus: import("@angular/core").OutputEmitterRef<void>;
216
+ /**
217
+ * @description The image files `imageUpload` takes, as an `accept` attribute: MIME types such as `image/png`,
218
+ * `image/*` for any image, and extensions such as `.png`.
219
+ */
220
+ readonly imageAccept: import("@angular/core").InputSignal<string>;
221
+ /** @description The largest image file, in bytes, that `imageUpload` takes. Null takes any size. */
222
+ readonly imageMaxFileSize: import("@angular/core").InputSignal<number | null>;
223
+ /**
224
+ * @description Uploads image files, and returns the image's address: as a promise or an observable, the same
225
+ * way as the file upload's `upload`. With it, the image form takes a file, and images pasted or dropped into the
226
+ * content upload in place, with a placeholder while they do. Without it, images are added by their address.
227
+ */
228
+ readonly imageUpload: import("@angular/core").InputSignal<FileUploadHandler | null>;
169
229
  /**
170
230
  * @description Marks the editor as invalid once it has been touched. When bound to a signal form field via
171
231
  * `[formField]`, the form sets it.
172
232
  */
173
233
  readonly invalid: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
234
+ /**
235
+ * @description Finds the mentions to offer as `@` and a query are typed. With it, a list of suggestions opens at
236
+ * the `@`: the arrow keys move through it, Enter or Tab puts the highlighted one in the content, and Escape closes
237
+ * it. A mention is kept in the HTML as `<span data-type="mention" data-id="…">`.
238
+ */
239
+ readonly mentionSearch: import("@angular/core").InputSignal<EditorMentionSearch | null>;
174
240
  /**
175
241
  * @description Text shown in the empty editor, and given to assistive technology as `aria-placeholder`. It is not
176
242
  * a name: use a label or `aria-label` too.
@@ -193,6 +259,10 @@ export declare class EditorComponent implements FormValueControl<string> {
193
259
  * @description The settings of the editor. Changing them rebuilds the editor and keeps its document.
194
260
  */
195
261
  readonly settings: import("@angular/core").InputSignal<Partial<EditorSettings>>;
262
+ /** @description Shows how many characters the content has, under it. A `characterLimit` shows the count anyway. */
263
+ readonly showCharacterCount: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
264
+ /** @description Shows how many words the content has, under it. */
265
+ readonly showWordCount: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
196
266
  /**
197
267
  * @description Emits when the editor loses focus.
198
268
  * Form directives (`[formField]`, `ngModel`, `formControl`) listen to this to mark the field as touched.
@@ -249,6 +319,11 @@ export declare class EditorComponent implements FormValueControl<string> {
249
319
  "required": false;
250
320
  "isSignal": true;
251
321
  };
322
+ "characterLimit": {
323
+ "alias": "characterLimit";
324
+ "required": false;
325
+ "isSignal": true;
326
+ };
252
327
  "content": {
253
328
  "alias": "content";
254
329
  "required": false;
@@ -259,11 +334,31 @@ export declare class EditorComponent implements FormValueControl<string> {
259
334
  "required": false;
260
335
  "isSignal": true;
261
336
  };
337
+ "imageAccept": {
338
+ "alias": "imageAccept";
339
+ "required": false;
340
+ "isSignal": true;
341
+ };
342
+ "imageMaxFileSize": {
343
+ "alias": "imageMaxFileSize";
344
+ "required": false;
345
+ "isSignal": true;
346
+ };
347
+ "imageUpload": {
348
+ "alias": "imageUpload";
349
+ "required": false;
350
+ "isSignal": true;
351
+ };
262
352
  "invalid": {
263
353
  "alias": "invalid";
264
354
  "required": false;
265
355
  "isSignal": true;
266
356
  };
357
+ "mentionSearch": {
358
+ "alias": "mentionSearch";
359
+ "required": false;
360
+ "isSignal": true;
361
+ };
267
362
  "placeholder": {
268
363
  "alias": "placeholder";
269
364
  "required": false;
@@ -284,6 +379,16 @@ export declare class EditorComponent implements FormValueControl<string> {
284
379
  "required": false;
285
380
  "isSignal": true;
286
381
  };
382
+ "showCharacterCount": {
383
+ "alias": "showCharacterCount";
384
+ "required": false;
385
+ "isSignal": true;
386
+ };
387
+ "showWordCount": {
388
+ "alias": "showWordCount";
389
+ "required": false;
390
+ "isSignal": true;
391
+ };
287
392
  "touched": {
288
393
  "alias": "touched";
289
394
  "required": false;
@@ -311,4 +416,21 @@ export declare class EditorComponent implements FormValueControl<string> {
311
416
  }, never, never, true, never>;
312
417
  }
313
418
  export declare const EDITOR_DEFAULT_MESSAGES: MonaEditorMessages;
314
- export type { ContentChangeEvent, EditorSettings };
419
+ /** What {@link countEditorText} counts: characters as people see them, or words. */
420
+ type EditorTextUnit = "characters" | "words";
421
+ /**
422
+ * Counts the characters or words of the editor's HTML value, as the editor's own count does: the text people see,
423
+ * without the markup. Use it in a validator for a limit:
424
+ *
425
+ * ```ts
426
+ * validate(path.body, ({ value }) =>
427
+ * countEditorText(value(), "characters") > 500 ? { kind: "tooLong", message: "Keep it to 500 characters." } : undefined
428
+ * );
429
+ * ```
430
+ *
431
+ * @param html The editor's value.
432
+ * @param unit Characters, as people see them, or words.
433
+ * @param locale The locale whose rules find the words, such as `"ja-JP"`. Defaults to the browser's.
434
+ */
435
+ export declare function countEditorText(html: string, unit: EditorTextUnit, locale?: string): number;
436
+ export type { ContentChangeEvent, EditorMention, EditorMentionSearch, EditorSettings, EditorTextUnit };
@@ -3,6 +3,7 @@ import { ElementRef } from "@angular/core";
3
3
  import { FormValueControl } from "@angular/forms/signals";
4
4
  import { Observable } from "rxjs";
5
5
  import { MonaFileUploadMessages } from "@nanahoshi/mona-ui/i18n";
6
+ import "@nanahoshi/mona-ui/internal";
6
7
  /**
7
8
  * What the upload function gets with each file.
8
9
  */
@@ -361,6 +361,14 @@ export interface MonaEditorMessages {
361
361
  readonly bold: string;
362
362
  /** The label of the Cancel button in the link dialog and the insert image form. */
363
363
  readonly cancel: string;
364
+ /** The count under the content when `showCharacterCount` is set and there's no `characterLimit`. */
365
+ readonly characterCount: (count: number) => string;
366
+ /** Describes the content when it has a `characterLimit`, given the limit. Not shown, only read with the content. */
367
+ readonly characterLimitHint: (limit: number) => string;
368
+ /** The count under the content while it is within its `characterLimit`, given the characters left. */
369
+ readonly charactersLeft: (count: number) => string;
370
+ /** The count under the content once it is over its `characterLimit`, given the characters over it. */
371
+ readonly charactersOver: (count: number) => string;
364
372
  /** The label of the toolbar button that toggles a code block. */
365
373
  readonly codeBlock: string;
366
374
  /** The label of the toolbar color picker that sets the text color. */
@@ -375,6 +383,8 @@ export interface MonaEditorMessages {
375
383
  readonly deleteRow: string;
376
384
  /** The label of the toolbar button that deletes the table. */
377
385
  readonly deleteTable: string;
386
+ /** The title of the image form's window, and the label of the image button, when an image is selected. */
387
+ readonly editImage: string;
378
388
  /** The title of the link dialog when the selection is already in a link. */
379
389
  readonly editLink: string;
380
390
  /** The label of the URL field in the link dialog. */
@@ -389,6 +399,16 @@ export interface MonaEditorMessages {
389
399
  readonly heightPx: string;
390
400
  /** The accessible name of the toolbar's undo and redo button group. */
391
401
  readonly historyGroup: string;
402
+ /** The accessible name of the file drop zone in the image form, shown when the editor has `imageUpload`. */
403
+ readonly imageFile: string;
404
+ /** Announced when a pasted or dropped image has uploaded and is in the content, given the file's name. */
405
+ readonly imageInserted: (name: string) => string;
406
+ /** Announced when a pasted or dropped image is larger than `imageMaxFileSize`, given its name and the size. */
407
+ readonly imageTooLarge: (name: string, size: string) => string;
408
+ /** Announced when a pasted or dropped image fails to upload, given the file's name. */
409
+ readonly imageUploadFailed: (name: string) => string;
410
+ /** Announced when a pasted or dropped image starts uploading, and names its placeholder, given the file's name. */
411
+ readonly imageUploading: (name: string) => string;
392
412
  /** The label of the image URL field in the insert image form. */
393
413
  readonly imageUrl: string;
394
414
  /** The label of the toolbar button that increases the indentation. */
@@ -419,6 +439,14 @@ export interface MonaEditorMessages {
419
439
  readonly linkGroup: string;
420
440
  /** The accessible name of the toolbar's list button group. */
421
441
  readonly listGroup: string;
442
+ /** Shown in the mention suggestions when the search finds no one. */
443
+ readonly mentionNoResults: string;
444
+ /** Announced when the mention suggestions change, given how many there are. */
445
+ readonly mentionResults: (count: number) => string;
446
+ /** Shown in the mention suggestions while the search runs. */
447
+ readonly mentionSearching: string;
448
+ /** The accessible name of the mention suggestions list. */
449
+ readonly mentionSuggestions: string;
422
450
  /** The label of the toolbar button that merges the selected cells. */
423
451
  readonly mergeCells: string;
424
452
  /** The label of the toolbar button that decreases the indentation. */
@@ -431,6 +459,8 @@ export interface MonaEditorMessages {
431
459
  readonly redo: string;
432
460
  /** The label of the toolbar button and the link dialog button that remove the link. */
433
461
  readonly removeLink: string;
462
+ /** The label of the image form's button that applies the changes to a selected image. */
463
+ readonly save: string;
434
464
  /** The label of the toolbar's font family dropdown. */
435
465
  readonly selectFontFamily: string;
436
466
  /** The label of the toolbar's font size dropdown. */
@@ -462,6 +492,8 @@ export interface MonaEditorMessages {
462
492
  readonly undo: string;
463
493
  /** The label of the width field in the insert image form. */
464
494
  readonly widthPx: string;
495
+ /** The count under the content when `showWordCount` is set, given the number of words. */
496
+ readonly wordCount: (count: number) => string;
465
497
  }
466
498
  /**
467
499
  * The file upload's drop zone, its list of files, and what it announces as files are added, uploaded and removed.
@@ -103,6 +103,13 @@ export declare const MONA_FIELDSET_DISABLED: InjectionToken<Signal<boolean>>;
103
103
  * @param disabled Reads the control's own disabled state. It runs lazily, so it may read an input declared later.
104
104
  */
105
105
  export declare function injectEffectiveDisabled(disabled: () => boolean): Signal<boolean>;
106
+ /** Splits an `accept` attribute into its lowercase tokens, dropping empty ones. */
107
+ export declare function parseAccept(accept: string | null | undefined): string[];
108
+ /**
109
+ * Whether a file matches one of the `accept` tokens, the way the browser's file dialog does: by its extension, its
110
+ * whole MIME type, or a MIME type's first half such as `image/*`. No tokens accept every file.
111
+ */
112
+ export declare function matchesAccept(file: File, accept: readonly string[]): boolean;
106
113
  /**
107
114
  * A control wrapped by a `mona-label` that has no native input, so the browser can't associate them.
108
115
  */
@@ -255,6 +262,36 @@ export declare class RovingToolbar {
255
262
  /** Gives the active control the Tab stop and takes it from the others. */
256
263
  sync(): void;
257
264
  }
265
+ /** What an upload function gets with each file. The file upload's `FileUploadContext` has the same shape. */
266
+ export interface UploadRunContext {
267
+ /** Reports how much of the file has been sent. `total` defaults to the file's size. */
268
+ progress(loaded: number, total?: number): void;
269
+ /** Aborted when the upload is stopped. */
270
+ readonly signal: AbortSignal;
271
+ }
272
+ /** An upload function, as the file upload's `FileUploadHandler`: it returns a promise or an observable. */
273
+ export type UploadRunHandler = (file: File, context: UploadRunContext) => Observable<unknown> | Promise<unknown>;
274
+ /** What {@link runUpload} reports. None of them runs after the upload is stopped. */
275
+ export interface UploadRunCallbacks {
276
+ /** The upload failed, with what it failed with. */
277
+ failure(error: unknown): void;
278
+ /** How much of the file has been sent, from 0 to 1. */
279
+ progress(fraction: number): void;
280
+ /** The upload finished, with what it returned. */
281
+ success(response: unknown): void;
282
+ }
283
+ /**
284
+ * Runs an upload function for one file. A promise's result, or an observable's last value, is what the upload
285
+ * returned; for HttpClient's events (`reportProgress: true`, `observe: "events"`), the upload progress events report
286
+ * progress and the response's body is the result. A thrown error, a rejected promise or an observable's error is a
287
+ * failure.
288
+ *
289
+ * The callbacks can run before this returns, since an observable can complete at once.
290
+ *
291
+ * @returns A function that stops the upload: it aborts the context's signal and unsubscribes an observable, and no
292
+ * callback runs after it.
293
+ */
294
+ export declare function runUpload(handler: UploadRunHandler, file: File, callbacks: UploadRunCallbacks): () => void;
258
295
  export declare const rxTimeout: (destroyRef: DestroyRef, fn: Action$1, delay?: number) => void;
259
296
  export type VariantInputs<T> = { [K in keyof T]-?: Signal<T[K]>; };
260
297
  /**
@@ -235,6 +235,10 @@ export declare const MONA_AR_SA_LOCALE: {
235
235
  backgroundColor: string;
236
236
  bold: string;
237
237
  cancel: string;
238
+ characterCount: (count: number) => string;
239
+ characterLimitHint: (limit: number) => string;
240
+ charactersLeft: (count: number) => string;
241
+ charactersOver: (count: number) => string;
238
242
  codeBlock: string;
239
243
  color: string;
240
244
  contentLabel: string;
@@ -242,6 +246,7 @@ export declare const MONA_AR_SA_LOCALE: {
242
246
  deleteColumn: string;
243
247
  deleteRow: string;
244
248
  deleteTable: string;
249
+ editImage: string;
245
250
  editLink: string;
246
251
  enterUrl: string;
247
252
  fontSize: string;
@@ -249,6 +254,11 @@ export declare const MONA_AR_SA_LOCALE: {
249
254
  heading: (level: number) => string;
250
255
  heightPx: string;
251
256
  historyGroup: string;
257
+ imageFile: string;
258
+ imageInserted: (name: string) => string;
259
+ imageTooLarge: (name: string, size: string) => string;
260
+ imageUploadFailed: (name: string) => string;
261
+ imageUploading: (name: string) => string;
252
262
  imageUrl: string;
253
263
  indent: string;
254
264
  indentGroup: string;
@@ -264,12 +274,17 @@ export declare const MONA_AR_SA_LOCALE: {
264
274
  justify: string;
265
275
  linkGroup: string;
266
276
  listGroup: string;
277
+ mentionNoResults: string;
278
+ mentionResults: (count: number) => string;
279
+ mentionSearching: string;
280
+ mentionSuggestions: string;
267
281
  mergeCells: string;
268
282
  outdent: string;
269
283
  paragraph: string;
270
284
  quotation: string;
271
285
  redo: string;
272
286
  removeLink: string;
287
+ save: string;
273
288
  selectFontFamily: string;
274
289
  selectFontSize: string;
275
290
  splitCell: string;
@@ -284,6 +299,7 @@ export declare const MONA_AR_SA_LOCALE: {
284
299
  underline: string;
285
300
  undo: string;
286
301
  widthPx: string;
302
+ wordCount: (count: number) => string;
287
303
  };
288
304
  fileUpload: {
289
305
  browse: string;