@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
@@ -18,14 +18,21 @@ Component.
18
18
  | `aria-describedby` | `string` | `""` | The id of an element that describes the content, such as a hint or an error message. |
19
19
  | `aria-label` | `string` | `""` | The accessible name of the content. Without it or `aria-labelledby`, the content is named "Rich text editor" (translated). |
20
20
  | `aria-labelledby` | `string` | `""` | The id of a visible label for the content, such as a `<label>` next to the editor. |
21
+ | `characterLimit` | `number \| null` | `null` | How many characters the content should fit, counted as people see them: the text without the markup, where an emoji or a letter with an accent counts once. Under the content, a count says how many are left. Typing past the limit isn't blocked, so nothing pasted is lost: the count turns into how many are over, and the editor shows as invalid. For a form, validate the value with `countEditorText`. |
21
22
  | `class` | `string` | `""` | CSS classes applied to the host element. |
22
23
  | `content` | `string \| JSONContent` | — | **Deprecated.** Use `value` (HTML), or `[formField]` with a signal form. To read the JSON, use the `update` event or the `json` property. The initial content of the editor, as HTML or a `JSONContent` document. A later change replaces the document, unless it is the content the editor already has. |
23
24
  | `disabled` | `boolean` | `false` | Disables the editor: the content can't be edited or focused for editing, and the toolbar is inert. When bound to a signal form field via `[formField]`, the form sets it. |
25
+ | `imageAccept` | `string` | `"image/*"` | The image files `imageUpload` takes, as an `accept` attribute: MIME types such as `image/png`, `image/*` for any image, and extensions such as `.png`. |
26
+ | `imageMaxFileSize` | `number \| null` | `null` | The largest image file, in bytes, that `imageUpload` takes. Null takes any size. |
27
+ | `imageUpload` | `FileUploadHandler \| null` | `null` | Uploads image files, and returns the image's address: as a promise or an observable, the same way as the file upload's `upload`. With it, the image form takes a file, and images pasted or dropped into the content upload in place, with a placeholder while they do. Without it, images are added by their address. |
24
28
  | `invalid` | `boolean` | `false` | Marks the editor as invalid once it has been touched. When bound to a signal form field via `[formField]`, the form sets it. |
29
+ | `mentionSearch` | `EditorMentionSearch \| null` | `null` | Finds the mentions to offer as `@` and a query are typed. With it, a list of suggestions opens at the `@`: the arrow keys move through it, Enter or Tab puts the highlighted one in the content, and Escape closes it. A mention is kept in the HTML as `<span data-type="mention" data-id="…">`. |
25
30
  | `placeholder` | `string` | `""` | Text shown in the empty editor, and given to assistive technology as `aria-placeholder`. It is not a name: use a label or `aria-label` too. |
26
31
  | `readonly` | `boolean` | `false` | Makes the content read-only and hides the toolbar. When bound to a signal form field via `[formField]`, the form sets it. |
27
32
  | `required` | `boolean` | `false` | Marks the editor as required: once touched, an empty editor is invalid. |
28
33
  | `settings` | `Partial<EditorSettings>` | — | The settings of the editor. Changing them rebuilds the editor and keeps its document. |
34
+ | `showCharacterCount` | `boolean` | `false` | Shows how many characters the content has, under it. A `characterLimit` shows the count anyway. |
35
+ | `showWordCount` | `boolean` | `false` | Shows how many words the content has, under it. |
29
36
  | `touched` | `boolean` | `false` | Sets the touched state. When bound to a signal form field via `[formField]`, the form sets it. |
30
37
  | `value` (two-way) | `string` | `""` | The content of the editor as HTML. An empty editor has the value `""`. Use `[(value)]`, or `[formField]` with a signal form. |
31
38
 
@@ -55,6 +62,23 @@ Component.
55
62
  | --- | --- |
56
63
  | `focus(options?: FocusOptions): void` | Moves focus into the editor, keeping the selection it had. |
57
64
 
65
+ ## `countEditorText`
66
+
67
+ Function.
68
+
69
+ Counts the characters or words of the editor's HTML value, as the editor's own count does: the text people see,
70
+ without the markup. Use it in a validator for a limit:
71
+
72
+ ```ts
73
+ validate(path.body, ({ value }) =>
74
+ countEditorText(value(), "characters") > 500 ? { kind: "tooLong", message: "Keep it to 500 characters." } : undefined
75
+ );
76
+ ```
77
+
78
+ ```typescript
79
+ function countEditorText(html: string, unit: EditorTextUnit, locale?: string): number;
80
+ ```
81
+
58
82
  ## `EDITOR_DEFAULT_MESSAGES`
59
83
 
60
84
  Constant.
