@lexion-rte/extensions 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 +108 -0
- package/package.json +5 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @lexion-rte/extensions
|
|
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,108 @@
|
|
|
1
|
+
# @lexion-rte/extensions
|
|
2
|
+
|
|
3
|
+
Feature extension bundle for Lexion.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@lexion-rte/extensions` ships:
|
|
8
|
+
|
|
9
|
+
- starter-kit schema and commands
|
|
10
|
+
- AI extension primitives (`AIService`, `aiExtension`)
|
|
11
|
+
- collaboration extension primitives (`createCollaborationExtension`)
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @lexion-rte/extensions @lexion-rte/core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
For collaboration features:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add yjs y-protocols y-prosemirror
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Exports
|
|
26
|
+
|
|
27
|
+
- `starterKitExtension`
|
|
28
|
+
- `starterKitSchema`
|
|
29
|
+
- `createStarterKitSchema()`
|
|
30
|
+
- `createStarterKitCommands()`
|
|
31
|
+
- `starterKitCommandNames`
|
|
32
|
+
- `aiExtension`, `aiCommandNames`, `AIService`, `createAIService()`
|
|
33
|
+
- `createCollaborationExtension()`, `collaborationCommandNames`
|
|
34
|
+
|
|
35
|
+
## Starter Kit Commands
|
|
36
|
+
|
|
37
|
+
`starterKitCommandNames` includes:
|
|
38
|
+
|
|
39
|
+
- `setParagraph`
|
|
40
|
+
- `toggleHeading`
|
|
41
|
+
- `toggleBold`
|
|
42
|
+
- `toggleItalic`
|
|
43
|
+
- `wrapBulletList`
|
|
44
|
+
- `wrapOrderedList`
|
|
45
|
+
- `liftListItem`
|
|
46
|
+
- `sinkListItem`
|
|
47
|
+
- `setLink`
|
|
48
|
+
- `unsetLink`
|
|
49
|
+
- `undo`
|
|
50
|
+
- `redo`
|
|
51
|
+
|
|
52
|
+
## Starter Kit Example
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { LexionEditor } from "@lexion-rte/core";
|
|
56
|
+
import { starterKitExtension, starterKitCommandNames } from "@lexion-rte/extensions";
|
|
57
|
+
|
|
58
|
+
const editor = new LexionEditor({ extensions: [starterKitExtension] });
|
|
59
|
+
|
|
60
|
+
editor.execute(starterKitCommandNames.toggleHeading, { level: 2 });
|
|
61
|
+
editor.execute(starterKitCommandNames.toggleBold);
|
|
62
|
+
editor.execute(starterKitCommandNames.setLink, {
|
|
63
|
+
href: "https://example.com",
|
|
64
|
+
title: "Example"
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## AI Service Example
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { LexionEditor } from "@lexion-rte/core";
|
|
72
|
+
import { AIService, aiExtension, starterKitExtension } from "@lexion-rte/extensions";
|
|
73
|
+
|
|
74
|
+
const editor = new LexionEditor({
|
|
75
|
+
extensions: [starterKitExtension, aiExtension]
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const service = new AIService({
|
|
79
|
+
async generate({ prompt, selection }) {
|
|
80
|
+
return `Prompt: ${prompt}\nSelection: ${selection}`;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
await service.generateAndApply(editor, "Rewrite this paragraph clearly");
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Collaboration Example
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { LexionEditor } from "@lexion-rte/core";
|
|
91
|
+
import {
|
|
92
|
+
createCollaborationExtension,
|
|
93
|
+
collaborationCommandNames,
|
|
94
|
+
starterKitExtension
|
|
95
|
+
} from "@lexion-rte/extensions";
|
|
96
|
+
import * as Y from "yjs";
|
|
97
|
+
import { Awareness } from "y-protocols/awareness";
|
|
98
|
+
|
|
99
|
+
const ydoc = new Y.Doc();
|
|
100
|
+
const awareness = new Awareness(ydoc);
|
|
101
|
+
const fragment = ydoc.getXmlFragment("lexion");
|
|
102
|
+
|
|
103
|
+
const editor = new LexionEditor({
|
|
104
|
+
extensions: [starterKitExtension, createCollaborationExtension({ fragment, awareness })]
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
editor.execute(collaborationCommandNames.undo);
|
|
108
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lexion-rte/extensions",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Feature extensions 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/extensions"
|
|
20
20
|
},
|
|
21
|
-
"homepage": "https://github.com/
|
|
21
|
+
"homepage": "https://github.com/dariusve/lexion/tree/main/packages/extensions",
|
|
22
22
|
"bugs": {
|
|
23
|
-
"url": "https://github.com/
|
|
23
|
+
"url": "https://github.com/dariusve/lexion/issues"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
26
|
"lexion",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"y-prosemirror": "^1.2.12",
|
|
44
44
|
"y-protocols": "^1.0.6",
|
|
45
45
|
"yjs": "^13.6.23",
|
|
46
|
-
"@lexion-rte/core": "0.1.
|
|
46
|
+
"@lexion-rte/core": "0.1.2"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "tsc -p tsconfig.json",
|