wysio 0.0.0-stage → 0.2.0-alpha.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 (89) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +21 -0
  3. package/README.md +242 -2
  4. package/dist/auto-init.d.ts +12 -0
  5. package/dist/auto-init.d.ts.map +1 -0
  6. package/dist/cdn-full.d.ts +3 -0
  7. package/dist/cdn-full.d.ts.map +1 -0
  8. package/dist/cdn.d.ts +2 -0
  9. package/dist/cdn.d.ts.map +1 -0
  10. package/dist/commands.d.ts +19 -0
  11. package/dist/commands.d.ts.map +1 -0
  12. package/dist/content.d.ts +31 -0
  13. package/dist/content.d.ts.map +1 -0
  14. package/dist/editor.d.ts +158 -0
  15. package/dist/editor.d.ts.map +1 -0
  16. package/dist/emitter.d.ts +9 -0
  17. package/dist/emitter.d.ts.map +1 -0
  18. package/dist/format-html.d.ts +7 -0
  19. package/dist/format-html.d.ts.map +1 -0
  20. package/dist/i18n.d.ts +16 -0
  21. package/dist/i18n.d.ts.map +1 -0
  22. package/dist/icons.d.ts +34 -0
  23. package/dist/icons.d.ts.map +1 -0
  24. package/dist/index.d.ts +17 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/locales/nl.d.ts +81 -0
  27. package/dist/locales/nl.d.ts.map +1 -0
  28. package/dist/markdown/index.d.ts +17 -0
  29. package/dist/markdown/index.d.ts.map +1 -0
  30. package/dist/markdown.js +179 -0
  31. package/dist/markdown.js.map +1 -0
  32. package/dist/messages.d.ts +83 -0
  33. package/dist/messages.d.ts.map +1 -0
  34. package/dist/plugin.d.ts +94 -0
  35. package/dist/plugin.d.ts.map +1 -0
  36. package/dist/plugins/alignment.d.ts +10 -0
  37. package/dist/plugins/alignment.d.ts.map +1 -0
  38. package/dist/plugins/base.d.ts +7 -0
  39. package/dist/plugins/base.d.ts.map +1 -0
  40. package/dist/plugins/blocks.d.ts +4 -0
  41. package/dist/plugins/blocks.d.ts.map +1 -0
  42. package/dist/plugins/clear-formatting.d.ts +10 -0
  43. package/dist/plugins/clear-formatting.d.ts.map +1 -0
  44. package/dist/plugins/color.d.ts +36 -0
  45. package/dist/plugins/color.d.ts.map +1 -0
  46. package/dist/plugins/heading.d.ts +3 -0
  47. package/dist/plugins/heading.d.ts.map +1 -0
  48. package/dist/plugins/history.d.ts +2 -0
  49. package/dist/plugins/history.d.ts.map +1 -0
  50. package/dist/plugins/image.d.ts +56 -0
  51. package/dist/plugins/image.d.ts.map +1 -0
  52. package/dist/plugins/index.d.ts +29 -0
  53. package/dist/plugins/index.d.ts.map +1 -0
  54. package/dist/plugins/link.d.ts +15 -0
  55. package/dist/plugins/link.d.ts.map +1 -0
  56. package/dist/plugins/lists.d.ts +2 -0
  57. package/dist/plugins/lists.d.ts.map +1 -0
  58. package/dist/plugins/marks.d.ts +7 -0
  59. package/dist/plugins/marks.d.ts.map +1 -0
  60. package/dist/plugins/paste.d.ts +9 -0
  61. package/dist/plugins/paste.d.ts.map +1 -0
  62. package/dist/plugins/placeholder.d.ts +3 -0
  63. package/dist/plugins/placeholder.d.ts.map +1 -0
  64. package/dist/plugins/source.d.ts +5 -0
  65. package/dist/plugins/source.d.ts.map +1 -0
  66. package/dist/plugins/table.d.ts +14 -0
  67. package/dist/plugins/table.d.ts.map +1 -0
  68. package/dist/registry-BfhH2s8N.js +19 -0
  69. package/dist/registry-BfhH2s8N.js.map +1 -0
  70. package/dist/registry.d.ts +10 -0
  71. package/dist/registry.d.ts.map +1 -0
  72. package/dist/schema.d.ts +5 -0
  73. package/dist/schema.d.ts.map +1 -0
  74. package/dist/style.css +824 -0
  75. package/dist/toolbar/toolbar.d.ts +56 -0
  76. package/dist/toolbar/toolbar.d.ts.map +1 -0
  77. package/dist/ui/menu.d.ts +20 -0
  78. package/dist/ui/menu.d.ts.map +1 -0
  79. package/dist/ui/popover.d.ts +29 -0
  80. package/dist/ui/popover.d.ts.map +1 -0
  81. package/dist/url.d.ts +23 -0
  82. package/dist/url.d.ts.map +1 -0
  83. package/dist/web-component.d.ts +21 -0
  84. package/dist/web-component.d.ts.map +1 -0
  85. package/dist/wysio.full.iife.js +72 -0
  86. package/dist/wysio.iife.js +49 -0
  87. package/dist/wysio.js +2668 -0
  88. package/dist/wysio.js.map +1 -0
  89. package/package.json +70 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # wysio
