@lexion-rte/tools 0.1.0 → 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 +21 -0
- package/README.md +62 -0
- package/package.json +5 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @lexion-rte/tools
|
|
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
|
+
|
|
11
|
+
## 0.1.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Update package metadata and documentation for the `@lexion-rte` package set.
|
|
16
|
+
|
|
17
|
+
- Align repository/homepage/bugs metadata with the current GitHub repository owner.
|
|
18
|
+
- Add package-level README files with package purpose and usage examples.
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- @lexion-rte/core@0.1.1
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @lexion-rte/tools
|
|
2
|
+
|
|
3
|
+
Conversion utilities for Lexion editor documents.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@lexion-rte/tools` provides:
|
|
8
|
+
|
|
9
|
+
- `toText(editor)`
|
|
10
|
+
- `fromText(editor, text)`
|
|
11
|
+
- `toHTML(editor, context?)`
|
|
12
|
+
- `fromHTML(editor, html, context?)`
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @lexion-rte/tools @lexion-rte/core
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Typical pairing:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm add @lexion-rte/tools @lexion-rte/core @lexion-rte/extensions
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Browser Example
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { LexionEditor } from "@lexion-rte/core";
|
|
30
|
+
import { starterKitExtension } from "@lexion-rte/extensions";
|
|
31
|
+
import { fromText, toHTML, toText } from "@lexion-rte/tools";
|
|
32
|
+
|
|
33
|
+
const editor = new LexionEditor({ extensions: [starterKitExtension] });
|
|
34
|
+
|
|
35
|
+
fromText(editor, "Line one\n\nLine two");
|
|
36
|
+
console.log(toText(editor));
|
|
37
|
+
console.log(toHTML(editor));
|
|
38
|
+
```
|
|
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.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Document conversion tools for the Lexion editor platform.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"license": "GPL-3.0-only",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "https://github.com/
|
|
18
|
+
"url": "https://github.com/dariusve/lexion.git",
|
|
19
19
|
"directory": "packages/tools"
|
|
20
20
|
},
|
|
21
|
-
"homepage": "https://github.com/
|
|
21
|
+
"homepage": "https://github.com/dariusve/lexion/tree/main/packages/tools",
|
|
22
22
|
"bugs": {
|
|
23
|
-
"url": "https://github.com/
|
|
23
|
+
"url": "https://github.com/dariusve/lexion/issues"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
26
|
"lexion",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"prosemirror-model": "^1.22.3",
|
|
37
|
-
"@lexion-rte/core": "0.1.
|
|
37
|
+
"@lexion-rte/core": "0.1.2"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsc -p tsconfig.json",
|