@editora/core 1.0.32 → 1.0.33

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/README.md CHANGED
@@ -52,6 +52,10 @@ Or from npm, for a bundler such as Vite, webpack or esbuild:
52
52
  npm install @editora/core
53
53
  ```
54
54
 
55
+ A bundler (Vite, webpack, esbuild, Next.js) handles the packages on any Node version. Importing them in plain
56
+ Node, with no bundler in between (a script, a test runner, a server render that keeps dependencies external), needs
57
+ Node 20.19 or later, or 22.12 or later: older releases, Node 18 included, cannot load them.
58
+
55
59
  ## Quick start
56
60
 
57
61
  ```html
@@ -164,8 +168,12 @@ The editor in the picture at the top of this page is configured like this:
164
168
  ```
165
169
 
166
170
  You can also configure an editor from JavaScript with `editor.setConfig({ toolbar: 'bold italic', height: 300 })`.
171
+ `setConfig` rebuilds the editor and keeps what the user has typed; pass `content` to replace it instead.
167
172
  To switch the theme at run time, set the attribute: `editor.setAttribute('theme', 'dark')`.
168
173
 
174
+ `readonly` shows content that cannot be edited. `disabled` goes further, like a disabled form field: it also
175
+ disables the toolbar buttons and takes the editor out of the tab order. Both work as attributes and in `setConfig`.
176
+
169
177
  ### Toolbar items
170
178
 
171
179
  `toolbar` takes names separated by spaces, with `|` between groups. The names are camelCase and case-sensitive
@@ -229,13 +237,13 @@ loaded by, is in [`@editora/plugins`](https://www.npmjs.com/package/@editora/plu
229
237
  | `setContent(html)` | Replaces the content. The HTML is sanitised first. |
230
238
  | `execCommand(name)` | Runs a command, as the toolbar does: `toggleBold`, `toggleItalic`, `toggleBulletList`, `insertTable`, `undo`, and so on. Returns `true` if the command ran. |
231
239
  | `focus()` / `blur()` | Moves the focus into or out of the editor. |
232
- | `setConfig(options)` | Changes options at run time, such as `toolbar` or `height`. |
240
+ | `setConfig(options)` | Rebuilds the editor with new options, such as `toolbar`, `height`, `theme` or `disabled`. What the user typed is kept; `content` replaces it. |
233
241
  | `getAPI()` | The same methods as an object, plus `on(event, handler)`, `getConfig()` and `setReadonly(boolean)`. |
234
242
 
235
243
  | Event | `event.detail` | |
236
244
  | --- | --- | --- |
237
- | `editor-ready` | | The editor has been built. It fires again if the editor is rebuilt, for example after you change `plugins` or `toolbar`. |
238
- | `content-change` | `{ html }` | The content changed. It can fire more than once for the same HTML, so compare before you save. |
245
+ | `editor-ready` | | The editor has been built. It fires again if the editor is rebuilt, for example after you change `plugins` or `toolbar` (once, however many attributes you change together). |
246
+ | `content-change` | `{ html }` | The content changed. It fires once after the user pauses typing, and when the editor loses the focus with a change that has not been reported yet, so it does not repeat the same HTML. |
239
247
  | `editor-focus` / `editor-blur` | | The editor gained or lost the focus. |
240
248
  | `editor-destroy` | | The editor was torn down. |
241
249