@lexion-rte/tools 0.1.1 → 0.1.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @lexion-rte/tools
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Refresh package metadata links and expand package-level README documentation.
8
+ - Updated dependencies
9
+ - @lexion-rte/core@0.1.2
10
+
3
11
  ## 0.1.1
4
12
 
5
13
  ### Patch Changes
package/README.md CHANGED
@@ -1,29 +1,62 @@
1
1
  # @lexion-rte/tools
2
2
 
3
- Document conversion helpers for Lexion.
3
+ Conversion utilities for Lexion editor documents.
4
4
 
5
- ## What It Is
5
+ ## Overview
6
6
 
7
- `@lexion-rte/tools` provides conversion utilities such as `toText`, `fromText`, `toHTML`, and `fromHTML`.
7
+ `@lexion-rte/tools` provides:
8
+
9
+ - `toText(editor)`
10
+ - `fromText(editor, text)`
11
+ - `toHTML(editor, context?)`
12
+ - `fromHTML(editor, html, context?)`
8
13
 
9
14
  ## Install
10
15
 
16
+ ```bash
17
+ pnpm add @lexion-rte/tools @lexion-rte/core
18
+ ```
19
+
20
+ Typical pairing:
21
+
11
22
  ```bash
12
23
  pnpm add @lexion-rte/tools @lexion-rte/core @lexion-rte/extensions
13
24
  ```
14
25
 
15
- ## Usage
26
+ ## Browser Example
16
27
 
17
28
  ```ts
18
29
  import { LexionEditor } from "@lexion-rte/core";
19
30
  import { starterKitExtension } from "@lexion-rte/extensions";
20
- import { fromText, toText } from "@lexion-rte/tools";
31
+ import { fromText, toHTML, toText } from "@lexion-rte/tools";
21
32
 
22
- const editor = new LexionEditor({
23
- extensions: [starterKitExtension]
24
- });
33
+ const editor = new LexionEditor({ extensions: [starterKitExtension] });
25
34
 
26
- fromText(editor, "Line 1\n\nLine 2");
35
+ fromText(editor, "Line one\n\nLine two");
27
36
  console.log(toText(editor));
37
+ console.log(toHTML(editor));
28
38
  ```
29
39
 
40
+ ## Server / Node Example
41
+
42
+ `toHTML` and `fromHTML` require a DOM `Document` when not running in the browser.
43
+
44
+ ```ts
45
+ import { JSDOM } from "jsdom";
46
+ import { LexionEditor } from "@lexion-rte/core";
47
+ import { starterKitExtension } from "@lexion-rte/extensions";
48
+ import { fromHTML, toHTML } from "@lexion-rte/tools";
49
+
50
+ const dom = new JSDOM("<!doctype html><html><body></body></html>");
51
+ const editor = new LexionEditor({ extensions: [starterKitExtension] });
52
+
53
+ fromHTML(editor, "<p><strong>Hello</strong> world</p>", { document: dom.window.document });
54
+ const html = toHTML(editor, { document: dom.window.document });
55
+ console.log(html);
56
+ ```
57
+
58
+ ## Notes
59
+
60
+ - `fromText` creates paragraph blocks separated by blank lines.
61
+ - Single newlines inside a paragraph map to `hard_break` when supported by schema.
62
+ - Conversions depend on the active editor schema.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexion-rte/tools",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Document conversion tools for the Lexion editor platform.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "prosemirror-model": "^1.22.3",
37
- "@lexion-rte/core": "0.1.1"
37
+ "@lexion-rte/core": "0.1.2"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "tsc -p tsconfig.json",