@writeon/core 0.2.0 → 1.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/llms-full.txt CHANGED
@@ -175,6 +175,7 @@ Or use the [default kit](/guide/kit.md): a themeable toolbar and content styles
175
175
  ## Next
176
176
 
177
177
  - [Other frameworks](/guide/frameworks.md): Svelte, Angular, Solid, Lit and the rest.
178
+ - [Web component](/guide/element.md): `<writeon-editor>` for Blade, Twig and plain HTML forms, no build step.
178
179
  - [Core concepts](/guide/concepts.md): documents, extensions, commands and state.
179
180
  - [Saving and loading](/guide/saving.md): store JSON, convert to HTML or Markdown.
180
181
  - [Security](/guide/security.md): validate on the server before you store or render.
@@ -307,11 +308,11 @@ const editor = createEditor({ extensions, label: 'Notes' })
307
308
  // and the rest come in a separate chunk.
308
309
  // The document, undo history and selection are kept.
309
310
  export async function turnOnAdvanced(): Promise<void> {
310
- await editor.enable(() => import('@writeon/advanced'))
311
+ await editor.extend(() => import('@writeon/advanced'))
311
312
  }
312
313
  ```
313
314
 
314
- `editor.enable()` adds behaviour to the running editor and keeps the document, undo history and selection. Extensions already added are skipped, so calling it twice is harmless.
315
+ `editor.extend()` adds behaviour to the running editor and keeps the document, undo history and selection. Extensions already added are skipped, so calling it twice is harmless.
315
316
 
316
317
  If you do not need lazy loading, pass everything up front:
317
318
 
@@ -388,7 +389,7 @@ editor.run(setFontFamily(null))
388
389
  - **Pasted text keeps** a font when its `font-family` starts with one of yours, a colour when it is exactly one of yours, and alignment.
389
390
  - **Contrast:** `textColor()` warns while you develop when a colour is under 4.5:1 on the background (`background`, default white).
390
391
  - **Markdown** has no fonts or colours: `toMarkdown()` keeps the text without them.
391
- - For menus, `activeFontFamily(state)` and `activeTextColor(state)` give the current id, and `textAlignmentAt(state)` the alignment.
392
+ - For menus, `activeFontFamily(editor)` and `activeTextColor(editor)` give the current id, and `activeTextAlign(editor)` the alignment.
392
393
 
393
394
  ### Image addresses
394
395
 
@@ -638,9 +639,9 @@ const bold = $derived(state.current.marks.has('bold'))
638
639
 
639
640
  <main>
640
641
  <h1>Writeon · Svelte</h1>
641
- <div class="rte-root">
642
+ <div class="writeon-root">
642
643
  <div use:kitToolbar={editor}></div>
643
- <div use:editorContent={editor} class="rte-content"></div>
644
+ <div use:editorContent={editor} class="writeon-content"></div>
644
645
  </div>
645
646
  <p data-testid="status">
646
647
  Block: {state.current.block.type} ·
@@ -704,9 +705,9 @@ import { editorState } from './writeon'
704
705
  template: `
705
706
  <main>
706
707
  <h1>Writeon · Angular</h1>
707
- <div class="rte-root">
708
+ <div class="writeon-root">
708
709
  <div #toolbar></div>
709
- <div #content class="rte-content"></div>
710
+ <div #content class="writeon-content"></div>
710
711
  </div>
711
712
  <p data-testid="status">
712
713
  Block: {{ state().block.type }} ·
@@ -781,6 +782,180 @@ The packages are ES modules only. Vitest runs them as they are. Jest needs its E
781
782
 
782
783
  ---
783
784
 
