@writeon/core 0.1.0 → 0.3.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/dist/commands.d.ts +5 -4
- package/dist/extension.d.ts +1 -1
- package/dist/extensions.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +13 -2
- package/dist/presets.d.ts +1 -1
- package/dist/{types-Dy7Bm7XX.d.ts → types-XoUXB0kY.d.ts} +17 -6
- package/llms-full.txt +1315 -257
- package/llms.txt +6 -1
- package/package.json +1 -6
package/llms-full.txt
CHANGED
|
@@ -174,6 +174,8 @@ Or use the [default kit](/guide/kit.md): a themeable toolbar and content styles
|
|
|
174
174
|
|
|
175
175
|
## Next
|
|
176
176
|
|
|
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.
|
|
177
179
|
- [Core concepts](/guide/concepts.md): documents, extensions, commands and state.
|
|
178
180
|
- [Saving and loading](/guide/saving.md): store JSON, convert to HTML or Markdown.
|
|
179
181
|
- [Security](/guide/security.md): validate on the server before you store or render.
|
|
@@ -306,11 +308,11 @@ const editor = createEditor({ extensions, label: 'Notes' })
|
|
|
306
308
|
// and the rest come in a separate chunk.
|
|
307
309
|
// The document, undo history and selection are kept.
|
|
308
310
|
export async function turnOnAdvanced(): Promise<void> {
|
|
309
|
-
await editor.
|
|
311
|
+
await editor.extend(() => import('@writeon/advanced'))
|
|
310
312
|
}
|
|
311
313
|
```
|
|
312
314
|
|
|
313
|
-
`editor.
|
|
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.
|
|
314
316
|
|
|
315
317
|
If you do not need lazy loading, pass everything up front:
|
|
316
318
|
|
|
@@ -387,7 +389,7 @@ editor.run(setFontFamily(null))
|
|
|
387
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.
|
|
388
390
|
- **Contrast:** `textColor()` warns while you develop when a colour is under 4.5:1 on the background (`background`, default white).
|
|
389
391
|
- **Markdown** has no fonts or colours: `toMarkdown()` keeps the text without them.
|
|
390
|
-
- For menus, `activeFontFamily(
|
|
392
|
+
- For menus, `activeFontFamily(editor)` and `activeTextColor(editor)` give the current id, and `activeTextAlign(editor)` the alignment.
|
|
391
393
|
|
|
392
394
|
### Image addresses
|
|
393
395
|
|
|
@@ -547,6 +549,413 @@ Things to know:
|
|
|
547
549
|
|
|
548
550
|
---
|
|
549
551
|
|
|
552
|
+
Source: /guide/frameworks.md
|
|
553
|
+
|
|
554
|
+
# Other frameworks
|
|
555
|
+
|
|
556
|
+
React and Vue have adapters (`@writeon/react`, `@writeon/vue`). Everything else works too, without one: the core is plain TypeScript with no framework inside, and the [default kit](/guide/kit.md) toolbar is plain DOM. Connecting the editor to a framework takes four steps:
|
|
557
|
+
|
|
558
|
+
| Step | What to call | When |
|
|
559
|
+
| --- | --- | --- |
|
|
560
|
+
| Create | `createEditor({ extensions, label })` | Once per component. No DOM needed yet. |
|
|
561
|
+
| Mount | `editor.mount(element)` | When the element exists, after the first render. |
|
|
562
|
+
| Read state | `editor.subscribe(listener)` and `editor.getSnapshot()` | Whenever the UI shows editor state (active marks, undo). |
|
|
563
|
+
| Destroy | `editor.destroy()` | When the component goes away. |
|
|
564
|
+
|
|
565
|
+
`subscribe()` calls the listener **without a value**, at most once per microtask, however many changes happened. Read the new state with `getSnapshot()`: it returns the same object until the state changes, so frameworks can compare by reference.
|
|
566
|
+
|
|
567
|
+
The examples below are built and tested in CI ([examples/svelte](https://github.com/writeon-editor/writeon/tree/main/examples/svelte), [examples/angular](https://github.com/writeon-editor/writeon/tree/main/examples/angular)).
|
|
568
|
+
|
|
569
|
+
## Svelte
|
|
570
|
+
|
|
571
|
+
Svelte 5. `createSubscriber` turns `subscribe()` into a reactive value; two actions mount the editor and the kit toolbar.
|
|
572
|
+
|
|
573
|
+
**writeon.svelte.ts**
|
|
574
|
+
|
|
575
|
+
```ts
|
|
576
|
+
import type { Editor, EditorSnapshot } from '@writeon/core'
|
|
577
|
+
import { mountToolbar } from '@writeon/kit'
|
|
578
|
+
import type { Action } from 'svelte/action'
|
|
579
|
+
import { createSubscriber } from 'svelte/reactivity'
|
|
580
|
+
|
|
581
|
+
// The editor state as a reactive value: read .current in markup or
|
|
582
|
+
// in $derived. It listens only while something reads it.
|
|
583
|
+
export function editorState(editor: Editor): {
|
|
584
|
+
readonly current: EditorSnapshot
|
|
585
|
+
} {
|
|
586
|
+
const subscribe = createSubscriber((update) =>
|
|
587
|
+
editor.subscribe(update),
|
|
588
|
+
)
|
|
589
|
+
return {
|
|
590
|
+
get current() {
|
|
591
|
+
subscribe()
|
|
592
|
+
return editor.getSnapshot()
|
|
593
|
+
},
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// use:editorContent={editor} mounts the editable area. The editor is
|
|
598
|
+
// destroyed together with the element.
|
|
599
|
+
export const editorContent: Action<HTMLElement, Editor> = (
|
|
600
|
+
node,
|
|
601
|
+
editor,
|
|
602
|
+
) => {
|
|
603
|
+
editor.mount(node)
|
|
604
|
+
return { destroy: () => editor.destroy() }
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// use:kitToolbar={editor} adds the default kit toolbar.
|
|
608
|
+
export const kitToolbar: Action<HTMLElement, Editor> = (
|
|
609
|
+
node,
|
|
610
|
+
editor,
|
|
611
|
+
) => {
|
|
612
|
+
const toolbar = mountToolbar(node, editor)
|
|
613
|
+
return { destroy: () => toolbar.destroy() }
|
|
614
|
+
}
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
**App.svelte**
|
|
618
|
+
|
|
619
|
+
```svelte
|
|
620
|
+
<script lang="ts">
|
|
621
|
+
import { createEditor } from '@writeon/core'
|
|
622
|
+
import { basic } from '@writeon/core/presets'
|
|
623
|
+
import '@writeon/kit/style.css'
|
|
624
|
+
import {
|
|
625
|
+
editorContent,
|
|
626
|
+
editorState,
|
|
627
|
+
kitToolbar,
|
|
628
|
+
} from './writeon.svelte'
|
|
629
|
+
|
|
630
|
+
// One editor per component. It attaches to the DOM in editorContent.
|
|
631
|
+
const editor = createEditor({
|
|
632
|
+
extensions: basic(),
|
|
633
|
+
label: 'Svelte example',
|
|
634
|
+
placeholder: 'Start writing…',
|
|
635
|
+
})
|
|
636
|
+
const state = editorState(editor)
|
|
637
|
+
const bold = $derived(state.current.marks.has('bold'))
|
|
638
|
+
</script>
|
|
639
|
+
|
|
640
|
+
<main>
|
|
641
|
+
<h1>Writeon · Svelte</h1>
|
|
642
|
+
<div class="rte-root">
|
|
643
|
+
<div use:kitToolbar={editor}></div>
|
|
644
|
+
<div use:editorContent={editor} class="rte-content"></div>
|
|
645
|
+
</div>
|
|
646
|
+
<p data-testid="status">
|
|
647
|
+
Block: {state.current.block.type} ·
|
|
648
|
+
Bold: {bold ? 'on' : 'off'} ·
|
|
649
|
+
Undo: {state.current.canUndo ? 'yes' : 'no'}
|
|
650
|
+
</p>
|
|
651
|
+
</main>
|
|
652
|
+
|
|
653
|
+
<style>
|
|
654
|
+
main {
|
|
655
|
+
max-width: 720px;
|
|
656
|
+
margin: 40px auto;
|
|
657
|
+
padding: 0 16px;
|
|
658
|
+
font-family: system-ui, sans-serif;
|
|
659
|
+
}
|
|
660
|
+
</style>
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
With Svelte stores instead of runes: `readable(editor.getSnapshot(), (set) => editor.subscribe(() => set(editor.getSnapshot())))`. A store must pass its value to its subscribers, which is why `editor` itself is not one.
|
|
664
|
+
|
|
665
|
+
## Angular
|
|
666
|
+
|
|
667
|
+
Angular 22, standalone and zoneless. A signal holds the snapshot; `afterNextRender` mounts the editor once the template is in the DOM.
|
|
668
|
+
|
|
669
|
+
**writeon.ts**
|
|
670
|
+
|
|
671
|
+
```ts
|
|
672
|
+
import { DestroyRef, inject, type Signal, signal } from '@angular/core'
|
|
673
|
+
import type { Editor, EditorSnapshot } from '@writeon/core'
|
|
674
|
+
|
|
675
|
+
// The editor state as a signal. Call it in an injection context (a
|
|
676
|
+
// field initializer or the constructor); it stops listening when the
|
|
677
|
+
// component is destroyed.
|
|
678
|
+
export function editorState(editor: Editor): Signal<EditorSnapshot> {
|
|
679
|
+
const state = signal(editor.getSnapshot())
|
|
680
|
+
const off = editor.subscribe(() => state.set(editor.getSnapshot()))
|
|
681
|
+
inject(DestroyRef).onDestroy(off)
|
|
682
|
+
return state.asReadonly()
|
|
683
|
+
}
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
**app.component.ts**
|
|
687
|
+
|
|
688
|
+
```ts
|
|
689
|
+
import {
|
|
690
|
+
afterNextRender,
|
|
691
|
+
Component,
|
|
692
|
+
computed,
|
|
693
|
+
DestroyRef,
|
|
694
|
+
type ElementRef,
|
|
695
|
+
inject,
|
|
696
|
+
viewChild,
|
|
697
|
+
} from '@angular/core'
|
|
698
|
+
import { createEditor } from '@writeon/core'
|
|
699
|
+
import { basic } from '@writeon/core/presets'
|
|
700
|
+
import { type KitToolbar, mountToolbar } from '@writeon/kit'
|
|
701
|
+
import { editorState } from './writeon'
|
|
702
|
+
|
|
703
|
+
@Component({
|
|
704
|
+
selector: 'app-root',
|
|
705
|
+
template: `
|
|
706
|
+
<main>
|
|
707
|
+
<h1>Writeon · Angular</h1>
|
|
708
|
+
<div class="rte-root">
|
|
709
|
+
<div #toolbar></div>
|
|
710
|
+
<div #content class="rte-content"></div>
|
|
711
|
+
</div>
|
|
712
|
+
<p data-testid="status">
|
|
713
|
+
Block: {{ state().block.type }} ·
|
|
714
|
+
Bold: {{ bold() ? 'on' : 'off' }} ·
|
|
715
|
+
Undo: {{ state().canUndo ? 'yes' : 'no' }}
|
|
716
|
+
</p>
|
|
717
|
+
</main>
|
|
718
|
+
`,
|
|
719
|
+
styles: `
|
|
720
|
+
main {
|
|
721
|
+
max-width: 720px;
|
|
722
|
+
margin: 40px auto;
|
|
723
|
+
padding: 0 16px;
|
|
724
|
+
font-family: system-ui, sans-serif;
|
|
725
|
+
}
|
|
726
|
+
`,
|
|
727
|
+
})
|
|
728
|
+
export class AppComponent {
|
|
729
|
+
private readonly toolbarHost =
|
|
730
|
+
viewChild.required<ElementRef<HTMLElement>>('toolbar')
|
|
731
|
+
private readonly contentHost =
|
|
732
|
+
viewChild.required<ElementRef<HTMLElement>>('content')
|
|
733
|
+
|
|
734
|
+
// One editor per component. It attaches to the DOM after the first
|
|
735
|
+
// render, and the toolbar goes before the editor on destroy.
|
|
736
|
+
readonly editor = createEditor({
|
|
737
|
+
extensions: basic(),
|
|
738
|
+
label: 'Angular example',
|
|
739
|
+
placeholder: 'Start writing…',
|
|
740
|
+
})
|
|
741
|
+
readonly state = editorState(this.editor)
|
|
742
|
+
readonly bold = computed(() => this.state().marks.has('bold'))
|
|
743
|
+
|
|
744
|
+
constructor() {
|
|
745
|
+
let toolbar: KitToolbar | undefined
|
|
746
|
+
afterNextRender(() => {
|
|
747
|
+
this.editor.mount(this.contentHost().nativeElement)
|
|
748
|
+
toolbar = mountToolbar(
|
|
749
|
+
this.toolbarHost().nativeElement,
|
|
750
|
+
this.editor,
|
|
751
|
+
)
|
|
752
|
+
})
|
|
753
|
+
inject(DestroyRef).onDestroy(() => {
|
|
754
|
+
toolbar?.destroy()
|
|
755
|
+
this.editor.destroy()
|
|
756
|
+
})
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
Add `@writeon/kit/style.css` to `styles` in `angular.json`. In an app that still uses zone.js, call `mount()` inside `NgZone.runOutsideAngular()`: the editor's own DOM events then do not run change detection on every keystroke, and the signal still updates the view.
|
|
762
|
+
|
|
763
|
+
## Solid, Lit and others
|
|
764
|
+
|
|
765
|
+
The same four steps, in that framework's lifecycle:
|
|
766
|
+
|
|
767
|
+
| Framework | Mount | State | Destroy |
|
|
768
|
+
| --- | --- | --- | --- |
|
|
769
|
+
| Solid | `onMount` | `createSignal`, set from `subscribe()` | `onCleanup` |
|
|
770
|
+
| Lit | `firstUpdated` | a reactive property, set from `subscribe()` | `disconnectedCallback` |
|
|
771
|
+
| Plain JavaScript | when the element exists | `subscribe()` | when you remove it |
|
|
772
|
+
|
|
773
|
+
See [Getting started](/guide/getting-started.md#your-first-editor) for the plain JavaScript version.
|
|
774
|
+
|
|
775
|
+
## Your own UI
|
|
776
|
+
|
|
777
|
+
The kit toolbar works everywhere. To build your own, the [headless UI](/guide/headless-ui.md) controllers do too: `applyProps(element, props)` puts their attributes and event handlers on your elements, as in its [plain JavaScript](/guide/headless-ui.md#plain-javascript) example. Call it from the controller's `subscribe()`.
|
|
778
|
+
|
|
779
|
+
## Testing
|
|
780
|
+
|
|
781
|
+
The packages are ES modules only. Vitest runs them as they are. Jest needs its ESM mode: `node --experimental-vm-modules node_modules/jest/bin/jest.js`, with `testEnvironment: 'jsdom'` for tests that mount an editor.
|
|
782
|
+
|
|
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"><p>Hello</p></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
|
+
|
|
550
959
|
Source: /guide/security.md
|
|
551
960
|
|
|
552
961
|
# Security
|
|
@@ -601,7 +1010,7 @@ export async function savePost(
|
|
|
601
1010
|
- checks the JSON shape and refuses `__proto__`, `constructor` and `prototype` keys;
|
|
602
1011
|
- enforces limits: size (1 MB), depth (32) and node count (50 000) by default;
|
|
603
1012
|
- removes unknown nodes, marks and attributes, invalid attribute values and content the schema does not allow;
|
|
604
|
-
- 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;
|
|
605
1014
|
- in `'strip'` mode (default) returns the cleaned document and what was removed; in `'strict'` mode refuses the whole document instead.
|
|
606
1015
|
|
|
607
1016
|
`toSafeHTML()` renders only what the schema knows, escapes all text and checks every URL again.
|
|
@@ -893,6 +1302,8 @@ export function MyToolbar({ editor }: { editor: Editor }) {
|
|
|
893
1302
|
}
|
|
894
1303
|
```
|
|
895
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
|
+
|
|
896
1307
|
## Positioning
|
|
897
1308
|
|
|
898
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:
|
|
@@ -950,7 +1361,7 @@ Packages: `@writeon/core` (editor, `/presets`, `/commands`, `/extension`),
|
|
|
950
1361
|
`@writeon/react`, `@writeon/vue`, `@writeon/ui` (headless controllers),
|
|
951
1362
|
`@writeon/kit` (ready-made UI, `/react`, `/vue`, `/advanced`),
|
|
952
1363
|
`@writeon/advanced` (+ `/schema`), `@writeon/html`, `@writeon/markdown`,
|
|
953
|
-
`@writeon/server
|
|
1364
|
+
`@writeon/server`, `@writeon/element` (`<writeon-editor>` web component for HTML forms).
|
|
954
1365
|
|
|
955
1366
|
Rules:
|
|
956
1367
|
- Store the document as JSON: `editor.getJSON()` (`DocJSON`). HTML and Markdown are
|
|
@@ -964,7 +1375,7 @@ Rules:
|
|
|
964
1375
|
- Commands are factories: `editor.run(toggleBold())`, `editor.can(toggleBold())`;
|
|
965
1376
|
several in one undo step with `editor.transaction((tx) => { … })`.
|
|
966
1377
|
- Advanced features: include `advancedSchema()` in the extensions from the start;
|
|
967
|
-
load the behaviour later with `editor.
|
|
1378
|
+
load the behaviour later with `editor.extend(() => import('@writeon/advanced'))`,
|
|
968
1379
|
or use the kit's `<Advanced>` / `mountAdvanced()`.
|
|
969
1380
|
- `editor.pm` (raw ProseMirror) is not a stable API; prefer commands, snapshots
|
|
970
1381
|
(`getSnapshot()`, `subscribe()`) and extensions (`defineExtension`).
|
|
@@ -979,6 +1390,64 @@ Every public function, type and option has JSDoc, often with an example. Assista
|
|
|
979
1390
|
|
|
980
1391
|
---
|
|
981
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 release.
|
|
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 `--rte-*` CSS variables, `.rte-root`, `.rte-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
|
+
|
|
982
1451
|
Source: /recipes/upload-s3.md
|
|
983
1452
|
|
|
984
1453
|
# Image uploads to S3
|
|
@@ -1012,7 +1481,7 @@ async function signUpload(
|
|
|
1012
1481
|
}
|
|
1013
1482
|
|
|
1014
1483
|
export async function enableUploads(editor: Editor): Promise<void> {
|
|
1015
|
-
await editor.
|
|
1484
|
+
await editor.extend([
|
|
1016
1485
|
imageUpload({
|
|
1017
1486
|
upload: presignedUploader({ getTarget: signUpload }),
|
|
1018
1487
|
// 5 MB
|
|
@@ -1108,6 +1577,9 @@ Source: /recipes/custom-blocks.md
|
|
|
1108
1577
|
|
|
1109
1578
|
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.
|
|
1110
1579
|
|
|
1580
|
+
**Experimental:**
|
|
1581
|
+
The `@writeon/advanced/embed` API can still change in a minor release (see [Stability](/guide/stability.md)). Stored blocks keep loading either way.
|
|
1582
|
+
|
|
1111
1583
|
```ts
|
|
1112
1584
|
import {
|
|
1113
1585
|
embed,
|
|
@@ -1160,7 +1632,7 @@ editor.run(updateEmbed({ category: 'saws', limit: 12 }))
|
|
|
1160
1632
|
- **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.
|
|
1161
1633
|
- **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.
|
|
1162
1634
|
- **Markdown**: `[[product-list {"category":"drills","limit":8}]]` on its own line, read back by `fromMarkdown()`.
|
|
1163
|
-
- **UI**: `embedKinds(
|
|
1635
|
+
- **UI**: `embedKinds(editor)` lists the kinds for your menu; `selectedEmbed(editor)` gives the selected block for a settings form.
|
|
1164
1636
|
|
|
1165
1637
|
---
|
|
1166
1638
|
|
|
@@ -1230,7 +1702,7 @@ Remember:
|
|
|
1230
1702
|
|
|
1231
1703
|
- **Add it on the server too**, or `validate()` removes the new mark as unknown.
|
|
1232
1704
|
- Commands are factories returning a command, like the built-in ones, so `editor.run(toggleHighlight())` and `editor.can(toggleHighlight())` read the same.
|
|
1233
|
-
- An extension with nodes or marks must be passed to `createEditor()`. `editor.
|
|
1705
|
+
- 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.
|
|
1234
1706
|
|
|
1235
1707
|
---
|
|
1236
1708
|
|
|
@@ -1303,8 +1775,7 @@ Source: /api/advanced/reference.md
|
|
|
1303
1775
|
|
|
1304
1776
|
Advanced editing behaviour: task lists, code blocks, image uploads, tables
|
|
1305
1777
|
and mentions. Load it lazily and turn it on with
|
|
1306
|
-
`editor.
|
|
1307
|
-
rte/advanced/schema`.
|
|
1778
|
+
`editor.extend(advanced())`; the node types come from `@writeon/advanced/schema`.
|
|
1308
1779
|
|
|
1309
1780
|
## Classes
|
|
1310
1781
|
|
|
@@ -1766,7 +2237,7 @@ Source: /api/advanced/variables/default.md
|
|
|
1766
2237
|
const default: Extension[];
|
|
1767
2238
|
```
|
|
1768
2239
|
|
|
1769
|
-
The default export, so `editor.
|
|
2240
|
+
The default export, so `editor.extend(() => import('@writeon/advanced'))` works.
|
|
1770
2241
|
|
|
1771
2242
|
---
|
|
1772
2243
|
|
|
@@ -1959,7 +2430,7 @@ All advanced behaviour. Pair it with `advancedSchema()` in `createEditor()`.
|
|
|
1959
2430
|
createEditor({ extensions: [...basic(), advancedSchema(), ...advanced()], label })
|
|
1960
2431
|
// or on demand, keeping the document, undo history and selection
|
|
1961
2432
|
createEditor({ extensions: [...basic(), advancedSchema()], label })
|
|
1962
|
-
await editor.
|
|
2433
|
+
await editor.extend(() => import('@writeon/advanced'))
|
|
1963
2434
|
```
|
|
1964
2435
|
|
|
1965
2436
|
---
|
|
@@ -2243,6 +2714,9 @@ branches. Documents store `{ type: 'embed', attrs: { kind, props } }`; the
|
|
|
2243
2714
|
kinds and their props are configured, so the server (`validate()`) drops
|
|
2244
2715
|
anything else. Small and eager: add `embed()` to the editor from the start.
|
|
2245
2716
|
|
|
2717
|
+
Experimental: the API can change in a minor release (see the stability
|
|
2718
|
+
page). Stored embeds keep loading.
|
|
2719
|
+
|
|
2246
2720
|
## Interfaces
|
|
2247
2721
|
|
|
2248
2722
|
- [EmbedBooleanProp](interfaces/EmbedBooleanProp.md)
|
|
@@ -2279,15 +2753,17 @@ Source: /api/advanced/embed/interfaces/EmbedBooleanProp.md
|
|
|
2279
2753
|
|
|
2280
2754
|
# Interface: EmbedBooleanProp
|
|
2281
2755
|
|
|
2756
|
+
**`Experimental`**
|
|
2757
|
+
|
|
2282
2758
|
A yes/no field of an embed.
|
|
2283
2759
|
|
|
2284
2760
|
## Properties
|
|
2285
2761
|
|
|
2286
2762
|
| Property | Type | Description |
|
|
2287
2763
|
| ------ | ------ | ------ |
|
|
2288
|
-
| <a id="property-default"></a> `default?` | `boolean` | Value for a new embed. Default false. |
|
|
2289
|
-
| <a id="property-label"></a> `label` | `string` | Shown in the form. |
|
|
2290
|
-
| <a id="property-type"></a> `type` | `"boolean"` | A yes/no field. |
|
|
2764
|
+
| <a id="property-default"></a> `default?` | `boolean` | **`Experimental`** Value for a new embed. Default false. |
|
|
2765
|
+
| <a id="property-label"></a> `label` | `string` | **`Experimental`** Shown in the form. |
|
|
2766
|
+
| <a id="property-type"></a> `type` | `"boolean"` | **`Experimental`** A yes/no field. |
|
|
2291
2767
|
|
|
2292
2768
|
---
|
|
2293
2769
|
|
|
@@ -2295,17 +2771,19 @@ Source: /api/advanced/embed/interfaces/EmbedEnumProp.md
|
|
|
2295
2771
|
|
|
2296
2772
|
# Interface: EmbedEnumProp
|
|
2297
2773
|
|
|
2774
|
+
**`Experimental`**
|
|
2775
|
+
|
|
2298
2776
|
A choice from fixed options.
|
|
2299
2777
|
|
|
2300
2778
|
## Properties
|
|
2301
2779
|
|
|
2302
2780
|
| Property | Type | Description |
|
|
2303
2781
|
| ------ | ------ | ------ |
|
|
2304
|
-
| <a id="property-default"></a> `default?` | `string` | Value for a new embed. |
|
|
2305
|
-
| <a id="property-label"></a> `label` | `string` | Shown in the form. |
|
|
2306
|
-
| <a id="property-options"></a> `options` | readonly [`EmbedOption`](EmbedOption.md)[] | The choices: the stored value and its label. |
|
|
2307
|
-
| <a id="property-required"></a> `required?` | `boolean` | Must be chosen. |
|
|
2308
|
-
| <a id="property-type"></a> `type` | `"enum"` | A choice from fixed options. |
|
|
2782
|
+
| <a id="property-default"></a> `default?` | `string` | **`Experimental`** Value for a new embed. |
|
|
2783
|
+
| <a id="property-label"></a> `label` | `string` | **`Experimental`** Shown in the form. |
|
|
2784
|
+
| <a id="property-options"></a> `options` | readonly [`EmbedOption`](EmbedOption.md)[] | **`Experimental`** The choices: the stored value and its label. |
|
|
2785
|
+
| <a id="property-required"></a> `required?` | `boolean` | **`Experimental`** Must be chosen. |
|
|
2786
|
+
| <a id="property-type"></a> `type` | `"enum"` | **`Experimental`** A choice from fixed options. |
|
|
2309
2787
|
|
|
2310
2788
|
---
|
|
2311
2789
|
|
|
@@ -2313,16 +2791,18 @@ Source: /api/advanced/embed/interfaces/EmbedKind.md
|
|
|
2313
2791
|
|
|
2314
2792
|
# Interface: EmbedKind
|
|
2315
2793
|
|
|
2794
|
+
**`Experimental`**
|
|
2795
|
+
|
|
2316
2796
|
A kind of block the user can insert.
|
|
2317
2797
|
|
|
2318
2798
|
## Properties
|
|
2319
2799
|
|
|
2320
2800
|
| Property | Type | Description |
|
|
2321
2801
|
| ------ | ------ | ------ |
|
|
2322
|
-
| <a id="property-description"></a> `description?` | `string` | A second line in the menu. |
|
|
2323
|
-
| <a id="property-id"></a> `id` | `string` | Stored in the document, e.g. `'pickup-branches'`. Letters, digits, `-` and `_`. |
|
|
2324
|
-
| <a id="property-label"></a> `label` | `string` | Shown in the menu and in the editor, e.g. `'Olib ketish filiallari'`. |
|
|
2325
|
-
| <a id="property-props"></a> `props?` | `Readonly`\<`Record`\<`string`, [`EmbedPropSpec`](../type-aliases/EmbedPropSpec.md)\>\> | Settings the user fills in, by field name (letters, digits, `_`). |
|
|
2802
|
+
| <a id="property-description"></a> `description?` | `string` | **`Experimental`** A second line in the menu. |
|
|
2803
|
+
| <a id="property-id"></a> `id` | `string` | **`Experimental`** Stored in the document, e.g. `'pickup-branches'`. Letters, digits, `-` and `_`. |
|
|
2804
|
+
| <a id="property-label"></a> `label` | `string` | **`Experimental`** Shown in the menu and in the editor, e.g. `'Olib ketish filiallari'`. |
|
|
2805
|
+
| <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, `_`). |
|
|
2326
2806
|
|
|
2327
2807
|
---
|
|
2328
2808
|
|
|
@@ -2330,19 +2810,21 @@ Source: /api/advanced/embed/interfaces/EmbedNumberProp.md
|
|
|
2330
2810
|
|
|
2331
2811
|
# Interface: EmbedNumberProp
|
|
2332
2812
|
|
|
2813
|
+
**`Experimental`**
|
|
2814
|
+
|
|
2333
2815
|
A number field of an embed.
|
|
2334
2816
|
|
|
2335
2817
|
## Properties
|
|
2336
2818
|
|
|
2337
2819
|
| Property | Type | Description |
|
|
2338
2820
|
| ------ | ------ | ------ |
|
|
2339
|
-
| <a id="property-default"></a> `default?` | `number` | Value for a new embed. |
|
|
2340
|
-
| <a id="property-integer"></a> `integer?` | `boolean` | Whole numbers only. |
|
|
2341
|
-
| <a id="property-label"></a> `label` | `string` | Shown in the form. |
|
|
2342
|
-
| <a id="property-max"></a> `max?` | `number` | Largest value. |
|
|
2343
|
-
| <a id="property-min"></a> `min?` | `number` | Smallest value. |
|
|
2344
|
-
| <a id="property-required"></a> `required?` | `boolean` | Must be filled in. |
|
|
2345
|
-
| <a id="property-type"></a> `type` | `"number"` | A number field. |
|
|
2821
|
+
| <a id="property-default"></a> `default?` | `number` | **`Experimental`** Value for a new embed. |
|
|
2822
|
+
| <a id="property-integer"></a> `integer?` | `boolean` | **`Experimental`** Whole numbers only. |
|
|
2823
|
+
| <a id="property-label"></a> `label` | `string` | **`Experimental`** Shown in the form. |
|
|
2824
|
+
| <a id="property-max"></a> `max?` | `number` | **`Experimental`** Largest value. |
|
|
2825
|
+
| <a id="property-min"></a> `min?` | `number` | **`Experimental`** Smallest value. |
|
|
2826
|
+
| <a id="property-required"></a> `required?` | `boolean` | **`Experimental`** Must be filled in. |
|
|
2827
|
+
| <a id="property-type"></a> `type` | `"number"` | **`Experimental`** A number field. |
|
|
2346
2828
|
|
|
2347
2829
|
---
|
|
2348
2830
|
|
|
@@ -2350,14 +2832,16 @@ Source: /api/advanced/embed/interfaces/EmbedOption.md
|
|
|
2350
2832
|
|
|
2351
2833
|
# Interface: EmbedOption
|
|
2352
2834
|
|
|
2835
|
+
**`Experimental`**
|
|
2836
|
+
|
|
2353
2837
|
One choice of an `enum` field.
|
|
2354
2838
|
|
|
2355
2839
|
## Properties
|
|
2356
2840
|
|
|
2357
2841
|
| Property | Type | Description |
|
|
2358
2842
|
| ------ | ------ | ------ |
|
|
2359
|
-
| <a id="property-label"></a> `label` | `string` | Shown in the form. |
|
|
2360
|
-
| <a id="property-value"></a> `value` | `string` | Stored in the document. |
|
|
2843
|
+
| <a id="property-label"></a> `label` | `string` | **`Experimental`** Shown in the form. |
|
|
2844
|
+
| <a id="property-value"></a> `value` | `string` | **`Experimental`** Stored in the document. |
|
|
2361
2845
|
|
|
2362
2846
|
---
|
|
2363
2847
|
|
|
@@ -2365,13 +2849,15 @@ Source: /api/advanced/embed/interfaces/EmbedOptions.md
|
|
|
2365
2849
|
|
|
2366
2850
|
# Interface: EmbedOptions
|
|
2367
2851
|
|
|
2852
|
+
**`Experimental`**
|
|
2853
|
+
|
|
2368
2854
|
Options for `embed()`.
|
|
2369
2855
|
|
|
2370
2856
|
## Properties
|
|
2371
2857
|
|
|
2372
2858
|
| Property | Type | Description |
|
|
2373
2859
|
| ------ | ------ | ------ |
|
|
2374
|
-
| <a id="property-kinds"></a> `kinds` | readonly [`EmbedKind`](EmbedKind.md)[] | The blocks the user can insert. |
|
|
2860
|
+
| <a id="property-kinds"></a> `kinds` | readonly [`EmbedKind`](EmbedKind.md)[] | **`Experimental`** The blocks the user can insert. |
|
|
2375
2861
|
|
|
2376
2862
|
---
|
|
2377
2863
|
|
|
@@ -2379,17 +2865,19 @@ Source: /api/advanced/embed/interfaces/EmbedStringProp.md
|
|
|
2379
2865
|
|
|
2380
2866
|
# Interface: EmbedStringProp
|
|
2381
2867
|
|
|
2868
|
+
**`Experimental`**
|
|
2869
|
+
|
|
2382
2870
|
A text field of an embed.
|
|
2383
2871
|
|
|
2384
2872
|
## Properties
|
|
2385
2873
|
|
|
2386
2874
|
| Property | Type | Description |
|
|
2387
2875
|
| ------ | ------ | ------ |
|
|
2388
|
-
| <a id="property-default"></a> `default?` | `string` | Value for a new embed. |
|
|
2389
|
-
| <a id="property-label"></a> `label` | `string` | Shown in the form. |
|
|
2390
|
-
| <a id="property-maxlength"></a> `maxLength?` | `number` | Longest value. Default 500. |
|
|
2391
|
-
| <a id="property-required"></a> `required?` | `boolean` | Must be filled in. |
|
|
2392
|
-
| <a id="property-type"></a> `type` | `"string"` | A text field. |
|
|
2876
|
+
| <a id="property-default"></a> `default?` | `string` | **`Experimental`** Value for a new embed. |
|
|
2877
|
+
| <a id="property-label"></a> `label` | `string` | **`Experimental`** Shown in the form. |
|
|
2878
|
+
| <a id="property-maxlength"></a> `maxLength?` | `number` | **`Experimental`** Longest value. Default 500. |
|
|
2879
|
+
| <a id="property-required"></a> `required?` | `boolean` | **`Experimental`** Must be filled in. |
|
|
2880
|
+
| <a id="property-type"></a> `type` | `"string"` | **`Experimental`** A text field. |
|
|
2393
2881
|
|
|
2394
2882
|
---
|
|
2395
2883
|
|
|
@@ -2397,15 +2885,17 @@ Source: /api/advanced/embed/interfaces/SelectedEmbed.md
|
|
|
2397
2885
|
|
|
2398
2886
|
# Interface: SelectedEmbed
|
|
2399
2887
|
|
|
2888
|
+
**`Experimental`**
|
|
2889
|
+
|
|
2400
2890
|
The selected embed, from `selectedEmbed()`.
|
|
2401
2891
|
|
|
2402
2892
|
## Properties
|
|
2403
2893
|
|
|
2404
2894
|
| Property | Type | Description |
|
|
2405
2895
|
| ------ | ------ | ------ |
|
|
2406
|
-
| <a id="property-kind"></a> `kind` | [`EmbedKind`](EmbedKind.md) | Its kind, as configured. |
|
|
2407
|
-
| <a id="property-pos"></a> `pos` | `number` | Its position in the document. |
|
|
2408
|
-
| <a id="property-props"></a> `props` | [`EmbedProps`](../type-aliases/EmbedProps.md) | Its settings. |
|
|
2896
|
+
| <a id="property-kind"></a> `kind` | [`EmbedKind`](EmbedKind.md) | **`Experimental`** Its kind, as configured. |
|
|
2897
|
+
| <a id="property-pos"></a> `pos` | `number` | **`Experimental`** Its position in the document. |
|
|
2898
|
+
| <a id="property-props"></a> `props` | [`EmbedProps`](../type-aliases/EmbedProps.md) | **`Experimental`** Its settings. |
|
|
2409
2899
|
|
|
2410
2900
|
---
|
|
2411
2901
|
|
|
@@ -2417,6 +2907,8 @@ Source: /api/advanced/embed/type-aliases/EmbedProps.md
|
|
|
2417
2907
|
type EmbedProps = Readonly<Record<string, EmbedPropValue>>;
|
|
2418
2908
|
```
|
|
2419
2909
|
|
|
2910
|
+
**`Experimental`**
|
|
2911
|
+
|
|
2420
2912
|
An embed's settings, by field name.
|
|
2421
2913
|
|
|
2422
2914
|
---
|
|
@@ -2433,6 +2925,8 @@ type EmbedPropSpec =
|
|
|
2433
2925
|
| EmbedEnumProp;
|
|
2434
2926
|
```
|
|
2435
2927
|
|
|
2928
|
+
**`Experimental`**
|
|
2929
|
+
|
|
2436
2930
|
One field of an embed's settings.
|
|
2437
2931
|
|
|
2438
2932
|
---
|
|
@@ -2445,6 +2939,8 @@ Source: /api/advanced/embed/type-aliases/EmbedPropValue.md
|
|
|
2445
2939
|
type EmbedPropValue = string | number | boolean;
|
|
2446
2940
|
```
|
|
2447
2941
|
|
|
2942
|
+
**`Experimental`**
|
|
2943
|
+
|
|
2448
2944
|
A stored prop value.
|
|
2449
2945
|
|
|
2450
2946
|
---
|
|
@@ -2457,6 +2953,8 @@ Source: /api/advanced/embed/variables/embed.md
|
|
|
2457
2953
|
const embed: (options) => Extension;
|
|
2458
2954
|
```
|
|
2459
2955
|
|
|
2956
|
+
**`Experimental`**
|
|
2957
|
+
|
|
2460
2958
|
Custom blocks your front end renders. Each kind is a block the user
|
|
2461
2959
|
inserts from a menu (and edits through a form when it has props); the
|
|
2462
2960
|
editor shows it as `[[Label]]`. HTML: `<div data-embed="kind"
|
|
@@ -2500,6 +2998,8 @@ Source: /api/advanced/embed/functions/embedDefaults.md
|
|
|
2500
2998
|
function embedDefaults(kind, props?): EmbedProps;
|
|
2501
2999
|
```
|
|
2502
3000
|
|
|
3001
|
+
**`Experimental`**
|
|
3002
|
+
|
|
2503
3003
|
The props of a new embed: the defaults, overridden by `props`, empty values dropped.
|
|
2504
3004
|
|
|
2505
3005
|
## Parameters
|
|
@@ -2520,16 +3020,18 @@ Source: /api/advanced/embed/functions/embedKinds.md
|
|
|
2520
3020
|
# Function: embedKinds()
|
|
2521
3021
|
|
|
2522
3022
|
```ts
|
|
2523
|
-
function embedKinds(
|
|
3023
|
+
function embedKinds(editor): readonly EmbedKind[];
|
|
2524
3024
|
```
|
|
2525
3025
|
|
|
3026
|
+
**`Experimental`**
|
|
3027
|
+
|
|
2526
3028
|
The kinds configured with `embed()` in this editor's schema, or none.
|
|
2527
3029
|
|
|
2528
3030
|
## Parameters
|
|
2529
3031
|
|
|
2530
3032
|
| Parameter | Type |
|
|
2531
3033
|
| ------ | ------ |
|
|
2532
|
-
| `
|
|
3034
|
+
| `editor` | [`Editor`](../../../core/interfaces/Editor.md) |
|
|
2533
3035
|
|
|
2534
3036
|
## Returns
|
|
2535
3037
|
|
|
@@ -2545,6 +3047,8 @@ Source: /api/advanced/embed/functions/embedPropsError.md
|
|
|
2545
3047
|
function embedPropsError(kind, props): string | null;
|
|
2546
3048
|
```
|
|
2547
3049
|
|
|
3050
|
+
**`Experimental`**
|
|
3051
|
+
|
|
2548
3052
|
Why `props` are not valid for `kind`, or null when they are. Missing
|
|
2549
3053
|
optional fields are fine; unknown fields, wrong types and values out of
|
|
2550
3054
|
range are not.
|
|
@@ -2570,6 +3074,8 @@ Source: /api/advanced/embed/functions/insertEmbed.md
|
|
|
2570
3074
|
function insertEmbed(kind, props?): Command;
|
|
2571
3075
|
```
|
|
2572
3076
|
|
|
3077
|
+
**`Experimental`**
|
|
3078
|
+
|
|
2573
3079
|
Insert an embed of `kind` with the defaults and `props`: in place of an
|
|
2574
3080
|
empty paragraph, after the paragraph holding the cursor (text is never
|
|
2575
3081
|
split) or after a selected node. The cursor ends in the paragraph below.
|
|
@@ -2594,16 +3100,18 @@ Source: /api/advanced/embed/functions/selectedEmbed.md
|
|
|
2594
3100
|
# Function: selectedEmbed()
|
|
2595
3101
|
|
|
2596
3102
|
```ts
|
|
2597
|
-
function selectedEmbed(
|
|
3103
|
+
function selectedEmbed(editor): SelectedEmbed | null;
|
|
2598
3104
|
```
|
|
2599
3105
|
|
|
3106
|
+
**`Experimental`**
|
|
3107
|
+
|
|
2600
3108
|
The selected embed (its kind, props and position), or null.
|
|
2601
3109
|
|
|
2602
3110
|
## Parameters
|
|
2603
3111
|
|
|
2604
3112
|
| Parameter | Type |
|
|
2605
3113
|
| ------ | ------ |
|
|
2606
|
-
| `
|
|
3114
|
+
| `editor` | [`Editor`](../../../core/interfaces/Editor.md) |
|
|
2607
3115
|
|
|
2608
3116
|
## Returns
|
|
2609
3117
|
|
|
@@ -2619,6 +3127,8 @@ Source: /api/advanced/embed/functions/updateEmbed.md
|
|
|
2619
3127
|
function updateEmbed(props): Command;
|
|
2620
3128
|
```
|
|
2621
3129
|
|
|
3130
|
+
**`Experimental`**
|
|
3131
|
+
|
|
2622
3132
|
Replace the props of the selected embed. Fails when they are not valid.
|
|
2623
3133
|
|
|
2624
3134
|
## Parameters
|
|
@@ -2664,11 +3174,11 @@ Small and eager: add them to the editor from the start, like
|
|
|
2664
3174
|
## Functions
|
|
2665
3175
|
|
|
2666
3176
|
- [activeFontFamily](functions/activeFontFamily.md)
|
|
3177
|
+
- [activeTextAlign](functions/activeTextAlign.md)
|
|
2667
3178
|
- [activeTextColor](functions/activeTextColor.md)
|
|
2668
3179
|
- [setFontFamily](functions/setFontFamily.md)
|
|
2669
3180
|
- [setTextAlign](functions/setTextAlign.md)
|
|
2670
3181
|
- [setTextColor](functions/setTextColor.md)
|
|
2671
|
-
- [textAlignmentAt](functions/textAlignmentAt.md)
|
|
2672
3182
|
|
|
2673
3183
|
---
|
|
2674
3184
|
|
|
@@ -2863,7 +3373,7 @@ Source: /api/advanced/formatting/functions/activeFontFamily.md
|
|
|
2863
3373
|
# Function: activeFontFamily()
|
|
2864
3374
|
|
|
2865
3375
|
```ts
|
|
2866
|
-
function activeFontFamily(
|
|
3376
|
+
function activeFontFamily(editor): string | null;
|
|
2867
3377
|
```
|
|
2868
3378
|
|
|
2869
3379
|
The font at the selection: its id, or null for none or a mix.
|
|
@@ -2872,7 +3382,7 @@ The font at the selection: its id, or null for none or a mix.
|
|
|
2872
3382
|
|
|
2873
3383
|
| Parameter | Type |
|
|
2874
3384
|
| ------ | ------ |
|
|
2875
|
-
| `
|
|
3385
|
+
| `editor` | [`Editor`](../../../core/interfaces/Editor.md) |
|
|
2876
3386
|
|
|
2877
3387
|
## Returns
|
|
2878
3388
|
|
|
@@ -2880,12 +3390,35 @@ The font at the selection: its id, or null for none or a mix.
|
|
|
2880
3390
|
|
|
2881
3391
|
---
|
|
2882
3392
|
|
|
3393
|
+
Source: /api/advanced/formatting/functions/activeTextAlign.md
|
|
3394
|
+
|
|
3395
|
+
# Function: activeTextAlign()
|
|
3396
|
+
|
|
3397
|
+
```ts
|
|
3398
|
+
function activeTextAlign(editor): TextAlignment | null;
|
|
3399
|
+
```
|
|
3400
|
+
|
|
3401
|
+
The alignment of the block that holds the selection (`'left'` when unset),
|
|
3402
|
+
or null when that block cannot be aligned.
|
|
3403
|
+
|
|
3404
|
+
## Parameters
|
|
3405
|
+
|
|
3406
|
+
| Parameter | Type |
|
|
3407
|
+
| ------ | ------ |
|
|
3408
|
+
| `editor` | [`Editor`](../../../core/interfaces/Editor.md) |
|
|
3409
|
+
|
|
3410
|
+
## Returns
|
|
3411
|
+
|
|
3412
|
+
[`TextAlignment`](../type-aliases/TextAlignment.md) \| `null`
|
|
3413
|
+
|
|
3414
|
+
---
|
|
3415
|
+
|
|
2883
3416
|
Source: /api/advanced/formatting/functions/activeTextColor.md
|
|
2884
3417
|
|
|
2885
3418
|
# Function: activeTextColor()
|
|
2886
3419
|
|
|
2887
3420
|
```ts
|
|
2888
|
-
function activeTextColor(
|
|
3421
|
+
function activeTextColor(editor): string | null;
|
|
2889
3422
|
```
|
|
2890
3423
|
|
|
2891
3424
|
The colour at the selection: its id, or null for none or a mix.
|
|
@@ -2894,7 +3427,7 @@ The colour at the selection: its id, or null for none or a mix.
|
|
|
2894
3427
|
|
|
2895
3428
|
| Parameter | Type |
|
|
2896
3429
|
| ------ | ------ |
|
|
2897
|
-
| `
|
|
3430
|
+
| `editor` | [`Editor`](../../../core/interfaces/Editor.md) |
|
|
2898
3431
|
|
|
2899
3432
|
## Returns
|
|
2900
3433
|
|
|
@@ -2968,28 +3501,6 @@ Set the colour of the selection (or of what is typed next); `null` removes it.
|
|
|
2968
3501
|
|
|
2969
3502
|
---
|
|
2970
3503
|
|
|
2971
|
-
Source: /api/advanced/formatting/functions/textAlignmentAt.md
|
|
2972
|
-
|
|
2973
|
-
# Function: textAlignmentAt()
|
|
2974
|
-
|
|
2975
|
-
```ts
|
|
2976
|
-
function textAlignmentAt(state): TextAlignment | null;
|
|
2977
|
-
```
|
|
2978
|
-
|
|
2979
|
-
The alignment of the block that holds the selection (`'left'` when unset).
|
|
2980
|
-
|
|
2981
|
-
## Parameters
|
|
2982
|
-
|
|
2983
|
-
| Parameter | Type |
|
|
2984
|
-
| ------ | ------ |
|
|
2985
|
-
| `state` | `EditorState` |
|
|
2986
|
-
|
|
2987
|
-
## Returns
|
|
2988
|
-
|
|
2989
|
-
[`TextAlignment`](../type-aliases/TextAlignment.md) \| `null`
|
|
2990
|
-
|
|
2991
|
-
---
|
|
2992
|
-
|
|
2993
3504
|
Source: /api/advanced/schema/reference.md
|
|
2994
3505
|
|
|
2995
3506
|
# @writeon/advanced/schema
|
|
@@ -3054,7 +3565,7 @@ The node types of advanced mode, without their behaviour: task lists,
|
|
|
3054
3565
|
code blocks, images, tables and mentions. Add it to `createEditor()` so documents that use these nodes
|
|
3055
3566
|
load and display everywhere (in basic mode the content stays visible and
|
|
3056
3567
|
its text editable), then turn on the behaviour with
|
|
3057
|
-
`editor.
|
|
3568
|
+
`editor.extend(() => import('@writeon/advanced'))`. Small, always loaded.
|
|
3058
3569
|
|
|
3059
3570
|
Use the same list on the server: `validate(doc, { extensions: [...basic(), advancedSchema()] })`.
|
|
3060
3571
|
|
|
@@ -3117,8 +3628,9 @@ migrations, URL rules and helpers.
|
|
|
3117
3628
|
## Type Aliases
|
|
3118
3629
|
|
|
3119
3630
|
- [Command](type-aliases/Command.md)
|
|
3120
|
-
- [
|
|
3631
|
+
- [EditorExtendSource](type-aliases/EditorExtendSource.md)
|
|
3121
3632
|
- [EditorLabel](type-aliases/EditorLabel.md)
|
|
3633
|
+
- [HeadingLevel](type-aliases/HeadingLevel.md)
|
|
3122
3634
|
|
|
3123
3635
|
## Variables
|
|
3124
3636
|
|
|
@@ -3224,6 +3736,7 @@ An editor instance, created by `createEditor()`.
|
|
|
3224
3736
|
|
|
3225
3737
|
| Property | Modifier | Type | Description |
|
|
3226
3738
|
| ------ | ------ | ------ | ------ |
|
|
3739
|
+
| <a id="property-isdestroyed"></a> `isDestroyed` | `readonly` | `boolean` | Whether `destroy()` was called. UI that defers work (a timer, a microtask) checks it before reading the editor again. |
|
|
3227
3740
|
| <a id="property-isempty"></a> `isEmpty` | `readonly` | `boolean` | Whether the document is a single empty text block. |
|
|
3228
3741
|
| <a id="property-pm"></a> `pm` | `readonly` | \{ `schema`: `Schema`; `state`: `EditorState`; `view`: `EditorView` \| `null`; \} | Direct access to ProseMirror. **Not a stable API**: it may change in any minor release. |
|
|
3229
3742
|
| `pm.schema` | `readonly` | `Schema` | The schema built from the extensions. |
|
|
@@ -3280,12 +3793,34 @@ Release everything. The editor cannot be used afterwards.
|
|
|
3280
3793
|
|
|
3281
3794
|
***
|
|
3282
3795
|
|
|
3283
|
-
### enable()
|
|
3796
|
+
### ~~enable()~~
|
|
3284
3797
|
|
|
3285
3798
|
```ts
|
|
3286
3799
|
enable(source): Promise<void>;
|
|
3287
3800
|
```
|
|
3288
3801
|
|
|
3802
|
+
#### Parameters
|
|
3803
|
+
|
|
3804
|
+
| Parameter | Type |
|
|
3805
|
+
| ------ | ------ |
|
|
3806
|
+
| `source` | [`EditorExtendSource`](../type-aliases/EditorExtendSource.md) |
|
|
3807
|
+
|
|
3808
|
+
#### Returns
|
|
3809
|
+
|
|
3810
|
+
`Promise`\<`void`\>
|
|
3811
|
+
|
|
3812
|
+
#### Deprecated
|
|
3813
|
+
|
|
3814
|
+
Renamed to `extend()`, which this calls. Removed in 1.0.
|
|
3815
|
+
|
|
3816
|
+
***
|
|
3817
|
+
|
|
3818
|
+
### extend()
|
|
3819
|
+
|
|
3820
|
+
```ts
|
|
3821
|
+
extend(source): Promise<void>;
|
|
3822
|
+
```
|
|
3823
|
+
|
|
3289
3824
|
Add behaviour (commands' keymaps, input rules, plugins) from more
|
|
3290
3825
|
extensions to the running editor, typically loaded on demand. The
|
|
3291
3826
|
document, undo history and selection are kept. Their nodes and marks
|
|
@@ -3296,7 +3831,7 @@ must already be in the schema: pass the schema extension (e.g.
|
|
|
3296
3831
|
|
|
3297
3832
|
| Parameter | Type |
|
|
3298
3833
|
| ------ | ------ |
|
|
3299
|
-
| `source` | [`
|
|
3834
|
+
| `source` | [`EditorExtendSource`](../type-aliases/EditorExtendSource.md) |
|
|
3300
3835
|
|
|
3301
3836
|
#### Returns
|
|
3302
3837
|
|
|
@@ -3305,7 +3840,7 @@ must already be in the schema: pass the schema extension (e.g.
|
|
|
3305
3840
|
#### Example
|
|
3306
3841
|
|
|
3307
3842
|
```ts
|
|
3308
|
-
await editor.
|
|
3843
|
+
await editor.extend(() => import('@writeon/advanced'))
|
|
3309
3844
|
```
|
|
3310
3845
|
|
|
3311
3846
|
***
|
|
@@ -3530,7 +4065,7 @@ Options for `createEditor()`.
|
|
|
3530
4065
|
| <a id="property-content"></a> `content?` | [`DocJSON`](DocJSON.md) \| `null` | Initial document. Omit for an empty document. |
|
|
3531
4066
|
| <a id="property-editable"></a> `editable?` | `boolean` | Whether the user can edit. Defaults to `true`. |
|
|
3532
4067
|
| <a id="property-element"></a> `element?` | `HTMLElement` | Element to mount into. Omit to create the editor first and call `mount()` later. |
|
|
3533
|
-
| <a id="property-extensions"></a> `extensions` | [`Extension`](Extension.md)[] | Extensions that make up the editor, usually a preset such as `basic()`. |
|
|
4068
|
+
| <a id="property-extensions"></a> `extensions` | readonly [`Extension`](Extension.md)[] | Extensions that make up the editor, usually a preset such as `basic()`. |
|
|
3534
4069
|
| <a id="property-label"></a> `label` | [`EditorLabel`](../type-aliases/EditorLabel.md) | Accessible name: an `aria-label` string or the id of a labelling element. |
|
|
3535
4070
|
| <a id="property-onblur"></a> `onBlur?` | (`editor`) => `void` | Called when the editable area loses focus, also when it is unmounted while focused. |
|
|
3536
4071
|
| <a id="property-onchange"></a> `onChange?` | (`editor`) => `void` | Called after every change to the document. |
|
|
@@ -3666,12 +4201,12 @@ pass it to `editor.run()` or `editor.can()`.
|
|
|
3666
4201
|
|
|
3667
4202
|
---
|
|
3668
4203
|
|
|
3669
|
-
Source: /api/core/type-aliases/
|
|
4204
|
+
Source: /api/core/type-aliases/EditorExtendSource.md
|
|
3670
4205
|
|
|
3671
|
-
# Type Alias:
|
|
4206
|
+
# Type Alias: EditorExtendSource
|
|
3672
4207
|
|
|
3673
4208
|
```ts
|
|
3674
|
-
type
|
|
4209
|
+
type EditorExtendSource =
|
|
3675
4210
|
| readonly Extension[]
|
|
3676
4211
|
| (() => Promise<
|
|
3677
4212
|
| readonly Extension[]
|
|
@@ -3680,7 +4215,7 @@ type EditorEnableSource =
|
|
|
3680
4215
|
}>);
|
|
3681
4216
|
```
|
|
3682
4217
|
|
|
3683
|
-
Extensions to
|
|
4218
|
+
Extensions to add, or a loader for them (a module whose default export is the list works too).
|
|
3684
4219
|
|
|
3685
4220
|
---
|
|
3686
4221
|
|
|
@@ -3722,6 +4257,18 @@ Id of the element that labels the editor (`aria-labelledby`).
|
|
|
3722
4257
|
|
|
3723
4258
|
---
|
|
3724
4259
|
|
|
4260
|
+
Source: /api/core/type-aliases/HeadingLevel.md
|
|
4261
|
+
|
|
4262
|
+
# Type Alias: HeadingLevel
|
|
4263
|
+
|
|
4264
|
+
```ts
|
|
4265
|
+
type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
4266
|
+
```
|
|
4267
|
+
|
|
4268
|
+
A heading level, `1` (`<h1>`) to `6` (`<h6>`).
|
|
4269
|
+
|
|
4270
|
+
---
|
|
4271
|
+
|
|
3725
4272
|
Source: /api/core/variables/DEFAULT_PROTOCOLS.md
|
|
3726
4273
|
|
|
3727
4274
|
# Variable: DEFAULT\_PROTOCOLS
|
|
@@ -3910,6 +4457,12 @@ lists, links, history.
|
|
|
3910
4457
|
- [undo](functions/undo.md)
|
|
3911
4458
|
- [unsetLink](functions/unsetLink.md)
|
|
3912
4459
|
|
|
4460
|
+
## References
|
|
4461
|
+
|
|
4462
|
+
### HeadingLevel
|
|
4463
|
+
|
|
4464
|
+
Re-exports [HeadingLevel](../type-aliases/HeadingLevel.md)
|
|
4465
|
+
|
|
3913
4466
|
---
|
|
3914
4467
|
|
|
3915
4468
|
Source: /api/core/commands/interfaces/LinkAttrs.md
|
|
@@ -4117,7 +4670,7 @@ Turn the selected blocks into headings of `level`. Requires the `heading` extens
|
|
|
4117
4670
|
|
|
4118
4671
|
| Parameter | Type |
|
|
4119
4672
|
| ------ | ------ |
|
|
4120
|
-
| `level` | `
|
|
4673
|
+
| `level` | [`HeadingLevel`](../../type-aliases/HeadingLevel.md) |
|
|
4121
4674
|
|
|
4122
4675
|
## Returns
|
|
4123
4676
|
|
|
@@ -4212,7 +4765,7 @@ Heading of `level` if the block is not one already, otherwise back to a paragrap
|
|
|
4212
4765
|
|
|
4213
4766
|
| Parameter | Type |
|
|
4214
4767
|
| ------ | ------ |
|
|
4215
|
-
| `level` | `
|
|
4768
|
+
| `level` | [`HeadingLevel`](../../type-aliases/HeadingLevel.md) |
|
|
4216
4769
|
|
|
4217
4770
|
## Returns
|
|
4218
4771
|
|
|
@@ -4509,305 +5062,756 @@ Options for the `heading` extension.
|
|
|
4509
5062
|
|
|
4510
5063
|
| Property | Type | Description |
|
|
4511
5064
|
| ------ | ------ | ------ |
|
|
4512
|
-
| <a id="property-levels"></a> `levels?` | readonly `
|
|
5065
|
+
| <a id="property-levels"></a> `levels?` | readonly [`HeadingLevel`](../../type-aliases/HeadingLevel.md)[] | Heading levels the user can create. Default `[1, 2, 3]`. |
|
|
5066
|
+
|
|
5067
|
+
---
|
|
5068
|
+
|
|
5069
|
+
Source: /api/core/extensions/interfaces/HistoryOptions.md
|
|
5070
|
+
|
|
5071
|
+
# Interface: HistoryOptions
|
|
5072
|
+
|
|
5073
|
+
Options for the `history` extension.
|
|
5074
|
+
|
|
5075
|
+
## Properties
|
|
5076
|
+
|
|
5077
|
+
| Property | Type | Description |
|
|
5078
|
+
| ------ | ------ | ------ |
|
|
5079
|
+
| <a id="property-depth"></a> `depth?` | `number` | How many undo steps to keep. Default 100. |
|
|
5080
|
+
| <a id="property-newgroupdelay"></a> `newGroupDelay?` | `number` | Changes closer together than this (ms) merge into one undo step. Default 500. |
|
|
5081
|
+
|
|
5082
|
+
---
|
|
5083
|
+
|
|
5084
|
+
Source: /api/core/extensions/interfaces/LinkOptions.md
|
|
5085
|
+
|
|
5086
|
+
# Interface: LinkOptions
|
|
5087
|
+
|
|
5088
|
+
Options for the `link` extension.
|
|
5089
|
+
|
|
5090
|
+
## Properties
|
|
5091
|
+
|
|
5092
|
+
| Property | Type | Description |
|
|
5093
|
+
| ------ | ------ | ------ |
|
|
5094
|
+
| <a id="property-protocols"></a> `protocols?` | readonly `string`[] | Allowed URL protocols. Default: `http`, `https`, `mailto`, `tel`. |
|
|
5095
|
+
|
|
5096
|
+
---
|
|
5097
|
+
|
|
5098
|
+
Source: /api/core/extensions/variables/blockquote.md
|
|
5099
|
+
|
|
5100
|
+
# Variable: blockquote
|
|
5101
|
+
|
|
5102
|
+
```ts
|
|
5103
|
+
const blockquote: () => Extension;
|
|
5104
|
+
```
|
|
5105
|
+
|
|
5106
|
+
Block quotes. `Mod-Shift-b` or `> `.
|
|
5107
|
+
|
|
5108
|
+
## Returns
|
|
5109
|
+
|
|
5110
|
+
[`Extension`](../../interfaces/Extension.md)
|
|
5111
|
+
|
|
5112
|
+
---
|
|
5113
|
+
|
|
5114
|
+
Source: /api/core/extensions/variables/bold.md
|
|
5115
|
+
|
|
5116
|
+
# Variable: bold
|
|
5117
|
+
|
|
5118
|
+
```ts
|
|
5119
|
+
const bold: () => Extension;
|
|
5120
|
+
```
|
|
5121
|
+
|
|
5122
|
+
Bold text. `Mod-b`, `**text**` or `__text__`.
|
|
5123
|
+
|
|
5124
|
+
## Returns
|
|
5125
|
+
|
|
5126
|
+
[`Extension`](../../interfaces/Extension.md)
|
|
5127
|
+
|
|
5128
|
+
---
|
|
5129
|
+
|
|
5130
|
+
Source: /api/core/extensions/variables/code.md
|
|
5131
|
+
|
|
5132
|
+
# Variable: code
|
|
5133
|
+
|
|
5134
|
+
```ts
|
|
5135
|
+
const code: () => Extension;
|
|
5136
|
+
```
|
|
5137
|
+
|
|
5138
|
+
Inline code. `Mod-e` or `` `text` ``. No other marks inside code.
|
|
5139
|
+
|
|
5140
|
+
## Returns
|
|
5141
|
+
|
|
5142
|
+
[`Extension`](../../interfaces/Extension.md)
|
|
5143
|
+
|
|
5144
|
+
---
|
|
5145
|
+
|
|
5146
|
+
Source: /api/core/extensions/variables/hardBreak.md
|
|
5147
|
+
|
|
5148
|
+
# Variable: hardBreak
|
|
5149
|
+
|
|
5150
|
+
```ts
|
|
5151
|
+
const hardBreak: () => Extension;
|
|
5152
|
+
```
|
|
5153
|
+
|
|
5154
|
+
Line break inside a block. `Shift-Enter` or `Mod-Enter`.
|
|
5155
|
+
|
|
5156
|
+
## Returns
|
|
5157
|
+
|
|
5158
|
+
[`Extension`](../../interfaces/Extension.md)
|
|
5159
|
+
|
|
5160
|
+
---
|
|
5161
|
+
|
|
5162
|
+
Source: /api/core/extensions/variables/heading.md
|
|
5163
|
+
|
|
5164
|
+
# Variable: heading
|
|
5165
|
+
|
|
5166
|
+
```ts
|
|
5167
|
+
const heading: (options?) => Extension;
|
|
5168
|
+
```
|
|
5169
|
+
|
|
5170
|
+
Headings. `Mod-Alt-1…6`, `# ` … `###### `; `Mod-Alt-0` back to paragraph.
|
|
5171
|
+
|
|
5172
|
+
## Parameters
|
|
5173
|
+
|
|
5174
|
+
| Parameter | Type |
|
|
5175
|
+
| ------ | ------ |
|
|
5176
|
+
| `options?` | [`HeadingOptions`](../interfaces/HeadingOptions.md) |
|
|
5177
|
+
|
|
5178
|
+
## Returns
|
|
5179
|
+
|
|
5180
|
+
[`Extension`](../../interfaces/Extension.md)
|
|
5181
|
+
|
|
5182
|
+
---
|
|
5183
|
+
|
|
5184
|
+
Source: /api/core/extensions/variables/history.md
|
|
5185
|
+
|
|
5186
|
+
# Variable: history
|
|
5187
|
+
|
|
5188
|
+
```ts
|
|
5189
|
+
const history: (options?) => Extension;
|
|
5190
|
+
```
|
|
5191
|
+
|
|
5192
|
+
Undo and redo. `Mod-z`, `Mod-Shift-z` / `Mod-y`; `Backspace` right after a shortcut undoes it.
|
|
5193
|
+
|
|
5194
|
+
## Parameters
|
|
5195
|
+
|
|
5196
|
+
| Parameter | Type |
|
|
5197
|
+
| ------ | ------ |
|
|
5198
|
+
| `options?` | [`HistoryOptions`](../interfaces/HistoryOptions.md) |
|
|
5199
|
+
|
|
5200
|
+
## Returns
|
|
5201
|
+
|
|
5202
|
+
[`Extension`](../../interfaces/Extension.md)
|
|
5203
|
+
|
|
5204
|
+
---
|
|
5205
|
+
|
|
5206
|
+
Source: /api/core/extensions/variables/italic.md
|
|
5207
|
+
|
|
5208
|
+
# Variable: italic
|
|
5209
|
+
|
|
5210
|
+
```ts
|
|
5211
|
+
const italic: () => Extension;
|
|
5212
|
+
```
|
|
5213
|
+
|
|
5214
|
+
Italic text. `Mod-i`, `*text*` or `_text_`.
|
|
5215
|
+
|
|
5216
|
+
## Returns
|
|
5217
|
+
|
|
5218
|
+
[`Extension`](../../interfaces/Extension.md)
|
|
5219
|
+
|
|
5220
|
+
---
|
|
5221
|
+
|
|
5222
|
+
Source: /api/core/extensions/variables/link.md
|
|
5223
|
+
|
|
5224
|
+
# Variable: link
|
|
5225
|
+
|
|
5226
|
+
```ts
|
|
5227
|
+
const link: (options?) => Extension;
|
|
5228
|
+
```
|
|
5229
|
+
|
|
5230
|
+
Links. Unsafe URLs (such as `javascript:`) are dropped on paste and refused
|
|
5231
|
+
by `setLink()`. Links never get `target="_blank"`: opening new windows
|
|
5232
|
+
without warning is an accessibility problem.
|
|
5233
|
+
|
|
5234
|
+
## Parameters
|
|
5235
|
+
|
|
5236
|
+
| Parameter | Type |
|
|
5237
|
+
| ------ | ------ |
|
|
5238
|
+
| `options?` | [`LinkOptions`](../interfaces/LinkOptions.md) |
|
|
5239
|
+
|
|
5240
|
+
## Returns
|
|
5241
|
+
|
|
5242
|
+
[`Extension`](../../interfaces/Extension.md)
|
|
5243
|
+
|
|
5244
|
+
---
|
|
5245
|
+
|
|
5246
|
+
Source: /api/core/extensions/variables/list.md
|
|
5247
|
+
|
|
5248
|
+
# Variable: list
|
|
5249
|
+
|
|
5250
|
+
```ts
|
|
5251
|
+
const list: () => Extension;
|
|
5252
|
+
```
|
|
5253
|
+
|
|
5254
|
+
Bullet and ordered lists. `Mod-Shift-8` / `Mod-Shift-7`, `- ` / `1. `, `Tab` / `Shift-Tab` to nest.
|
|
5255
|
+
|
|
5256
|
+
## Returns
|
|
5257
|
+
|
|
5258
|
+
[`Extension`](../../interfaces/Extension.md)
|
|
5259
|
+
|
|
5260
|
+
---
|
|
5261
|
+
|
|
5262
|
+
Source: /api/core/extensions/variables/strike.md
|
|
5263
|
+
|
|
5264
|
+
# Variable: strike
|
|
5265
|
+
|
|
5266
|
+
```ts
|
|
5267
|
+
const strike: () => Extension;
|
|
5268
|
+
```
|
|
5269
|
+
|
|
5270
|
+
Strikethrough. `Mod-Shift-s` or `~~text~~`.
|
|
5271
|
+
|
|
5272
|
+
## Returns
|
|
5273
|
+
|
|
5274
|
+
[`Extension`](../../interfaces/Extension.md)
|
|
5275
|
+
|
|
5276
|
+
---
|
|
5277
|
+
|
|
5278
|
+
Source: /api/core/extensions/variables/underline.md
|
|
5279
|
+
|
|
5280
|
+
# Variable: underline
|
|
5281
|
+
|
|
5282
|
+
```ts
|
|
5283
|
+
const underline: () => Extension;
|
|
5284
|
+
```
|
|
5285
|
+
|
|
5286
|
+
Underlined text. `Mod-u`.
|
|
5287
|
+
|
|
5288
|
+
## Returns
|
|
5289
|
+
|
|
5290
|
+
[`Extension`](../../interfaces/Extension.md)
|
|
5291
|
+
|
|
5292
|
+
---
|
|
5293
|
+
|
|
5294
|
+
Source: /api/core/presets/reference.md
|
|
5295
|
+
|
|
5296
|
+
# @writeon/core/presets
|
|
5297
|
+
|
|
5298
|
+
The `basic()` preset: everything a typical text field needs, each part
|
|
5299
|
+
configurable or switchable off.
|
|
5300
|
+
|
|
5301
|
+
## Interfaces
|
|
5302
|
+
|
|
5303
|
+
- [BasicOptions](interfaces/BasicOptions.md)
|
|
5304
|
+
|
|
5305
|
+
## Functions
|
|
5306
|
+
|
|
5307
|
+
- [basic](functions/basic.md)
|
|
5308
|
+
|
|
5309
|
+
---
|
|
5310
|
+
|
|
5311
|
+
Source: /api/core/presets/interfaces/BasicOptions.md
|
|
5312
|
+
|
|
5313
|
+
# Interface: BasicOptions
|
|
5314
|
+
|
|
5315
|
+
Per-extension settings for `basic()`. `false` leaves an extension out.
|
|
5316
|
+
|
|
5317
|
+
## Properties
|
|
5318
|
+
|
|
5319
|
+
| Property | Type | Description |
|
|
5320
|
+
| ------ | ------ | ------ |
|
|
5321
|
+
| <a id="property-blockquote"></a> `blockquote?` | `false` | Blockquotes. |
|
|
5322
|
+
| <a id="property-bold"></a> `bold?` | `false` | Bold. |
|
|
5323
|
+
| <a id="property-code"></a> `code?` | `false` | Inline code. |
|
|
5324
|
+
| <a id="property-hardbreak"></a> `hardBreak?` | `false` | Line breaks (`Shift-Enter`). |
|
|
5325
|
+
| <a id="property-heading"></a> `heading?` | \| `false` \| [`HeadingOptions`](../../extensions/interfaces/HeadingOptions.md) | Headings, or their options. |
|
|
5326
|
+
| <a id="property-history"></a> `history?` | \| `false` \| [`HistoryOptions`](../../extensions/interfaces/HistoryOptions.md) | Undo and redo, or their options. |
|
|
5327
|
+
| <a id="property-italic"></a> `italic?` | `false` | Italic. |
|
|
5328
|
+
| <a id="property-link"></a> `link?` | `false` \| [`LinkOptions`](../../extensions/interfaces/LinkOptions.md) | Links, or their options. |
|
|
5329
|
+
| <a id="property-list"></a> `list?` | `false` | Bullet and ordered lists. |
|
|
5330
|
+
| <a id="property-strike"></a> `strike?` | `false` | Strikethrough. |
|
|
5331
|
+
| <a id="property-underline"></a> `underline?` | `false` | Underline. |
|
|
5332
|
+
|
|
5333
|
+
---
|
|
5334
|
+
|
|
5335
|
+
Source: /api/core/presets/functions/basic.md
|
|
5336
|
+
|
|
5337
|
+
# Function: basic()
|
|
5338
|
+
|
|
5339
|
+
```ts
|
|
5340
|
+
function basic(options?): Extension[];
|
|
5341
|
+
```
|
|
5342
|
+
|
|
5343
|
+
The basic editor: paragraphs, headings, bold, italic, underline, strike,
|
|
5344
|
+
inline code, links, lists, blockquotes, line breaks and undo/redo.
|
|
5345
|
+
|
|
5346
|
+
## Parameters
|
|
5347
|
+
|
|
5348
|
+
| Parameter | Type |
|
|
5349
|
+
| ------ | ------ |
|
|
5350
|
+
| `options?` | [`BasicOptions`](../interfaces/BasicOptions.md) |
|
|
5351
|
+
|
|
5352
|
+
## Returns
|
|
5353
|
+
|
|
5354
|
+
[`Extension`](../../interfaces/Extension.md)[]
|
|
5355
|
+
|
|
5356
|
+
## Example
|
|
5357
|
+
|
|
5358
|
+
```ts
|
|
5359
|
+
basic() // everything, defaults
|
|
5360
|
+
basic({ strike: false }) // without strikethrough
|
|
5361
|
+
basic({ heading: { levels: [2, 3] } }) // only H2 and H3
|
|
5362
|
+
basic({ link: { protocols: ['https'] } }) // https links only
|
|
5363
|
+
```
|
|
5364
|
+
|
|
5365
|
+
---
|
|
5366
|
+
|
|
5367
|
+
Source: /api/element/reference.md
|
|
5368
|
+
|
|
5369
|
+
# @writeon/element
|
|
5370
|
+
|
|
5371
|
+
`<writeon-editor>`: Writeon as a web component and form field, for plain
|
|
5372
|
+
HTML, server-rendered pages (Laravel Blade, Symfony Twig, Django…) and any
|
|
5373
|
+
framework. Importing this module registers the element.
|
|
5374
|
+
|
|
5375
|
+
## Example
|
|
5376
|
+
|
|
5377
|
+
```html
|
|
5378
|
+
<link rel="stylesheet" href="…/@writeon/element/dist/style.css" />
|
|
5379
|
+
<script type="module">import '@writeon/element'</script>
|
|
5380
|
+
|
|
5381
|
+
<writeon-editor label="Article text">
|
|
5382
|
+
<textarea name="body">{{ $post->body }}</textarea>
|
|
5383
|
+
</writeon-editor>
|
|
5384
|
+
```
|
|
5385
|
+
|
|
5386
|
+
## Classes
|
|
5387
|
+
|
|
5388
|
+
- [WriteonEditor](classes/WriteonEditor.md)
|
|
5389
|
+
|
|
5390
|
+
## Type Aliases
|
|
5391
|
+
|
|
5392
|
+
- [WriteonFormat](type-aliases/WriteonFormat.md)
|
|
5393
|
+
|
|
5394
|
+
## Functions
|
|
5395
|
+
|
|
5396
|
+
- [defineWriteonEditor](functions/defineWriteonEditor.md)
|
|
5397
|
+
|
|
5398
|
+
---
|
|
5399
|
+
|
|
5400
|
+
Source: /api/element/classes/WriteonEditor.md
|
|
5401
|
+
|
|
5402
|
+
# Class: WriteonEditor
|
|
5403
|
+
|
|
5404
|
+
`<writeon-editor>`: the editor with the default kit, as a form field.
|
|
5405
|
+
|
|
5406
|
+
Put a `<textarea>` inside: it is the field until the element starts (and
|
|
5407
|
+
for good if JavaScript does not load), and it gives the name, the initial
|
|
5408
|
+
value and `required`. Its text is never run as HTML while the page loads.
|
|
5409
|
+
|
|
5410
|
+
```html
|
|
5411
|
+
<writeon-editor label="Article text">
|
|
5412
|
+
<textarea name="body"><p>Hello</p></textarea>
|
|
5413
|
+
</writeon-editor>
|
|
5414
|
+
```
|
|
5415
|
+
|
|
5416
|
+
The submitted value is HTML (or JSON with `format="json"`). Until the
|
|
5417
|
+
user changes the text, the form submits the original value unchanged.
|
|
5418
|
+
Always validate or sanitize it on the server.
|
|
5419
|
+
|
|
5420
|
+
## Extends
|
|
5421
|
+
|
|
5422
|
+
- `Base`
|
|
5423
|
+
|
|
5424
|
+
## Constructors
|
|
5425
|
+
|
|
5426
|
+
### Constructor
|
|
5427
|
+
|
|
5428
|
+
```ts
|
|
5429
|
+
new WriteonEditor(): WriteonEditor;
|
|
5430
|
+
```
|
|
5431
|
+
|
|
5432
|
+
#### Returns
|
|
5433
|
+
|
|
5434
|
+
`WriteonEditor`
|
|
5435
|
+
|
|
5436
|
+
#### Inherited from
|
|
5437
|
+
|
|
5438
|
+
`Base.constructor`
|
|
5439
|
+
|
|
5440
|
+
## Properties
|
|
5441
|
+
|
|
5442
|
+
### formAssociated
|
|
5443
|
+
|
|
5444
|
+
```ts
|
|
5445
|
+
static formAssociated: boolean = true;
|
|
5446
|
+
```
|
|
5447
|
+
|
|
5448
|
+
Takes part in forms like a built-in field (ElementInternals).
|
|
5449
|
+
|
|
5450
|
+
***
|
|
5451
|
+
|
|
5452
|
+
### observedAttributes
|
|
5453
|
+
|
|
5454
|
+
```ts
|
|
5455
|
+
static observedAttributes: string[];
|
|
5456
|
+
```
|
|
5457
|
+
|
|
5458
|
+
Attributes that update a running editor.
|
|
5459
|
+
|
|
5460
|
+
***
|
|
5461
|
+
|
|
5462
|
+
### upload
|
|
5463
|
+
|
|
5464
|
+
```ts
|
|
5465
|
+
upload: UploadFn | undefined;
|
|
5466
|
+
```
|
|
5467
|
+
|
|
5468
|
+
Upload function for images when `advanced` is on. `upload-url` sets a simple one.
|
|
5469
|
+
|
|
5470
|
+
## Accessors
|
|
5471
|
+
|
|
5472
|
+
### disabled
|
|
5473
|
+
|
|
5474
|
+
#### Get Signature
|
|
5475
|
+
|
|
5476
|
+
```ts
|
|
5477
|
+
get disabled(): boolean;
|
|
5478
|
+
```
|
|
5479
|
+
|
|
5480
|
+
Read-only and left out of the form, like `disabled` on a textarea. Reflects the attribute.
|
|
5481
|
+
|
|
5482
|
+
##### Returns
|
|
5483
|
+
|
|
5484
|
+
`boolean`
|
|
5485
|
+
|
|
5486
|
+
#### Set Signature
|
|
5487
|
+
|
|
5488
|
+
```ts
|
|
5489
|
+
set disabled(value): void;
|
|
5490
|
+
```
|
|
5491
|
+
|
|
5492
|
+
Sets or removes the `disabled` attribute.
|
|
5493
|
+
|
|
5494
|
+
##### Parameters
|
|
5495
|
+
|
|
5496
|
+
| Parameter | Type |
|
|
5497
|
+
| ------ | ------ |
|
|
5498
|
+
| `value` | `boolean` |
|
|
5499
|
+
|
|
5500
|
+
##### Returns
|
|
5501
|
+
|
|
5502
|
+
`void`
|
|
5503
|
+
|
|
5504
|
+
***
|
|
5505
|
+
|
|
5506
|
+
### editor
|
|
4513
5507
|
|
|
4514
|
-
|
|
5508
|
+
#### Get Signature
|
|
4515
5509
|
|
|
4516
|
-
|
|
5510
|
+
```ts
|
|
5511
|
+
get editor(): Editor | null;
|
|
5512
|
+
```
|
|
4517
5513
|
|
|
4518
|
-
|
|
5514
|
+
The editor, once the element is connected. Use it for commands and state.
|
|
4519
5515
|
|
|
4520
|
-
|
|
5516
|
+
##### Returns
|
|
4521
5517
|
|
|
4522
|
-
|
|
5518
|
+
[`Editor`](../../core/interfaces/Editor.md) \| `null`
|
|
4523
5519
|
|
|
4524
|
-
|
|
4525
|
-
| ------ | ------ | ------ |
|
|
4526
|
-
| <a id="property-depth"></a> `depth?` | `number` | How many undo steps to keep. Default 100. |
|
|
4527
|
-
| <a id="property-newgroupdelay"></a> `newGroupDelay?` | `number` | Changes closer together than this (ms) merge into one undo step. Default 500. |
|
|
5520
|
+
***
|
|
4528
5521
|
|
|
4529
|
-
|
|
5522
|
+
### form
|
|
4530
5523
|
|
|
4531
|
-
|
|
5524
|
+
#### Get Signature
|
|
4532
5525
|
|
|
4533
|
-
|
|
5526
|
+
```ts
|
|
5527
|
+
get form(): HTMLFormElement | null;
|
|
5528
|
+
```
|
|
4534
5529
|
|
|
4535
|
-
|
|
5530
|
+
The form the element belongs to.
|
|
4536
5531
|
|
|
4537
|
-
|
|
5532
|
+
##### Returns
|
|
4538
5533
|
|
|
4539
|
-
|
|
4540
|
-
| ------ | ------ | ------ |
|
|
4541
|
-
| <a id="property-protocols"></a> `protocols?` | readonly `string`[] | Allowed URL protocols. Default: `http`, `https`, `mailto`, `tel`. |
|
|
5534
|
+
`HTMLFormElement` \| `null`
|
|
4542
5535
|
|
|
4543
|
-
|
|
5536
|
+
***
|
|
4544
5537
|
|
|
4545
|
-
|
|
5538
|
+
### format
|
|
4546
5539
|
|
|
4547
|
-
|
|
5540
|
+
#### Get Signature
|
|
4548
5541
|
|
|
4549
5542
|
```ts
|
|
4550
|
-
|
|
5543
|
+
get format(): WriteonFormat;
|
|
4551
5544
|
```
|
|
4552
5545
|
|
|
4553
|
-
|
|
5546
|
+
`html` (default) or `json`: what `value` and the form use.
|
|
4554
5547
|
|
|
4555
|
-
|
|
5548
|
+
##### Returns
|
|
4556
5549
|
|
|
4557
|
-
[`
|
|
5550
|
+
[`WriteonFormat`](../type-aliases/WriteonFormat.md)
|
|
4558
5551
|
|
|
4559
|
-
|
|
5552
|
+
***
|
|
4560
5553
|
|
|
4561
|
-
|
|
5554
|
+
### labels
|
|
4562
5555
|
|
|
4563
|
-
|
|
5556
|
+
#### Get Signature
|
|
4564
5557
|
|
|
4565
5558
|
```ts
|
|
4566
|
-
|
|
5559
|
+
get labels(): NodeList;
|
|
4567
5560
|
```
|
|
4568
5561
|
|
|
4569
|
-
|
|
5562
|
+
The `<label>` elements of the field, as on a built-in field.
|
|
4570
5563
|
|
|
4571
|
-
|
|
5564
|
+
##### Returns
|
|
4572
5565
|
|
|
4573
|
-
|
|
5566
|
+
`NodeList`
|
|
4574
5567
|
|
|
4575
|
-
|
|
5568
|
+
***
|
|
4576
5569
|
|
|
4577
|
-
|
|
5570
|
+
### name
|
|
4578
5571
|
|
|
4579
|
-
|
|
5572
|
+
#### Get Signature
|
|
4580
5573
|
|
|
4581
5574
|
```ts
|
|
4582
|
-
|
|
5575
|
+
get name(): string | null;
|
|
4583
5576
|
```
|
|
4584
5577
|
|
|
4585
|
-
|
|
5578
|
+
The form field name, from `name` or the textarea's.
|
|
4586
5579
|
|
|
4587
|
-
|
|
5580
|
+
##### Returns
|
|
4588
5581
|
|
|
4589
|
-
|
|
5582
|
+
`string` \| `null`
|
|
4590
5583
|
|
|
4591
|
-
|
|
5584
|
+
***
|
|
4592
5585
|
|
|
4593
|
-
|
|
5586
|
+
### readOnly
|
|
4594
5587
|
|
|
4595
|
-
|
|
5588
|
+
#### Get Signature
|
|
4596
5589
|
|
|
4597
5590
|
```ts
|
|
4598
|
-
|
|
5591
|
+
get readOnly(): boolean;
|
|
4599
5592
|
```
|
|
4600
5593
|
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
## Returns
|
|
4604
|
-
|
|
4605
|
-
[`Extension`](../../interfaces/Extension.md)
|
|
5594
|
+
Not editable, but still sent with the form. Reflects the `readonly` attribute.
|
|
4606
5595
|
|
|
4607
|
-
|
|
5596
|
+
##### Returns
|
|
4608
5597
|
|
|
4609
|
-
|
|
5598
|
+
`boolean`
|
|
4610
5599
|
|
|
4611
|
-
|
|
5600
|
+
#### Set Signature
|
|
4612
5601
|
|
|
4613
5602
|
```ts
|
|
4614
|
-
|
|
5603
|
+
set readOnly(value): void;
|
|
4615
5604
|
```
|
|
4616
5605
|
|
|
4617
|
-
|
|
5606
|
+
Sets or removes the `readonly` attribute.
|
|
4618
5607
|
|
|
4619
|
-
|
|
5608
|
+
##### Parameters
|
|
4620
5609
|
|
|
4621
5610
|
| Parameter | Type |
|
|
4622
5611
|
| ------ | ------ |
|
|
4623
|
-
| `
|
|
5612
|
+
| `value` | `boolean` |
|
|
4624
5613
|
|
|
4625
|
-
|
|
5614
|
+
##### Returns
|
|
4626
5615
|
|
|
4627
|
-
|
|
5616
|
+
`void`
|
|
4628
5617
|
|
|
4629
|
-
|
|
5618
|
+
***
|
|
4630
5619
|
|
|
4631
|
-
|
|
5620
|
+
### required
|
|
4632
5621
|
|
|
4633
|
-
|
|
5622
|
+
#### Get Signature
|
|
4634
5623
|
|
|
4635
5624
|
```ts
|
|
4636
|
-
|
|
5625
|
+
get required(): boolean;
|
|
4637
5626
|
```
|
|
4638
5627
|
|
|
4639
|
-
|
|
5628
|
+
An empty editor blocks the submit. Reflects the attribute.
|
|
4640
5629
|
|
|
4641
|
-
|
|
5630
|
+
##### Returns
|
|
5631
|
+
|
|
5632
|
+
`boolean`
|
|
5633
|
+
|
|
5634
|
+
#### Set Signature
|
|
5635
|
+
|
|
5636
|
+
```ts
|
|
5637
|
+
set required(value): void;
|
|
5638
|
+
```
|
|
5639
|
+
|
|
5640
|
+
Sets or removes the `required` attribute.
|
|
5641
|
+
|
|
5642
|
+
##### Parameters
|
|
4642
5643
|
|
|
4643
5644
|
| Parameter | Type |
|
|
4644
5645
|
| ------ | ------ |
|
|
4645
|
-
| `
|
|
5646
|
+
| `value` | `boolean` |
|
|
4646
5647
|
|
|
4647
|
-
|
|
5648
|
+
##### Returns
|
|
4648
5649
|
|
|
4649
|
-
|
|
5650
|
+
`void`
|
|
4650
5651
|
|
|
4651
|
-
|
|
5652
|
+
***
|
|
4652
5653
|
|
|
4653
|
-
|
|
5654
|
+
### validationMessage
|
|
4654
5655
|
|
|
4655
|
-
|
|
5656
|
+
#### Get Signature
|
|
4656
5657
|
|
|
4657
5658
|
```ts
|
|
4658
|
-
|
|
5659
|
+
get validationMessage(): string;
|
|
4659
5660
|
```
|
|
4660
5661
|
|
|
4661
|
-
|
|
5662
|
+
The message shown when the field is invalid.
|
|
4662
5663
|
|
|
4663
|
-
|
|
5664
|
+
##### Returns
|
|
4664
5665
|
|
|
4665
|
-
|
|
5666
|
+
`string`
|
|
4666
5667
|
|
|
4667
|
-
|
|
5668
|
+
***
|
|
4668
5669
|
|
|
4669
|
-
|
|
5670
|
+
### validity
|
|
4670
5671
|
|
|
4671
|
-
|
|
5672
|
+
#### Get Signature
|
|
4672
5673
|
|
|
4673
5674
|
```ts
|
|
4674
|
-
|
|
5675
|
+
get validity(): ValidityState | undefined;
|
|
4675
5676
|
```
|
|
4676
5677
|
|
|
4677
|
-
|
|
4678
|
-
by `setLink()`. Links never get `target="_blank"`: opening new windows
|
|
4679
|
-
without warning is an accessibility problem.
|
|
5678
|
+
Validity, as on a built-in field (`valueMissing` for an empty `required` editor).
|
|
4680
5679
|
|
|
4681
|
-
|
|
5680
|
+
##### Returns
|
|
4682
5681
|
|
|
4683
|
-
|
|
4684
|
-
| ------ | ------ |
|
|
4685
|
-
| `options?` | [`LinkOptions`](../interfaces/LinkOptions.md) |
|
|
5682
|
+
`ValidityState` \| `undefined`
|
|
4686
5683
|
|
|
4687
|
-
|
|
5684
|
+
***
|
|
4688
5685
|
|
|
4689
|
-
|
|
5686
|
+
### value
|
|
4690
5687
|
|
|
4691
|
-
|
|
5688
|
+
#### Get Signature
|
|
4692
5689
|
|
|
4693
|
-
|
|
5690
|
+
```ts
|
|
5691
|
+
get value(): string;
|
|
5692
|
+
```
|
|
4694
5693
|
|
|
4695
|
-
|
|
5694
|
+
The current value: HTML, or JSON text with `format="json"`.
|
|
5695
|
+
|
|
5696
|
+
##### Returns
|
|
5697
|
+
|
|
5698
|
+
`string`
|
|
5699
|
+
|
|
5700
|
+
#### Set Signature
|
|
4696
5701
|
|
|
4697
5702
|
```ts
|
|
4698
|
-
|
|
5703
|
+
set value(value): void;
|
|
4699
5704
|
```
|
|
4700
5705
|
|
|
4701
|
-
|
|
5706
|
+
Replace the content; a `json` element takes JSON text.
|
|
4702
5707
|
|
|
4703
|
-
|
|
5708
|
+
##### Parameters
|
|
4704
5709
|
|
|
4705
|
-
|
|
5710
|
+
| Parameter | Type |
|
|
5711
|
+
| ------ | ------ |
|
|
5712
|
+
| `value` | `string` |
|
|
4706
5713
|
|
|
4707
|
-
|
|
5714
|
+
##### Returns
|
|
4708
5715
|
|
|
4709
|
-
|
|
5716
|
+
`void`
|
|
4710
5717
|
|
|
4711
|
-
|
|
5718
|
+
***
|
|
5719
|
+
|
|
5720
|
+
### willValidate
|
|
5721
|
+
|
|
5722
|
+
#### Get Signature
|
|
4712
5723
|
|
|
4713
5724
|
```ts
|
|
4714
|
-
|
|
5725
|
+
get willValidate(): boolean;
|
|
4715
5726
|
```
|
|
4716
5727
|
|
|
4717
|
-
|
|
5728
|
+
Whether the field takes part in form validation.
|
|
4718
5729
|
|
|
4719
|
-
|
|
5730
|
+
##### Returns
|
|
4720
5731
|
|
|
4721
|
-
|
|
5732
|
+
`boolean`
|
|
4722
5733
|
|
|
4723
|
-
|
|
5734
|
+
## Methods
|
|
4724
5735
|
|
|
4725
|
-
|
|
5736
|
+
### checkValidity()
|
|
4726
5737
|
|
|
4727
|
-
|
|
5738
|
+
```ts
|
|
5739
|
+
checkValidity(): boolean;
|
|
5740
|
+
```
|
|
5741
|
+
|
|
5742
|
+
Whether the field is valid; fires `invalid` when not.
|
|
5743
|
+
|
|
5744
|
+
#### Returns
|
|
5745
|
+
|
|
5746
|
+
`boolean`
|
|
5747
|
+
|
|
5748
|
+
***
|
|
5749
|
+
|
|
5750
|
+
### focus()
|
|
4728
5751
|
|
|
4729
5752
|
```ts
|
|
4730
|
-
|
|
5753
|
+
focus(): void;
|
|
4731
5754
|
```
|
|
4732
5755
|
|
|
4733
|
-
|
|
5756
|
+
Focus the editable area.
|
|
4734
5757
|
|
|
4735
|
-
|
|
5758
|
+
#### Returns
|
|
4736
5759
|
|
|
4737
|
-
|
|
5760
|
+
`void`
|
|
4738
5761
|
|
|
4739
|
-
|
|
5762
|
+
#### Overrides
|
|
4740
5763
|
|
|
4741
|
-
|
|
5764
|
+
`Base.focus`
|
|
4742
5765
|
|
|
4743
|
-
|
|
5766
|
+
***
|
|
4744
5767
|
|
|
4745
|
-
|
|
4746
|
-
configurable or switchable off.
|
|
5768
|
+
### reportValidity()
|
|
4747
5769
|
|
|
4748
|
-
|
|
5770
|
+
```ts
|
|
5771
|
+
reportValidity(): boolean;
|
|
5772
|
+
```
|
|
4749
5773
|
|
|
4750
|
-
|
|
5774
|
+
Like `checkValidity()`, and shows the message to the user.
|
|
4751
5775
|
|
|
4752
|
-
|
|
5776
|
+
#### Returns
|
|
4753
5777
|
|
|
4754
|
-
|
|
5778
|
+
`boolean`
|
|
4755
5779
|
|
|
4756
5780
|
---
|
|
4757
5781
|
|
|
4758
|
-
Source: /api/
|
|
4759
|
-
|
|
4760
|
-
# Interface: BasicOptions
|
|
5782
|
+
Source: /api/element/type-aliases/WriteonFormat.md
|
|
4761
5783
|
|
|
4762
|
-
|
|
5784
|
+
# Type Alias: WriteonFormat
|
|
4763
5785
|
|
|
4764
|
-
|
|
5786
|
+
```ts
|
|
5787
|
+
type WriteonFormat = "html" | "json";
|
|
5788
|
+
```
|
|
4765
5789
|
|
|
4766
|
-
|
|
4767
|
-
| ------ | ------ | ------ |
|
|
4768
|
-
| <a id="property-blockquote"></a> `blockquote?` | `false` | Blockquotes. |
|
|
4769
|
-
| <a id="property-bold"></a> `bold?` | `false` | Bold. |
|
|
4770
|
-
| <a id="property-code"></a> `code?` | `false` | Inline code. |
|
|
4771
|
-
| <a id="property-hardbreak"></a> `hardBreak?` | `false` | Line breaks (`Shift-Enter`). |
|
|
4772
|
-
| <a id="property-heading"></a> `heading?` | \| `false` \| [`HeadingOptions`](../../extensions/interfaces/HeadingOptions.md) | Headings, or their options. |
|
|
4773
|
-
| <a id="property-history"></a> `history?` | \| `false` \| [`HistoryOptions`](../../extensions/interfaces/HistoryOptions.md) | Undo and redo, or their options. |
|
|
4774
|
-
| <a id="property-italic"></a> `italic?` | `false` | Italic. |
|
|
4775
|
-
| <a id="property-link"></a> `link?` | `false` \| [`LinkOptions`](../../extensions/interfaces/LinkOptions.md) | Links, or their options. |
|
|
4776
|
-
| <a id="property-list"></a> `list?` | `false` | Bullet and ordered lists. |
|
|
4777
|
-
| <a id="property-strike"></a> `strike?` | `false` | Strikethrough. |
|
|
4778
|
-
| <a id="property-underline"></a> `underline?` | `false` | Underline. |
|
|
5790
|
+
What the form submits: `html` (default) or the document as `json`.
|
|
4779
5791
|
|
|
4780
5792
|
---
|
|
4781
5793
|
|
|
4782
|
-
Source: /api/
|
|
5794
|
+
Source: /api/element/functions/defineWriteonEditor.md
|
|
4783
5795
|
|
|
4784
|
-
# Function:
|
|
5796
|
+
# Function: defineWriteonEditor()
|
|
4785
5797
|
|
|
4786
5798
|
```ts
|
|
4787
|
-
function
|
|
5799
|
+
function defineWriteonEditor(name?): void;
|
|
4788
5800
|
```
|
|
4789
5801
|
|
|
4790
|
-
|
|
4791
|
-
|
|
5802
|
+
Register the element under `name` (default `writeon-editor`). Called on
|
|
5803
|
+
import; call it again for another tag name. Does nothing without a DOM or
|
|
5804
|
+
when the name is taken.
|
|
4792
5805
|
|
|
4793
5806
|
## Parameters
|
|
4794
5807
|
|
|
4795
|
-
| Parameter | Type |
|
|
4796
|
-
| ------ | ------ |
|
|
4797
|
-
| `
|
|
5808
|
+
| Parameter | Type | Default value |
|
|
5809
|
+
| ------ | ------ | ------ |
|
|
5810
|
+
| `name?` | `string` | `'writeon-editor'` |
|
|
4798
5811
|
|
|
4799
5812
|
## Returns
|
|
4800
5813
|
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
## Example
|
|
4804
|
-
|
|
4805
|
-
```ts
|
|
4806
|
-
basic() // everything, defaults
|
|
4807
|
-
basic({ strike: false }) // without strikethrough
|
|
4808
|
-
basic({ heading: { levels: [2, 3] } }) // only H2 and H3
|
|
4809
|
-
basic({ link: { protocols: ['https'] } }) // https links only
|
|
4810
|
-
```
|
|
5814
|
+
`void`
|
|
4811
5815
|
|
|
4812
5816
|
---
|
|
4813
5817
|
|
|
@@ -4861,7 +5865,7 @@ Options for `toHTML()`.
|
|
|
4861
5865
|
| Property | Type | Description |
|
|
4862
5866
|
| ------ | ------ | ------ |
|
|
4863
5867
|
| <a id="property-extensions"></a> `extensions` | readonly [`Extension`](../../core/interfaces/Extension.md)[] | The same extensions the editor uses. |
|
|
4864
|
-
| <a id="property-urls"></a> `urls?` | \{ `protocols?`: readonly `string`[]; \} | Allowed protocols for `href`/`src`. Default: http, https, mailto
|
|
5868
|
+
| <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. |
|
|
4865
5869
|
| `urls.protocols?` | readonly `string`[] | Allowed URL protocols, without the colon. |
|
|
4866
5870
|
|
|
4867
5871
|
---
|
|
@@ -5068,8 +6072,8 @@ Options for `mountToolbar()`.
|
|
|
5068
6072
|
| Property | Type | Description |
|
|
5069
6073
|
| ------ | ------ | ------ |
|
|
5070
6074
|
| <a id="property-blocktypes"></a> `blockTypes?` | `boolean` | Show the "Text style" menu (paragraph, headings). Default true. |
|
|
5071
|
-
| <a id="property-exclude"></a> `exclude?` | readonly `
|
|
5072
|
-
| <a id="property-headinglevels"></a> `headingLevels?` | readonly `
|
|
6075
|
+
| <a id="property-exclude"></a> `exclude?` | readonly [`BasicToolbarItemId`](../../ui/type-aliases/BasicToolbarItemId.md)[] | Buttons to leave out, by id (e.g. `['underline', 'code']`). |
|
|
6076
|
+
| <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]. |
|
|
5073
6077
|
| <a id="property-idprefix"></a> `idPrefix?` | `string` | Prefix for element ids, needed when several editors share a page. Default: generated. |
|
|
5074
6078
|
| <a id="property-link"></a> `link?` | `boolean` | Show the link button and form. Default true. Set `false` for the `Mod-k` shortcut too. |
|
|
5075
6079
|
| <a id="property-messages"></a> `messages?` | `Partial`\<[`Messages`](../../ui/interfaces/Messages.md)\> | UI texts, e.g. `uz` from `@writeon/ui/locales/uz`. Default English. |
|
|
@@ -5270,7 +6274,7 @@ function mountAdvanced(
|
|
|
5270
6274
|
Mount the default kit's advanced UI: image dialog and uploads, table
|
|
5271
6275
|
actions, task list and code block buttons in the kit toolbar, the `/`
|
|
5272
6276
|
command menu, `@` mentions and the selection bubble. Also turns on the
|
|
5273
|
-
advanced behaviour (`editor.
|
|
6277
|
+
advanced behaviour (`editor.extend()`), keeping the document and undo
|
|
5274
6278
|
history. The editor must have `advancedSchema()`. Load this module on
|
|
5275
6279
|
demand, so none of it is in your main bundle.
|
|
5276
6280
|
|
|
@@ -5361,8 +6365,8 @@ Props of `<Toolbar>`: the editor plus `KitToolbarOptions`.
|
|
|
5361
6365
|
| ------ | ------ | ------ | ------ |
|
|
5362
6366
|
| <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) |
|
|
5363
6367
|
| <a id="property-editor"></a> `editor` | [`Editor`](../../../core/interfaces/Editor.md) | The editor to control. A different editor remounts the toolbar. | - |
|
|
5364
|
-
| <a id="property-exclude"></a> `exclude?` | readonly `
|
|
5365
|
-
| <a id="property-headinglevels"></a> `headingLevels?` | readonly `
|
|
6368
|
+
| <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) |
|
|
6369
|
+
| <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) |
|
|
5366
6370
|
| <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) |
|
|
5367
6371
|
| <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) |
|
|
5368
6372
|
| <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) |
|
|
@@ -5501,8 +6505,8 @@ Props of `<Toolbar>`: the editor plus `KitToolbarOptions`.
|
|
|
5501
6505
|
| ------ | ------ | ------ | ------ |
|
|
5502
6506
|
| <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) |
|
|
5503
6507
|
| <a id="property-editor"></a> `editor` | [`Editor`](../../../core/interfaces/Editor.md) | The editor to control. Read once, on mount. | - |
|
|
5504
|
-
| <a id="property-exclude"></a> `exclude?` | readonly `
|
|
5505
|
-
| <a id="property-headinglevels"></a> `headingLevels?` | readonly `
|
|
6508
|
+
| <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) |
|
|
6509
|
+
| <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) |
|
|
5506
6510
|
| <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) |
|
|
5507
6511
|
| <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) |
|
|
5508
6512
|
| <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) |
|
|
@@ -6599,14 +7603,20 @@ Source: /api/react/interfaces/UseToolbarResult.md
|
|
|
6599
7603
|
|
|
6600
7604
|
# Interface: UseToolbarResult
|
|
6601
7605
|
|
|
6602
|
-
Returned by `useToolbar()
|
|
7606
|
+
Returned by `useToolbar()`: the controller state as fields, plus the items and prop getters.
|
|
7607
|
+
|
|
7608
|
+
## Extends
|
|
7609
|
+
|
|
7610
|
+
- [`ToolbarState`](../../ui/interfaces/ToolbarState.md)
|
|
6603
7611
|
|
|
6604
7612
|
## Properties
|
|
6605
7613
|
|
|
6606
|
-
| Property | Modifier | Type | Description |
|
|
6607
|
-
| ------ | ------ | ------ | ------ |
|
|
6608
|
-
| <a id="property-
|
|
6609
|
-
| <a id="property-
|
|
7614
|
+
| Property | Modifier | Type | Description | Inherited from |
|
|
7615
|
+
| ------ | ------ | ------ | ------ | ------ |
|
|
7616
|
+
| <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) |
|
|
7617
|
+
| <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) |
|
|
7618
|
+
| <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) |
|
|
7619
|
+
| <a id="property-items"></a> `items` | `readonly` | readonly [`ToolbarItem`](../../ui/interfaces/ToolbarItem.md)[] | The items passed in `options`. | - |
|
|
6610
7620
|
|
|
6611
7621
|
## Methods
|
|
6612
7622
|
|
|
@@ -7189,7 +8199,7 @@ Options for `validate()`.
|
|
|
7189
8199
|
| <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. |
|
|
7190
8200
|
| <a id="property-limits"></a> `limits?` | [`ValidateLimits`](ValidateLimits.md) | Size limits. Defaults are listed on `ValidateLimits`. |
|
|
7191
8201
|
| <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. |
|
|
7192
|
-
| <a id="property-urls"></a> `urls?` | \{ `protocols?`: readonly `string`[]; \} | Allowed protocols for every `href`/`src` attribute. Default: http, https, mailto
|
|
8202
|
+
| <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. |
|
|
7193
8203
|
| `urls.protocols?` | readonly `string`[] | Allowed URL protocols, without the colon. |
|
|
7194
8204
|
|
|
7195
8205
|
---
|
|
@@ -7447,7 +8457,8 @@ menu and suggestions. Renders nothing.
|
|
|
7447
8457
|
- [createTooltip](functions/createTooltip.md)
|
|
7448
8458
|
- [displayShortcut](functions/displayShortcut.md)
|
|
7449
8459
|
- [filterSuggestions](functions/filterSuggestions.md)
|
|
7450
|
-
- [format](functions/format.md)
|
|
8460
|
+
- [~~format~~](functions/format.md)
|
|
8461
|
+
- [formatMessage](functions/formatMessage.md)
|
|
7451
8462
|
- [isApplePlatform](functions/isApplePlatform.md)
|
|
7452
8463
|
- [matchesShortcut](functions/matchesShortcut.md)
|
|
7453
8464
|
- [mergeElementProps](functions/mergeElementProps.md)
|
|
@@ -7465,7 +8476,7 @@ Options for `basicBlockTypeItems()`.
|
|
|
7465
8476
|
|
|
7466
8477
|
| Property | Type | Description |
|
|
7467
8478
|
| ------ | ------ | ------ |
|
|
7468
|
-
| <a id="property-levels"></a> `levels?` | readonly `
|
|
8479
|
+
| <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 } })`. |
|
|
7469
8480
|
| <a id="property-messages"></a> `messages?` | `Partial`\<[`Messages`](Messages.md)\> | Labels to override; English by default. |
|
|
7470
8481
|
|
|
7471
8482
|
---
|
|
@@ -8832,6 +9843,10 @@ Source: /api/ui/interfaces/ToolbarState.md
|
|
|
8832
9843
|
|
|
8833
9844
|
Snapshot of a toolbar.
|
|
8834
9845
|
|
|
9846
|
+
## Extended by
|
|
9847
|
+
|
|
9848
|
+
- [`UseToolbarResult`](../../react/interfaces/UseToolbarResult.md)
|
|
9849
|
+
|
|
8835
9850
|
## Properties
|
|
8836
9851
|
|
|
8837
9852
|
| Property | Modifier | Type | Description |
|
|
@@ -9487,13 +10502,38 @@ containing) it, case-insensitive. Use it in `items` for static lists.
|
|
|
9487
10502
|
|
|
9488
10503
|
Source: /api/ui/functions/format.md
|
|
9489
10504
|
|
|
9490
|
-
# Function: format()
|
|
10505
|
+
# ~~Function: format()~~
|
|
9491
10506
|
|
|
9492
10507
|
```ts
|
|
9493
10508
|
function format(message, values): string;
|
|
9494
10509
|
```
|
|
9495
10510
|
|
|
9496
|
-
|
|
10511
|
+
## Parameters
|
|
10512
|
+
|
|
10513
|
+
| Parameter | Type |
|
|
10514
|
+
| ------ | ------ |
|
|
10515
|
+
| `message` | `string` |
|
|
10516
|
+
| `values` | `Record`\<`string`, `string` \| `number`\> |
|
|
10517
|
+
|
|
10518
|
+
## Returns
|
|
10519
|
+
|
|
10520
|
+
`string`
|
|
10521
|
+
|
|
10522
|
+
## Deprecated
|
|
10523
|
+
|
|
10524
|
+
Renamed to `formatMessage()`, which this calls. Removed in 1.0.
|
|
10525
|
+
|
|
10526
|
+
---
|
|
10527
|
+
|
|
10528
|
+
Source: /api/ui/functions/formatMessage.md
|
|
10529
|
+
|
|
10530
|
+
# Function: formatMessage()
|
|
10531
|
+
|
|
10532
|
+
```ts
|
|
10533
|
+
function formatMessage(message, values): string;
|
|
10534
|
+
```
|
|
10535
|
+
|
|
10536
|
+
Fill `{name}` placeholders in a message, e.g. `formatMessage(m.heading, { level: 2 })`.
|
|
9497
10537
|
|
|
9498
10538
|
## Parameters
|
|
9499
10539
|
|
|
@@ -9603,6 +10643,22 @@ English with any given overrides.
|
|
|
9603
10643
|
|
|
9604
10644
|
---
|
|
9605
10645
|
|
|
10646
|
+
Source: /api/ui/locales/en/reference.md
|
|
10647
|
+
|
|
10648
|
+
# @writeon/ui/locales/en
|
|
10649
|
+
|
|
10650
|
+
English messages for the UI controllers and the kit: the default. The same
|
|
10651
|
+
object as `en` from `@writeon/ui`; this entry exists so locales can be
|
|
10652
|
+
loaded by code, e.g. `import(\`@writeon/ui/locales/${lang}\`)`.
|
|
10653
|
+
|
|
10654
|
+
## References
|
|
10655
|
+
|
|
10656
|
+
### default
|
|
10657
|
+
|
|
10658
|
+
Renames and re-exports [en](../../variables/en.md)
|
|
10659
|
+
|
|
10660
|
+
---
|
|
10661
|
+
|
|
9606
10662
|
Source: /api/ui/locales/ru/reference.md
|
|
9607
10663
|
|
|
9608
10664
|
# @writeon/ui/locales/ru
|
|
@@ -9782,7 +10838,7 @@ Options for `useEditor()`. `element` is handled by `<EditorContent>`; `editable`
|
|
|
9782
10838
|
| ------ | ------ | ------ | ------ |
|
|
9783
10839
|
| <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) |
|
|
9784
10840
|
| <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. | - |
|
|
9785
|
-
| <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) |
|
|
10841
|
+
| <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) |
|
|
9786
10842
|
| <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) |
|
|
9787
10843
|
| <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) |
|
|
9788
10844
|
| <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) |
|
|
@@ -10796,6 +11852,7 @@ Source: /api/reference.md
|
|
|
10796
11852
|
- [@writeon/core/extension](core/extension/reference.md)
|
|
10797
11853
|
- [@writeon/core/extensions](core/extensions/reference.md)
|
|
10798
11854
|
- [@writeon/core/presets](core/presets/reference.md)
|
|
11855
|
+
- [@writeon/element](element/reference.md)
|
|
10799
11856
|
- [@writeon/html](html/reference.md)
|
|
10800
11857
|
- [@writeon/kit](kit/reference.md)
|
|
10801
11858
|
- [@writeon/kit/advanced](kit/advanced/reference.md)
|
|
@@ -10806,6 +11863,7 @@ Source: /api/reference.md
|
|
|
10806
11863
|
- [@writeon/react](react/reference.md)
|
|
10807
11864
|
- [@writeon/server](server/reference.md)
|
|
10808
11865
|
- [@writeon/ui](ui/reference.md)
|
|
11866
|
+
- [@writeon/ui/locales/en](ui/locales/en/reference.md)
|
|
10809
11867
|
- [@writeon/ui/locales/ru](ui/locales/ru/reference.md)
|
|
10810
11868
|
- [@writeon/ui/locales/uz](ui/locales/uz/reference.md)
|
|
10811
11869
|
- [@writeon/vue](vue/reference.md)
|