@writeon/core 0.3.0 → 1.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { d as HeadingLevel, t as Command } from "./types-XoUXB0kY.js";
1
+ import { d as HeadingLevel, t as Command } from "./types-Bd25IgDH.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. */
@@ -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-XoUXB0kY.js";
9
+ import { c as Extension, l as ExtensionContext, n as DocJSON, p as NodeAttribute, t as Command, u as ExtensionSpec } from "./types-Bd25IgDH.js";
10
10
  import "prosemirror-state";
11
11
  import { InputRule } from "prosemirror-inputrules";
12
12
  /**
@@ -1,4 +1,4 @@
1
- import { c as Extension, d as HeadingLevel } from "./types-XoUXB0kY.js";
1
+ import { c as Extension, d as HeadingLevel } from "./types-Bd25IgDH.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/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-XoUXB0kY.js";
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-Bd25IgDH.js";
9
9
  /**
10
10
  * A debounced function with explicit control over pending calls.
11
11
  */
package/dist/index.js CHANGED
@@ -282,13 +282,6 @@ function createEditor(options) {
282
282
  view === null || view === void 0 || view.setProps({});
283
283
  changed();
284
284
  },
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
285
  async extend(source) {
293
286
  assertAlive();
294
287
  const added = await loadExtensions(source);
@@ -327,7 +320,6 @@ function createEditor(options) {
327
320
  if (options.element) mount(options.element);
328
321
  return editor;
329
322
  }
330
- let warnedEnable = false;
331
323
  async function loadExtensions(source) {
332
324
  const loaded = typeof source === "function" ? await source() : source;
333
325
  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-XoUXB0kY.js";
9
+ import { c as Extension } from "./types-Bd25IgDH.js";
10
10
  /** Per-extension settings for `basic()`. `false` leaves an extension out. */
11
11
  export interface BasicOptions {
12
12
  /** Headings, or their options. */
@@ -149,10 +149,6 @@ interface Editor {
149
149
  * ```
150
150
  */
151
151
  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
152
  /**
157
153
  * Attach to a DOM element. Document and history are kept across mount/unmount.
158
154
  * Throws if already mounted.
package/llms-full.txt CHANGED
@@ -639,9 +639,9 @@ const bold = $derived(state.current.marks.has('bold'))
639
639
 
640
640
  <main>
641
641
  <h1>Writeon · Svelte</h1>
642
- <div class="rte-root">
642
+ <div class="writeon-root">
643
643
  <div use:kitToolbar={editor}></div>
644
- <div use:editorContent={editor} class="rte-content"></div>
644
+ <div use:editorContent={editor} class="writeon-content"></div>
645
645
  </div>
646
646
  <p data-testid="status">
647
647
  Block: {state.current.block.type} ·
@@ -705,9 +705,9 @@ import { editorState } from './writeon'
705
705
  template: `
706
706
  <main>
707
707
  <h1>Writeon · Angular</h1>
708
- <div class="rte-root">
708
+ <div class="writeon-root">
709
709
  <div #toolbar></div>
710
- <div #content class="rte-content"></div>
710
+ <div #content class="writeon-content"></div>
711
711
  </div>
712
712
  <p data-testid="status">
713
713
  Block: {{ state().block.type }} ·
@@ -1105,9 +1105,9 @@ export function Editor() {
1105
1105
  const editor = useEditor({ extensions, label: 'Message' })
1106
1106
 
1107
1107
  return (
1108
- <div className="rte-root">
1108
+ <div className="writeon-root">
1109
1109
  <Toolbar editor={editor} />
1110
- <EditorContent editor={editor} className="rte-content" />
1110
+ <EditorContent editor={editor} className="writeon-content" />
1111
1111
 
1112
1112
  {/* Loaded on demand, after mount. */}
1113
1113
  <Advanced
@@ -1138,10 +1138,10 @@ const editor = useEditor({
1138
1138
  </script>
1139
1139
 
1140
1140
  <template>
1141
- <div class="rte-root">
1141
+ <div class="writeon-root">
1142
1142
  <!-- Buttons, menus and announcements in Uzbek. -->
1143
1143
  <Toolbar :editor="editor" :messages="uz" />
1144
- <EditorContent :editor="editor" class="rte-content" />
1144
+ <EditorContent :editor="editor" class="writeon-content" />
1145
1145
  <Advanced :editor="editor" :messages="uz" />
1146
1146
  </div>
1147
1147
  </template>
@@ -1156,11 +1156,11 @@ import { basic } from '@writeon/core/presets'
1156
1156
  import '@writeon/kit/style.css'
1157
1157
  import { mountToolbar } from '@writeon/kit'
1158
1158
 
1159
- // <div class="rte-root">
1159
+ // <div class="writeon-root">
1160
1160
  // <div id="toolbar"></div>
1161
- // <div id="editor" class="rte-content"></div>
1161
+ // <div id="editor" class="writeon-content"></div>
1162
1162
  // </div>
1163
- const root = document.querySelector<HTMLElement>('.rte-root')
1163
+ const root = document.querySelector<HTMLElement>('.writeon-root')
1164
1164
  const toolbarHost = document.querySelector<HTMLElement>('#toolbar')
1165
1165
  const element = document.querySelector<HTMLElement>('#editor')
1166
1166
  if (!root || !toolbarHost || !element) {
@@ -1179,7 +1179,7 @@ const { mountAdvanced } = await import('@writeon/kit/advanced')
1179
1179
  mountAdvanced(root, editor, { slash: true })
1180
1180
  ```
1181
1181
 
1182
- - `.rte-root` is the frame; `.rte-content` styles the document (headings, lists, code, tables, task lists, images, mentions) without Tailwind Typography.
1182
+ - `.writeon-root` is the frame; `.writeon-content` styles the document (headings, lists, code, tables, task lists, images, mentions) without Tailwind Typography.
1183
1183
  - `<Toolbar>` / `mountToolbar()`: undo/redo, text style menu, marks, lists, quote, clear formatting, link, tooltips. Options: `messages`, `blockTypes`, `headingLevels`, `link`, `exclude`, `mobile`.
1184
1184
  - `<Advanced>` / `mountAdvanced()` needs `advancedSchema()` in the editor. It turns on the advanced behaviour and adds:
1185
1185
  - image, table, task list and code block buttons to the toolbar;
@@ -1190,19 +1190,19 @@ Its code is a separate chunk, loaded after mount.
1190
1190
 
1191
1191
  ## Theme
1192
1192
 
1193
- Every colour, radius and font is a CSS variable on `.rte-root`:
1193
+ Every colour, radius and font is a CSS variable on `.writeon-root`:
1194
1194
 
1195
1195
  ```css
1196
- .rte-root {
1197
- --rte-color-accent: #0d9488;
1198
- --rte-color-accent-soft: #ccfbf1;
1199
- --rte-color-accent-text: #115e59;
1200
- --rte-radius: 4px;
1201
- --rte-font: "Inter", sans-serif;
1196
+ .writeon-root {
1197
+ --writeon-color-accent: #0d9488;
1198
+ --writeon-color-accent-soft: #ccfbf1;
1199
+ --writeon-color-accent-text: #115e59;
1200
+ --writeon-radius: 4px;
1201
+ --writeon-font: "Inter", sans-serif;
1202
1202
  }
1203
1203
  ```
1204
1204
 
1205
- Dark mode follows the system. To choose explicitly, set `data-theme="dark"` or `data-theme="light"` on `.rte-root` or any ancestor.
1205
+ Dark mode follows the system. To choose explicitly, set `data-theme="dark"` or `data-theme="light"` on `.writeon-root` or any ancestor.
1206
1206
 
1207
1207
  Each kit rule has the specificity of one class, so CSS resets such as Tailwind's preflight do not undo it, and any rule of yours with one class overrides it.
1208
1208
 
@@ -1405,14 +1405,14 @@ In 0.x a minor release may still break the API; its changelog says how to update
1405
1405
 
1406
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
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.
1408
+ - A test keeps the promise: documents with every node, mark and attribute, as the published releases since 0.1.0 stored them, must load, pass `validate()` in strict mode and render to the same HTML in every 1.x release. The HTML those releases wrote (what a form with `<writeon-editor>` stores) must read back to the same document.
1409
1409
 
1410
1410
  ## What semver covers
1411
1411
 
1412
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
1413
  - **The document format**: `DocJSON`, the node, mark and attribute names, and what each value means.
1414
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`.
1415
+ - **The kit's styling hooks**: the `--writeon-*` CSS variables, `.writeon-root`, `.writeon-content` and `data-theme`.
1416
1416
  - **`<writeon-editor>`**: the tag name, its attributes, properties and events, and what it sends with the form.
1417
1417
  - **Error codes** of `validate()` (`unknown-node`, `unsafe-url`, …). Messages are for people and can change.
1418
1418
 
@@ -1448,6 +1448,56 @@ A major release of Writeon may drop a Node.js version that has reached its end o
1448
1448
 
1449
1449
  ---
1450
1450
 
1451
+ Source: /guide/upgrade-1.md
1452
+
1453
+ # Upgrading to 1.0
1454
+
1455
+ 1.0 is the first release covered by the [stability promise](/guide/stability.md). Coming from 0.x, you change some names in your code and CSS. **Stored documents need nothing:** 1.0 reads every document and every HTML value that 0.x stored.
1456
+
1457
+ ## The `rte-` prefix is now `writeon-`
1458
+
1459
+ Before the project was called Writeon, its CSS used the prefix `rte-`. Every class, CSS variable, data attribute and generated id now uses `writeon-`:
1460
+
1461
+ | 0.x | 1.0 |
1462
+ | --- | --- |
1463
+ | `.rte-root`, `.rte-content`, `.rte-toolbar`, … | `.writeon-root`, `.writeon-content`, `.writeon-toolbar`, … |
1464
+ | `--rte-color-accent`, `--rte-radius`, … | `--writeon-color-accent`, `--writeon-radius`, … |
1465
+ | `data-rte-item`, `data-rte-upload` | `data-writeon-item`, `data-writeon-upload` |
1466
+ | `--rte-upload-progress` | `--writeon-upload-progress` |
1467
+ | `class="rte-embed"` in `toHTML()` output | `class="writeon-embed"` |
1468
+
1469
+ Find what to change in your project:
1470
+
1471
+ ```sh
1472
+ grep -rnE -- "rte-" src/
1473
+ ```
1474
+
1475
+ In most projects, replacing `rte-` with `writeon-` in your stylesheets and templates is all there is to it. For custom blocks, select `[data-embed]` instead of the class: the attribute has not changed and is in the HTML of every version.
1476
+
1477
+ ## Renamed APIs
1478
+
1479
+ | 0.x | 1.0 |
1480
+ | --- | --- |
1481
+ | `editor.enable(…)` | `editor.extend(…)` |
1482
+ | `format()` from `@writeon/ui` | `formatMessage()` |
1483
+ | `textAlignmentAt(editor.pm.state)` | `activeTextAlign(editor)` |
1484
+ | `activeFontFamily(editor.pm.state)`, `activeTextColor(…)`, `embedKinds(…)`, `selectedEmbed(…)` | the same functions with `editor` |
1485
+ | `toolbar.state.active` from React `useToolbar()` | `toolbar.active` (also `enabled`, `focusId`) |
1486
+
1487
+ TypeScript points at each of these after the update. `enable()` and `format()` warned in the console since 0.3.
1488
+
1489
+ ## Behaviour to check
1490
+
1491
+ - `validate()`, `toHTML()` and `toSafeHTML()` take the allowed link protocols from `link()` in your extensions. If you passed `urls.protocols` only to repeat them, you can remove it.
1492
+ - `setHeading()`, `toggleHeading()` and `heading({ levels })` take `1` to `6` in the types.
1493
+ - `@writeon/advanced/embed` is [experimental](/guide/stability.md#what-it-does-not-cover): its API can change in a minor release; stored blocks keep loading.
1494
+
1495
+ ## Stored documents
1496
+
1497
+ Nothing to do. JSON documents keep `schemaVersion: 1`, and HTML stored by a form with `<writeon-editor>` reads back to the same document (old `rte-embed` classes included). A test checks this against documents made with the published 0.x releases.
1498
+
1499
+ ---
1500
+
1451
1501
  Source: /recipes/upload-s3.md
1452
1502
 
1453
1503
  # Image uploads to S3
@@ -2299,8 +2349,8 @@ const imageUpload: (options) => Extension;
2299
2349
 
2300
2350
  Upload images that are pasted, dropped or chosen with a file picker
2301
2351
  (`uploadImages(editor, files)`), showing an accessible progress
2302
- placeholder (`[data-rte-upload]`, `role="progressbar"`, CSS variable
2303
- `--rte-upload-progress`) where each will appear. Requires `advancedSchema()`.
2352
+ placeholder (`[data-writeon-upload]`, `role="progressbar"`, CSS variable
2353
+ `--writeon-upload-progress`) where each will appear. Requires `advancedSchema()`.
2304
2354
 
2305
2355
  ## Parameters
2306
2356
 
@@ -3793,28 +3843,6 @@ Release everything. The editor cannot be used afterwards.
3793
3843
 
3794
3844
  ***
3795
3845
 
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
3846
  ### extend()
3819
3847
 
3820
3848
  ```ts
@@ -6294,7 +6322,7 @@ demand, so none of it is in your main bundle.
6294
6322
 
6295
6323
  ```ts
6296
6324
  const { mountAdvanced } = await import('@writeon/kit/advanced')
6297
- mountAdvanced(document.querySelector('.rte-root'), editor, {
6325
+ mountAdvanced(document.querySelector('.writeon-root'), editor, {
6298
6326
  messages: uz,
6299
6327
  upload: fetchUploader({ url: '/api/upload' }),
6300
6328
  mentions: (query) => searchPeople(query),
@@ -6384,7 +6412,7 @@ function Advanced(__namedParameters): ReactElement;
6384
6412
 
6385
6413
  The default kit's advanced UI for React: image dialog and uploads, table
6386
6414
  actions, the `/` menu, `@` mentions and the selection bubble. Its code is
6387
- loaded on demand, after mount. Put it inside `.rte-root`, next to
6415
+ loaded on demand, after mount. Put it inside `.writeon-root`, next to
6388
6416
  `<Toolbar />`. Options are read once, on mount.
6389
6417
 
6390
6418
  ## Parameters
@@ -6400,9 +6428,9 @@ loaded on demand, after mount. Put it inside `.rte-root`, next to
6400
6428
  ## Example
6401
6429
 
6402
6430
  ```tsx
6403
- <div className="rte-root">
6431
+ <div className="writeon-root">
6404
6432
  <Toolbar editor={editor} messages={uz} />
6405
- <EditorContent editor={editor} className="rte-content" />
6433
+ <EditorContent editor={editor} className="writeon-content" />
6406
6434
  <Advanced editor={editor} messages={uz} upload={fetchUploader({ url: '/api/upload' })} />
6407
6435
  </div>
6408
6436
  ```
@@ -6435,9 +6463,9 @@ The default kit toolbar for React. Options are read once, on mount.
6435
6463
  import '@writeon/kit/style.css'
6436
6464
  import { Toolbar } from '@writeon/kit/react'
6437
6465
 
6438
- <div className="rte-root">
6466
+ <div className="writeon-root">
6439
6467
  <Toolbar editor={editor} messages={uz} />
6440
- <EditorContent editor={editor} className="rte-content" />
6468
+ <EditorContent editor={editor} className="writeon-content" />
6441
6469
  </div>
6442
6470
  ```
6443
6471
 
@@ -6524,15 +6552,15 @@ const Advanced: DefineSetupFnComponent<AdvancedProps>;
6524
6552
 
6525
6553
  The default kit's advanced UI for Vue: image dialog and uploads, table
6526
6554
  actions, the `/` menu, `@` mentions and the selection bubble. Its code is
6527
- loaded on demand, after mount. Put it inside `.rte-root`, next to
6555
+ loaded on demand, after mount. Put it inside `.writeon-root`, next to
6528
6556
  `<Toolbar />`. Options are read once, on mount.
6529
6557
 
6530
6558
  ## Example
6531
6559
 
6532
6560
  ```vue
6533
- <div class="rte-root">
6561
+ <div class="writeon-root">
6534
6562
  <Toolbar :editor="editor" :messages="uz" />
6535
- <EditorContent :editor="editor" class="rte-content" />
6563
+ <EditorContent :editor="editor" class="writeon-content" />
6536
6564
  <Advanced :editor="editor" :messages="uz" :upload="upload" />
6537
6565
  </div>
6538
6566
  ```
@@ -6552,9 +6580,9 @@ The default kit toolbar for Vue. Options are read once, on mount.
6552
6580
  ## Example
6553
6581
 
6554
6582
  ```vue
6555
- <div class="rte-root">
6583
+ <div class="writeon-root">
6556
6584
  <Toolbar :editor="editor" :messages="uz" />
6557
- <EditorContent :editor="editor" class="rte-content" />
6585
+ <EditorContent :editor="editor" class="writeon-content" />
6558
6586
  </div>
6559
6587
  ```
6560
6588
 
@@ -8457,7 +8485,6 @@ menu and suggestions. Renders nothing.
8457
8485
  - [createTooltip](functions/createTooltip.md)
8458
8486
  - [displayShortcut](functions/displayShortcut.md)
8459
8487
  - [filterSuggestions](functions/filterSuggestions.md)
8460
- - [~~format~~](functions/format.md)
8461
8488
  - [formatMessage](functions/formatMessage.md)
8462
8489
  - [isApplePlatform](functions/isApplePlatform.md)
8463
8490
  - [matchesShortcut](functions/matchesShortcut.md)
@@ -10500,31 +10527,6 @@ containing) it, case-insensitive. Use it in `items` for static lists.
10500
10527
 
10501
10528
  ---
10502
10529
 
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
10530
  Source: /api/ui/functions/formatMessage.md
10529
10531
 
10530
10532
  # 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@writeon/core",
3
- "version": "0.3.0",
3
+ "version": "1.0.0-rc.0",
4
4
  "description": "Framework-agnostic, headless, accessible rich text editor core built on ProseMirror",
5
5
  "license": "MIT",
6
6
  "author": "Ma'ruf Sheraliyev (https://github.com/mfs1011)",