gzkx-editor 0.0.0 → 0.0.1
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/core/README.md +124 -0
- package/core/package.json +2 -1
- package/package.json +1 -2
package/core/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# @gzkx-editor/core
|
|
2
|
+
|
|
3
|
+
GZKX Editor — all ProseMirror modules bundled into a single package.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @gzkx-editor/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires `orderedmap` as a peer dependency:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install orderedmap
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { EditorState } from '@gzkx-editor/core';
|
|
21
|
+
import { EditorView } from '@gzkx-editor/core';
|
|
22
|
+
import { Schema, DOMParser } from '@gzkx-editor/core';
|
|
23
|
+
import { exampleSetup } from '@gzkx-editor/core';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Creating an Editor
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
import { EditorState } from '@gzkx-editor/core';
|
|
32
|
+
import { EditorView } from '@gzkx-editor/core';
|
|
33
|
+
import { schemaBasic } from '@gzkx-editor/core';
|
|
34
|
+
import { exampleSetupProvider } from '@gzkx-editor/core';
|
|
35
|
+
|
|
36
|
+
const state = EditorState.create({
|
|
37
|
+
doc: DOMParser.fromSchema(schemaBasic).parse('<p>Hello world</p>'),
|
|
38
|
+
plugins: exampleSetupProvider({ schema: schemaBasic })
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const view = new EditorView(document.body, { state });
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Schema
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
import { Schema } from '@gzkx-editor/core';
|
|
48
|
+
|
|
49
|
+
// Define a custom schema
|
|
50
|
+
const mySchema = new Schema({
|
|
51
|
+
nodes: {
|
|
52
|
+
doc: { content: 'block+' },
|
|
53
|
+
paragraph: { group: 'block', content: 'inline*' },
|
|
54
|
+
text: { group: 'inline' },
|
|
55
|
+
},
|
|
56
|
+
marks: {
|
|
57
|
+
strong: {},
|
|
58
|
+
em: {},
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Editor State & Transactions
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
import { EditorState } from '@gzkx-editor/core';
|
|
67
|
+
import { Selection, TextSelection } from '@gzkx-editor/core';
|
|
68
|
+
import { Transaction } from '@gzkx-editor/core';
|
|
69
|
+
|
|
70
|
+
// Create state
|
|
71
|
+
const state = EditorState.create({ schema });
|
|
72
|
+
|
|
73
|
+
// Dispatch a transaction
|
|
74
|
+
view.dispatch(state.tr.insertText('Hello'));
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Commands
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
import { deleteSelection, joinBackward, wrapIn } from '@gzkx-editor/core';
|
|
81
|
+
|
|
82
|
+
// Run a command
|
|
83
|
+
if (deleteSelection(state, dispatch)) {
|
|
84
|
+
// ...
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Key Modules
|
|
89
|
+
|
|
90
|
+
This package includes all the following modules:
|
|
91
|
+
|
|
92
|
+
| Module | Exports |
|
|
93
|
+
|--------|---------|
|
|
94
|
+
| **model** | `Node`, `Fragment`, `Slice`, `Mark`, `Schema`, `DOMParser`, `DOMSerializer` |
|
|
95
|
+
| **transform** | `Step`, `Transform`, `ReplaceStep`, `AddMarkStep`, `ReplaceAroundStep` |
|
|
96
|
+
| **state** | `EditorState`, `Transaction`, `Selection`, `Plugin` |
|
|
97
|
+
| **view** | `EditorView`, `Decoration`, `DecorationSet` |
|
|
98
|
+
| **commands** | `deleteSelection`, `joinBackward`, `wrapIn`, `setBlockType`, `toggleMark` |
|
|
99
|
+
| **keymap** | `keymap`, `baseKeymap` |
|
|
100
|
+
| **inputrules** | `inputRules`, `smartQuotes`, `wrappingInputRule` |
|
|
101
|
+
| **history** | `history`, `undo`, `redo`, `historyKeymap` |
|
|
102
|
+
| **dropcursor** | `dropCursor` |
|
|
103
|
+
| **gapcursor** | `gapCursor` |
|
|
104
|
+
| **schema-basic** | `schemaBasic`, `listSchema` |
|
|
105
|
+
| **schema-list** | `orderedList`, `bulletList`, `listItem` |
|
|
106
|
+
| **menu** | `menuBar`, `dropdown`, `menuItem`, `icons` |
|
|
107
|
+
| **collab** | `collab`, `sendable`, `receive` |
|
|
108
|
+
| **example-setup** | `exampleSetup`, `buildMenuItems`, `buildKeymap`, `buildInputRules` |
|
|
109
|
+
| **markdown** | `parser`, `serializer`, `toMarkdown` |
|
|
110
|
+
| **search** | `searchKeymap`, `findDialog` |
|
|
111
|
+
| **changeset** | `Change`, `ChangeSet` |
|
|
112
|
+
| **test-builder** | `builder`, `doc`, `paragraph`, `text`, `blockquote` |
|
|
113
|
+
|
|
114
|
+
## TypeScript
|
|
115
|
+
|
|
116
|
+
This package ships TypeScript declarations for all exports.
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
import { Node, Schema, EditorState } from '@gzkx-editor/core';
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|
package/core/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gzkx-editor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "Structured WYSIWYM editor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"maintainers": [
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"workspaces": [
|
|
28
28
|
"*"
|
|
29
29
|
],
|
|
30
|
-
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
33
32
|
"esbuild": "^0.28.0",
|