2
+
3
+ ## 0.2.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f9a237b: Clean paste: new `paste` plugin cleans pasted HTML from Word, Google Docs, Outlook and web pages before the schema parses it (removes Office markup, comments, scripts, styles, form controls, attributes and empty paragraphs; turns style-only formatting into tags; converts Word list paragraphs into flat lists). Exported as `cleanPastedHTML`. Ctrl/Cmd+Shift+V pastes plain text.
8
+ - 862b5e8: Extra formatting: text alignment on paragraphs and headings (`wysio-align-*` classes; menu, toolbar items and Ctrl/Cmd+Shift+L/E/R/J), text colour and highlight limited to configurable palettes (`wysio-color-*` / `wysio-highlight-*` classes; palette picker; `paletteCSS()` for custom palettes) and clear formatting (Ctrl/Cmd+\). New plugin API option `schema.extendNodes`. Paste: HTML copied from a ProseMirror editor is no longer cleaned (fixes losing formatting and slice information when copying within the editor), and `wysio-*` classes survive pasting.
9
+ - d645bd2: Form integration: `name` option keeps a hidden input (or names a textarea target) in sync in the editor's `format`, and form reset restores the initial content. `autoInit()` creates editors for `[data-wysio]` elements with JSON options from `data-wysio-options` (plus defaults), `getEditor()` finds them, and `registerPlugin()` lets JSON name plugins (`wysio/markdown` registers `markdown`). `<wysio-editor>` gets `format` and `plugins` attributes and falls back to a hidden input without `ElementInternals`. An element's existing HTML is always read as HTML.
10
+ - 9ba51b7: i18n: `locale` option with built-in English and Dutch (`'nl'`, also matching `'nl-BE'` etc.) or a custom messages object, falling back to English for missing strings; `messages` still overrides single strings. `registerLocale()` and `availableLocales()` add languages, `t()` supports `{name}` placeholders, the toolbar and dialogs get a `lang` attribute, and `<wysio-editor>` takes a `locale` attribute.
11
+ - 7fe9ec2: Images: inline `image` node with sanitised `src` (http(s) and relative; base64 raster `data:` URLs only with `image({ allowDataUrls: true })`), `alt`, `title`, `width`, `height` and `align` (output as a `wysio-image-*` class; TinyMCE float styles are read on input). Image dialog for URL, alt text and alignment, which also edits or removes the selected image. `upload` adapter option for the dialog, paste and drop, with progress placeholders, abort on destroy and a new `error` event. New `removePlugins` option; a plugin in `plugins` with the same name as a built-in replaces it. The link dialog now shares a reusable popover.
12
+ - 45645ba: Markdown: new `wysio/markdown` entry with a `markdown()` plugin, `parseMarkdown()` and `serializeMarkdown()`; `editor.getMarkdown()`, `setContent(md, { format: 'markdown' })` and a `format` option (`'html' | 'json' | 'markdown'`) for initial content and textarea sync. CommonMark + GFM tables and strikethrough; input is sanitised like HTML, raw HTML stays text; lossy as documented. Plugins can add text formats via `formats`. New CDN file `wysio.full.iife.js` includes Markdown; `wysio.iife.js` does not.
13
+ - 4edecfd: Source view: optional `source` toolbar item (not in the default toolbar) that switches to a textarea with indented HTML. Edits are parsed through the schema as you type, so they are sanitised like `setContent()` and `getHTML()`, `change` and form sync stay current. New `editor.mode` (`'wysiwyg' | 'source'`) with `setMode()` and a `mode` event, `formatHTML()`, and an `availableInSourceMode` flag for toolbar items.
14
+ - 10b7bc9: Basic tables: `table` plugin built on prosemirror-tables with a 10 × 10 size picker (optional header row), a table actions menu (add/delete rows and columns, toggle header row, delete table) and matching individual toolbar items. Tab / Shift-Tab move between cells; Tab in the last cell adds a row. `colspan`/`rowspan` are kept and validated; other table attributes are dropped. Adds the gap cursor and drop cursor to the base plugin.
15
+ - 63faa68: Toolbar: items that don't fit move into a "More" menu (`toolbarMode: 'overflow'`, the default; `'wrap'` keeps wrapping), `sticky` option (with optional offset), dropdown carets and current-state icons on the alignment and colour buttons, `aria-haspopup` / `aria-expanded` on buttons that open popovers (`wysio:popover` event), and `labelKey`, `popover`, `dropdown` and `render` for custom toolbar items.
16
+
17
+ ### Patch Changes
18
+
19
+ - 9304555: Accessibility pass: Escape in a popover returns focus to the editor and moving focus out of a popover closes it; pressed menu items and the dark-mode primary button meet AA contrast (new `--wysio-button-primary-fg`); table size picker targets are 24px; pressed and selected states show outlines in forced-colors mode; the gap cursor and upload bar respect `prefers-reduced-motion`.
20
+
21
+ ## 0.1.0-alpha.0
22
+
23
+ ### Minor Changes
24
+
25
+ - ce00a31: First version of the core editor: ProseMirror schema (paragraph, headings 1–4, bold, italic, underline, strike, inline code, link, lists, blockquote, hard break, horizontal rule), accessible toolbar, link dialog, history, placeholder, input rules, plugin API, light/dark theme and the `<wysio-editor>` web component.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rens Verhaeven
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,243 @@
1
- # Temporary Holding Version
1
+ # wysio
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Core package of [Wysio Editor](https://www.wysio-editor.com): a ProseMirror-based WYSIWYG editor. MIT licensed.
4
+
5
+ > Under active development. Not ready for production use yet.
6
+
7
+ ## Usage
8
+
9
+ ```ts
10
+ import { createEditor } from 'wysio';
11
+ import 'wysio/style.css';
12
+
13
+ const editor = createEditor('#editor', {
14
+ content: '<p>Hello</p>', // HTML string or ProseMirror JSON
15
+ toolbar: [
16
+ 'bold',
17
+ 'italic',
18
+ 'underline',
19
+ '|',
20
+ 'heading',
21
+ 'bulletList',
22
+ 'orderedList',
23
+ '|',
24
+ 'link',
25
+ '|',
26
+ 'undo',
27
+ 'redo',
28
+ ],
29
+ placeholder: 'Start writing…',
30
+ onChange: (editor) => console.log(editor.getHTML()),
31
+ });
32
+
33
+ editor.getHTML(); // sanitised HTML ('' when empty)
34
+ editor.getJSON();
35
+ editor.setContent('<p>New</p>');
36
+ editor.on('focus', () => {});
37
+ editor.destroy();
38
+ ```
39
+
40
+ Passing a `<textarea>` keeps its value in sync, so plain form posts work.
41
+
42
+ ### Forms
43
+
44
+ ```ts
45
+ createEditor('#editor', { name: 'body' }); // hidden <input name="body"> kept in sync
46
+ createEditor('#editor', { name: 'body', format: 'markdown', plugins: [markdown()] }); // submit Markdown
47
+ ```
48
+
49
+ `format` (`'html'` default, `'json'`, `'markdown'`) decides what is submitted; the `content` option and a textarea's value are read in that format, while an element's existing HTML is always read as HTML. With a `<textarea>` target, `name` names the textarea. Resetting the form restores the initial content.
50
+
51
+ Server-rendered pages can use `autoInit()`, which turns every `[data-wysio]` element into an editor with options from `data-wysio-options` (JSON). Pass what JSON can't hold, such as the upload adapter, as defaults:
52
+
53
+ ```html
54
+ <form method="post">
55
+ <div
56
+ data-wysio
57
+ data-wysio-options='{"name":"body","locale":"nl","toolbar":["bold","italic","|","link"]}'
58
+ >
59
+ <p>Existing content</p>
60
+ </div>
61
+ <textarea
62
+ name="notes"
63
+ data-wysio
64
+ data-wysio-options='{"format":"markdown","plugins":["markdown"]}'
65
+ ></textarea>
66
+ </form>
67
+ <script src="wysio.full.iife.js"></script>
68
+ <script>
69
+ Wysio.autoInit({ upload: myUploadAdapter });
70
+ </script>
71
+ ```
72
+
73
+ It skips elements that already have an editor (safe to call again after the page changes), logs and skips elements it cannot set up, and `getEditor(element)` returns an element's editor. Plugins can be named in JSON once registered with `registerPlugin(name, factory)`; importing `wysio/markdown` (or using `wysio.full.iife.js`) registers `markdown`.
74
+
75
+ ### Web component
76
+
77
+ ```ts
78
+ import { defineWysioElement } from 'wysio';
79
+ defineWysioElement(); // registers <wysio-editor>
80
+ ```
81
+
82
+ ```html
83
+ <form>
84
+ <wysio-editor name="body" value="<p>Hello</p>" toolbar="bold italic | link"></wysio-editor>
85
+ </form>
86
+ ```
87
+
88
+ It is form-associated (with a hidden input as fallback in browsers without `ElementInternals`), has a `value` property in its `format` attribute's format, takes `name`, `format`, `locale`, `plugins`, `placeholder`, `toolbar`, `readonly` and `disabled` attributes, and fires `change`. The CDN builds (`wysio.iife.js`, or `wysio.full.iife.js` with Markdown) register it automatically and expose `window.Wysio`.
89
+
90
+ ### Images
91
+
92
+ ```ts
93
+ createEditor(el, {
94
+ // Optional upload adapter: used by the image dialog, paste and drop.
95
+ upload: async (file, { signal, onProgress }) => {
96
+ const body = new FormData();
97
+ body.append('file', file);
98
+ const res = await fetch('/uploads', { method: 'POST', body, signal });
99
+ return { url: (await res.json()).url }; // or just the URL string
100
+ },
101
+ });
102
+ editor.on('error', (editor, error, { source, file }) => {}); // failed uploads
103
+ ```
104
+
105
+ Image `src` must be http(s) or relative. Base64 `data:` URLs are only accepted with `plugins: [image({ allowDataUrls: true })]`. Alignment is output as a class (`wysio-image-left|center|right`), and TinyMCE-style float/margin styles are read on input.
106
+
107
+ ### Tables
108
+
109
+ The `table` toolbar item opens a size picker (up to 10 × 10, optional header row) or, inside a table, a menu to add or delete rows and columns, toggle the header row (the table's first row) or delete the table. Tab / Shift-Tab move between cells; Tab in the last cell adds a row. The actions are also available as separate toolbar items: `tableAddRowBefore`, `tableAddRowAfter`, `tableAddColumnBefore`, `tableAddColumnAfter`, `tableDeleteRow`, `tableDeleteColumn`, `tableToggleHeaderRow`, `tableDelete`.
110
+
111
+ Output is plain `<table><tbody><tr><th|td>`; `colspan`/`rowspan` from pasted content are kept (integers 1–50), all styling attributes are dropped. Merging cells and resizing columns are not part of the free editor.
112
+
113
+ ### Alignment, colours and clear formatting
114
+
115
+ - **Alignment** (`align` menu, or `alignLeft` / `alignCenter` / `alignRight` / `alignJustify`; Ctrl/Cmd+Shift+L/E/R/J) on paragraphs and headings, output as `class="wysio-align-center"` etc. TinyMCE's `style="text-align: …"` is read on input.
116
+ - **Text colour and highlight** (`textColor`, `highlight`) from a palette of 8 colours each, output as `<span class="wysio-color-red">` and `<mark class="wysio-highlight-yellow">`. Inline `color` / `background-color` styles that match a palette colour are read on input; other colours are dropped. Use your own palette with `plugins: [textColor({ colors: [{ name: 'brand', value: '#0a7' }] })]` and add the CSS from `paletteCSS('text', colors)` to your stylesheet.
117
+ - **Clear formatting** (`clearFormatting`, Ctrl/Cmd+\\) removes all marks except links and resets alignment.
118
+
119
+ All formatting is output as `wysio-*` classes (no inline styles), so stored HTML works with a strict Content Security Policy and a simple server-side allowlist. Pages that display the content need the alignment, image and palette rules from `wysio/style.css`.
120
+
121
+ ### Source view
122
+
123
+ Add `'source'` to the toolbar (it is not in the default set) to switch between the editor and a textarea with indented HTML:
124
+
125
+ ```ts
126
+ import { createEditor, defaultToolbar } from 'wysio';
127
+ createEditor(el, { toolbar: [...defaultToolbar, '|', 'source'] });
128
+ ```
129
+
130
+ Edits in the textarea are parsed through the schema as you type, so they are sanitised exactly like `setContent()`, and `getHTML()`, the `change` event and form sync stay current while the source view is open. Other toolbar items are disabled meanwhile. `editor.mode` is `'wysiwyg'` or `'source'`, with a `mode` event; `formatHTML(html)` is exported.
131
+
132
+ ### Markdown
133
+
134
+ Markdown is an opt-in entry point, so apps that don't use it don't load `markdown-it`:
135
+
136
+ ```ts
137
+ import { createEditor } from 'wysio';
138
+ import { markdown } from 'wysio/markdown';
139
+
140
+ const editor = createEditor(el, { plugins: [markdown()] });
141
+ editor.setContent('# Hello\n\n*world*', { format: 'markdown' });
142
+ editor.getMarkdown();
143
+
144
+ // Or read and write Markdown by default, also for a textarea:
145
+ createEditor(textarea, { plugins: [markdown()], format: 'markdown' });
146
+ ```
147
+
148
+ CommonMark plus GFM tables and strikethrough. Markdown input is sanitised exactly like HTML input; raw HTML in Markdown is kept as literal text. The conversion is **lossy** in both directions:
149
+
150
+ - Output drops underline, text colour, highlight, alignment, link targets and image size/alignment. GFM tables always get a header row (the first row), cells are flattened to one line, and merged cells are padded with empty cells.
151
+ - Input has no code block node: fenced and indented code become a paragraph of inline code lines. Headings 5 and 6 become heading 4.
152
+
153
+ `parseMarkdown(md, schema)` and `serializeMarkdown(doc)` are exported too. On a CDN, use `wysio.full.iife.js` for Markdown (`Wysio.markdown()`); the default `wysio.iife.js` leaves it out (about 45 kB gzip smaller).
154
+
155
+ ### Paste
156
+
157
+ Pasted HTML (Word, Google Docs, Outlook, web pages) is cleaned before the schema parses it: comments, Office markup, scripts, styles, form controls, `style`/`class`/`id` and empty paragraphs are removed, `span`/`font` are unwrapped, and bold/italic/underline/strike written as inline styles (Google Docs) become tags. Word list paragraphs become flat `<ul>`/`<ol>` lists. Headings, lists, links, tables and images (when the image plugin is enabled) are kept. The aim is clean output, not a faithful copy of the source formatting.
158
+
159
+ Paste as plain text with Ctrl/Cmd+Shift+V. Use `removePlugins: ['paste']` to skip the cleaner (the schema still sanitises), or `cleanPastedHTML(html)` to run it yourself.
160
+
161
+ ### Choosing plugins
162
+
163
+ ```ts
164
+ createEditor(el, {
165
+ removePlugins: ['image', 'horizontalRule'], // leave out built-ins
166
+ plugins: [image({ types: ['image/png'] })], // same name as a built-in = replace it
167
+ });
168
+ ```
169
+
170
+ ### Toolbar items
171
+
172
+ `heading`, `bold`, `italic`, `underline`, `strike`, `code`, `bulletList`, `orderedList`, `blockquote`, `horizontalRule`, `table`, `link`, `unlink`, `image`, `source` (not in the default toolbar), `undo`, `redo`, and `|` as separator. `toolbar: false` hides the toolbar. Alt+F10 moves focus to the toolbar; Escape returns to the text.
173
+
174
+ On narrow screens, items that don't fit move into a **More** menu (`toolbarMode: 'wrap'` wraps them onto more rows instead). `sticky: true` keeps the toolbar visible while scrolling long content; a number offsets it, e.g. `sticky: 64` below a 64px fixed header.
175
+
176
+ Custom items come from plugins:
177
+
178
+ ```ts
179
+ const wordCount = definePlugin({
180
+ name: 'wordCount',
181
+ toolbarItems: () => ({
182
+ wordCount: {
183
+ labelKey: 'wordCount', // translated via `messages` / the locale
184
+ icon: '<svg …>…</svg>',
185
+ run: (editor) => alert(editor.getText().split(/\s+/).filter(Boolean).length),
186
+ },
187
+ }),
188
+ });
189
+ createEditor(el, {
190
+ plugins: [wordCount],
191
+ toolbar: [...defaultToolbar, '|', 'wordCount'],
192
+ messages: { wordCount: 'Word count' },
193
+ });
194
+ ```
195
+
196
+ Items can also take `command`, `isActive`, `isEnabled`, `shortcut`, `popover` (for `aria-expanded`), `dropdown` (caret) and `render` (update the button, e.g. its icon, on every change).
197
+
198
+ ### Plugins
199
+
200
+ Plugins can add nodes and marks, change nodes from other plugins (`schema.extendNodes`), and add toolbar items, key bindings, input rules and ProseMirror plugins.
201
+
202
+ ```ts
203
+ import { toggleMark } from 'prosemirror-commands';
204
+ import { definePlugin } from 'wysio';
205
+
206
+ const highlight = definePlugin({
207
+ name: 'highlight',
208
+ schema: { marks: { highlight: { parseDOM: [{ tag: 'mark' }], toDOM: () => ['mark', 0] } } },
209
+ keymap: ({ schema }) => ({ 'Mod-Shift-h': toggleMark(schema.marks.highlight!) }),
210
+ toolbarItems: ({ schema }) => ({
211
+ highlight: {
212
+ label: 'Highlight',
213
+ icon: '<b>H</b>',
214
+ command: toggleMark(schema.marks.highlight!),
215
+ },
216
+ }),
217
+ });
218
+
219
+ createEditor(el, { plugins: [highlight], toolbar: ['bold', 'highlight'] });
220
+ ```
221
+
222
+ ### Languages
223
+
224
+ ```ts
225
+ createEditor(el, { locale: 'nl' }); // built in: 'en' (default) and 'nl'; 'nl-BE' etc. also match
226
+ createEditor(el, { locale: { bold: 'Fett', italic: 'Kursiv' } }); // your own strings
227
+ createEditor(el, { locale: 'nl', messages: { bold: 'Dikgedrukt' } }); // override single strings
228
+ ```
229
+
230
+ Missing strings fall back to English. Add more languages with `registerLocale('de', messages)`; the full list of keys is in `defaultMessages` (and `nl` shows a complete translation). The web component takes a `locale` attribute. The language is set when the editor is created.
231
+
232
+ ### Accessibility
233
+
234
+ - The toolbar is one tab stop (`role="toolbar"`): arrow keys, Home and End move between items, Alt+F10 jumps from the text to the toolbar and Escape goes back. Items that don't fit are in a **More** disclosure.
235
+ - Toggles use `aria-pressed`; buttons that open popovers use `aria-haspopup` / `aria-expanded`; unavailable items use `aria-disabled` and stay focusable.
236
+ - Dialogs and menus open with focus inside, support arrow keys where they have a list or grid, close on Escape (focus returns to the text) and close when focus leaves them.
237
+ - All labels are translated, and the toolbar and dialogs carry the UI language in `lang`.
238
+ - Colours meet WCAG AA contrast in light and dark mode; targets are at least 24px. In forced colours (Windows high contrast), pressed and selected states are shown with outlines; animations stop with `prefers-reduced-motion`.
239
+ - The E2E suite runs axe (WCAG 2.2 AA + best practices) on the demo with every popover open, in light, dark and Dutch.
240
+
241
+ ### Theming
242
+
243
+ Override any `--wysio-*` CSS variable (check contrast when you change colours). Dark mode: `data-theme="dark"` on the editor or any ancestor.
@@ -0,0 +1,12 @@
1
+ import { type Editor, type EditorOptions } from './editor';
2
+ /** The editor created for an element by {@link autoInit} (or `null`). */
3
+ export declare function getEditor(element: Element): Editor | null;
4
+ /**
5
+ * Creates an editor for every element with a `data-wysio` attribute inside `root`
6
+ * (default: the document). Options come from the element's `data-wysio-options`
7
+ * JSON, on top of `defaults` (use those for what JSON can't hold, like `upload`).
8
+ * Elements that already have an editor are skipped, so it is safe to call again
9
+ * after the page changes. Returns the editors it created.
10
+ */
11
+ export declare function autoInit(defaults?: EditorOptions | ((element: HTMLElement) => EditorOptions), root?: ParentNode): Editor[];
12
+ //# sourceMappingURL=auto-init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-init.d.ts","sourceRoot":"","sources":["../src/auto-init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzE,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAEzD;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,GAAE,aAAa,GAAG,CAAC,CAAC,OAAO,EAAE,WAAW,KAAK,aAAa,CAAM,EACxE,IAAI,GAAE,UAAqB,GAC1B,MAAM,EAAE,CA+BV"}
@@ -0,0 +1,3 @@
1
+ export * from './index';
2
+ export { markdown, parseMarkdown, serializeMarkdown } from './markdown';
3
+ //# sourceMappingURL=cdn-full.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cdn-full.d.ts","sourceRoot":"","sources":["../src/cdn-full.ts"],"names":[],"mappings":"AAOA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
package/dist/cdn.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './index';
2
+ //# sourceMappingURL=cdn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cdn.d.ts","sourceRoot":"","sources":["../src/cdn.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { Mark, MarkType, NodeType, ResolvedPos } from 'prosemirror-model';
2
+ import type { Command, EditorState } from 'prosemirror-state';
3
+ export declare function isMarkActive(state: EditorState, type: MarkType): boolean;
4
+ /** Nearest ancestor of the selection start whose type is one of `types`. */
5
+ export declare function findAncestor(state: EditorState, types: readonly NodeType[]): {
6
+ node: import("prosemirror-model").Node;
7
+ depth: number;
8
+ pos: number;
9
+ } | null;
10
+ /** Toggles between `listType`, the other list type(s) and no list. */
11
+ export declare function toggleList(listType: NodeType, itemType: NodeType, listTypes: NodeType[]): Command;
12
+ export declare function toggleWrap(type: NodeType): Command;
13
+ /** The full extent of the mark of `type` around `$pos`, if any. */
14
+ export declare function getMarkRange($pos: ResolvedPos, type: MarkType): {
15
+ from: number;
16
+ to: number;
17
+ mark: Mark;
18
+ } | null;
19
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG/E,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE9D,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAIxE;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,QAAQ,EAAE;;;;SAO1E;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAQjG;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAGlD;AAED,mEAAmE;AACnE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,QAAQ,GACb;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,CAuBjD"}
@@ -0,0 +1,31 @@
1
+ import { Node as PMNode, type Schema } from 'prosemirror-model';
2
+ /** ProseMirror JSON document. */
3
+ export interface JSONContent {
4
+ type: string;
5
+ attrs?: Record<string, unknown>;
6
+ content?: JSONContent[];
7
+ marks?: {
8
+ type: string;
9
+ attrs?: Record<string, unknown>;
10
+ }[];
11
+ text?: string;
12
+ }
13
+ /** Content accepted by the editor: an HTML string or a ProseMirror JSON document. */
14
+ export type Content = string | JSONContent | null | undefined;
15
+ /**
16
+ * Parses HTML into a document. The HTML is parsed in an inert document (no scripts run,
17
+ * no resources load); only what the schema's parse rules accept is kept.
18
+ */
19
+ export declare function parseHTML(schema: Schema, html: string, doc?: Document): PMNode;
20
+ export declare function serializeHTML(schema: Schema, node: PMNode, doc?: Document): string;
21
+ /**
22
+ * Passes a document through the HTML serializer and parser, so content that did not
23
+ * come from HTML (JSON, Markdown) is held to exactly the same rules as HTML input
24
+ * (e.g. unsafe link URLs are dropped).
25
+ */
26
+ export declare function normalizeDoc(schema: Schema, node: PMNode, doc?: Document): PMNode;
27
+ /** Loads a JSON document, sanitised like HTML input. */
28
+ export declare function parseJSON(schema: Schema, json: JSONContent, doc?: Document): PMNode;
29
+ export declare function createDoc(schema: Schema, content: Content, doc?: Document): PMNode;
30
+ export declare function isDocEmpty(node: PMNode): boolean;
31
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,IAAI,IAAI,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE1F,iCAAiC;AACjC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,EAAE,CAAC;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qFAAqF;AACrF,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;AAQ9D;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,GAAG,MAAM,CAM9E;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,GAAG,MAAM,CAOlF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,GAAG,MAAM,CAOjF;AAED,wDAAwD;AACxD,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,QAAQ,GAAG,MAAM,CAInF;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,QAAQ,GAAG,MAAM,CAIlF;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMhD"}
@@ -0,0 +1,158 @@
1
+ import type { Schema } from 'prosemirror-model';
2
+ import { EditorState, type Command, type Transaction } from 'prosemirror-state';
3
+ import { EditorView } from 'prosemirror-view';
4
+ import { type Content, type JSONContent } from './content';
5
+ import { type Messages } from './messages';
6
+ import type { WysioPlugin } from './plugin';
7
+ import type { UploadHandler } from './plugins/image';
8
+ import { type ToolbarMode } from './toolbar/toolbar';
9
+ export declare const defaultToolbar: string[];
10
+ /** Text formats for content: HTML, a ProseMirror JSON string, or one added by a plugin (`markdown`). */
11
+ export type ContentFormat = 'html' | 'json' | 'markdown' | (string & {});
12
+ export interface EditorOptions {
13
+ /**
14
+ * Initial content: a string in `format` (HTML by default) or a ProseMirror JSON object.
15
+ * Defaults to the element's HTML (or a textarea's value).
16
+ */
17
+ content?: Content;
18
+ /**
19
+ * How string content (the `content` option, a textarea's value) is read, and what is
20
+ * written to a textarea or the `name` input. `markdown` needs the markdown plugin.
21
+ * Default `html`.
22
+ */
23
+ format?: ContentFormat;
24
+ /**
25
+ * Form field name. The editor keeps a hidden input with this name in sync (in
26
+ * `format`), so it works in plain HTML forms. For a textarea target, this sets the
27
+ * textarea's name instead. Resetting the form restores the initial content.
28
+ */
29
+ name?: string;
30
+ /** Toolbar item names, with `'|'` as separator. `false` hides the toolbar. */
31
+ toolbar?: readonly string[] | false;
32
+ /**
33
+ * Extra plugins, added after the built-in ones. A plugin with the same name as a
34
+ * built-in replaces it (e.g. `image({ allowDataUrls: true })`). Strings are looked up
35
+ * among registered plugins (see `registerPlugin`), e.g. `'markdown'`.
36
+ */
37
+ plugins?: readonly (WysioPlugin | string)[];
38
+ /** Names of built-in plugins to leave out, e.g. `['image', 'horizontalRule']`. */
39
+ removePlugins?: readonly string[];
40
+ placeholder?: string;
41
+ editable?: boolean;
42
+ /** Accessible name of the editing area. */
43
+ ariaLabel?: string;
44
+ /**
45
+ * `overflow` (default): items that don't fit move into a "More" menu.
46
+ * `wrap`: the toolbar wraps onto more rows.
47
+ */
48
+ toolbarMode?: ToolbarMode;
49
+ /**
50
+ * Keep the toolbar visible while scrolling long content. A number sets the distance
51
+ * from the top of the viewport in pixels (e.g. below a fixed site header).
52
+ */
53
+ sticky?: boolean | number;
54
+ /**
55
+ * UI language: a code such as `nl` or `nl-BE` (built in: `en`, `nl`; add more with
56
+ * `registerLocale`), or a messages object. Missing strings fall back to English.
57
+ */
58
+ locale?: string | Messages;
59
+ /** Overrides for individual UI strings, applied on top of `locale`. */
60
+ messages?: Messages;
61
+ onChange?: (editor: Editor) => void;
62
+ /**
63
+ * Upload adapter for image files (dialog file picker, paste, drop). Resolves with the
64
+ * public URL. Without it, images can only be added by URL.
65
+ */
66
+ upload?: UploadHandler;
67
+ }
68
+ export interface EditorErrorInfo {
69
+ /** What failed. */
70
+ source: 'upload';
71
+ file?: File;
72
+ }
73
+ /** `wysiwyg` is normal editing; `source` is the HTML source view. */
74
+ export type EditorMode = 'wysiwyg' | 'source';
75
+ export interface EditorEvents extends Record<string, unknown[]> {
76
+ /** The editor switched between WYSIWYG and source view. */
77
+ mode: [editor: Editor, mode: EditorMode];
78
+ change: [editor: Editor];
79
+ focus: [editor: Editor, event: FocusEvent];
80
+ blur: [editor: Editor, event: FocusEvent];
81
+ /** Every state update, including selection changes. */
82
+ transaction: [editor: Editor, transaction: Transaction];
83
+ destroy: [editor: Editor];
84
+ /** Something failed in the background (e.g. an upload). Logged to the console when nobody listens. */
85
+ error: [editor: Editor, error: unknown, info: EditorErrorInfo];
86
+ }
87
+ export declare class Editor {
88
+ /** Root element (gets the `wysio` class). */
89
+ readonly dom: HTMLElement;
90
+ readonly view: EditorView;
91
+ readonly schema: Schema;
92
+ readonly options: Readonly<EditorOptions>;
93
+ private readonly emitter;
94
+ private readonly toolbar;
95
+ private readonly textarea;
96
+ private readonly input;
97
+ private readonly form;
98
+ private initialContent;
99
+ private readonly plugins;
100
+ private readonly messages;
101
+ /** Resolved UI language code (e.g. `nl`), or `null` for a custom messages object. */
102
+ readonly locale: string | null;
103
+ private readonly formats;
104
+ private editable;
105
+ private currentMode;
106
+ private destroyed;
107
+ constructor(target: HTMLElement | string, options?: EditorOptions);
108
+ private createProseMirrorPlugins;
109
+ private dispatch;
110
+ private changed;
111
+ /** Writes the content to the textarea target and/or the `name` input. */
112
+ private syncTextarea;
113
+ private onFormReset;
114
+ get state(): EditorState;
115
+ /** Current mode. Plugins (e.g. the source view) switch it with {@link setMode}. */
116
+ get mode(): EditorMode;
117
+ /** Switches the mode flag; the plugin that owns the mode handles the UI. */
118
+ setMode(mode: EditorMode): void;
119
+ get isEditable(): boolean;
120
+ get isEmpty(): boolean;
121
+ /** Translated UI string. */
122
+ /** Translated UI string, with `{name}` placeholders filled from `params`. */
123
+ t(key: string, params?: Record<string, string | number>): string;
124
+ /** Sanitised HTML. Contains only elements and attributes the schema allows. Empty string when empty. */
125
+ getHTML(): string;
126
+ getJSON(): JSONContent;
127
+ /** Markdown (needs the markdown plugin from `wysio/markdown`). Lossy: see its docs. */
128
+ getMarkdown(): string;
129
+ /** The content as a string in the given format. */
130
+ serialize(format: ContentFormat): string;
131
+ private formatHandler;
132
+ /** Builds a sanitised document from content: an object is JSON, a string is read as `format`. */
133
+ private parseContent;
134
+ getText(): string;
135
+ /**
136
+ * Replaces the content and resets undo history. A string is read as `format`
137
+ * (default: the editor's `format` option, else HTML). Emits `change` only when
138
+ * `emitChange` is set.
139
+ */
140
+ setContent(content: Content, { emitChange, format, }?: {
141
+ emitChange?: boolean;
142
+ format?: ContentFormat;
143
+ }): void;
144
+ setEditable(editable: boolean): void;
145
+ /** Runs a ProseMirror command and returns focus to the editor. */
146
+ exec(command: Command): boolean;
147
+ /** Reports a background error through the `error` event (or the console). */
148
+ reportError(error: unknown, info: EditorErrorInfo): void;
149
+ /** Whether a plugin with this name is active. */
150
+ hasPlugin(name: string): boolean;
151
+ focus(): void;
152
+ on<E extends keyof EditorEvents>(event: E, handler: (...args: EditorEvents[E]) => void): () => void;
153
+ off<E extends keyof EditorEvents>(event: E, handler: (...args: EditorEvents[E]) => void): void;
154
+ /** Removes the editor. A div target keeps the final HTML; a textarea is shown again with the final value. */
155
+ destroy(): void;
156
+ }
157
+ export declare function createEditor(target: HTMLElement | string, options?: EditorOptions): Editor;
158
+ //# sourceMappingURL=editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAkB,MAAM,EAAE,MAAM,mBAAmB,CAAC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itter<Events extends Record<string, unknown[]>> {
2
+ private listeners;
3
+ on<E extends keyof Events>(event: E, listener: (...args: Events[E]) => void): () => void;
4
+ off<E extends keyof Events>(event: E, listener: (...args: Events[E]) => void): void;
5
+ emit<E extends keyof Events>(event: E, ...args: Events[E]): void;
6
+ has(event: keyof Events): boolean;
7
+ clear(): void;
8
+ }
9
+ //# sourceMappingURL=emitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../src/emitter.ts"],"names":[],"mappings":"AAGA,qBAAa,OAAO,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;IAC3D,OAAO,CAAC,SAAS,CAA6C;IAE9D,EAAE,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;IAOxF,GAAG,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI;IAInF,IAAI,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI;IAIhE,GAAG,CAAC,KAAK,EAAE,MAAM,MAAM,GAAG,OAAO;IAIjC,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Pretty-prints editor HTML for the source view: one block per line, children of
3
+ * lists, quotes and tables indented. Inline content is left untouched, so the
4
+ * result parses back to the same document.
5
+ */
6
+ export declare function formatHTML(html: string, indent?: string, doc?: Document): string;
7
+ //# sourceMappingURL=format-html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-html.d.ts","sourceRoot":"","sources":["../src/format-html.ts"],"names":[],"mappings":"AAoCA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,SAAO,EAAE,GAAG,GAAE,QAAmB,GAAG,MAAM,CA0BxF"}
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { type Messages } from './messages';
2
+ /** Makes a locale available by code (e.g. `de`, or `pt-br` for a regional variant). */
3
+ export declare function registerLocale(code: string, messages: Messages): void;
4
+ /** Built-in and registered locale codes. */
5
+ export declare function availableLocales(): string[];
6
+ /**
7
+ * Finds messages for a code: the exact code first (`nl-be`), then its language
8
+ * (`nl`). Returns the code that matched, or `null` when nothing did.
9
+ */
10
+ export declare function findLocale(code: string): {
11
+ code: string;
12
+ messages: Messages;
13
+ } | null;
14
+ /** Replaces `{name}` placeholders with values; unknown placeholders are left as-is. */
15
+ export declare function interpolate(text: string, params?: Record<string, string | number>): string;
16
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAO5D,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAErE;AAED,4CAA4C;AAC5C,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAAG,IAAI,CAOpF;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAK1F"}