@@ -78,6 +102,22 @@ The content of the editor after a user change, emitted by `EditorComponent.updat
78
102
 
79
103
  **Used by:** [`EditorComponent`](editor.md#editorcomponent)
80
104
 
105
+ ## `EditorMention`
106
+
107
+ Interface.
108
+
109
+ Someone, or something, the content can mention. A mention keeps both: the content shows `@label`, and the HTML
110
+ keeps the id in `data-id` for the page to read, such as to notify the person.
111
+
112
+ ### Properties
113
+
114
+ | Name | Type | Description |
115
+ | --- | --- | --- |
116
+ | `id` (read-only) | `string` | What the mention refers to, such as a user id. |
117
+ | `label` (read-only) | `string` | What the mention shows after the `@`, such as a name. |
118
+
119
+ **Used by:** [`EditorMentionSearch`](editor.md#editormentionsearch)
120
+
81
121
  ## `EditorSettings`
82
122
 
83
123
  Interface.
@@ -107,6 +147,7 @@ control, and the editor no longer keeps that kind of content.
107
147
  | `italic` | `boolean` | Whether the toolbar shows the italic button and the editor keeps italic text. |
108
148
  | `link` | `boolean` | Whether the toolbar shows the link buttons and the editor keeps links, turning typed URLs into links. |
109
149
  | `list` | `boolean` | Whether the toolbar shows the numbered and bulleted list buttons and the editor keeps those lists. |
150
+ | `mention?` | `boolean` | Whether the editor keeps mentions, and offers them as `@` is typed when it has a `mentionSearch`. It has no toolbar control. Optional, unlike the others, so settings written before it still compile. |
110
151
  | `strikethrough` | `boolean` | Whether the toolbar shows the strikethrough button and the editor keeps struck-through text. |
111
152
  | `subscript` | `boolean` | Whether the toolbar shows the subscript button and the editor keeps subscript text. |
112
153
  | `superscript` | `boolean` | Whether the toolbar shows the superscript button and the editor keeps superscript text. |
@@ -115,3 +156,29 @@ control, and the editor no longer keeps that kind of content.
115
156
  | `underline` | `boolean` | Whether the toolbar shows the underline button and the editor keeps underlined text. |
116
157
 
117
158
  **Used by:** [`EditorComponent`](editor.md#editorcomponent)
159
+
160
+ ## `EditorMentionSearch`
161
+
162
+ Type alias.
163
+
164
+ Finds the mentions to offer for the text typed after `@`, which is empty right after the `@`. It returns them, or a
165
+ promise or an observable of them; a new search replaces one still running, so an observable can be HttpClient's
166
+ request. Return a few, such as the first ten matches: the list doesn't page.
167
+
168
+ ```typescript
169
+ type EditorMentionSearch = ( query: string ) => Iterable<EditorMention> | Observable<Iterable<EditorMention>> | Promise<Iterable<EditorMention>>;
170
+ ```
171
+
172
+ **Used by:** [`EditorComponent`](editor.md#editorcomponent)
173
+
174
+ ## `EditorTextUnit`
175
+
176
+ Type alias.
177
+
178
+ What `countEditorText` counts: characters as people see them, or words.
179
+
180
+ ```typescript
181
+ type EditorTextUnit = "characters" | "words";
182
+ ```
183
+
184
+ **Used by:** [`countEditorText`](editor.md#counteditortext)
@@ -139,7 +139,7 @@ last value does. For a promise, what it resolves to does. A rejected promise or
139
139
  type FileUploadHandler = (file: File, context: FileUploadContext) => Observable<unknown> | Promise<unknown>;
140
140
  ```
141
141
 
