@writeon/core 0.3.0 → 1.0.0-rc.1
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 +1 -1
- package/dist/extension.d.ts +1 -1
- package/dist/extensions.d.ts +1 -1
- package/dist/extensions.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -8
- package/dist/presets.d.ts +1 -1
- package/dist/{types-XoUXB0kY.d.ts → types-CKTNafiT.d.ts} +14 -4
- package/llms-full.txt +130 -87
- package/llms.txt +1 -0
- package/package.json +1 -1
package/dist/commands.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as HeadingLevel, t as Command } from "./types-
|
|
1
|
+
import { d as HeadingLevel, t as Command } from "./types-CKTNafiT.js";
|
|
2
2
|
/** Toggle bold on the selection. Requires the `bold` extension. */
|
|
3
3
|
export declare const toggleBold: () => Command;
|
|
4
4
|
/** Toggle italic on the selection. Requires the `italic` extension. */
|
package/dist/extension.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module @writeon/core/extension
|
|
7
7
|
*/
|
|
8
8
|
import { MarkType, Node, Schema } from "prosemirror-model";
|
|
9
|
-
import { c as Extension, l as ExtensionContext, n as DocJSON, p as NodeAttribute, t as Command, u as ExtensionSpec } from "./types-
|
|
9
|
+
import { c as Extension, l as ExtensionContext, n as DocJSON, p as NodeAttribute, t as Command, u as ExtensionSpec } from "./types-CKTNafiT.js";
|
|
10
10
|
import "prosemirror-state";
|
|
11
11
|
import { InputRule } from "prosemirror-inputrules";
|
|
12
12
|
/**
|
package/dist/extensions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as Extension, d as HeadingLevel } from "./types-
|
|
1
|
+
import { c as Extension, d as HeadingLevel } from "./types-CKTNafiT.js";
|
|
2
2
|
/** Bold text. `Mod-b`, `**text**` or `__text__`. */
|
|
3
3
|
export declare const bold: () => Extension;
|
|
4
4
|
/** Italic text. `Mod-i`, `*text*` or `_text_`. */
|
package/dist/extensions.js
CHANGED
|
@@ -307,7 +307,8 @@ const hardBreak = defineExtension(() => ({
|
|
|
307
307
|
group: "inline",
|
|
308
308
|
selectable: false,
|
|
309
309
|
parseDOM: [{ tag: "br" }],
|
|
310
|
-
toDOM: () => ["br"]
|
|
310
|
+
toDOM: () => ["br"],
|
|
311
|
+
leafText: () => "\n"
|
|
311
312
|
} },
|
|
312
313
|
keymap: () => ({
|
|
313
314
|
"Shift-Enter": insertHardBreak(),
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
* @module @writeon/core
|
|
7
7
|
*/
|
|
8
|
-
import { a as EditorLabel, c as Extension, d as HeadingLevel, f as MarkJSON, h as TransactionScope, i as EditorExtendSource, m as NodeJSON, n as DocJSON, o as EditorOptions, r as Editor, s as EditorSnapshot, t as Command } from "./types-
|
|
8
|
+
import { a as EditorLabel, c as Extension, d as HeadingLevel, f as MarkJSON, h as TransactionScope, i as EditorExtendSource, m as NodeJSON, n as DocJSON, o as EditorOptions, r as Editor, s as EditorSnapshot, t as Command } from "./types-CKTNafiT.js";
|
|
9
9
|
/**
|
|
10
10
|
* A debounced function with explicit control over pending calls.
|
|
11
11
|
*/
|
package/dist/index.js
CHANGED
|
@@ -249,6 +249,11 @@ function createEditor(options) {
|
|
|
249
249
|
content: (_json$content = state.doc.toJSON().content) !== null && _json$content !== void 0 ? _json$content : []
|
|
250
250
|
};
|
|
251
251
|
},
|
|
252
|
+
getText(textOptions) {
|
|
253
|
+
var _textOptions$blockSep;
|
|
254
|
+
assertAlive();
|
|
255
|
+
return state.doc.textBetween(0, state.doc.content.size, (_textOptions$blockSep = textOptions === null || textOptions === void 0 ? void 0 : textOptions.blockSeparator) !== null && _textOptions$blockSep !== void 0 ? _textOptions$blockSep : "\n\n");
|
|
256
|
+
},
|
|
252
257
|
setContent(doc, setOptions) {
|
|
253
258
|
assertAlive();
|
|
254
259
|
const next = parseContent(schema, doc);
|
|
@@ -282,13 +287,6 @@ function createEditor(options) {
|
|
|
282
287
|
view === null || view === void 0 || view.setProps({});
|
|
283
288
|
changed();
|
|
284
289
|
},
|
|
285
|
-
enable(source) {
|
|
286
|
-
if (!warnedEnable) {
|
|
287
|
-
warnedEnable = true;
|
|
288
|
-
console.warn("[writeon] editor.enable() is renamed to editor.extend(). enable() is removed in 1.0.");
|
|
289
|
-
}
|
|
290
|
-
return editor.extend(source);
|
|
291
|
-
},
|
|
292
290
|
async extend(source) {
|
|
293
291
|
assertAlive();
|
|
294
292
|
const added = await loadExtensions(source);
|
|
@@ -327,7 +325,6 @@ function createEditor(options) {
|
|
|
327
325
|
if (options.element) mount(options.element);
|
|
328
326
|
return editor;
|
|
329
327
|
}
|
|
330
|
-
let warnedEnable = false;
|
|
331
328
|
async function loadExtensions(source) {
|
|
332
329
|
const loaded = typeof source === "function" ? await source() : source;
|
|
333
330
|
return "default" in loaded ? loaded.default : loaded;
|
package/dist/presets.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module @writeon/core/presets
|
|
7
7
|
*/
|
|
8
8
|
import { HeadingOptions, HistoryOptions, LinkOptions } from "./extensions.js";
|
|
9
|
-
import { c as Extension } from "./types-
|
|
9
|
+
import { c as Extension } from "./types-CKTNafiT.js";
|
|
10
10
|
/** Per-extension settings for `basic()`. `false` leaves an extension out. */
|
|
11
11
|
export interface BasicOptions {
|
|
12
12
|
/** Headings, or their options. */
|
|
@@ -119,6 +119,20 @@ interface Editor {
|
|
|
119
119
|
subscribe(listener: () => void): () => void;
|
|
120
120
|
/** The document in the JSON format, stamped with the current `schemaVersion`. */
|
|
121
121
|
getJSON(): DocJSON;
|
|
122
|
+
/**
|
|
123
|
+
* The document as plain text, e.g. to count words or characters. Blocks are
|
|
124
|
+
* separated by `blockSeparator` (default a blank line, `"\n\n"`), a line
|
|
125
|
+
* break is `"\n"`, and a mention is `"@"` and its label. Images and other
|
|
126
|
+
* nodes without text add nothing.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* const words = editor.getText().split(/\s+/).filter(Boolean).length
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
getText(options?: {
|
|
134
|
+
blockSeparator?: string;
|
|
135
|
+
}): string;
|
|
122
136
|
/** Replace the document. Not added to undo history unless `addToHistory` is `true`. */
|
|
123
137
|
setContent(doc: DocJSON, options?: {
|
|
124
138
|
addToHistory?: boolean;
|
|
@@ -149,10 +163,6 @@ interface Editor {
|
|
|
149
163
|
* ```
|
|
150
164
|
*/
|
|
151
165
|
extend(source: EditorExtendSource): Promise<void>;
|
|
152
|
-
/**
|
|
153
|
-
* @deprecated Renamed to `extend()`, which this calls. Removed in 1.0.
|
|
154
|
-
*/
|
|
155
|
-
enable(source: EditorExtendSource): Promise<void>;
|
|
156
166
|
/**
|
|
157
167
|
* Attach to a DOM element. Document and history are kept across mount/unmount.
|
|
158
168
|
* Throws if already mounted.
|
package/llms-full.txt
CHANGED
|
@@ -8,8 +8,8 @@ Source: /guide/getting-started.md
|
|
|
8
8
|
|
|
9
9
|
# Getting started
|
|
10
10
|
|
|
11
|
-
**
|
|
12
|
-
|
|
11
|
+
**Release candidate:**
|
|
12
|
+
These pages describe 1.0, now a release candidate. Install it with the `rc` tag (`npm install @writeon/core@rc`); without it you get 0.x. Coming from 0.x: [Upgrading to 1.0](/guide/upgrade-1.md).
|
|
13
13
|
|
|
14
14
|
## Install
|
|
15
15
|
|
|
@@ -270,6 +270,15 @@ export function examples(editor: Editor) {
|
|
|
270
270
|
|
|
271
271
|
In React, `useEditorState(editor, selector)` re-renders only when the selected value changes; in Vue, it returns a ref.
|
|
272
272
|
|
|
273
|
+
`editor.getText()` returns the document as plain text, with a blank line between blocks, for example to count words:
|
|
274
|
+
|
|
275
|
+
```ts
|
|
276
|
+
const words = useEditorState(
|
|
277
|
+
editor,
|
|
278
|
+
() => editor.getText().split(/\s+/).filter(Boolean).length,
|
|
279
|
+
)
|
|
280
|
+
```
|
|
281
|
+
|
|
273
282
|
## Lifecycle
|
|
274
283
|
|
|
275
284
|
- `createEditor({ element })` mounts at once; without `element`, call `editor.mount(el)` later. Document and history survive `unmount()` and `mount()`.
|
|
@@ -639,9 +648,9 @@ const bold = $derived(state.current.marks.has('bold'))
|
|
|
639
648
|
|
|
640
649
|
<main>
|
|
641
650
|
<h1>Writeon · Svelte</h1>
|
|
642
|
-
<div class="
|
|
651
|
+
<div class="writeon-root">
|
|
643
652
|
<div use:kitToolbar={editor}></div>
|
|
644
|
-
<div use:editorContent={editor} class="
|
|
653
|
+
<div use:editorContent={editor} class="writeon-content"></div>
|
|
645
654
|
</div>
|
|
646
655
|
<p data-testid="status">
|
|
647
656
|
Block: {state.current.block.type} ·
|
|
@@ -705,9 +714,9 @@ import { editorState } from './writeon'
|
|
|
705
714
|
template: `
|
|
706
715
|
<main>
|
|
707
716
|
<h1>Writeon · Angular</h1>
|
|
708
|
-
<div class="
|
|
717
|
+
<div class="writeon-root">
|
|
709
718
|
<div #toolbar></div>
|
|
710
|
-
<div #content class="
|
|
719
|
+
<div #content class="writeon-content"></div>
|
|
711
720
|
</div>
|
|
712
721
|
<p data-testid="status">
|
|
713
722
|
Block: {{ state().block.type }} ·
|
|
@@ -793,8 +802,8 @@ Source: /guide/element.md
|
|
|
793
802
|
From a CDN, with no build step. Pin the version you tested with:
|
|
794
803
|
|
|
795
804
|
```html
|
|
796
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@writeon/element@0.
|
|
797
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@writeon/element@0.
|
|
805
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@writeon/element@1.0.0-rc.0/dist/style.css" />
|
|
806
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@writeon/element@1.0.0-rc.0/dist/cdn/writeon-editor.js"></script>
|
|
798
807
|
```
|
|
799
808
|
|
|
800
809
|
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:
|
|
@@ -842,6 +851,8 @@ Put a `<textarea>` inside, with the name and the current value:
|
|
|
842
851
|
|
|
843
852
|
Print the value **escaped** (`{{ }}`, not `{!! !!}` or `|raw`). A textarea shows text, never runs it, so stored HTML cannot run while the page loads.
|
|
844
853
|
|
|
854
|
+
There is no `value` attribute (the element warns in the console if it finds one): the textarea is what keeps the field working before and without JavaScript. From JavaScript, set the `value` property.
|
|
855
|
+
|
|
845
856
|
What the element does with the textarea:
|
|
846
857
|
|
|
847
858
|
- **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.
|
|
@@ -1105,9 +1116,9 @@ export function Editor() {
|
|
|
1105
1116
|
const editor = useEditor({ extensions, label: 'Message' })
|
|
1106
1117
|
|
|
1107
1118
|
return (
|
|
1108
|
-
<div className="
|
|
1119
|
+
<div className="writeon-root">
|
|
1109
1120
|
<Toolbar editor={editor} />
|
|
1110
|
-
<EditorContent editor={editor} className="
|
|
1121
|
+
<EditorContent editor={editor} className="writeon-content" />
|
|
1111
1122
|
|
|
1112
1123
|
{/* Loaded on demand, after mount. */}
|
|
1113
1124
|
<Advanced
|
|
@@ -1138,10 +1149,10 @@ const editor = useEditor({
|
|
|
1138
1149
|
</script>
|
|
1139
1150
|
|
|
1140
1151
|
<template>
|
|
1141
|
-
<div class="
|
|
1152
|
+
<div class="writeon-root">
|
|
1142
1153
|
<!-- Buttons, menus and announcements in Uzbek. -->
|
|
1143
1154
|
<Toolbar :editor="editor" :messages="uz" />
|
|
1144
|
-
<EditorContent :editor="editor" class="
|
|
1155
|
+
<EditorContent :editor="editor" class="writeon-content" />
|
|
1145
1156
|
<Advanced :editor="editor" :messages="uz" />
|
|
1146
1157
|
</div>
|
|
1147
1158
|
</template>
|
|
@@ -1156,11 +1167,11 @@ import { basic } from '@writeon/core/presets'
|
|
|
1156
1167
|
import '@writeon/kit/style.css'
|
|
1157
1168
|
import { mountToolbar } from '@writeon/kit'
|
|
1158
1169
|
|
|
1159
|
-
// <div class="
|
|
1170
|
+
// <div class="writeon-root">
|
|
1160
1171
|
// <div id="toolbar"></div>
|
|
1161
|
-
// <div id="editor" class="
|
|
1172
|
+
// <div id="editor" class="writeon-content"></div>
|
|
1162
1173
|
// </div>
|
|
1163
|
-
const root = document.querySelector<HTMLElement>('.
|
|
1174
|
+
const root = document.querySelector<HTMLElement>('.writeon-root')
|
|
1164
1175
|
const toolbarHost = document.querySelector<HTMLElement>('#toolbar')
|
|
1165
1176
|
const element = document.querySelector<HTMLElement>('#editor')
|
|
1166
1177
|
if (!root || !toolbarHost || !element) {
|
|
@@ -1179,7 +1190,7 @@ const { mountAdvanced } = await import('@writeon/kit/advanced')
|
|
|
1179
1190
|
mountAdvanced(root, editor, { slash: true })
|
|
1180
1191
|
```
|
|
1181
1192
|
|
|
1182
|
-
- `.
|
|
1193
|
+
- `.writeon-root` is the frame; `.writeon-content` styles the document (headings, lists, code, tables, task lists, images, mentions) without Tailwind Typography.
|
|
1183
1194
|
- `<Toolbar>` / `mountToolbar()`: undo/redo, text style menu, marks, lists, quote, clear formatting, link, tooltips. Options: `messages`, `blockTypes`, `headingLevels`, `link`, `exclude`, `mobile`.
|
|
1184
1195
|
- `<Advanced>` / `mountAdvanced()` needs `advancedSchema()` in the editor. It turns on the advanced behaviour and adds:
|
|
1185
1196
|
- image, table, task list and code block buttons to the toolbar;
|
|
@@ -1190,19 +1201,19 @@ Its code is a separate chunk, loaded after mount.
|
|
|
1190
1201
|
|
|
1191
1202
|
## Theme
|
|
1192
1203
|
|
|
1193
|
-
Every colour, radius and font is a CSS variable on `.
|
|
1204
|
+
Every colour, radius and font is a CSS variable on `.writeon-root`:
|
|
1194
1205
|
|
|
1195
1206
|
```css
|
|
1196
|
-
.
|
|
1197
|
-
--
|
|
1198
|
-
--
|
|
1199
|
-
--
|
|
1200
|
-
--
|
|
1201
|
-
--
|
|
1207
|
+
.writeon-root {
|
|
1208
|
+
--writeon-color-accent: #0d9488;
|
|
1209
|
+
--writeon-color-accent-soft: #ccfbf1;
|
|
1210
|
+
--writeon-color-accent-text: #115e59;
|
|
1211
|
+
--writeon-radius: 4px;
|
|
1212
|
+
--writeon-font: "Inter", sans-serif;
|
|
1202
1213
|
}
|
|
1203
1214
|
```
|
|
1204
1215
|
|
|
1205
|
-
Dark mode follows the system. To choose explicitly, set `data-theme="dark"` or `data-theme="light"` on `.
|
|
1216
|
+
Dark mode follows the system. To choose explicitly, set `data-theme="dark"` or `data-theme="light"` on `.writeon-root` or any ancestor.
|
|
1206
1217
|
|
|
1207
1218
|
Each kit rule has the specificity of one class, so CSS resets such as Tailwind's preflight do not undo it, and any rule of yours with one class overrides it.
|
|
1208
1219
|
|
|
@@ -1405,14 +1416,14 @@ In 0.x a minor release may still break the API; its changelog says how to update
|
|
|
1405
1416
|
|
|
1406
1417
|
- 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
1418
|
- 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.
|
|
1419
|
+
- A test keeps the promise: documents with every node, mark and attribute, as the published releases since 0.1.0 stored them, must load, pass `validate()` in strict mode and render to the same HTML in every 1.x release. The HTML those releases wrote (what a form with `<writeon-editor>` stores) must read back to the same document.
|
|
1409
1420
|
|
|
1410
1421
|
## What semver covers
|
|
1411
1422
|
|
|
1412
1423
|
- **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
1424
|
- **The document format**: `DocJSON`, the node, mark and attribute names, and what each value means.
|
|
1414
1425
|
- **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 `--
|
|
1426
|
+
- **The kit's styling hooks**: the `--writeon-*` CSS variables, `.writeon-root`, `.writeon-content` and `data-theme`.
|
|
1416
1427
|
- **`<writeon-editor>`**: the tag name, its attributes, properties and events, and what it sends with the form.
|
|
1417
1428
|
- **Error codes** of `validate()` (`unknown-node`, `unsafe-url`, …). Messages are for people and can change.
|
|
1418
1429
|
|
|
@@ -1448,6 +1459,56 @@ A major release of Writeon may drop a Node.js version that has reached its end o
|
|
|
1448
1459
|
|
|
1449
1460
|
---
|
|
1450
1461
|
|
|
1462
|
+
Source: /guide/upgrade-1.md
|
|
1463
|
+
|
|
1464
|
+
# Upgrading to 1.0
|
|
1465
|
+
|
|
1466
|
+
1.0 is the first release covered by the [stability promise](/guide/stability.md). Coming from 0.x, you change some names in your code and CSS. **Stored documents need nothing:** 1.0 reads every document and every HTML value that 0.x stored.
|
|
1467
|
+
|
|
1468
|
+
## The `rte-` prefix is now `writeon-`
|
|
1469
|
+
|
|
1470
|
+
Before the project was called Writeon, its CSS used the prefix `rte-`. Every class, CSS variable, data attribute and generated id now uses `writeon-`:
|
|
1471
|
+
|
|
1472
|
+
| 0.x | 1.0 |
|
|
1473
|
+
| --- | --- |
|
|
1474
|
+
| `.rte-root`, `.rte-content`, `.rte-toolbar`, … | `.writeon-root`, `.writeon-content`, `.writeon-toolbar`, … |
|
|
1475
|
+
| `--rte-color-accent`, `--rte-radius`, … | `--writeon-color-accent`, `--writeon-radius`, … |
|
|
1476
|
+
| `data-rte-item`, `data-rte-upload` | `data-writeon-item`, `data-writeon-upload` |
|
|
1477
|
+
| `--rte-upload-progress` | `--writeon-upload-progress` |
|
|
1478
|
+
| `class="rte-embed"` in `toHTML()` output | `class="writeon-embed"` |
|
|
1479
|
+
|
|
1480
|
+
Find what to change in your project:
|
|
1481
|
+
|
|
1482
|
+
```sh
|
|
1483
|
+
grep -rnE -- "rte-" src/
|
|
1484
|
+
```
|
|
1485
|
+
|
|
1486
|
+
In most projects, replacing `rte-` with `writeon-` in your stylesheets and templates is all there is to it. For custom blocks, select `[data-embed]` instead of the class: the attribute has not changed and is in the HTML of every version.
|
|
1487
|
+
|
|
1488
|
+
## Renamed APIs
|
|
1489
|
+
|
|
1490
|
+
| 0.x | 1.0 |
|
|
1491
|
+
| --- | --- |
|
|
1492
|
+
| `editor.enable(…)` | `editor.extend(…)` |
|
|
1493
|
+
| `format()` from `@writeon/ui` | `formatMessage()` |
|
|
1494
|
+
| `textAlignmentAt(editor.pm.state)` | `activeTextAlign(editor)` |
|
|
1495
|
+
| `activeFontFamily(editor.pm.state)`, `activeTextColor(…)`, `embedKinds(…)`, `selectedEmbed(…)` | the same functions with `editor` |
|
|
1496
|
+
| `toolbar.state.active` from React `useToolbar()` | `toolbar.active` (also `enabled`, `focusId`) |
|
|
1497
|
+
|
|
1498
|
+
TypeScript points at each of these after the update. `enable()` and `format()` warned in the console since 0.3.
|
|
1499
|
+
|
|
1500
|
+
## Behaviour to check
|
|
1501
|
+
|
|
1502
|
+
- `validate()`, `toHTML()` and `toSafeHTML()` take the allowed link protocols from `link()` in your extensions. If you passed `urls.protocols` only to repeat them, you can remove it.
|
|
1503
|
+
- `setHeading()`, `toggleHeading()` and `heading({ levels })` take `1` to `6` in the types.
|
|
1504
|
+
- `@writeon/advanced/embed` is [experimental](/guide/stability.md#what-it-does-not-cover): its API can change in a minor release; stored blocks keep loading.
|
|
1505
|
+
|
|
1506
|
+
## Stored documents
|
|
1507
|
+
|
|
1508
|
+
Nothing to do. JSON documents keep `schemaVersion: 1`, and HTML stored by a form with `<writeon-editor>` reads back to the same document (old `rte-embed` classes included). A test checks this against documents made with the published 0.x releases.
|
|
1509
|
+
|
|
1510
|
+
---
|
|
1511
|
+
|
|
1451
1512
|
Source: /recipes/upload-s3.md
|
|
1452
1513
|
|
|
1453
1514
|
# Image uploads to S3
|
|
@@ -2299,8 +2360,8 @@ const imageUpload: (options) => Extension;
|
|
|
2299
2360
|
|
|
2300
2361
|
Upload images that are pasted, dropped or chosen with a file picker
|
|
2301
2362
|
(`uploadImages(editor, files)`), showing an accessible progress
|
|
2302
|
-
placeholder (`[data-
|
|
2303
|
-
`--
|
|
2363
|
+
placeholder (`[data-writeon-upload]`, `role="progressbar"`, CSS variable
|
|
2364
|
+
`--writeon-upload-progress`) where each will appear. Requires `advancedSchema()`.
|
|
2304
2365
|
|
|
2305
2366
|
## Parameters
|
|
2306
2367
|
|
|
@@ -3793,28 +3854,6 @@ Release everything. The editor cannot be used afterwards.
|
|
|
3793
3854
|
|
|
3794
3855
|
***
|
|
3795
3856
|
|
|
3796
|
-
### ~~enable()~~
|
|
3797
|
-
|
|
3798
|
-
```ts
|
|
3799
|
-
enable(source): Promise<void>;
|
|
3800
|
-
```
|
|
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
3857
|
### extend()
|
|
3819
3858
|
|
|
3820
3859
|
```ts
|
|
@@ -3893,6 +3932,36 @@ Current state for rendering UI. Returns the same frozen object until the state c
|
|
|
3893
3932
|
|
|
3894
3933
|
***
|
|
3895
3934
|
|
|
3935
|
+
### getText()
|
|
3936
|
+
|
|
3937
|
+
```ts
|
|
3938
|
+
getText(options?): string;
|
|
3939
|
+
```
|
|
3940
|
+
|
|
3941
|
+
The document as plain text, e.g. to count words or characters. Blocks are
|
|
3942
|
+
separated by `blockSeparator` (default a blank line, `"\n\n"`), a line
|
|
3943
|
+
break is `"\n"`, and a mention is `"@"` and its label. Images and other
|
|
3944
|
+
nodes without text add nothing.
|
|
3945
|
+
|
|
3946
|
+
#### Parameters
|
|
3947
|
+
|
|
3948
|
+
| Parameter | Type |
|
|
3949
|
+
| ------ | ------ |
|
|
3950
|
+
| `options?` | \{ `blockSeparator?`: `string`; \} |
|
|
3951
|
+
| `options.blockSeparator?` | `string` |
|
|
3952
|
+
|
|
3953
|
+
#### Returns
|
|
3954
|
+
|
|
3955
|
+
`string`
|
|
3956
|
+
|
|
3957
|
+
#### Example
|
|
3958
|
+
|
|
3959
|
+
```ts
|
|
3960
|
+
const words = editor.getText().split(/\s+/).filter(Boolean).length
|
|
3961
|
+
```
|
|
3962
|
+
|
|
3963
|
+
***
|
|
3964
|
+
|
|
3896
3965
|
### isActive()
|
|
3897
3966
|
|
|
3898
3967
|
```ts
|
|
@@ -6294,7 +6363,7 @@ demand, so none of it is in your main bundle.
|
|
|
6294
6363
|
|
|
6295
6364
|
```ts
|
|
6296
6365
|
const { mountAdvanced } = await import('@writeon/kit/advanced')
|
|
6297
|
-
mountAdvanced(document.querySelector('.
|
|
6366
|
+
mountAdvanced(document.querySelector('.writeon-root'), editor, {
|
|
6298
6367
|
messages: uz,
|
|
6299
6368
|
upload: fetchUploader({ url: '/api/upload' }),
|
|
6300
6369
|
mentions: (query) => searchPeople(query),
|
|
@@ -6384,7 +6453,7 @@ function Advanced(__namedParameters): ReactElement;
|
|
|
6384
6453
|
|
|
6385
6454
|
The default kit's advanced UI for React: image dialog and uploads, table
|
|
6386
6455
|
actions, the `/` menu, `@` mentions and the selection bubble. Its code is
|
|
6387
|
-
loaded on demand, after mount. Put it inside `.
|
|
6456
|
+
loaded on demand, after mount. Put it inside `.writeon-root`, next to
|
|
6388
6457
|
`<Toolbar />`. Options are read once, on mount.
|
|
6389
6458
|
|
|
6390
6459
|
## Parameters
|
|
@@ -6400,9 +6469,9 @@ loaded on demand, after mount. Put it inside `.rte-root`, next to
|
|
|
6400
6469
|
## Example
|
|
6401
6470
|
|
|
6402
6471
|
```tsx
|
|
6403
|
-
<div className="
|
|
6472
|
+
<div className="writeon-root">
|
|
6404
6473
|
<Toolbar editor={editor} messages={uz} />
|
|
6405
|
-
<EditorContent editor={editor} className="
|
|
6474
|
+
<EditorContent editor={editor} className="writeon-content" />
|
|
6406
6475
|
<Advanced editor={editor} messages={uz} upload={fetchUploader({ url: '/api/upload' })} />
|
|
6407
6476
|
</div>
|
|
6408
6477
|
```
|
|
@@ -6435,9 +6504,9 @@ The default kit toolbar for React. Options are read once, on mount.
|
|
|
6435
6504
|
import '@writeon/kit/style.css'
|
|
6436
6505
|
import { Toolbar } from '@writeon/kit/react'
|
|
6437
6506
|
|
|
6438
|
-
<div className="
|
|
6507
|
+
<div className="writeon-root">
|
|
6439
6508
|
<Toolbar editor={editor} messages={uz} />
|
|
6440
|
-
<EditorContent editor={editor} className="
|
|
6509
|
+
<EditorContent editor={editor} className="writeon-content" />
|
|
6441
6510
|
</div>
|
|
6442
6511
|
```
|
|
6443
6512
|
|
|
@@ -6524,15 +6593,15 @@ const Advanced: DefineSetupFnComponent<AdvancedProps>;
|
|
|
6524
6593
|
|
|
6525
6594
|
The default kit's advanced UI for Vue: image dialog and uploads, table
|
|
6526
6595
|
actions, the `/` menu, `@` mentions and the selection bubble. Its code is
|
|
6527
|
-
loaded on demand, after mount. Put it inside `.
|
|
6596
|
+
loaded on demand, after mount. Put it inside `.writeon-root`, next to
|
|
6528
6597
|
`<Toolbar />`. Options are read once, on mount.
|
|
6529
6598
|
|
|
6530
6599
|
## Example
|
|
6531
6600
|
|
|
6532
6601
|
```vue
|
|
6533
|
-
<div class="
|
|
6602
|
+
<div class="writeon-root">
|
|
6534
6603
|
<Toolbar :editor="editor" :messages="uz" />
|
|
6535
|
-
<EditorContent :editor="editor" class="
|
|
6604
|
+
<EditorContent :editor="editor" class="writeon-content" />
|
|
6536
6605
|
<Advanced :editor="editor" :messages="uz" :upload="upload" />
|
|
6537
6606
|
</div>
|
|
6538
6607
|
```
|
|
@@ -6552,9 +6621,9 @@ The default kit toolbar for Vue. Options are read once, on mount.
|
|
|
6552
6621
|
## Example
|
|
6553
6622
|
|
|
6554
6623
|
```vue
|
|
6555
|
-
<div class="
|
|
6624
|
+
<div class="writeon-root">
|
|
6556
6625
|
<Toolbar :editor="editor" :messages="uz" />
|
|
6557
|
-
<EditorContent :editor="editor" class="
|
|
6626
|
+
<EditorContent :editor="editor" class="writeon-content" />
|
|
6558
6627
|
</div>
|
|
6559
6628
|
```
|
|
6560
6629
|
|
|
@@ -8457,7 +8526,6 @@ menu and suggestions. Renders nothing.
|
|
|
8457
8526
|
- [createTooltip](functions/createTooltip.md)
|
|
8458
8527
|
- [displayShortcut](functions/displayShortcut.md)
|
|
8459
8528
|
- [filterSuggestions](functions/filterSuggestions.md)
|
|
8460
|
-
- [~~format~~](functions/format.md)
|
|
8461
8529
|
- [formatMessage](functions/formatMessage.md)
|
|
8462
8530
|
- [isApplePlatform](functions/isApplePlatform.md)
|
|
8463
8531
|
- [matchesShortcut](functions/matchesShortcut.md)
|
|
@@ -10500,31 +10568,6 @@ containing) it, case-insensitive. Use it in `items` for static lists.
|
|
|
10500
10568
|
|
|
10501
10569
|
---
|
|
10502
10570
|
|
|
10503
|
-
Source: /api/ui/functions/format.md
|
|
10504
|
-
|
|
10505
|
-
# ~~Function: format()~~
|
|
10506
|
-
|
|
10507
|
-
```ts
|
|
10508
|
-
function format(message, values): string;
|
|
10509
|
-
```
|
|
10510
|
-
|
|
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
10571
|
Source: /api/ui/functions/formatMessage.md
|
|
10529
10572
|
|
|
10530
10573
|
# Function: formatMessage()
|
package/llms.txt
CHANGED
|
@@ -20,6 +20,7 @@ Every link below is plain Markdown. Everything in one file: [llms-full.txt](/llm
|
|
|
20
20
|
- [Headless UI](/guide/headless-ui.md): Behaviour and accessibility without markup: controllers with state and prop getters for your own UI.
|
|
21
21
|
- [Working with AI assistants](/guide/ai.md): Docs for coding assistants: llms.txt, llms-full.txt, Markdown pages and an AGENTS.md block.
|
|
22
22
|
- [Stability](/guide/stability.md): What a Writeon release may change: semver from 1.0, stored documents that always load, deprecations, supported browsers and Node.js.
|
|
23
|
+
- [Upgrading to 1.0](/guide/upgrade-1.md): Upgrade from Writeon 0.x to 1.0: the writeon- CSS prefix, renamed APIs, and why stored documents need nothing.
|
|
23
24
|
|
|
24
25
|
## Recipes
|
|
25
26
|
|
package/package.json
CHANGED