@lexion-rte/core 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 +16 -0
- package/README.md +112 -0
- package/package.json +4 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# @lexion-rte/core
|
|
2
|
+
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Refresh package metadata links and expand package-level README documentation.
|
|
8
|
+
|
|
9
|
+
## 0.1.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Update package metadata and documentation for the `@lexion-rte` package set.
|
|
14
|
+
|
|
15
|
+
- Align repository/homepage/bugs metadata with the current GitHub repository owner.
|
|
16
|
+
- Add package-level README files with package purpose and usage examples.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# @lexion-rte/core
|
|
2
|
+
|
|
3
|
+
Headless editor runtime for the Lexion platform.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@lexion-rte/core` provides:
|
|
8
|
+
|
|
9
|
+
- editor state and schema management
|
|
10
|
+
- command registration/execution
|
|
11
|
+
- extension lifecycle hooks (`onCreate`, `onDestroy`)
|
|
12
|
+
- JSON document input/output
|
|
13
|
+
|
|
14
|
+
This package does not render UI by itself. Pair it with `@lexion-rte/extensions` and optionally an adapter package.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add @lexion-rte/core
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Typical pairing:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add @lexion-rte/core @lexion-rte/extensions
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { LexionEditor } from "@lexion-rte/core";
|
|
32
|
+
import { starterKitExtension, starterKitCommandNames } from "@lexion-rte/extensions";
|
|
33
|
+
|
|
34
|
+
const editor = new LexionEditor({
|
|
35
|
+
extensions: [starterKitExtension]
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
editor.execute(starterKitCommandNames.toggleBold);
|
|
39
|
+
console.log(editor.getJSON());
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Editor Options
|
|
43
|
+
|
|
44
|
+
`LexionEditor` accepts:
|
|
45
|
+
|
|
46
|
+
- `schema?: Schema`
|
|
47
|
+
- `doc?: JSONDocument`
|
|
48
|
+
- `extensions?: LexionExtension[]`
|
|
49
|
+
- `plugins?: LexionPlugin[]` (alias for extensions)
|
|
50
|
+
- `commands?: CommandMap`
|
|
51
|
+
|
|
52
|
+
## Core API
|
|
53
|
+
|
|
54
|
+
Main instance members:
|
|
55
|
+
|
|
56
|
+
- `schema`
|
|
57
|
+
- `state`
|
|
58
|
+
- `doc`
|
|
59
|
+
- `getJSON()`
|
|
60
|
+
- `setJSON(document)`
|
|
61
|
+
- `dispatchTransaction(transaction)`
|
|
62
|
+
- `execute(command, ...args)`
|
|
63
|
+
- `registerCommand(name, handler)`
|
|
64
|
+
- `unregisterCommand(name)`
|
|
65
|
+
- `use(extension)`
|
|
66
|
+
- `removePlugin(key)`
|
|
67
|
+
- `destroy()`
|
|
68
|
+
|
|
69
|
+
## Custom Command Example
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { LexionEditor } from "@lexion-rte/core";
|
|
73
|
+
import { starterKitExtension } from "@lexion-rte/extensions";
|
|
74
|
+
|
|
75
|
+
const editor = new LexionEditor({ extensions: [starterKitExtension] });
|
|
76
|
+
|
|
77
|
+
editor.registerCommand("insertTimestamp", ({ state, dispatch }) => {
|
|
78
|
+
const { from, to } = state.selection;
|
|
79
|
+
dispatch(state.tr.insertText(new Date().toISOString(), from, to));
|
|
80
|
+
return true;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
editor.execute("insertTimestamp");
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Extension Lifecycle Example
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import type { LexionExtension } from "@lexion-rte/core";
|
|
90
|
+
|
|
91
|
+
const auditExtension: LexionExtension = {
|
|
92
|
+
key: "audit",
|
|
93
|
+
onCreate: ({ editor }) => {
|
|
94
|
+
console.log("created", editor.getJSON());
|
|
95
|
+
},
|
|
96
|
+
onDestroy: () => {
|
|
97
|
+
console.log("destroyed");
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Error Behavior
|
|
103
|
+
|
|
104
|
+
- Executing an unknown command throws `Unknown command: <name>`.
|
|
105
|
+
- Using an editor after `destroy()` throws an error.
|
|
106
|
+
- Registering duplicate command names throws.
|
|
107
|
+
|
|
108
|
+
## Related Packages
|
|
109
|
+
|
|
110
|
+
- `@lexion-rte/extensions` for starter-kit, AI, and collaboration features
|
|
111
|
+
- `@lexion-rte/tools` for HTML/text conversions
|
|
112
|
+
- adapter packages (`web`, `react`, `vue`, etc.) for UI integration
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lexion-rte/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Headless core runtime 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/core"
|
|
20
20
|
},
|
|
21
|
-
"homepage": "https://github.com/
|
|
21
|
+
"homepage": "https://github.com/dariusve/lexion/tree/main/packages/core",
|
|
22
22
|
"bugs": {
|
|
23
|
-
"url": "https://github.com/
|
|
23
|
+
"url": "https://github.com/dariusve/lexion/issues"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
26
|
"lexion",
|