142
- **Used by:** [`FileUploadComponent`](file-upload.md#fileuploadcomponent)
142
+ **Used by:** [`EditorComponent`](editor.md#editorcomponent), [`FileUploadComponent`](file-upload.md#fileuploadcomponent)
143
143
 
144
144
  ## `FileUploadRejection`
145
145
 
package/docs/api/i18n.md CHANGED
@@ -1146,6 +1146,10 @@ Interface.
1146
1146
  | `backgroundColor` (read-only) | `string` | The label of the toolbar color picker that sets the text's highlight color. |
1147
1147
  | `bold` (read-only) | `string` | The label of the toolbar button that toggles bold. |
1148
1148
  | `cancel` (read-only) | `string` | The label of the Cancel button in the link dialog and the insert image form. |
1149
+ | `characterCount` (read-only) | `(count: number) => string` | The count under the content when `showCharacterCount` is set and there's no `characterLimit`. |
1150
+ | `characterLimitHint` (read-only) | `(limit: number) => string` | Describes the content when it has a `characterLimit`, given the limit. Not shown, only read with the content. |
1151
+ | `charactersLeft` (read-only) | `(count: number) => string` | The count under the content while it is within its `characterLimit`, given the characters left. |
1152
+ | `charactersOver` (read-only) | `(count: number) => string` | The count under the content once it is over its `characterLimit`, given the characters over it. |
1149
1153
  | `codeBlock` (read-only) | `string` | The label of the toolbar button that toggles a code block. |
1150
1154
  | `color` (read-only) | `string` | The label of the toolbar color picker that sets the text color. |
1151
1155
  | `contentLabel` (read-only) | `string` | The accessible name of the editable content when the editor has no `aria-label` or `aria-labelledby`. |
@@ -1153,6 +1157,7 @@ Interface.
1153
1157
  | `deleteColumn` (read-only) | `string` | The label of the toolbar button that deletes the current column. |
1154
1158
  | `deleteRow` (read-only) | `string` | The label of the toolbar button that deletes the current row. |
1155
1159
  | `deleteTable` (read-only) | `string` | The label of the toolbar button that deletes the table. |
1160
+ | `editImage` (read-only) | `string` | The title of the image form's window, and the label of the image button, when an image is selected. |
1156
1161
  | `editLink` (read-only) | `string` | The title of the link dialog when the selection is already in a link. |
1157
1162
  | `enterUrl` (read-only) | `string` | The label of the URL field in the link dialog. |
1158
1163
  | `fontSize` (read-only) | `string` | The placeholder of the font size dropdown when the text has no specific size. |
@@ -1160,6 +1165,11 @@ Interface.
1160
1165
  | `heading` (read-only) | `(level: number) => string` | The text of a heading level in the format dropdown, given the level number. |
1161
1166
  | `heightPx` (read-only) | `string` | The label of the height field in the insert image form. |
1162
1167
  | `historyGroup` (read-only) | `string` | The accessible name of the toolbar's undo and redo button group. |
1168
+ | `imageFile` (read-only) | `string` | The accessible name of the file drop zone in the image form, shown when the editor has `imageUpload`. |
1169
+ | `imageInserted` (read-only) | `(name: string) => string` | Announced when a pasted or dropped image has uploaded and is in the content, given the file's name. |
1170
+ | `imageTooLarge` (read-only) | `(name: string, size: string) => string` | Announced when a pasted or dropped image is larger than `imageMaxFileSize`, given its name and the size. |
1171
+ | `imageUploadFailed` (read-only) | `(name: string) => string` | Announced when a pasted or dropped image fails to upload, given the file's name. |
1172
+ | `imageUploading` (read-only) | `(name: string) => string` | Announced when a pasted or dropped image starts uploading, and names its placeholder, given the file's name. |
1163
1173
  | `imageUrl` (read-only) | `string` | The label of the image URL field in the insert image form. |
1164
1174
  | `indent` (read-only) | `string` | The label of the toolbar button that increases the indentation. |
1165
1175
  | `indentGroup` (read-only) | `string` | The accessible name of the toolbar's indent and outdent button group. |
@@ -1175,12 +1185,17 @@ Interface.
1175
1185
  | `justify` (read-only) | `string` | The label of the toolbar button that justifies the text. |
1176
1186
  | `linkGroup` (read-only) | `string` | The accessible name of the toolbar's link button group. |
1177
1187
  | `listGroup` (read-only) | `string` | The accessible name of the toolbar's list button group. |
1188
+ | `mentionNoResults` (read-only) | `string` | Shown in the mention suggestions when the search finds no one. |
1189
+ | `mentionResults` (read-only) | `(count: number) => string` | Announced when the mention suggestions change, given how many there are. |
1190
+ | `mentionSearching` (read-only) | `string` | Shown in the mention suggestions while the search runs. |
1191
+ | `mentionSuggestions` (read-only) | `string` | The accessible name of the mention suggestions list. |
1178
1192
  | `mergeCells` (read-only) | `string` | The label of the toolbar button that merges the selected cells. |
1179
1193
  | `outdent` (read-only) | `string` | The label of the toolbar button that decreases the indentation. |
1180
1194
  | `paragraph` (read-only) | `string` | The text of the plain paragraph option in the format dropdown. |
1181
1195
  | `quotation` (read-only) | `string` | The label of the toolbar button that toggles a block quote. |
1182
1196
  | `redo` (read-only) | `string` | The label of the toolbar button that redoes the last undone change. |
1183
1197
  | `removeLink` (read-only) | `string` | The label of the toolbar button and the link dialog button that remove the link. |
1198
+ | `save` (read-only) | `string` | The label of the image form's button that applies the changes to a selected image. |
1184
1199
  | `selectFontFamily` (read-only) | `string` | The label of the toolbar's font family dropdown. |
1185
1200
  | `selectFontSize` (read-only) | `string` | The label of the toolbar's font size dropdown. |
1186
1201
  | `splitCell` (read-only) | `string` | The label of the toolbar button that splits a merged cell. |
@@ -1195,6 +1210,7 @@ Interface.
1195
1210
  | `underline` (read-only) | `string` | The label of the toolbar button that toggles underline. |
1196
1211
  | `undo` (read-only) | `string` | The label of the toolbar button that undoes the last change. |
1197
1212
  | `widthPx` (read-only) | `string` | The label of the width field in the insert image form. |
1213
+ | `wordCount` (read-only) | `(count: number) => string` | The count under the content when `showWordCount` is set, given the number of words. |
1198
1214
 
1199
1215
  **Used by:** [`EDITOR_DEFAULT_MESSAGES`](editor.md#editor-default-messages), [`MonaLocaleMessages`](i18n.md#monalocalemessages)
1200
1216