785
+ Source: /guide/element.md
786
+
787
+ # Web component
788
+
789
+ `@writeon/element` is the editor as an HTML element, `<writeon-editor>`. It needs no framework and no build step, so it fits server-rendered pages: Laravel Blade, Symfony Twig, Django, Rails, plain HTML. It works inside a `<form>` like a `<textarea>`.
790
+
791
+ ## Install
792
+
793
+ From a CDN, with no build step. Pin the version you tested with:
794
+
795
+ ```html
796
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@writeon/element@0.1/dist/style.css" />
797
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@writeon/element@0.1/dist/cdn/writeon-editor.js"></script>
798
+ ```
799
+
800
+ The CDN file has everything in it (about 115 KB gzipped). With a bundler (Vite, webpack), install the package instead; it shares ProseMirror and Writeon with the rest of your app:
801
+
802
+ ```sh
803
+ npm install @writeon/element
804
+ ```
805
+
806
+ ```ts
807
+ import '@writeon/element/style.css'
808
+ import '@writeon/element' // registers <writeon-editor>
809
+ ```
810
+
811
+ ## Use it in a form
812
+
813
+ Put a `<textarea>` inside, with the name and the current value:
814
+
815
+ ```blade [Blade]
816
+ <form method="post" action="/posts/{{ $post->id }}">
817
+ @csrf
818
+ <writeon-editor label="Article text" locale="uz">
819
+ <textarea name="body" required>{{ $post->body }}</textarea>
820
+ </writeon-editor>
821
+ <button>Save</button>
822
+ </form>
823
+ ```
824
+
825
+ ```twig [Twig]
826
+ <form method="post">
827
+ <writeon-editor label="Article text">
828
+ <textarea name="body" required>{{ post.body }}</textarea>
829
+ </writeon-editor>
830
+ <button>Save</button>
831
+ </form>
832
+ ```
833
+
834
+ ```html [HTML]
835
+ <form method="post">
836
+ <writeon-editor label="Article text">
837
+ <textarea name="body">&lt;p&gt;Hello&lt;/p&gt;</textarea>
838
+ </writeon-editor>
839
+ <button>Save</button>
840
+ </form>
841
+ ```
842
+
843
+ Print the value **escaped** (`{{ }}`, not `{!! !!}` or `|raw`). A textarea shows text, never runs it, so stored HTML cannot run while the page loads.
844
+
845
+ What the element does with the textarea:
846
+
847
+ - **Until the element starts, and if JavaScript does not load, the textarea is the field.** The form still sends the text. If the element cannot start (no accessible name, a value it cannot read), the textarea stays and a `writeon-error` event says why.
848
+ - Once it starts, it takes the textarea's `name`, `required`, `disabled` and `id` (for `<label for>`), and hides it.
849
+ - **Until the user changes the text, the form sends the original value unchanged**, even HTML the editor would not keep. Opening and saving a page never rewrites old content.
850
+ - After a change, the form sends the editor's HTML.
851
+
852
+ It also behaves like a form field in the other ways: `required` blocks the submit and focuses the editor (the message is in the editor's language), a form reset brings back the original value, and a disabled `<fieldset>` makes it read-only and leaves it out of the form.
853
+
854
+ ## Attributes
855
+
856
+ | Attribute | Meaning |
857
+ | --- | --- |
858
+ | `label` | The accessible name. Required, unless a `<label for="…">` points at the textarea's `id`. |
859
+ | `name` | The form field name. Usually taken from the textarea. |
860
+ | `locale` | `en`, `uz` or `ru`, for the toolbar and messages. Default: the nearest `lang` attribute, then English. |
861
+ | `placeholder` | Text shown while empty. |
862
+ | `required`, `readonly`, `disabled` | As on a textarea. |
863
+ | `format` | `html` (default) or `json`: what the form sends. |
864
+ | `toolbar` | `none` hides the toolbar. |
865
+ | `advanced` | Tables, images, task lists, code blocks, the `/` menu and the formatting bubble. Loaded when needed. |
866
+ | `upload-url` | With `advanced`: images are uploaded with a `POST` (field `file`) to this address, which answers `{ "url": "…" }`. |
867
+
868
+ Tables, images and task lists in stored HTML are kept even without `advanced`; the attribute only adds the tools to create and edit them.
869
+
870
+ ## JavaScript
871
+
872
+ ```ts
873
+ const field = document.querySelector('writeon-editor')
874
+
875
+ field.value // the current HTML (or JSON with format="json")
876
+ field.value = '<p>New text</p>'
877
+ field.editor // the full Editor: commands, state, getJSON()
878
+ field.upload = myUploadFunction // instead of upload-url, e.g. to add headers
879
+
880
+ field.addEventListener('input', () => {}) // every change
881
+ field.addEventListener('change', () => {}) // on leaving, after a change
882
+ ```
883
+
884
+ For an upload that needs a CSRF header (Laravel), set `upload` with `fetchUploader({ url, headers })` from `@writeon/advanced`; see [Image uploads](/recipes/upload-s3.md).
885
+
886
+ ## Security: sanitize on the server
887
+
888
+ The form sends HTML, and **anyone can send any HTML** to your server without the editor. Sanitize it before you store it, with an allowlist of exactly what the editor produces.
889
+
890
+ In PHP, with [symfony/html-sanitizer](https://symfony.com/doc/current/html_sanitizer.html) (works in Laravel too):
891
+
892
+ ```php
893
+ <?php
894
+ // composer require symfony/html-sanitizer:^7.4
895
+
896
+ use Symfony\Component\HtmlSanitizer\HtmlSanitizer;
897
+ use Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig;
898
+
899
+ // Exactly the tags and attributes <writeon-editor> produces. Anything
900
+ // else (scripts, event handlers, style, iframes, forms) is removed.
901
+ function writeon_sanitizer(): HtmlSanitizer
902
+ {
903
+ $config = (new HtmlSanitizerConfig())
904
+ ->allowElement('p')
905
+ ->allowElement('h1')
906
+ ->allowElement('h2')
907
+ ->allowElement('h3')
908
+ ->allowElement('strong')
909
+ ->allowElement('em')
910
+ ->allowElement('u')
911
+ ->allowElement('s')
912
+ ->allowElement('br')
913
+ ->allowElement('blockquote')
914
+ ->allowElement('div')
915
+ ->allowElement('code', ['class'])
916
+ ->allowElement('pre', ['data-language'])
917
+ ->allowElement('a', ['href', 'title'])
918
+ ->forceAttribute('a', 'rel', 'noopener noreferrer nofollow')
919
+ ->allowElement('ul', ['data-type'])
920
+ ->allowElement('ol', ['start'])
921
+ ->allowElement('li', ['data-type', 'data-checked'])
922
+ ->allowElement('span', ['data-type', 'data-id', 'data-label'])
923
+ ->allowElement('img', ['src', 'alt', 'title', 'width', 'height', 'data-alt-missing'])
924
+ ->allowElement('table')
925
+ ->allowElement('tbody')
926
+ ->allowElement('tr')
927
+ ->allowElement('th', ['colspan', 'rowspan', 'data-colwidth'])
928
+ ->allowElement('td', ['colspan', 'rowspan', 'data-colwidth'])
929
+ ->allowLinkSchemes(['http', 'https', 'mailto', 'tel'])
930
+ ->allowRelativeLinks()
931
+ ->allowMediaSchemes(['http', 'https'])
932
+ ->allowRelativeMedias()
933
+ ->withMaxInputLength(1_000_000);
934
+
935
+ return new HtmlSanitizer($config);
936
+ }
937
+ ```
938
+
939
+ Call `writeon_sanitizer()->sanitize($request->input('body'))` before you store the field.
940
+
941
+ This configuration is tested against the editor's output and against common attacks.
942
+
943
+ Then print the stored, sanitized value as HTML (`{!! $post->body !!}`) inside an element with your content styles. The checkbox of a task list item is not kept (an `<input>` in content is a risk); style `li[data-checked="true"]` in your CSS instead.
944
+
945
+ With a Node.js backend, send `format="json"` and use `validate()` and `toSafeHTML()` from `@writeon/server`, as described in [Security](/guide/security.md).
946
+
947
+ ## Livewire, Turbo and other DOM updaters
948
+
949
+ - **Livewire:** add `wire:ignore` to the element (or a wrapper), so Livewire does not replace the editor's DOM on every update. Read the value from the form, or with `field.value`.
950
+ - **Turbo / Hotwire:** works as is. A page restored from Turbo's cache starts with the last edited text.
951
+ - **htmx:** swapping the element out and in starts a new editor with the value of its textarea.
952
+
953
+ ## Limits
954
+
955
+ The element is the editor with the default kit. Mentions, custom blocks, fonts and colours have no attributes: use `field.editor`, or the npm packages directly with [your framework](/guide/frameworks.md).
956
+
957
+ ---
958
+
784
959
  Source: /guide/security.md
785
960
 
786
961
  # Security
@@ -835,7 +1010,7 @@ export async function savePost(
835
1010
  - checks the JSON shape and refuses `__proto__`, `constructor` and `prototype` keys;
836
1011
  - enforces limits: size (1 MB), depth (32) and node count (50 000) by default;
837
1012
  - removes unknown nodes, marks and attributes, invalid attribute values and content the schema does not allow;
838
- - removes links and images whose address is not allowed (`javascript:`, `data:` and so on);
1013
+ - removes links and images whose address is not allowed (`javascript:`, `data:` and so on). The allowed protocols are those of `link()` in the extensions you pass (`basic({ link: { protocols } })`), so the server accepts exactly what the editor does; `urls: { protocols }` overrides them;
839
1014
  - in `'strip'` mode (default) returns the cleaned document and what was removed; in `'strict'` mode refuses the whole document instead.
840
1015
 
841
1016
  `toSafeHTML()` renders only what the schema knows, escapes all text and checks every URL again.
@@ -930,9 +1105,9 @@ export function Editor() {
930
1105
  const editor = useEditor({ extensions, label: 'Message' })
931
1106
 
932
1107
  return (
933
- <div className="rte-root">
1108
+ <div className="writeon-root">
934
1109
  <Toolbar editor={editor} />
935
- <EditorContent editor={editor} className="rte-content" />
1110
+ <EditorContent editor={editor} className="writeon-content" />
936
1111
 
937
1112
  {/* Loaded on demand, after mount. */}
938
1113
  <Advanced
@@ -963,10 +1138,10 @@ const editor = useEditor({
963
1138
  </script>
964
1139
 
965
1140
  <template>
966
- <div class="rte-root">
1141
+ <div class="writeon-root">
967
1142
  <!-- Buttons, menus and announcements in Uzbek. -->
968
1143
  <Toolbar :editor="editor" :messages="uz" />
969
- <EditorContent :editor="editor" class="rte-content" />
1144
+ <EditorContent :editor="editor" class="writeon-content" />
970
1145
  <Advanced :editor="editor" :messages="uz" />
971
1146
  </div>
972
1147
  </template>
@@ -981,11 +1156,11 @@ import { basic } from '@writeon/core/presets'
981
1156
  import '@writeon/kit/style.css'
982
1157
  import { mountToolbar } from '@writeon/kit'
983
1158
 
984
- // <div class="rte-root">
1159
+ // <div class="writeon-root">
985
1160
  // <div id="toolbar"></div>
986
- // <div id="editor" class="rte-content"></div>
1161
+ // <div id="editor" class="writeon-content"></div>
987
1162
  // </div>
988
- const root = document.querySelector<HTMLElement>('.rte-root')
1163
+ const root = document.querySelector<HTMLElement>('.writeon-root')
989
1164
  const toolbarHost = document.querySelector<HTMLElement>('#toolbar')
990
1165
  const element = document.querySelector<HTMLElement>('#editor')
991
1166
  if (!root || !toolbarHost || !element) {
@@ -1004,7 +1179,7 @@ const { mountAdvanced } = await import('@writeon/kit/advanced')
1004
1179
  mountAdvanced(root, editor, { slash: true })
1005
1180
  ```
1006
1181
 
1007
- - `.rte-root` is the frame; `.rte-content` styles the document (headings, lists, code, tables, task lists, images, mentions) without Tailwind Typography.
1182
+ - `.writeon-root` is the frame; `.writeon-content` styles the document (headings, lists, code, tables, task lists, images, mentions) without Tailwind Typography.
1008
1183
  - `<Toolbar>` / `mountToolbar()`: undo/redo, text style menu, marks, lists, quote, clear formatting, link, tooltips. Options: `messages`, `blockTypes`, `headingLevels`, `link`, `exclude`, `mobile`.
1009
1184
  - `<Advanced>` / `mountAdvanced()` needs `advancedSchema()` in the editor. It turns on the advanced behaviour and adds:
1010
1185
  - image, table, task list and code block buttons to the toolbar;
@@ -1015,19 +1190,19 @@ Its code is a separate chunk, loaded after mount.
1015
1190
 
1016
1191
  ## Theme
1017
1192
 
1018
- Every colour, radius and font is a CSS variable on `.rte-root`:
1193
+ Every colour, radius and font is a CSS variable on `.writeon-root`:
1019
1194
 
1020
1195
  ```css
1021
- .rte-root {
1022
- --rte-color-accent: #0d9488;
1023
- --rte-color-accent-soft: #ccfbf1;
1024
- --rte-color-accent-text: #115e59;
1025
- --rte-radius: 4px;
1026
- --rte-font: "Inter", sans-serif;
1196
+ .writeon-root {
1197
+ --writeon-color-accent: #0d9488;
1198
+ --writeon-color-accent-soft: #ccfbf1;
1199
+ --writeon-color-accent-text: #115e59;
1200
+ --writeon-radius: 4px;
1201
+ --writeon-font: "Inter", sans-serif;
1027
1202
  }
1028
1203
  ```
1029
1204
 
1030
- Dark mode follows the system. To choose explicitly, set `data-theme="dark"` or `data-theme="light"` on `.rte-root` or any ancestor.
1205
+ Dark mode follows the system. To choose explicitly, set `data-theme="dark"` or `data-theme="light"` on `.writeon-root` or any ancestor.
1031
1206
 
1032
1207
  Each kit rule has the specificity of one class, so CSS resets such as Tailwind's preflight do not undo it, and any rule of yours with one class overrides it.
1033
1208
 
@@ -1127,6 +1302,8 @@ export function MyToolbar({ editor }: { editor: Editor }) {
1127
1302
  }
1128
1303
  ```
1129
1304
 
1305
+ To add your own props to a prop getter's output, use `mergeProps()` from `@writeon/react`, or Vue's own `mergeProps()` from `vue`: both chain event handlers instead of replacing them.
1306
+
1130
1307
  ## Positioning
1131
1308
 
1132
1309
  Controllers never position anything. Popups that follow the text (bubble, suggestion lists) expose a `reference` compatible with [Floating UI](https://floating-ui.com)'s virtual elements:
@@ -1184,7 +1361,7 @@ Packages: `@writeon/core` (editor, `/presets`, `/commands`, `/extension`),
1184
1361
  `@writeon/react`, `@writeon/vue`, `@writeon/ui` (headless controllers),
1185
1362
  `@writeon/kit` (ready-made UI, `/react`, `/vue`, `/advanced`),
1186
1363
  `@writeon/advanced` (+ `/schema`), `@writeon/html`, `@writeon/markdown`,
1187
- `@writeon/server`.
1364
+ `@writeon/server`, `@writeon/element` (`<writeon-editor>` web component for HTML forms).
1188
1365
 
1189
1366
  Rules:
1190
1367
  - Store the document as JSON: `editor.getJSON()` (`DocJSON`). HTML and Markdown are
@@ -1198,7 +1375,7 @@ Rules:
1198
1375
  - Commands are factories: `editor.run(toggleBold())`, `editor.can(toggleBold())`;
1199
1376
  several in one undo step with `editor.transaction((tx) => { … })`.
1200
1377
  - Advanced features: include `advancedSchema()` in the extensions from the start;
1201
- load the behaviour later with `editor.enable(() => import('@writeon/advanced'))`,
1378
+ load the behaviour later with `editor.extend(() => import('@writeon/advanced'))`,
1202
1379
  or use the kit's `<Advanced>` / `mountAdvanced()`.
1203
1380
  - `editor.pm` (raw ProseMirror) is not a stable API; prefer commands, snapshots
1204
1381
  (`getSnapshot()`, `subscribe()`) and extensions (`defineExtension`).
@@ -1213,6 +1390,114 @@ Every public function, type and option has JSDoc, often with an example. Assista
1213
1390
 
1214
1391
  ---
1215
1392
 
1393
+ Source: /guide/stability.md
1394
+
1395
+ # Stability
1396
+
1397
+ From 1.0, Writeon follows [semantic versioning](https://semver.org): a patch fixes, a minor adds, and only a major breaks. This page says what counts as breaking.
1398
+
1399
+ **Before 1.0:**
1400
+ In 0.x a minor release may still break the API; its changelog says how to update. Stored documents are the exception: the promise below already holds since 0.1.0.
1401
+
1402
+ ## Stored documents
1403
+
1404
+ **Every 1.x release reads every document stored since 0.1.0.** You never have to rewrite your database for a Writeon update.
1405
+
1406
+ - A document carries its format version (`schemaVersion`). When the format changes, the release ships a migration, and `createEditor()` and `validate()` apply it on load. To store the upgraded form, run `migrateDoc()` yourself.
1407
+ - An older release refuses a document from a newer one with a clear error instead of loading it partly.
1408
+ - A test keeps the promise: documents with every node, mark and attribute, as the published releases since 0.1.0 stored them, must load, pass `validate()` in strict mode and render to the same HTML in every 1.x release. The HTML those releases wrote (what a form with `<writeon-editor>` stores) must read back to the same document.
1409
+
1410
+ ## What semver covers
1411
+
1412
+ - **The TypeScript API**: everything the package entry points export (`@writeon/core`, `@writeon/advanced/schema`, …). The repository keeps it as text in [`api/`](https://github.com/writeon-editor/writeon/tree/main/api), and a pull request that changes it shows the change there.
1413
+ - **The document format**: `DocJSON`, the node, mark and attribute names, and what each value means.
1414
+ - **The HTML of `toHTML()` and `toSafeHTML()`**: the elements, attributes and classes they write for a document. A minor release may add an attribute, never remove or rename one. `fromHTML()` reads what every earlier 1.x wrote.
1415
+ - **The kit's styling hooks**: the `--writeon-*` CSS variables, `.writeon-root`, `.writeon-content` and `data-theme`.
1416
+ - **`<writeon-editor>`**: the tag name, its attributes, properties and events, and what it sends with the form.
1417
+ - **Error codes** of `validate()` (`unknown-node`, `unsafe-url`, …). Messages are for people and can change.
1418
+
1419
+ ## What it does not cover
1420
+
1421
+ - **`editor.pm`**, the ProseMirror view and state. It follows ProseMirror's own releases.
1422
+ - **Anything marked `@experimental`** in its docs, now `@writeon/advanced/embed`. It can change in a minor; the changelog says so. Stored documents are still covered.
1423
+ - **Anything marked `@internal`**, and imports of files inside a package (`@writeon/core/dist/…`) instead of its entry points.
1424
+ - **The markup of the editing UI**: toolbar, menus and popovers, except the styling hooks above. Style them through the CSS variables.
1425
+ - **Bug fixes.** When behaviour does not match the docs, a patch fixes the behaviour, even if some code relied on it.
1426
+
1427
+ ## Deprecations
1428
+
1429
+ A minor release can deprecate an API; the next major removes it at the earliest. A deprecated API:
1430
+
1431
+ - is marked `@deprecated` with what to use instead, so your editor shows it crossed out;
1432
+ - warns once in the console when it is first used;
1433
+ - is listed in the changelog of the release that deprecates it and in the upgrade guide of the major.
1434
+
1435
+ ## Browsers
1436
+
1437
+ Writeon supports browsers released in the last two years: Chrome, Edge, Firefox and Safari, on desktop, Android and iOS. Every change runs the end-to-end tests in current Chromium, Firefox and WebKit, and on emulated Android and iPhone screens.
1438
+
1439
+ `<writeon-editor>` needs form-associated custom elements: Chrome and Edge 77, Firefox 98, Safari 16.4 or later.
1440
+
1441
+ Dropping a browser that is still within the two years is a breaking change.
1442
+
1443
+ ## Node.js
1444
+
1445
+ `@writeon/html`, `@writeon/markdown` and `@writeon/server` run on the server without a DOM, on the maintained LTS versions of Node.js: 22, 24 and 26, all tested on every change. The packages are ES modules only: load them with `import`.
1446
+
1447
+ A major release of Writeon may drop a Node.js version that has reached its end of life.
1448
+
1449
+ ---
1450
+
1451
+ Source: /guide/upgrade-1.md
1452
+
1453
+ # Upgrading to 1.0
1454
+
1455
+ 1.0 is the first release covered by the [stability promise](/guide/stability.md). Coming from 0.x, you change some names in your code and CSS. **Stored documents need nothing:** 1.0 reads every document and every HTML value that 0.x stored.
1456
+
1457
+ ## The `rte-` prefix is now `writeon-`
1458
+
1459
+ Before the project was called Writeon, its CSS used the prefix `rte-`. Every class, CSS variable, data attribute and generated id now uses `writeon-`:
1460
+
1461
+ | 0.x | 1.0 |
1462
+ | --- | --- |
1463
+ | `.rte-root`, `.rte-content`, `.rte-toolbar`, … | `.writeon-root`, `.writeon-content`, `.writeon-toolbar`, … |
1464
+ | `--rte-color-accent`, `--rte-radius`, … | `--writeon-color-accent`, `--writeon-radius`, … |
1465
+ | `data-rte-item`, `data-rte-upload` | `data-writeon-item`, `data-writeon-upload` |
1466
+ | `--rte-upload-progress` | `--writeon-upload-progress` |
1467
+ | `class="rte-embed"` in `toHTML()` output | `class="writeon-embed"` |
1468
+
1469
+ Find what to change in your project:
1470
+
1471
+ ```sh
1472
+ grep -rnE -- "rte-" src/
1473
+ ```
1474
+
1475
+ In most projects, replacing `rte-` with `writeon-` in your stylesheets and templates is all there is to it. For custom blocks, select `[data-embed]` instead of the class: the attribute has not changed and is in the HTML of every version.
1476
+
1477
+ ## Renamed APIs
1478
+
1479
+ | 0.x | 1.0 |
1480
+ | --- | --- |
1481
+ | `editor.enable(…)` | `editor.extend(…)` |
1482
+ | `format()` from `@writeon/ui` | `formatMessage()` |
1483
+ | `textAlignmentAt(editor.pm.state)` | `activeTextAlign(editor)` |
1484
+ | `activeFontFamily(editor.pm.state)`, `activeTextColor(…)`, `embedKinds(…)`, `selectedEmbed(…)` | the same functions with `editor` |
1485
+ | `toolbar.state.active` from React `useToolbar()` | `toolbar.active` (also `enabled`, `focusId`) |
1486
+
1487
+ TypeScript points at each of these after the update. `enable()` and `format()` warned in the console since 0.3.
1488
+
1489
+ ## Behaviour to check
1490
+
1491
+ - `validate()`, `toHTML()` and `toSafeHTML()` take the allowed link protocols from `link()` in your extensions. If you passed `urls.protocols` only to repeat them, you can remove it.
1492
+ - `setHeading()`, `toggleHeading()` and `heading({ levels })` take `1` to `6` in the types.
1493
+ - `@writeon/advanced/embed` is [experimental](/guide/stability.md#what-it-does-not-cover): its API can change in a minor release; stored blocks keep loading.
1494
+
1495
+ ## Stored documents
1496
+
1497
+ Nothing to do. JSON documents keep `schemaVersion: 1`, and HTML stored by a form with `<writeon-editor>` reads back to the same document (old `rte-embed` classes included). A test checks this against documents made with the published 0.x releases.
1498
+
1499
+ ---
1500
+
1216
1501
  Source: /recipes/upload-s3.md
1217
1502
 
1218
1503
  # Image uploads to S3
@@ -1246,7 +1531,7 @@ async function signUpload(
1246
1531
  }
1247
1532
 
1248
1533
  export async function enableUploads(editor: Editor): Promise<void> {
1249
- await editor.enable([
1534
+ await editor.extend([
1250
1535
  imageUpload({
1251
1536
  upload: presignedUploader({ getTarget: signUpload }),
1252
1537
  // 5 MB
@@ -1342,6 +1627,9 @@ Source: /recipes/custom-blocks.md
1342
1627
 
1343
1628
  Some content is not text: a list of pickup branches, a product carousel, a map. Store it as a **custom block** (an embed) and let your front end render the component.
1344
1629
 
1630
+ **Experimental:**
1631
+ The `@writeon/advanced/embed` API can still change in a minor release (see [Stability](/guide/stability.md)). Stored blocks keep loading either way.
1632
+
1345
1633
  ```ts
1346
1634
  import {
1347
1635
  embed,
@@ -1394,7 +1682,7 @@ editor.run(updateEmbed({ category: 'saws', limit: 12 }))
1394
1682
  - **Settings** (`props`) are typed fields: `string`, `number` (with `min`, `max`, `integer`), `boolean` and `enum` (fixed `options`), each `required` or with a `default`. `embedPropsError(kind, props)` explains what is wrong, for your form.
1395
1683
  - **On the server**, `validate()` removes a block whose kind is not configured or whose props do not fit it (unknown fields, wrong types, a missing required field). Props are always a flat object of plain values.
1396
1684
  - **Markdown**: `[[product-list {"category":"drills","limit":8}]]` on its own line, read back by `fromMarkdown()`.
1397
- - **UI**: `embedKinds(state)` lists the kinds for your menu; `selectedEmbed(state)` gives the selected block for a settings form.
1685
+ - **UI**: `embedKinds(editor)` lists the kinds for your menu; `selectedEmbed(editor)` gives the selected block for a settings form.
1398
1686
 
1399
1687
  ---
1400
1688
 
@@ -1464,7 +1752,7 @@ Remember:
1464
1752
 
1465
1753
  - **Add it on the server too**, or `validate()` removes the new mark as unknown.
1466
1754
  - Commands are factories returning a command, like the built-in ones, so `editor.run(toggleHighlight())` and `editor.can(toggleHighlight())` read the same.
1467
- - An extension with nodes or marks must be passed to `createEditor()`. `editor.enable()` only adds behaviour; for that, split the extension into a schema part and a behaviour part, like `@writeon/advanced` does.
1755
+ - An extension with nodes or marks must be passed to `createEditor()`. `editor.extend()` only adds behaviour; for that, split the extension into a schema part and a behaviour part, like `@writeon/advanced` does.
1468
1756
 
1469
1757
  ---
1470
1758
 
@@ -1537,8 +1825,7 @@ Source: /api/advanced/reference.md
1537
1825
 
1538
1826
  Advanced editing behaviour: task lists, code blocks, image uploads, tables
1539
1827
  and mentions. Load it lazily and turn it on with
1540
- `editor.enable(advanced())`; the node types come from `@mfsv-
1541
- rte/advanced/schema`.
1828
+ `editor.extend(advanced())`; the node types come from `@writeon/advanced/schema`.
1542
1829
 
1543
1830
  ## Classes
1544
1831
 
@@ -2000,7 +2287,7 @@ Source: /api/advanced/variables/default.md
2000
2287
  const default: Extension[];
2001
2288
  ```
2002
2289
 
2003
- The default export, so `editor.enable(() => import('@writeon/advanced'))` works.
2290
+ The default export, so `editor.extend(() => import('@writeon/advanced'))` works.
2004
2291
 
2005
2292
  ---
2006
2293
 
@@ -2062,8 +2349,8 @@ const imageUpload: (options) => Extension;
2062
2349
 
2063
2350
  Upload images that are pasted, dropped or chosen with a file picker
2064
2351
  (`uploadImages(editor, files)`), showing an accessible progress
2065
- placeholder (`[data-rte-upload]`, `role="progressbar"`, CSS variable
2066
- `--rte-upload-progress`) where each will appear. Requires `advancedSchema()`.
2352
+ placeholder (`[data-writeon-upload]`, `role="progressbar"`, CSS variable
2353
+ `--writeon-upload-progress`) where each will appear. Requires `advancedSchema()`.
2067
2354
 
2068
2355
  ## Parameters
2069
2356
 
@@ -2193,7 +2480,7 @@ All advanced behaviour. Pair it with `advancedSchema()` in `createEditor()`.
2193
2480
  createEditor({ extensions: [...basic(), advancedSchema(), ...advanced()], label })
2194
2481
  // or on demand, keeping the document, undo history and selection
2195
2482
  createEditor({ extensions: [...basic(), advancedSchema()], label })
2196
- await editor.enable(() => import('@writeon/advanced'))
2483
+ await editor.extend(() => import('@writeon/advanced'))
2197
2484
  ```
2198
2485
 
2199
2486
  ---
@@ -2477,6 +2764,9 @@ branches. Documents store `{ type: 'embed', attrs: { kind, props } }`; the
2477
2764
  kinds and their props are configured, so the server (`validate()`) drops
2478
2765
  anything else. Small and eager: add `embed()` to the editor from the start.
2479
2766
 
2767
+ Experimental: the API can change in a minor release (see the stability
2768
+ page). Stored embeds keep loading.
2769
+
2480
2770
  ## Interfaces
2481
2771
 
2482
2772
  - [EmbedBooleanProp](interfaces/EmbedBooleanProp.md)
@@ -2513,15 +2803,17 @@ Source: /api/advanced/embed/interfaces/EmbedBooleanProp.md
2513
2803
 
2514
2804
  # Interface: EmbedBooleanProp
2515
2805
 
2806
+ **`Experimental`**
2807
+
2516
2808
  A yes/no field of an embed.
2517
2809
 
2518
2810
  ## Properties
2519
2811
 
2520
2812
  | Property | Type | Description |
2521
2813
  | ------ | ------ | ------ |
2522
- | <a id="property-default"></a> `default?` | `boolean` | Value for a new embed. Default false. |
2523
- | <a id="property-label"></a> `label` | `string` | Shown in the form. |
2524
- | <a id="property-type"></a> `type` | `"boolean"` | A yes/no field. |
2814
+ | <a id="property-default"></a> `default?` | `boolean` | **`Experimental`** Value for a new embed. Default false. |
2815
+ | <a id="property-label"></a> `label` | `string` | **`Experimental`** Shown in the form. |
2816
+ | <a id="property-type"></a> `type` | `"boolean"` | **`Experimental`** A yes/no field. |
2525
2817
 
2526
2818
  ---
2527
2819
 
@@ -2529,17 +2821,19 @@ Source: /api/advanced/embed/interfaces/EmbedEnumProp.md
2529
2821
 
2530
2822
  # Interface: EmbedEnumProp
2531
2823
 
2824
+ **`Experimental`**
2825
+
2532
2826
  A choice from fixed options.
2533
2827
 
2534
2828
  ## Properties
2535
2829
 
2536
2830
  | Property | Type | Description |
2537
2831
  | ------ | ------ | ------ |
2538
- | <a id="property-default"></a> `default?` | `string` | Value for a new embed. |
2539
- | <a id="property-label"></a> `label` | `string` | Shown in the form. |
2540
- | <a id="property-options"></a> `options` | readonly [`EmbedOption`](EmbedOption.md)[] | The choices: the stored value and its label. |
2541
- | <a id="property-required"></a> `required?` | `boolean` | Must be chosen. |
2542
- | <a id="property-type"></a> `type` | `"enum"` | A choice from fixed options. |
2832
+ | <a id="property-default"></a> `default?` | `string` | **`Experimental`** Value for a new embed. |
2833
+ | <a id="property-label"></a> `label` | `string` | **`Experimental`** Shown in the form. |
2834
+ | <a id="property-options"></a> `options` | readonly [`EmbedOption`](EmbedOption.md)[] | **`Experimental`** The choices: the stored value and its label. |
2835
+ | <a id="property-required"></a> `required?` | `boolean` | **`Experimental`** Must be chosen. |
2836
+ | <a id="property-type"></a> `type` | `"enum"` | **`Experimental`** A choice from fixed options. |
2543
2837
 
2544
2838
  ---
2545
2839
 
@@ -2547,16 +2841,18 @@ Source: /api/advanced/embed/interfaces/EmbedKind.md
2547
2841
 
2548
2842
  # Interface: EmbedKind
2549
2843
 
2844
+ **`Experimental`**
2845
+
2550
2846
  A kind of block the user can insert.
2551
2847
 
2552
2848
  ## Properties
2553
2849
 
2554
2850
  | Property | Type | Description |
2555
2851
  | ------ | ------ | ------ |
2556
- | <a id="property-description"></a> `description?` | `string` | A second line in the menu. |
2557
- | <a id="property-id"></a> `id` | `string` | Stored in the document, e.g. `'pickup-branches'`. Letters, digits, `-` and `_`. |
2558
- | <a id="property-label"></a> `label` | `string` | Shown in the menu and in the editor, e.g. `'Olib ketish filiallari'`. |
2559
- | <a id="property-props"></a> `props?` | `Readonly`\<`Record`\<`string`, [`EmbedPropSpec`](../type-aliases/EmbedPropSpec.md)\>\> | Settings the user fills in, by field name (letters, digits, `_`). |
2852
+ | <a id="property-description"></a> `description?` | `string` | **`Experimental`** A second line in the menu. |
2853
+ | <a id="property-id"></a> `id` | `string` | **`Experimental`** Stored in the document, e.g. `'pickup-branches'`. Letters, digits, `-` and `_`. |
2854
+ | <a id="property-label"></a> `label` | `string` | **`Experimental`** Shown in the menu and in the editor, e.g. `'Olib ketish filiallari'`. |
2855
+ | <a id="property-props"></a> `props?` | `Readonly`\<`Record`\<`string`, [`EmbedPropSpec`](../type-aliases/EmbedPropSpec.md)\>\> | **`Experimental`** Settings the user fills in, by field name (letters, digits, `_`). |
2560
2856
 
2561
2857
  ---
2562
2858
 
@@ -2564,19 +2860,21 @@ Source: /api/advanced/embed/interfaces/EmbedNumberProp.md
2564
2860
 
2565
2861
  # Interface: EmbedNumberProp
2566
2862
 
2863
+ **`Experimental`**
2864
+
2567
2865
  A number field of an embed.
2568
2866
 
2569
2867
  ## Properties
2570
2868
 
2571
2869
  | Property | Type | Description |
2572
2870
  | ------ | ------ | ------ |
2573
- | <a id="property-default"></a> `default?` | `number` | Value for a new embed. |
2574
- | <a id="property-integer"></a> `integer?` | `boolean` | Whole numbers only. |
2575
- | <a id="property-label"></a> `label` | `string` | Shown in the form. |
2576
- | <a id="property-max"></a> `max?` | `number` | Largest value. |
2577
- | <a id="property-min"></a> `min?` | `number` | Smallest value. |
2578
- | <a id="property-required"></a> `required?` | `boolean` | Must be filled in. |
2579
- | <a id="property-type"></a> `type` | `"number"` | A number field. |
2871
+ | <a id="property-default"></a> `default?` | `number` | **`Experimental`** Value for a new embed. |
2872
+ | <a id="property-integer"></a> `integer?` | `boolean` | **`Experimental`** Whole numbers only. |
2873
+ | <a id="property-label"></a> `label` | `string` | **`Experimental`** Shown in the form. |
2874
+ | <a id="property-max"></a> `max?` | `number` | **`Experimental`** Largest value. |
2875
+ | <a id="property-min"></a> `min?` | `number` | **`Experimental`** Smallest value. |
2876
+ | <a id="property-required"></a> `required?` | `boolean` | **`Experimental`** Must be filled in. |
2877
+ | <a id="property-type"></a> `type` | `"number"` | **`Experimental`** A number field. |
2580
2878
 
2581
2879
  ---
2582
2880
 
@@ -2584,14 +2882,16 @@ Source: /api/advanced/embed/interfaces/EmbedOption.md
2584
2882
 
2585
2883
  # Interface: EmbedOption
2586
2884
 
2885
+ **`Experimental`**
2886
+
2587
2887
  One choice of an `enum` field.
2588
2888
 
2589
2889
  ## Properties
2590
2890
 
2591
2891
  | Property | Type | Description |
2592
2892
  | ------ | ------ | ------ |
2593
- | <a id="property-label"></a> `label` | `string` | Shown in the form. |
2594
- | <a id="property-value"></a> `value` | `string` | Stored in the document. |
2893
+ | <a id="property-label"></a> `label` | `string` | **`Experimental`** Shown in the form. |
2894
+ | <a id="property-value"></a> `value` | `string` | **`Experimental`** Stored in the document. |
2595
2895
 
2596
2896
  ---
2597
2897
 
@@ -2599,13 +2899,15 @@ Source: /api/advanced/embed/interfaces/EmbedOptions.md
2599
2899
 
2600
2900
  # Interface: EmbedOptions
2601
2901
 
2902
+ **`Experimental`**
2903
+
2602
2904
  Options for `embed()`.
2603
2905
 
2604
2906
  ## Properties
2605
2907
 
2606
2908
  | Property | Type | Description |
2607
2909
  | ------ | ------ | ------ |
2608
- | <a id="property-kinds"></a> `kinds` | readonly [`EmbedKind`](EmbedKind.md)[] | The blocks the user can insert. |
2910
+ | <a id="property-kinds"></a> `kinds` | readonly [`EmbedKind`](EmbedKind.md)[] | **`Experimental`** The blocks the user can insert. |
2609
2911
 
2610
2912
  ---
2611
2913
 
@@ -2613,17 +2915,19 @@ Source: /api/advanced/embed/interfaces/EmbedStringProp.md
2613
2915
 
2614
2916
  # Interface: EmbedStringProp
2615
2917
 
2918
+ **`Experimental`**
2919
+
2616
2920
  A text field of an embed.
2617
2921
 
2618
2922
  ## Properties
2619
2923
 
2620
2924
  | Property | Type | Description |
2621
2925
  | ------ | ------ | ------ |
2622
- | <a id="property-default"></a> `default?` | `string` | Value for a new embed. |
2623
- | <a id="property-label"></a> `label` | `string` | Shown in the form. |
2624
- | <a id="property-maxlength"></a> `maxLength?` | `number` | Longest value. Default 500. |
2625
- | <a id="property-required"></a> `required?` | `boolean` | Must be filled in. |
2626
- | <a id="property-type"></a> `type` | `"string"` | A text field. |
2926
+ | <a id="property-default"></a> `default?` | `string` | **`Experimental`** Value for a new embed. |
2927
+ | <a id="property-label"></a> `label` | `string` | **`Experimental`** Shown in the form. |
2928
+ | <a id="property-maxlength"></a> `maxLength?` | `number` | **`Experimental`** Longest value. Default 500. |
2929
+ | <a id="property-required"></a> `required?` | `boolean` | **`Experimental`** Must be filled in. |
2930
+ | <a id="property-type"></a> `type` | `"string"` | **`Experimental`** A text field. |
2627
2931
 
2628
2932
  ---
2629
2933
 
@@ -2631,15 +2935,17 @@ Source: /api/advanced/embed/interfaces/SelectedEmbed.md
2631
2935
 
2632
2936
  # Interface: SelectedEmbed
2633
2937
 
2938
+ **`Experimental`**
2939
+
2634
2940
  The selected embed, from `selectedEmbed()`.
2635
2941
 
2636
2942
  ## Properties
2637
2943
 
2638
2944
  | Property | Type | Description |
2639
2945
  | ------ | ------ | ------ |
2640
- | <a id="property-kind"></a> `kind` | [`EmbedKind`](EmbedKind.md) | Its kind, as configured. |
2641
- | <a id="property-pos"></a> `pos` | `number` | Its position in the document. |
2642
- | <a id="property-props"></a> `props` | [`EmbedProps`](../type-aliases/EmbedProps.md) | Its settings. |
2946
+ | <a id="property-kind"></a> `kind` | [`EmbedKind`](EmbedKind.md) | **`Experimental`** Its kind, as configured. |
2947
+ | <a id="property-pos"></a> `pos` | `number` | **`Experimental`** Its position in the document. |
2948
+ | <a id="property-props"></a> `props` | [`EmbedProps`](../type-aliases/EmbedProps.md) | **`Experimental`** Its settings. |
2643
2949
 
2644
2950
  ---
2645
2951
 
@@ -2651,6 +2957,8 @@ Source: /api/advanced/embed/type-aliases/EmbedProps.md
2651
2957
  type EmbedProps = Readonly<Record<string, EmbedPropValue>>;
2652
2958
  ```
2653
2959
 
2960
+ **`Experimental`**
2961
+
2654
2962
  An embed's settings, by field name.
2655
2963
 
2656
2964
  ---
@@ -2667,6 +2975,8 @@ type EmbedPropSpec =
2667
2975
  | EmbedEnumProp;
2668
2976
  ```
2669
2977
 
2978
+ **`Experimental`**
2979
+
2670
2980
  One field of an embed's settings.
2671
2981
 
2672
2982
  ---
@@ -2679,6 +2989,8 @@ Source: /api/advanced/embed/type-aliases/EmbedPropValue.md
2679
2989
  type EmbedPropValue = string | number | boolean;
2680
2990
  ```
2681
2991
 
2992
+ **`Experimental`**
2993
+
2682
2994
  A stored prop value.
2683
2995
 
2684
2996
  ---
@@ -2691,6 +3003,8 @@ Source: /api/advanced/embed/variables/embed.md
2691
3003
  const embed: (options) => Extension;
2692
3004
  ```
2693
3005
 
3006
+ **`Experimental`**
3007
+
2694
3008
  Custom blocks your front end renders. Each kind is a block the user
2695
3009
  inserts from a menu (and edits through a form when it has props); the
2696
3010
  editor shows it as `[[Label]]`. HTML: `<div data-embed="kind"
@@ -2734,6 +3048,8 @@ Source: /api/advanced/embed/functions/embedDefaults.md
2734
3048
  function embedDefaults(kind, props?): EmbedProps;
2735
3049
  ```
2736
3050
 
3051
+ **`Experimental`**
3052
+
2737
3053
  The props of a new embed: the defaults, overridden by `props`, empty values dropped.
2738
3054
 
2739
3055
  ## Parameters
@@ -2754,16 +3070,18 @@ Source: /api/advanced/embed/functions/embedKinds.md
2754
3070
  # Function: embedKinds()
2755
3071
 
2756
3072
  ```ts
2757
- function embedKinds(state): readonly EmbedKind[];
3073
+ function embedKinds(editor): readonly EmbedKind[];
2758
3074
  ```
2759
3075
 
3076
+ **`Experimental`**
3077
+
2760
3078
  The kinds configured with `embed()` in this editor's schema, or none.
2761
3079
 
2762
3080
  ## Parameters
2763
3081
 
2764
3082
  | Parameter | Type |
2765
3083
  | ------ | ------ |
2766
- | `state` | `EditorState` |
3084
+ | `editor` | [`Editor`](../../../core/interfaces/Editor.md) |
2767
3085
 
2768
3086
  ## Returns
2769
3087
 
@@ -2779,6 +3097,8 @@ Source: /api/advanced/embed/functions/embedPropsError.md
2779
3097
  function embedPropsError(kind, props): string | null;
2780
3098
  ```
2781
3099
 
3100
+ **`Experimental`**
3101
+
2782
3102
  Why `props` are not valid for `kind`, or null when they are. Missing
2783
3103
  optional fields are fine; unknown fields, wrong types and values out of
2784
3104
  range are not.
@@ -2804,6 +3124,8 @@ Source: /api/advanced/embed/functions/insertEmbed.md
2804
3124
  function insertEmbed(kind, props?): Command;
2805
3125
  ```
2806
3126
 
3127
+ **`Experimental`**
3128
+
2807
3129
  Insert an embed of `kind` with the defaults and `props`: in place of an
2808
3130
  empty paragraph, after the paragraph holding the cursor (text is never
2809
3131
  split) or after a selected node. The cursor ends in the paragraph below.
@@ -2828,16 +3150,18 @@ Source: /api/advanced/embed/functions/selectedEmbed.md
2828
3150
  # Function: selectedEmbed()
2829
3151
 
2830
3152
  ```ts
2831
- function selectedEmbed(state): SelectedEmbed | null;
3153
+ function selectedEmbed(editor): SelectedEmbed | null;
2832
3154
  ```
2833
3155
 
3156
+ **`Experimental`**
3157
+
2834
3158
  The selected embed (its kind, props and position), or null.
2835
3159
 
2836
3160
  ## Parameters
2837
3161
 
2838
3162
  | Parameter | Type |
2839
3163
  | ------ | ------ |
2840
- | `state` | `EditorState` |
3164
+ | `editor` | [`Editor`](../../../core/interfaces/Editor.md) |
2841
3165
 
2842
3166
  ## Returns
2843
3167
 
@@ -2853,6 +3177,8 @@ Source: /api/advanced/embed/functions/updateEmbed.md
2853
3177
  function updateEmbed(props): Command;
2854
3178
  ```
2855
3179
 
3180
+ **`Experimental`**
3181
+
2856
3182
  Replace the props of the selected embed. Fails when they are not valid.
2857
3183
 
2858
3184
  ## Parameters
@@ -2898,11 +3224,11 @@ Small and eager: add them to the editor from the start, like
2898
3224
  ## Functions
2899
3225
 
2900
3226
  - [activeFontFamily](functions/activeFontFamily.md)
3227
+ - [activeTextAlign](functions/activeTextAlign.md)
2901
3228
  - [activeTextColor](functions/activeTextColor.md)
2902
3229
  - [setFontFamily](functions/setFontFamily.md)
2903
3230
  - [setTextAlign](functions/setTextAlign.md)
2904
3231
  - [setTextColor](functions/setTextColor.md)
2905
- - [textAlignmentAt](functions/textAlignmentAt.md)
2906
3232
 
2907
3233
  ---
2908
3234
 
@@ -3097,7 +3423,7 @@ Source: /api/advanced/formatting/functions/activeFontFamily.md
3097
3423
  # Function: activeFontFamily()
3098
3424
 
3099
3425
  ```ts
3100
- function activeFontFamily(state): string | null;
3426
+ function activeFontFamily(editor): string | null;
3101
3427
  ```
3102
3428
 
3103
3429
  The font at the selection: its id, or null for none or a mix.
@@ -3106,7 +3432,7 @@ The font at the selection: its id, or null for none or a mix.
3106
3432
 
3107
3433
  | Parameter | Type |
3108
3434
  | ------ | ------ |
3109
- | `state` | `EditorState` |
3435
+ | `editor` | [`Editor`](../../../core/interfaces/Editor.md) |
3110
3436
 
3111
3437
  ## Returns
3112
3438
 
@@ -3114,12 +3440,35 @@ The font at the selection: its id, or null for none or a mix.
3114
3440
 
3115
3441
  ---
3116
3442
 
3443
+ Source: /api/advanced/formatting/functions/activeTextAlign.md
3444
+
3445
+ # Function: activeTextAlign()
3446
+
3447
+ ```ts
3448
+ function activeTextAlign(editor): TextAlignment | null;
3449
+ ```
3450
+
3451
+ The alignment of the block that holds the selection (`'left'` when unset),
3452
+ or null when that block cannot be aligned.
3453
+
3454
+ ## Parameters
3455
+
3456
+ | Parameter | Type |
3457
+ | ------ | ------ |
3458
+ | `editor` | [`Editor`](../../../core/interfaces/Editor.md) |
3459
+
3460
+ ## Returns
3461
+
3462
+ [`TextAlignment`](../type-aliases/TextAlignment.md) \| `null`
3463
+
3464
+ ---
3465
+
3117
3466
  Source: /api/advanced/formatting/functions/activeTextColor.md
3118
3467
 
3119
3468
  # Function: activeTextColor()
3120
3469
 
3121
3470
  ```ts
3122
- function activeTextColor(state): string | null;
3471
+ function activeTextColor(editor): string | null;
3123
3472
  ```
3124
3473
 
3125
3474
  The colour at the selection: its id, or null for none or a mix.
@@ -3128,7 +3477,7 @@ The colour at the selection: its id, or null for none or a mix.
3128
3477
 
3129
3478
  | Parameter | Type |
3130
3479
  | ------ | ------ |
3131
- | `state` | `EditorState` |
3480
+ | `editor` | [`Editor`](../../../core/interfaces/Editor.md) |
3132
3481
 
3133
3482
  ## Returns
3134
3483
 
@@ -3202,28 +3551,6 @@ Set the colour of the selection (or of what is typed next); `null` removes it.
3202
3551
 
3203
3552
  ---
3204
3553
 
3205
- Source: /api/advanced/formatting/functions/textAlignmentAt.md
3206
-
3207
- # Function: textAlignmentAt()
3208
-
3209
- ```ts
3210
- function textAlignmentAt(state): TextAlignment | null;
3211
- ```
3212
-
3213
- The alignment of the block that holds the selection (`'left'` when unset).
3214
-
3215
- ## Parameters
3216
-
3217
- | Parameter | Type |
3218
- | ------ | ------ |
3219
- | `state` | `EditorState` |
3220
-
3221
- ## Returns
3222
-
3223
- [`TextAlignment`](../type-aliases/TextAlignment.md) \| `null`
3224
-
3225
- ---
3226
-
3227
3554
  Source: /api/advanced/schema/reference.md
3228
3555
 
3229
3556
  # @writeon/advanced/schema
@@ -3288,7 +3615,7 @@ The node types of advanced mode, without their behaviour: task lists,
3288
3615
  code blocks, images, tables and mentions. Add it to `createEditor()` so documents that use these nodes
3289
3616
  load and display everywhere (in basic mode the content stays visible and
3290
3617
  its text editable), then turn on the behaviour with
3291
- `editor.enable(() => import('@writeon/advanced'))`. Small, always loaded.
3618
+ `editor.extend(() => import('@writeon/advanced'))`. Small, always loaded.
3292
3619
 
3293
3620
  Use the same list on the server: `validate(doc, { extensions: [...basic(), advancedSchema()] })`.
3294
3621
 
@@ -3351,8 +3678,9 @@ migrations, URL rules and helpers.
3351
3678
  ## Type Aliases
3352
3679
 
3353
3680
  - [Command](type-aliases/Command.md)
3354
- - [EditorEnableSource](type-aliases/EditorEnableSource.md)
3681
+ - [EditorExtendSource](type-aliases/EditorExtendSource.md)
3355
3682
  - [EditorLabel](type-aliases/EditorLabel.md)
3683
+ - [HeadingLevel](type-aliases/HeadingLevel.md)
3356
3684
 
3357
3685
  ## Variables
3358
3686
 
@@ -3515,10 +3843,10 @@ Release everything. The editor cannot be used afterwards.
3515
3843
 
3516
3844
  ***
3517
3845
 
3518
- ### enable()
3846
+ ### extend()
3519
3847
 
3520
3848
  ```ts
3521
- enable(source): Promise<void>;
3849
+ extend(source): Promise<void>;
3522
3850
  ```
3523
3851
 
3524
3852
  Add behaviour (commands' keymaps, input rules, plugins) from more
@@ -3531,7 +3859,7 @@ must already be in the schema: pass the schema extension (e.g.
3531
3859
 
3532
3860
  | Parameter | Type |
3533
3861
  | ------ | ------ |
3534
- | `source` | [`EditorEnableSource`](../type-aliases/EditorEnableSource.md) |
3862
+ | `source` | [`EditorExtendSource`](../type-aliases/EditorExtendSource.md) |
3535
3863
 
3536
3864
  #### Returns
3537
3865
 
@@ -3540,7 +3868,7 @@ must already be in the schema: pass the schema extension (e.g.
3540
3868
  #### Example
3541
3869
 
3542
3870
  ```ts
3543
- await editor.enable(() => import('@writeon/advanced'))
3871
+ await editor.extend(() => import('@writeon/advanced'))
3544
3872
  ```
3545
3873
 
3546
3874
  ***
@@ -3765,7 +4093,7 @@ Options for `createEditor()`.
3765
4093
  | <a id="property-content"></a> `content?` | [`DocJSON`](DocJSON.md) \| `null` | Initial document. Omit for an empty document. |
3766
4094
  | <a id="property-editable"></a> `editable?` | `boolean` | Whether the user can edit. Defaults to `true`. |
3767
4095
  | <a id="property-element"></a> `element?` | `HTMLElement` | Element to mount into. Omit to create the editor first and call `mount()` later. |
3768
- | <a id="property-extensions"></a> `extensions` | [`Extension`](Extension.md)[] | Extensions that make up the editor, usually a preset such as `basic()`. |
4096
+ | <a id="property-extensions"></a> `extensions` | readonly [`Extension`](Extension.md)[] | Extensions that make up the editor, usually a preset such as `basic()`. |
3769
4097
  | <a id="property-label"></a> `label` | [`EditorLabel`](../type-aliases/EditorLabel.md) | Accessible name: an `aria-label` string or the id of a labelling element. |
3770
4098
  | <a id="property-onblur"></a> `onBlur?` | (`editor`) => `void` | Called when the editable area loses focus, also when it is unmounted while focused. |
3771
4099
  | <a id="property-onchange"></a> `onChange?` | (`editor`) => `void` | Called after every change to the document. |
@@ -3901,12 +4229,12 @@ pass it to `editor.run()` or `editor.can()`.
3901
4229
 
3902
4230
  ---
3903
4231
 
3904
- Source: /api/core/type-aliases/EditorEnableSource.md
4232
+ Source: /api/core/type-aliases/EditorExtendSource.md
3905
4233
 
3906
- # Type Alias: EditorEnableSource
4234
+ # Type Alias: EditorExtendSource
3907
4235
 
3908
4236
  ```ts
3909
- type EditorEnableSource =
4237
+ type EditorExtendSource =
3910
4238
  | readonly Extension[]
3911
4239
  | (() => Promise<
3912
4240
  | readonly Extension[]
@@ -3915,7 +4243,7 @@ type EditorEnableSource =
3915
4243
  }>);
3916
4244
  ```
3917
4245
 
3918
- Extensions to enable, or a loader for them (a module whose default export is the list works too).
4246
+ Extensions to add, or a loader for them (a module whose default export is the list works too).
3919
4247
 
3920
4248
  ---
3921
4249
 
@@ -3957,6 +4285,18 @@ Id of the element that labels the editor (`aria-labelledby`).
3957
4285
 
3958
4286
  ---
3959
4287
 
4288
+ Source: /api/core/type-aliases/HeadingLevel.md
4289
+
4290
+ # Type Alias: HeadingLevel
4291
+
4292
+ ```ts
4293
+ type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
4294
+ ```
4295
+
4296
+ A heading level, `1` (`<h1>`) to `6` (`<h6>`).
4297
+
4298
+ ---
4299
+
3960
4300
  Source: /api/core/variables/DEFAULT_PROTOCOLS.md
3961
4301
 
3962
4302
  # Variable: DEFAULT\_PROTOCOLS
@@ -4145,6 +4485,12 @@ lists, links, history.
4145
4485
  - [undo](functions/undo.md)
4146
4486
  - [unsetLink](functions/unsetLink.md)
4147
4487
 
4488
+ ## References
4489
+
4490
+ ### HeadingLevel
4491
+
4492
+ Re-exports [HeadingLevel](../type-aliases/HeadingLevel.md)
4493
+
4148
4494
  ---
4149
4495
 
4150
4496
  Source: /api/core/commands/interfaces/LinkAttrs.md
@@ -4352,7 +4698,7 @@ Turn the selected blocks into headings of `level`. Requires the `heading` extens
4352
4698
 
4353
4699
  | Parameter | Type |
4354
4700
  | ------ | ------ |
4355
- | `level` | `number` |
4701
+ | `level` | [`HeadingLevel`](../../type-aliases/HeadingLevel.md) |
4356
4702
 
4357
4703
  ## Returns
4358
4704
 
@@ -4447,7 +4793,7 @@ Heading of `level` if the block is not one already, otherwise back to a paragrap
4447
4793
 
4448
4794
  | Parameter | Type |
4449
4795
  | ------ | ------ |
4450
- | `level` | `number` |
4796
+ | `level` | [`HeadingLevel`](../../type-aliases/HeadingLevel.md) |
4451
4797
 
4452
4798
  ## Returns
4453
4799
 
@@ -4744,7 +5090,7 @@ Options for the `heading` extension.
4744
5090
 
4745
5091
  | Property | Type | Description |
4746
5092
  | ------ | ------ | ------ |
4747
- | <a id="property-levels"></a> `levels?` | readonly `number`[] | Heading levels the user can create. Default `[1, 2, 3]`. |
5093
+ | <a id="property-levels"></a> `levels?` | readonly [`HeadingLevel`](../../type-aliases/HeadingLevel.md)[] | Heading levels the user can create. Default `[1, 2, 3]`. |
4748
5094
 
4749
5095
  ---
4750
5096
 
@@ -5046,6 +5392,457 @@ basic({ link: { protocols: ['https'] } }) // https links only
5046
5392
 
5047
5393
  ---
5048
5394
 
5395
+ Source: /api/element/reference.md
5396
+
5397
+ # @writeon/element
5398
+
5399
+ `<writeon-editor>`: Writeon as a web component and form field, for plain
5400
+ HTML, server-rendered pages (Laravel Blade, Symfony Twig, Django…) and any
5401
+ framework. Importing this module registers the element.
5402
+
5403
+ ## Example
5404
+
5405
+ ```html
5406
+ <link rel="stylesheet" href="…/@writeon/element/dist/style.css" />
5407
+ <script type="module">import '@writeon/element'</script>
5408
+
5409
+ <writeon-editor label="Article text">
5410
+ <textarea name="body">{{ $post->body }}</textarea>
5411
+ </writeon-editor>
5412
+ ```
5413
+
5414
+ ## Classes
5415
+
5416
+ - [WriteonEditor](classes/WriteonEditor.md)
5417
+
5418
+ ## Type Aliases
5419
+
5420
+ - [WriteonFormat](type-aliases/WriteonFormat.md)
5421
+
5422
+ ## Functions
5423
+
5424
+ - [defineWriteonEditor](functions/defineWriteonEditor.md)
5425
+
5426
+ ---
5427
+
5428
+ Source: /api/element/classes/WriteonEditor.md
5429
+
5430
+ # Class: WriteonEditor
5431
+
5432
+ `<writeon-editor>`: the editor with the default kit, as a form field.
5433
+
5434
+ Put a `<textarea>` inside: it is the field until the element starts (and
5435
+ for good if JavaScript does not load), and it gives the name, the initial
5436
+ value and `required`. Its text is never run as HTML while the page loads.
5437
+
5438
+ ```html
5439
+ <writeon-editor label="Article text">
5440
+ <textarea name="body">&lt;p&gt;Hello&lt;/p&gt;</textarea>
5441
+ </writeon-editor>
5442
+ ```
5443
+
5444
+ The submitted value is HTML (or JSON with `format="json"`). Until the
5445
+ user changes the text, the form submits the original value unchanged.
5446
+ Always validate or sanitize it on the server.
5447
+
5448
+ ## Extends
5449
+
5450
+ - `Base`
5451
+
5452
+ ## Constructors
5453
+
5454
+ ### Constructor
5455
+
5456
+ ```ts
5457
+ new WriteonEditor(): WriteonEditor;
5458
+ ```
5459
+
5460
+ #### Returns
5461
+
5462
+ `WriteonEditor`
5463
+
5464
+ #### Inherited from
5465
+
5466
+ `Base.constructor`
5467
+
5468
+ ## Properties
5469
+
5470
+ ### formAssociated
5471
+
5472
+ ```ts
5473
+ static formAssociated: boolean = true;
5474
+ ```
5475
+
5476
+ Takes part in forms like a built-in field (ElementInternals).
5477
+
5478
+ ***
5479
+
5480
+ ### observedAttributes
5481
+
5482
+ ```ts
5483
+ static observedAttributes: string[];
5484
+ ```
5485
+
5486
+ Attributes that update a running editor.
5487
+
5488
+ ***
5489
+
5490
+ ### upload
5491
+
5492
+ ```ts
5493
+ upload: UploadFn | undefined;
5494
+ ```
5495
+
5496
+ Upload function for images when `advanced` is on. `upload-url` sets a simple one.
5497
+
5498
+ ## Accessors
5499
+
5500
+ ### disabled
5501
+
5502
+ #### Get Signature
5503
+
5504
+ ```ts
5505
+ get disabled(): boolean;
5506
+ ```
5507
+
5508
+ Read-only and left out of the form, like `disabled` on a textarea. Reflects the attribute.
5509
+
5510
+ ##### Returns
5511
+
5512
+ `boolean`
5513
+
5514
+ #### Set Signature
5515
+
5516
+ ```ts
5517
+ set disabled(value): void;
5518
+ ```
5519
+
5520
+ Sets or removes the `disabled` attribute.
5521
+
5522
+ ##### Parameters
5523
+
5524
+ | Parameter | Type |
5525
+ | ------ | ------ |
5526
+ | `value` | `boolean` |
5527
+
5528
+ ##### Returns
5529
+
5530
+ `void`
5531
+
5532
+ ***
5533
+
5534
+ ### editor
5535
+
5536
+ #### Get Signature
5537
+
5538
+ ```ts
5539
+ get editor(): Editor | null;
5540
+ ```
5541
+
5542
+ The editor, once the element is connected. Use it for commands and state.
5543
+
5544
+ ##### Returns
5545
+
5546
+ [`Editor`](../../core/interfaces/Editor.md) \| `null`
5547
+
5548
+ ***
5549
+
5550
+ ### form
5551
+
5552
+ #### Get Signature
5553
+
5554
+ ```ts
5555
+ get form(): HTMLFormElement | null;
5556
+ ```
5557
+
5558
+ The form the element belongs to.
5559
+
5560
+ ##### Returns
5561
+
5562
+ `HTMLFormElement` \| `null`
5563
+
5564
+ ***
5565
+
5566
+ ### format
5567
+
5568
+ #### Get Signature
5569
+
5570
+ ```ts
5571
+ get format(): WriteonFormat;
5572
+ ```
5573
+
5574
+ `html` (default) or `json`: what `value` and the form use.
5575
+
5576
+ ##### Returns
5577
+
5578
+ [`WriteonFormat`](../type-aliases/WriteonFormat.md)
5579
+
5580
+ ***
5581
+
5582
+ ### labels
5583
+
5584
+ #### Get Signature
5585
+
5586
+ ```ts
5587
+ get labels(): NodeList;
5588
+ ```
5589
+
5590
+ The `<label>` elements of the field, as on a built-in field.
5591
+
5592
+ ##### Returns
5593
+
5594
+ `NodeList`
5595
+
5596
+ ***
5597
+
5598
+ ### name
5599
+
5600
+ #### Get Signature
5601
+
5602
+ ```ts
5603
+ get name(): string | null;
5604
+ ```
5605
+
5606
+ The form field name, from `name` or the textarea's.
5607
+
5608
+ ##### Returns
5609
+
5610
+ `string` \| `null`
5611
+
5612
+ ***
5613
+
5614
+ ### readOnly
5615
+
5616
+ #### Get Signature
5617
+
5618
+ ```ts
5619
+ get readOnly(): boolean;
5620
+ ```
5621
+
5622
+ Not editable, but still sent with the form. Reflects the `readonly` attribute.
5623
+
5624
+ ##### Returns
5625
+
5626
+ `boolean`
5627
+
5628
+ #### Set Signature
5629
+
5630
+ ```ts
5631
+ set readOnly(value): void;
5632
+ ```
5633
+
5634
+ Sets or removes the `readonly` attribute.
5635
+
5636
+ ##### Parameters
5637
+
5638
+ | Parameter | Type |
5639
+ | ------ | ------ |
5640
+ | `value` | `boolean` |
5641
+
5642
+ ##### Returns
5643
+
5644
+ `void`
5645
+
5646
+ ***
5647
+
5648
+ ### required
5649
+
5650
+ #### Get Signature
5651
+
5652
+ ```ts
5653
+ get required(): boolean;
5654
+ ```
5655
+
5656
+ An empty editor blocks the submit. Reflects the attribute.
5657
+
5658
+ ##### Returns
5659
+
5660
+ `boolean`
5661
+
5662
+ #### Set Signature
5663
+
5664
+ ```ts
5665
+ set required(value): void;
5666
+ ```
5667
+
5668
+ Sets or removes the `required` attribute.
5669
+
5670
+ ##### Parameters
5671
+
5672
+ | Parameter | Type |
5673
+ | ------ | ------ |
5674
+ | `value` | `boolean` |
5675
+
5676
+ ##### Returns
5677
+
5678
+ `void`
5679
+
5680
+ ***
5681
+
5682
+ ### validationMessage
5683
+
5684
+ #### Get Signature
5685
+
5686
+ ```ts
5687
+ get validationMessage(): string;
5688
+ ```
5689
+
5690
+ The message shown when the field is invalid.
5691
+
5692
+ ##### Returns
5693
+
5694
+ `string`
5695
+
5696
+ ***
5697
+
5698
+ ### validity
5699
+
5700
+ #### Get Signature
5701
+
5702
+ ```ts
5703
+ get validity(): ValidityState | undefined;
5704
+ ```
5705
+
5706
+ Validity, as on a built-in field (`valueMissing` for an empty `required` editor).
5707
+
5708
+ ##### Returns
5709
+
5710
+ `ValidityState` \| `undefined`
5711
+
5712
+ ***
5713
+
5714
+ ### value
5715
+
5716
+ #### Get Signature
5717
+
5718
+ ```ts
5719
+ get value(): string;
5720
+ ```
5721
+
5722
+ The current value: HTML, or JSON text with `format="json"`.
5723
+
5724
+ ##### Returns
5725
+
5726
+ `string`
5727
+
5728
+ #### Set Signature
5729
+
5730
+ ```ts
5731
+ set value(value): void;
5732
+ ```
5733
+
5734
+ Replace the content; a `json` element takes JSON text.
5735
+
5736
+ ##### Parameters
5737
+
5738
+ | Parameter | Type |
5739
+ | ------ | ------ |
5740
+ | `value` | `string` |
5741
+
5742
+ ##### Returns
5743
+
5744
+ `void`
5745
+
5746
+ ***
5747
+
5748
+ ### willValidate
5749
+
5750
+ #### Get Signature
5751
+
5752
+ ```ts
5753
+ get willValidate(): boolean;
5754
+ ```
5755
+
5756
+ Whether the field takes part in form validation.
5757
+
5758
+ ##### Returns
5759
+
5760
+ `boolean`
5761
+
5762
+ ## Methods
5763
+
5764
+ ### checkValidity()
5765
+
5766
+ ```ts
5767
+ checkValidity(): boolean;
5768
+ ```
5769
+
5770
+ Whether the field is valid; fires `invalid` when not.
5771
+
5772
+ #### Returns
5773
+
5774
+ `boolean`
5775
+
5776
+ ***
5777
+
5778
+ ### focus()
5779
+
5780
+ ```ts
5781
+ focus(): void;
5782
+ ```
5783
+
5784
+ Focus the editable area.
5785
+
5786
+ #### Returns
5787
+
5788
+ `void`
5789
+
5790
+ #### Overrides
5791
+
5792
+ `Base.focus`
5793
+
5794
+ ***
5795
+
5796
+ ### reportValidity()
5797
+
5798
+ ```ts
5799
+ reportValidity(): boolean;
5800
+ ```
5801
+
5802
+ Like `checkValidity()`, and shows the message to the user.
5803
+
5804
+ #### Returns
5805
+
5806
+ `boolean`
5807
+
5808
+ ---
5809
+
5810
+ Source: /api/element/type-aliases/WriteonFormat.md
5811
+
5812
+ # Type Alias: WriteonFormat
5813
+
5814
+ ```ts
5815
+ type WriteonFormat = "html" | "json";
5816
+ ```
5817
+
5818
+ What the form submits: `html` (default) or the document as `json`.
5819
+
5820
+ ---
5821
+
5822
+ Source: /api/element/functions/defineWriteonEditor.md
5823
+
5824
+ # Function: defineWriteonEditor()
5825
+
5826
+ ```ts
5827
+ function defineWriteonEditor(name?): void;
5828
+ ```
5829
+
5830
+ Register the element under `name` (default `writeon-editor`). Called on
5831
+ import; call it again for another tag name. Does nothing without a DOM or
5832
+ when the name is taken.
5833
+
5834
+ ## Parameters
5835
+
5836
+ | Parameter | Type | Default value |
5837
+ | ------ | ------ | ------ |
5838
+ | `name?` | `string` | `'writeon-editor'` |
5839
+
5840
+ ## Returns
5841
+
5842
+ `void`
5843
+
5844
+ ---
5845
+
5049
5846
  Source: /api/html/reference.md
5050
5847
 
5051
5848
  # @writeon/html
@@ -5096,7 +5893,7 @@ Options for `toHTML()`.
5096
5893
  | Property | Type | Description |
5097
5894
  | ------ | ------ | ------ |
5098
5895
  | <a id="property-extensions"></a> `extensions` | readonly [`Extension`](../../core/interfaces/Extension.md)[] | The same extensions the editor uses. |
5099
- | <a id="property-urls"></a> `urls?` | \{ `protocols?`: readonly `string`[]; \} | Allowed protocols for `href`/`src`. Default: http, https, mailto, tel. |
5896
+ | <a id="property-urls"></a> `urls?` | \{ `protocols?`: readonly `string`[]; \} | Allowed protocols for `href`/`src`. Default: those of the `link()` extension in `extensions` (`link({ protocols })`), or http, https, mailto and tel. |
5100
5897
  | `urls.protocols?` | readonly `string`[] | Allowed URL protocols, without the colon. |
5101
5898
 
5102
5899
  ---
@@ -5303,8 +6100,8 @@ Options for `mountToolbar()`.
5303
6100
  | Property | Type | Description |
5304
6101
  | ------ | ------ | ------ |
5305
6102
  | <a id="property-blocktypes"></a> `blockTypes?` | `boolean` | Show the "Text style" menu (paragraph, headings). Default true. |
5306
- | <a id="property-exclude"></a> `exclude?` | readonly `string`[] | Buttons to leave out, by id (e.g. `['underline', 'code']`). |
5307
- | <a id="property-headinglevels"></a> `headingLevels?` | readonly `number`[] | Heading levels in that menu. Match `basic({ heading: { levels } })`. Default [1, 2, 3]. |
6103
+ | <a id="property-exclude"></a> `exclude?` | readonly [`BasicToolbarItemId`](../../ui/type-aliases/BasicToolbarItemId.md)[] | Buttons to leave out, by id (e.g. `['underline', 'code']`). |
6104
+ | <a id="property-headinglevels"></a> `headingLevels?` | readonly [`HeadingLevel`](../../core/type-aliases/HeadingLevel.md)[] | Heading levels in that menu. Match `basic({ heading: { levels } })`. Default [1, 2, 3]. |
5308
6105
  | <a id="property-idprefix"></a> `idPrefix?` | `string` | Prefix for element ids, needed when several editors share a page. Default: generated. |
5309
6106
  | <a id="property-link"></a> `link?` | `boolean` | Show the link button and form. Default true. Set `false` for the `Mod-k` shortcut too. |
5310
6107
  | <a id="property-messages"></a> `messages?` | `Partial`\<[`Messages`](../../ui/interfaces/Messages.md)\> | UI texts, e.g. `uz` from `@writeon/ui/locales/uz`. Default English. |
@@ -5505,7 +6302,7 @@ function mountAdvanced(
5505
6302
  Mount the default kit's advanced UI: image dialog and uploads, table
5506
6303
  actions, task list and code block buttons in the kit toolbar, the `/`
5507
6304
  command menu, `@` mentions and the selection bubble. Also turns on the
5508
- advanced behaviour (`editor.enable()`), keeping the document and undo
6305
+ advanced behaviour (`editor.extend()`), keeping the document and undo
5509
6306
  history. The editor must have `advancedSchema()`. Load this module on
5510
6307
  demand, so none of it is in your main bundle.
5511
6308
 
@@ -5525,7 +6322,7 @@ demand, so none of it is in your main bundle.
5525
6322
 
5526
6323
  ```ts
5527
6324
  const { mountAdvanced } = await import('@writeon/kit/advanced')
5528
- mountAdvanced(document.querySelector('.rte-root'), editor, {
6325
+ mountAdvanced(document.querySelector('.writeon-root'), editor, {
5529
6326
  messages: uz,
5530
6327
  upload: fetchUploader({ url: '/api/upload' }),
5531
6328
  mentions: (query) => searchPeople(query),
@@ -5596,8 +6393,8 @@ Props of `<Toolbar>`: the editor plus `KitToolbarOptions`.
5596
6393
  | ------ | ------ | ------ | ------ |
5597
6394
  | <a id="property-blocktypes"></a> `blockTypes?` | `boolean` | Show the "Text style" menu (paragraph, headings). Default true. | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`blockTypes`](../../interfaces/KitToolbarOptions.md#property-blocktypes) |
5598
6395
  | <a id="property-editor"></a> `editor` | [`Editor`](../../../core/interfaces/Editor.md) | The editor to control. A different editor remounts the toolbar. | - |
5599
- | <a id="property-exclude"></a> `exclude?` | readonly `string`[] | Buttons to leave out, by id (e.g. `['underline', 'code']`). | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`exclude`](../../interfaces/KitToolbarOptions.md#property-exclude) |
5600
- | <a id="property-headinglevels"></a> `headingLevels?` | readonly `number`[] | Heading levels in that menu. Match `basic({ heading: { levels } })`. Default [1, 2, 3]. | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`headingLevels`](../../interfaces/KitToolbarOptions.md#property-headinglevels) |
6396
+ | <a id="property-exclude"></a> `exclude?` | readonly [`BasicToolbarItemId`](../../../ui/type-aliases/BasicToolbarItemId.md)[] | Buttons to leave out, by id (e.g. `['underline', 'code']`). | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`exclude`](../../interfaces/KitToolbarOptions.md#property-exclude) |
6397
+ | <a id="property-headinglevels"></a> `headingLevels?` | readonly [`HeadingLevel`](../../../core/type-aliases/HeadingLevel.md)[] | Heading levels in that menu. Match `basic({ heading: { levels } })`. Default [1, 2, 3]. | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`headingLevels`](../../interfaces/KitToolbarOptions.md#property-headinglevels) |
5601
6398
  | <a id="property-idprefix"></a> `idPrefix?` | `string` | Prefix for element ids, needed when several editors share a page. Default: generated. | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`idPrefix`](../../interfaces/KitToolbarOptions.md#property-idprefix) |
5602
6399
  | <a id="property-link"></a> `link?` | `boolean` | Show the link button and form. Default true. Set `false` for the `Mod-k` shortcut too. | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`link`](../../interfaces/KitToolbarOptions.md#property-link) |
5603
6400
  | <a id="property-messages"></a> `messages?` | `Partial`\<[`Messages`](../../../ui/interfaces/Messages.md)\> | UI texts, e.g. `uz` from `@writeon/ui/locales/uz`. Default English. | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`messages`](../../interfaces/KitToolbarOptions.md#property-messages) |
@@ -5615,7 +6412,7 @@ function Advanced(__namedParameters): ReactElement;
5615
6412
 
5616
6413
  The default kit's advanced UI for React: image dialog and uploads, table
5617
6414
  actions, the `/` menu, `@` mentions and the selection bubble. Its code is
5618
- loaded on demand, after mount. Put it inside `.rte-root`, next to
6415
+ loaded on demand, after mount. Put it inside `.writeon-root`, next to
5619
6416
  `<Toolbar />`. Options are read once, on mount.
5620
6417
 
5621
6418
  ## Parameters
@@ -5631,9 +6428,9 @@ loaded on demand, after mount. Put it inside `.rte-root`, next to
5631
6428
  ## Example
5632
6429
 
5633
6430
  ```tsx
5634
- <div className="rte-root">
6431
+ <div className="writeon-root">
5635
6432
  <Toolbar editor={editor} messages={uz} />
5636
- <EditorContent editor={editor} className="rte-content" />
6433
+ <EditorContent editor={editor} className="writeon-content" />
5637
6434
  <Advanced editor={editor} messages={uz} upload={fetchUploader({ url: '/api/upload' })} />
5638
6435
  </div>
5639
6436
  ```
@@ -5666,9 +6463,9 @@ The default kit toolbar for React. Options are read once, on mount.
5666
6463
  import '@writeon/kit/style.css'
5667
6464
  import { Toolbar } from '@writeon/kit/react'
5668
6465
 
5669
- <div className="rte-root">
6466
+ <div className="writeon-root">
5670
6467
  <Toolbar editor={editor} messages={uz} />
5671
- <EditorContent editor={editor} className="rte-content" />
6468
+ <EditorContent editor={editor} className="writeon-content" />
5672
6469
  </div>
5673
6470
  ```
5674
6471
 
@@ -5736,8 +6533,8 @@ Props of `<Toolbar>`: the editor plus `KitToolbarOptions`.
5736
6533
  | ------ | ------ | ------ | ------ |
5737
6534
  | <a id="property-blocktypes"></a> `blockTypes?` | `boolean` | Show the "Text style" menu (paragraph, headings). Default true. | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`blockTypes`](../../interfaces/KitToolbarOptions.md#property-blocktypes) |
5738
6535
  | <a id="property-editor"></a> `editor` | [`Editor`](../../../core/interfaces/Editor.md) | The editor to control. Read once, on mount. | - |
5739
- | <a id="property-exclude"></a> `exclude?` | readonly `string`[] | Buttons to leave out, by id (e.g. `['underline', 'code']`). | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`exclude`](../../interfaces/KitToolbarOptions.md#property-exclude) |
5740
- | <a id="property-headinglevels"></a> `headingLevels?` | readonly `number`[] | Heading levels in that menu. Match `basic({ heading: { levels } })`. Default [1, 2, 3]. | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`headingLevels`](../../interfaces/KitToolbarOptions.md#property-headinglevels) |
6536
+ | <a id="property-exclude"></a> `exclude?` | readonly [`BasicToolbarItemId`](../../../ui/type-aliases/BasicToolbarItemId.md)[] | Buttons to leave out, by id (e.g. `['underline', 'code']`). | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`exclude`](../../interfaces/KitToolbarOptions.md#property-exclude) |
6537
+ | <a id="property-headinglevels"></a> `headingLevels?` | readonly [`HeadingLevel`](../../../core/type-aliases/HeadingLevel.md)[] | Heading levels in that menu. Match `basic({ heading: { levels } })`. Default [1, 2, 3]. | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`headingLevels`](../../interfaces/KitToolbarOptions.md#property-headinglevels) |
5741
6538
  | <a id="property-idprefix"></a> `idPrefix?` | `string` | Prefix for element ids, needed when several editors share a page. Default: generated. | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`idPrefix`](../../interfaces/KitToolbarOptions.md#property-idprefix) |
5742
6539
  | <a id="property-link"></a> `link?` | `boolean` | Show the link button and form. Default true. Set `false` for the `Mod-k` shortcut too. | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`link`](../../interfaces/KitToolbarOptions.md#property-link) |
5743
6540
  | <a id="property-messages"></a> `messages?` | `Partial`\<[`Messages`](../../../ui/interfaces/Messages.md)\> | UI texts, e.g. `uz` from `@writeon/ui/locales/uz`. Default English. | [`KitToolbarOptions`](../../interfaces/KitToolbarOptions.md).[`messages`](../../interfaces/KitToolbarOptions.md#property-messages) |
@@ -5755,15 +6552,15 @@ const Advanced: DefineSetupFnComponent<AdvancedProps>;
5755
6552
 
5756
6553
  The default kit's advanced UI for Vue: image dialog and uploads, table
5757
6554
  actions, the `/` menu, `@` mentions and the selection bubble. Its code is
5758
- loaded on demand, after mount. Put it inside `.rte-root`, next to
6555
+ loaded on demand, after mount. Put it inside `.writeon-root`, next to
5759
6556
  `<Toolbar />`. Options are read once, on mount.
5760
6557
 
5761
6558
  ## Example
5762
6559
 
5763
6560
  ```vue
5764
- <div class="rte-root">
6561
+ <div class="writeon-root">
5765
6562
  <Toolbar :editor="editor" :messages="uz" />
5766
- <EditorContent :editor="editor" class="rte-content" />
6563
+ <EditorContent :editor="editor" class="writeon-content" />
5767
6564
  <Advanced :editor="editor" :messages="uz" :upload="upload" />
5768
6565
  </div>
5769
6566
  ```
@@ -5783,9 +6580,9 @@ The default kit toolbar for Vue. Options are read once, on mount.
5783
6580
  ## Example
5784
6581
 
5785
6582
  ```vue
5786
- <div class="rte-root">
6583
+ <div class="writeon-root">
5787
6584
  <Toolbar :editor="editor" :messages="uz" />
5788
- <EditorContent :editor="editor" class="rte-content" />
6585
+ <EditorContent :editor="editor" class="writeon-content" />
5789
6586
  </div>
5790
6587
  ```
5791
6588
 
@@ -6834,14 +7631,20 @@ Source: /api/react/interfaces/UseToolbarResult.md
6834
7631
 
6835
7632
  # Interface: UseToolbarResult
6836
7633
 
6837
- Returned by `useToolbar()`.
7634
+ Returned by `useToolbar()`: the controller state as fields, plus the items and prop getters.
7635
+
7636
+ ## Extends
7637
+
7638
+ - [`ToolbarState`](../../ui/interfaces/ToolbarState.md)
6838
7639
 
6839
7640
  ## Properties
6840
7641
 
6841
- | Property | Modifier | Type | Description |
6842
- | ------ | ------ | ------ | ------ |
6843
- | <a id="property-items"></a> `items` | `readonly` | readonly [`ToolbarItem`](../../ui/interfaces/ToolbarItem.md)[] | The items passed in `options`. |
6844
- | <a id="property-state"></a> `state` | `readonly` | [`ToolbarState`](../../ui/interfaces/ToolbarState.md) | The toolbar state; the component re-renders when it changes. |
7642
+ | Property | Modifier | Type | Description | Inherited from |
7643
+ | ------ | ------ | ------ | ------ | ------ |
7644
+ | <a id="property-active"></a> `active` | `readonly` | `Readonly`\<`Record`\<`string`, `boolean`\>\> | Whether each toggle item (by id) is on. Only items with `isActive` have an entry. | [`ToolbarState`](../../ui/interfaces/ToolbarState.md).[`active`](../../ui/interfaces/ToolbarState.md#property-active) |
7645
+ | <a id="property-enabled"></a> `enabled` | `readonly` | `Readonly`\<`Record`\<`string`, `boolean`\>\> | Whether each item's command (by id) can run now (`editor.can()`). | [`ToolbarState`](../../ui/interfaces/ToolbarState.md).[`enabled`](../../ui/interfaces/ToolbarState.md#property-enabled) |
7646
+ | <a id="property-focusid"></a> `focusId` | `readonly` | `string` \| `null` | The item that holds the toolbar's single Tab stop. | [`ToolbarState`](../../ui/interfaces/ToolbarState.md).[`focusId`](../../ui/interfaces/ToolbarState.md#property-focusid) |
7647
+ | <a id="property-items"></a> `items` | `readonly` | readonly [`ToolbarItem`](../../ui/interfaces/ToolbarItem.md)[] | The items passed in `options`. | - |
6845
7648
 
6846
7649
  ## Methods
6847
7650
 
@@ -7424,7 +8227,7 @@ Options for `validate()`.
7424
8227
  | <a id="property-extensions"></a> `extensions` | readonly [`Extension`](../../core/interfaces/Extension.md)[] | The same extensions the editor uses. Pass one shared array; its schema is cached. |
7425
8228
  | <a id="property-limits"></a> `limits?` | [`ValidateLimits`](ValidateLimits.md) | Size limits. Defaults are listed on `ValidateLimits`. |
7426
8229
  | <a id="property-mode"></a> `mode?` | `"strip"` \| `"strict"` | `'strip'` (default) removes what is invalid and reports it in `removed`. `'strict'` rejects the whole document if anything would be removed. Limit violations are always rejected. |
7427
- | <a id="property-urls"></a> `urls?` | \{ `protocols?`: readonly `string`[]; \} | Allowed protocols for every `href`/`src` attribute. Default: http, https, mailto, tel. |
8230
+ | <a id="property-urls"></a> `urls?` | \{ `protocols?`: readonly `string`[]; \} | Allowed protocols for every `href`/`src` attribute. Default: those of the `link()` extension in `extensions` (`link({ protocols })`), or http, https, mailto and tel. |
7428
8231
  | `urls.protocols?` | readonly `string`[] | Allowed URL protocols, without the colon. |
7429
8232
 
7430
8233
  ---
@@ -7682,7 +8485,7 @@ menu and suggestions. Renders nothing.
7682
8485
  - [createTooltip](functions/createTooltip.md)
7683
8486
  - [displayShortcut](functions/displayShortcut.md)
7684
8487
  - [filterSuggestions](functions/filterSuggestions.md)
7685
- - [format](functions/format.md)
8488
+ - [formatMessage](functions/formatMessage.md)
7686
8489
  - [isApplePlatform](functions/isApplePlatform.md)
7687
8490
  - [matchesShortcut](functions/matchesShortcut.md)
7688
8491
  - [mergeElementProps](functions/mergeElementProps.md)
@@ -7700,7 +8503,7 @@ Options for `basicBlockTypeItems()`.
7700
8503
 
7701
8504
  | Property | Type | Description |
7702
8505
  | ------ | ------ | ------ |
7703
- | <a id="property-levels"></a> `levels?` | readonly `number`[] | Heading levels to offer. Default `[1, 2, 3]`; match `basic({ heading: { levels } })`. |
8506
+ | <a id="property-levels"></a> `levels?` | readonly [`HeadingLevel`](../../core/type-aliases/HeadingLevel.md)[] | Heading levels to offer. Default `[1, 2, 3]`; match `basic({ heading: { levels } })`. |
7704
8507
  | <a id="property-messages"></a> `messages?` | `Partial`\<[`Messages`](Messages.md)\> | Labels to override; English by default. |
7705
8508
 
7706
8509
  ---
@@ -9067,6 +9870,10 @@ Source: /api/ui/interfaces/ToolbarState.md
9067
9870
 
9068
9871
  Snapshot of a toolbar.
9069
9872
 
9873
+ ## Extended by
9874
+
9875
+ - [`UseToolbarResult`](../../react/interfaces/UseToolbarResult.md)
9876
+
9070
9877
  ## Properties
9071
9878
 
9072
9879
  | Property | Modifier | Type | Description |
@@ -9720,15 +10527,15 @@ containing) it, case-insensitive. Use it in `items` for static lists.
9720
10527
 
9721
10528
  ---
9722
10529
 
9723
- Source: /api/ui/functions/format.md
10530
+ Source: /api/ui/functions/formatMessage.md
9724
10531
 
9725
- # Function: format()
10532
+ # Function: formatMessage()
9726
10533
 
9727
10534
  ```ts
9728
- function format(message, values): string;
10535
+ function formatMessage(message, values): string;
9729
10536
  ```
9730
10537
 
9731
- Fill `{name}` placeholders in a message.
10538
+ Fill `{name}` placeholders in a message, e.g. `formatMessage(m.heading, { level: 2 })`.
9732
10539
 
9733
10540
  ## Parameters
9734
10541
 
@@ -9838,6 +10645,22 @@ English with any given overrides.
9838
10645
 
9839
10646
  ---
9840
10647
 
10648
+ Source: /api/ui/locales/en/reference.md
10649
+
10650
+ # @writeon/ui/locales/en
10651
+
10652
+ English messages for the UI controllers and the kit: the default. The same
10653
+ object as `en` from `@writeon/ui`; this entry exists so locales can be
10654
+ loaded by code, e.g. `import(\`@writeon/ui/locales/${lang}\`)`.
10655
+
10656
+ ## References
10657
+
10658
+ ### default
10659
+
10660
+ Renames and re-exports [en](../../variables/en.md)
10661
+
10662
+ ---
10663
+
9841
10664
  Source: /api/ui/locales/ru/reference.md
9842
10665
 
9843
10666
  # @writeon/ui/locales/ru
@@ -10017,7 +10840,7 @@ Options for `useEditor()`. `element` is handled by `<EditorContent>`; `editable`
10017
10840
  | ------ | ------ | ------ | ------ |
10018
10841
  | <a id="property-content"></a> `content?` | [`DocJSON`](../../core/interfaces/DocJSON.md) \| `null` | Initial document. Omit for an empty document. | [`EditorOptions`](../../core/interfaces/EditorOptions.md).[`content`](../../core/interfaces/EditorOptions.md#property-content) |
10019
10842
  | <a id="property-editable"></a> `editable?` | `MaybeRefOrGetter`\<`boolean`\> | Whether the user can edit. A ref or getter is watched and applied on change. Default true. | - |
10020
- | <a id="property-extensions"></a> `extensions` | [`Extension`](../../core/interfaces/Extension.md)[] | Extensions that make up the editor, usually a preset such as `basic()`. | [`EditorOptions`](../../core/interfaces/EditorOptions.md).[`extensions`](../../core/interfaces/EditorOptions.md#property-extensions) |
10843
+ | <a id="property-extensions"></a> `extensions` | readonly [`Extension`](../../core/interfaces/Extension.md)[] | Extensions that make up the editor, usually a preset such as `basic()`. | [`EditorOptions`](../../core/interfaces/EditorOptions.md).[`extensions`](../../core/interfaces/EditorOptions.md#property-extensions) |
10021
10844
  | <a id="property-label"></a> `label` | [`EditorLabel`](../../core/type-aliases/EditorLabel.md) | Accessible name: an `aria-label` string or the id of a labelling element. | [`EditorOptions`](../../core/interfaces/EditorOptions.md).[`label`](../../core/interfaces/EditorOptions.md#property-label) |
10022
10845
  | <a id="property-onblur"></a> `onBlur?` | (`editor`) => `void` | Called when the editable area loses focus, also when it is unmounted while focused. | [`EditorOptions`](../../core/interfaces/EditorOptions.md).[`onBlur`](../../core/interfaces/EditorOptions.md#property-onblur) |
10023
10846
  | <a id="property-onchange"></a> `onChange?` | (`editor`) => `void` | Called after every change to the document. | [`EditorOptions`](../../core/interfaces/EditorOptions.md).[`onChange`](../../core/interfaces/EditorOptions.md#property-onchange) |
@@ -11031,6 +11854,7 @@ Source: /api/reference.md
11031
11854
  - [@writeon/core/extension](core/extension/reference.md)
11032
11855
  - [@writeon/core/extensions](core/extensions/reference.md)
11033
11856
  - [@writeon/core/presets](core/presets/reference.md)
11857
+ - [@writeon/element](element/reference.md)
11034
11858
  - [@writeon/html](html/reference.md)
11035
11859
  - [@writeon/kit](kit/reference.md)
11036
11860
  - [@writeon/kit/advanced](kit/advanced/reference.md)
@@ -11041,6 +11865,7 @@ Source: /api/reference.md
11041
11865
  - [@writeon/react](react/reference.md)
11042
11866
  - [@writeon/server](server/reference.md)
11043
11867
  - [@writeon/ui](ui/reference.md)
11868
+ - [@writeon/ui/locales/en](ui/locales/en/reference.md)
11044
11869
  - [@writeon/ui/locales/ru](ui/locales/ru/reference.md)
11045
11870
  - [@writeon/ui/locales/uz](ui/locales/uz/reference.md)
11046
11871
  - [@writeon/vue](vue/reference.md)