@kaitify/react 0.0.1-beta.4 → 0.0.1-beta.6
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/docs/.vitepress/cache/deps/_metadata.json +9 -9
- package/docs/.vitepress/config.ts +7 -2
- package/docs/changelog.md +5 -0
- package/docs/guide/install.md +5 -5
- package/docs/guide/wrapper.md +4 -0
- package/lib/editor/wrapper/props.d.ts +4 -0
- package/lib/kaitify-react.es.js +43 -18
- package/lib/kaitify-react.umd.js +2 -2
- package/package.json +2 -2
- package/src/editor/wrapper/props.ts +4 -0
- package/src/editor/wrapper/wrapper.tsx +1 -0
- package/tsconfig.json +1 -2
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
{
|
|
2
|
-
"hash": "
|
|
2
|
+
"hash": "c3f8d881",
|
|
3
3
|
"configHash": "1bbdb887",
|
|
4
|
-
"lockfileHash": "
|
|
5
|
-
"browserHash": "
|
|
4
|
+
"lockfileHash": "5d16e3cf",
|
|
5
|
+
"browserHash": "366a552c",
|
|
6
6
|
"optimized": {
|
|
7
7
|
"vue": {
|
|
8
8
|
"src": "../../../../node_modules/vue/dist/vue.runtime.esm-bundler.js",
|
|
9
9
|
"file": "vue.js",
|
|
10
|
-
"fileHash": "
|
|
10
|
+
"fileHash": "c84281de",
|
|
11
11
|
"needsInterop": false
|
|
12
12
|
},
|
|
13
13
|
"vitepress > @vue/devtools-api": {
|
|
14
14
|
"src": "../../../../node_modules/@vue/devtools-api/dist/index.js",
|
|
15
15
|
"file": "vitepress___@vue_devtools-api.js",
|
|
16
|
-
"fileHash": "
|
|
16
|
+
"fileHash": "8f151567",
|
|
17
17
|
"needsInterop": false
|
|
18
18
|
},
|
|
19
19
|
"vitepress > @vueuse/core": {
|
|
20
20
|
"src": "../../../../node_modules/@vueuse/core/index.mjs",
|
|
21
21
|
"file": "vitepress___@vueuse_core.js",
|
|
22
|
-
"fileHash": "
|
|
22
|
+
"fileHash": "552f5a37",
|
|
23
23
|
"needsInterop": false
|
|
24
24
|
},
|
|
25
25
|
"vitepress > @vueuse/integrations/useFocusTrap": {
|
|
26
26
|
"src": "../../../../node_modules/@vueuse/integrations/useFocusTrap.mjs",
|
|
27
27
|
"file": "vitepress___@vueuse_integrations_useFocusTrap.js",
|
|
28
|
-
"fileHash": "
|
|
28
|
+
"fileHash": "8fa0439b",
|
|
29
29
|
"needsInterop": false
|
|
30
30
|
},
|
|
31
31
|
"vitepress > mark.js/src/vanilla.js": {
|
|
32
32
|
"src": "../../../../node_modules/mark.js/src/vanilla.js",
|
|
33
33
|
"file": "vitepress___mark__js_src_vanilla__js.js",
|
|
34
|
-
"fileHash": "
|
|
34
|
+
"fileHash": "d9232ccd",
|
|
35
35
|
"needsInterop": false
|
|
36
36
|
},
|
|
37
37
|
"vitepress > minisearch": {
|
|
38
38
|
"src": "../../../../node_modules/minisearch/dist/es/index.js",
|
|
39
39
|
"file": "vitepress___minisearch.js",
|
|
40
|
-
"fileHash": "
|
|
40
|
+
"fileHash": "0b198074",
|
|
41
41
|
"needsInterop": false
|
|
42
42
|
}
|
|
43
43
|
},
|
|
@@ -53,12 +53,17 @@ export default defineConfig({
|
|
|
53
53
|
nav: [
|
|
54
54
|
{ text: '指南', link: '/guide/introduction', activeMatch: '/guide' },
|
|
55
55
|
{ text: '内置菜单', link: '/menus/introduction', activeMatch: '/menus' },
|
|
56
|
+
{ text: '更新日志', link: '/changelog' },
|
|
56
57
|
{
|
|
57
58
|
text: '在线体验',
|
|
58
59
|
link: 'https://www.so-better.cn/run?lib=kaitify-react',
|
|
59
60
|
target: '_blank'
|
|
60
61
|
},
|
|
61
|
-
{
|
|
62
|
+
{
|
|
63
|
+
text: '联系作者',
|
|
64
|
+
link: 'https://www.so-better.cn/author',
|
|
65
|
+
target: '_blank'
|
|
66
|
+
}
|
|
62
67
|
],
|
|
63
68
|
sidebar: {
|
|
64
69
|
'/guide': [
|
|
@@ -179,7 +184,7 @@ export default defineConfig({
|
|
|
179
184
|
},
|
|
180
185
|
vite: {
|
|
181
186
|
server: {
|
|
182
|
-
port:
|
|
187
|
+
port: 5406
|
|
183
188
|
}
|
|
184
189
|
}
|
|
185
190
|
})
|
package/docs/changelog.md
CHANGED
package/docs/guide/install.md
CHANGED
|
@@ -6,7 +6,7 @@ title: 安装
|
|
|
6
6
|
|
|
7
7
|
## 下载 kaitify-react 本地到使用
|
|
8
8
|
|
|
9
|
-
- 下载地址:[kaitify-react](https://registry.npmmirror.com/@kaitify/react/download/@kaitify/react-0.0.1-beta.
|
|
9
|
+
- 下载地址:[kaitify-react](https://registry.npmmirror.com/@kaitify/react/download/@kaitify/react-0.0.1-beta.5.tgz)
|
|
10
10
|
- 下载完成后最终解压得到一个 package 文件夹,进入 package 文件夹后,将 package 目录下的整个 lib 目录拷贝到你的项目下
|
|
11
11
|
- 在 html 页面中引入 js
|
|
12
12
|
|
|
@@ -28,7 +28,7 @@ title: 安装
|
|
|
28
28
|
|
|
29
29
|
```html
|
|
30
30
|
<!-- 引入固定版本的kaitify -->
|
|
31
|
-
<script src="https://unpkg.com/@kaitify/react@0.0.1-beta.
|
|
31
|
+
<script src="https://unpkg.com/@kaitify/react@0.0.1-beta.5/lib/kaitify-react.umd.js"></script>
|
|
32
32
|
<!-- 始终引入最新的kaitify -->
|
|
33
33
|
<script src="https://unpkg.com/@kaitify/react/lib/kaitify-react.umd.js"></script>
|
|
34
34
|
```
|
|
@@ -50,21 +50,21 @@ title: 安装
|
|
|
50
50
|
npm install @kaitify/react
|
|
51
51
|
|
|
52
52
|
# 安装指定版本
|
|
53
|
-
npm install @kaitify/react@0.0.1-beta.
|
|
53
|
+
npm install @kaitify/react@0.0.1-beta.5
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
```bash [yarn]
|
|
57
57
|
yarn install @kaitify/react
|
|
58
58
|
|
|
59
59
|
# 安装指定版本
|
|
60
|
-
yarn install @kaitify/react@0.0.1-beta.
|
|
60
|
+
yarn install @kaitify/react@0.0.1-beta.5
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
```bash [pnpm]
|
|
64
64
|
pnpm install @kaitify/react
|
|
65
65
|
|
|
66
66
|
# 安装指定版本
|
|
67
|
-
pnpm install @kaitify/react@0.0.1-beta.
|
|
67
|
+
pnpm install @kaitify/react@0.0.1-beta.5
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
:::
|
package/docs/guide/wrapper.md
CHANGED
|
@@ -216,6 +216,10 @@ export default function App() {
|
|
|
216
216
|
|
|
217
217
|
编辑器 `updateView` 执行时,通过比对新旧节点数组获取需要格式化的节点,在这些节点被格式化前,触发此方法,回调参数即当前需要被格式化的节点,该方法返回一个节点,返回的节点将会被格式化,如果你不需要任何特殊处理,返回入参提供的节点即可
|
|
218
218
|
|
|
219
|
+
##### onRedressSelection <Badge type="danger" text="(this: Editor) => void" />
|
|
220
|
+
|
|
221
|
+
编辑器进行光标纠正时触发,在这里可以修改虚拟光标的位置
|
|
222
|
+
|
|
219
223
|
##### onSelectionUpdate <Badge type="danger" text="(this: Editor, selection: Selection) => void" />
|
|
220
224
|
|
|
221
225
|
编辑器光标发生变化触发的事件,回调参数为编辑器的 `Selection` 对象实例
|
|
@@ -149,6 +149,10 @@ export type WrapperPropsType = {
|
|
|
149
149
|
* 编辑器updateView执行时,通过比对新旧节点数组获取需要格式化的节点,在这些节点被格式化前,触发此方法,回调参数即当前需要被格式化的节点,该方法返回一个节点,返回的节点将会被格式化,如果你不需要任何特殊处理,返回入参提供的节点即可
|
|
150
150
|
*/
|
|
151
151
|
onBeforePatchNodeToFormat?: EditorConfigureOptionType['onBeforePatchNodeToFormat'];
|
|
152
|
+
/**
|
|
153
|
+
* 编辑器进行光标纠正时触发,在这里可以修改虚拟光标的位置
|
|
154
|
+
*/
|
|
155
|
+
onRedressSelection?: EditorConfigureOptionType['onRedressSelection'];
|
|
152
156
|
/**
|
|
153
157
|
* 编辑器光标发生变化触发的事件
|
|
154
158
|
*/
|
package/lib/kaitify-react.es.js
CHANGED
|
@@ -2530,6 +2530,13 @@ const registerExtension = function(extension) {
|
|
|
2530
2530
|
return node;
|
|
2531
2531
|
};
|
|
2532
2532
|
}
|
|
2533
|
+
if (extension.onRedressSelection) {
|
|
2534
|
+
const fn2 = this.onRedressSelection;
|
|
2535
|
+
this.onRedressSelection = () => {
|
|
2536
|
+
extension.onRedressSelection.apply(this);
|
|
2537
|
+
if (fn2) fn2.apply(this);
|
|
2538
|
+
};
|
|
2539
|
+
}
|
|
2533
2540
|
if (extension.addCommands) {
|
|
2534
2541
|
const commands = extension.addCommands.apply(this);
|
|
2535
2542
|
this.commands = { ...this.commands, ...commands };
|
|
@@ -2606,21 +2613,20 @@ const updateSelection$1 = function() {
|
|
|
2606
2613
|
};
|
|
2607
2614
|
const redressSelection = function() {
|
|
2608
2615
|
if (!this.selection.focused()) {
|
|
2609
|
-
return
|
|
2616
|
+
return;
|
|
2610
2617
|
}
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2618
|
+
const startNode = this.selection.start.node;
|
|
2619
|
+
const endNode = this.selection.end.node;
|
|
2620
|
+
const startOffset = this.selection.start.offset;
|
|
2621
|
+
const endOffset = this.selection.end.offset;
|
|
2615
2622
|
const startNextNode = this.getNextSelectionNode(startNode);
|
|
2616
2623
|
if (startNextNode && startNextNode.isEqual(endNode) && startOffset == (startNode.isText() ? startNode.textContent.length : 1) && endOffset == 0) {
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2624
|
+
this.selection.end.node = startNode;
|
|
2625
|
+
this.selection.end.offset = startOffset;
|
|
2626
|
+
}
|
|
2627
|
+
if (this.onRedressSelection) {
|
|
2628
|
+
this.onRedressSelection.apply(this);
|
|
2622
2629
|
}
|
|
2623
|
-
return false;
|
|
2624
2630
|
};
|
|
2625
2631
|
const checkNodes = function() {
|
|
2626
2632
|
const nodes = this.stackNodes.filter((item) => {
|
|
@@ -3155,11 +3161,7 @@ const onSelectionChange = async function() {
|
|
|
3155
3161
|
if (!hasUpdate) {
|
|
3156
3162
|
return;
|
|
3157
3163
|
}
|
|
3158
|
-
|
|
3159
|
-
if (hasRedress) {
|
|
3160
|
-
await this.updateRealSelection();
|
|
3161
|
-
return;
|
|
3162
|
-
}
|
|
3164
|
+
redressSelection.apply(this);
|
|
3163
3165
|
this.history.updateSelection(this.selection);
|
|
3164
3166
|
if (typeof this.onSelectionUpdate == "function") {
|
|
3165
3167
|
this.onSelectionUpdate.apply(this, [this.selection]);
|
|
@@ -3307,6 +3309,7 @@ class Extension {
|
|
|
3307
3309
|
__publicField(this, "onAfterUpdateView");
|
|
3308
3310
|
__publicField(this, "onDetachMentBlockFromParent");
|
|
3309
3311
|
__publicField(this, "onBeforePatchNodeToFormat");
|
|
3312
|
+
__publicField(this, "onRedressSelection");
|
|
3310
3313
|
__publicField(this, "addCommands");
|
|
3311
3314
|
this.name = name;
|
|
3312
3315
|
}
|
|
@@ -3332,6 +3335,7 @@ class Extension {
|
|
|
3332
3335
|
if (options.onAfterUpdateView) extension.onAfterUpdateView = options.onAfterUpdateView;
|
|
3333
3336
|
if (options.onDetachMentBlockFromParent) extension.onDetachMentBlockFromParent = options.onDetachMentBlockFromParent;
|
|
3334
3337
|
if (options.onBeforePatchNodeToFormat) extension.onBeforePatchNodeToFormat = options.onBeforePatchNodeToFormat;
|
|
3338
|
+
if (options.onRedressSelection) extension.onRedressSelection = options.onRedressSelection;
|
|
3335
3339
|
if (options.addCommands) extension.addCommands = options.addCommands;
|
|
3336
3340
|
return extension;
|
|
3337
3341
|
}
|
|
@@ -35999,7 +36003,12 @@ const TableExtension = () => Extension.create({
|
|
|
35999
36003
|
const rows = nodes.filter((item) => item.isMatch({ tag: "tr" })).map((item) => {
|
|
36000
36004
|
item.parent = tbody;
|
|
36001
36005
|
if (item.hasChildren()) {
|
|
36002
|
-
item.children = item.children.
|
|
36006
|
+
item.children = item.children.map((it) => {
|
|
36007
|
+
if (!it.isMatch({ tag: "td" }) && !it.isMatch({ tag: "th" })) {
|
|
36008
|
+
it.toEmpty();
|
|
36009
|
+
}
|
|
36010
|
+
return it;
|
|
36011
|
+
});
|
|
36003
36012
|
}
|
|
36004
36013
|
return item;
|
|
36005
36014
|
});
|
|
@@ -36115,6 +36124,20 @@ const TableExtension = () => Extension.create({
|
|
|
36115
36124
|
}
|
|
36116
36125
|
}
|
|
36117
36126
|
},
|
|
36127
|
+
onRedressSelection() {
|
|
36128
|
+
if (this.selection.focused()) {
|
|
36129
|
+
const startNode = this.selection.start.node;
|
|
36130
|
+
const endNode = this.selection.end.node;
|
|
36131
|
+
if (!!startNode.getMatchNode({ tag: "td" }) && !!endNode.getMatchNode({ tag: "td" })) {
|
|
36132
|
+
const startOffset = this.selection.start.offset;
|
|
36133
|
+
const startNextNode = this.getNextSelectionNode(startNode);
|
|
36134
|
+
if (startNextNode && startNextNode.isEqual(endNode) && startOffset == (startNode.isText() ? startNode.textContent.length : 1)) {
|
|
36135
|
+
this.selection.start.node = endNode;
|
|
36136
|
+
this.selection.start.offset = 0;
|
|
36137
|
+
}
|
|
36138
|
+
}
|
|
36139
|
+
}
|
|
36140
|
+
},
|
|
36118
36141
|
addCommands() {
|
|
36119
36142
|
const getTable = () => {
|
|
36120
36143
|
return this.getMatchNodeBySelection({
|
|
@@ -36867,6 +36890,7 @@ class Editor {
|
|
|
36867
36890
|
__publicField(this, "onAfterUpdateView");
|
|
36868
36891
|
__publicField(this, "onDetachMentBlockFromParent");
|
|
36869
36892
|
__publicField(this, "onBeforePatchNodeToFormat");
|
|
36893
|
+
__publicField(this, "onRedressSelection");
|
|
36870
36894
|
__publicField(this, "guid", createGuid());
|
|
36871
36895
|
__publicField(this, "selection", new Selection());
|
|
36872
36896
|
__publicField(this, "history", new History());
|
|
@@ -37103,7 +37127,6 @@ class Editor {
|
|
|
37103
37127
|
}
|
|
37104
37128
|
if (typeof this.onDomParseNode == "function") {
|
|
37105
37129
|
node = this.onDomParseNode.apply(this, [node]);
|
|
37106
|
-
console.log("node", node);
|
|
37107
37130
|
}
|
|
37108
37131
|
return node;
|
|
37109
37132
|
}
|
|
@@ -38355,6 +38378,7 @@ class Editor {
|
|
|
38355
38378
|
if (options.onAfterUpdateView) editor.onAfterUpdateView = options.onAfterUpdateView;
|
|
38356
38379
|
if (options.onDetachMentBlockFromParent) editor.onDetachMentBlockFromParent = options.onDetachMentBlockFromParent;
|
|
38357
38380
|
if (options.onBeforePatchNodeToFormat) editor.onBeforePatchNodeToFormat = options.onBeforePatchNodeToFormat;
|
|
38381
|
+
if (options.onRedressSelection) editor.onRedressSelection = options.onRedressSelection;
|
|
38358
38382
|
editor.extensions.forEach((item) => registerExtension.apply(editor, [item]));
|
|
38359
38383
|
editor.setEditable(typeof options.editable == "boolean" ? options.editable : true);
|
|
38360
38384
|
await editor.review(options.value || "");
|
|
@@ -40212,6 +40236,7 @@ const Wrapper = forwardRef((props, ref) => {
|
|
|
40212
40236
|
onPasteFile: props.onPasteFile,
|
|
40213
40237
|
onDetachMentBlockFromParent: props.onDetachMentBlockFromParent,
|
|
40214
40238
|
onBeforePatchNodeToFormat: props.onBeforePatchNodeToFormat,
|
|
40239
|
+
onRedressSelection: props.onRedressSelection,
|
|
40215
40240
|
onInsertParagraph: props.onInsertParagraph,
|
|
40216
40241
|
onDeleteComplete: props.onDeleteComplete,
|
|
40217
40242
|
onKeydown: props.onKeydown,
|