@kaitify/core 0.0.1-beta.1 → 0.0.1-beta.10
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/lib/kaitify-core.es.js +501 -709
- package/lib/kaitify-core.umd.js +2 -2
- package/lib/model/Editor.d.ts +1 -1
- package/package.json +50 -50
- package/examples/App.vue +0 -342
- package/examples/content.js +0 -1
- package/examples/main.ts +0 -4
- package/examples/test.html +0 -23
- package/src/css/style.less +0 -56
- package/src/css/var.less +0 -45
- package/src/extensions/Extension.ts +0 -200
- package/src/extensions/align/index.ts +0 -115
- package/src/extensions/attachment/icon.svg +0 -1
- package/src/extensions/attachment/index.ts +0 -293
- package/src/extensions/attachment/style.less +0 -25
- package/src/extensions/back-color/index.ts +0 -56
- package/src/extensions/blockquote/index.ts +0 -144
- package/src/extensions/blockquote/style.less +0 -16
- package/src/extensions/bold/index.ts +0 -77
- package/src/extensions/code/index.ts +0 -295
- package/src/extensions/code/style.less +0 -14
- package/src/extensions/code-block/hljs.less +0 -183
- package/src/extensions/code-block/hljs.ts +0 -95
- package/src/extensions/code-block/index.ts +0 -308
- package/src/extensions/code-block/style.less +0 -20
- package/src/extensions/color/index.ts +0 -56
- package/src/extensions/font-family/index.ts +0 -80
- package/src/extensions/font-size/index.ts +0 -56
- package/src/extensions/heading/index.ts +0 -164
- package/src/extensions/heading/style.less +0 -42
- package/src/extensions/history/index.ts +0 -96
- package/src/extensions/horizontal/index.ts +0 -45
- package/src/extensions/horizontal/style.less +0 -13
- package/src/extensions/image/index.ts +0 -242
- package/src/extensions/image/style.less +0 -8
- package/src/extensions/indent/index.ts +0 -98
- package/src/extensions/index.ts +0 -29
- package/src/extensions/italic/index.ts +0 -77
- package/src/extensions/line-height/index.ts +0 -113
- package/src/extensions/link/index.ts +0 -184
- package/src/extensions/link/style.less +0 -19
- package/src/extensions/list/index.ts +0 -410
- package/src/extensions/list/style.less +0 -19
- package/src/extensions/math/index.ts +0 -233
- package/src/extensions/math/style.less +0 -21
- package/src/extensions/strikethrough/index.ts +0 -78
- package/src/extensions/subscript/index.ts +0 -77
- package/src/extensions/superscript/index.ts +0 -77
- package/src/extensions/table/index.ts +0 -1148
- package/src/extensions/table/style.less +0 -71
- package/src/extensions/task/index.ts +0 -243
- package/src/extensions/task/style.less +0 -59
- package/src/extensions/text/index.ts +0 -359
- package/src/extensions/underline/index.ts +0 -78
- package/src/extensions/video/index.ts +0 -273
- package/src/extensions/video/style.less +0 -8
- package/src/index.ts +0 -9
- package/src/model/Editor.ts +0 -1963
- package/src/model/History.ts +0 -115
- package/src/model/KNode.ts +0 -677
- package/src/model/Selection.ts +0 -39
- package/src/model/config/dom-observe.ts +0 -184
- package/src/model/config/event-handler.ts +0 -237
- package/src/model/config/format-patch.ts +0 -215
- package/src/model/config/format-rules.ts +0 -218
- package/src/model/config/function.ts +0 -1018
- package/src/model/index.ts +0 -6
- package/src/tools/index.ts +0 -156
- package/src/view/index.ts +0 -46
- package/src/view/js-render/dom-patch.ts +0 -324
- package/src/view/js-render/index.ts +0 -210
- package/vite-env.d.ts +0 -2
package/lib/model/Editor.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
2
|
+
"name": "@kaitify/core",
|
|
3
|
+
"version": "0.0.1-beta.10",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": "so-better",
|
|
7
|
+
"main": "lib/kaitify-core.umd.js",
|
|
8
|
+
"module": "lib/kaitify-core.es.js",
|
|
9
|
+
"types": "lib/index.d.ts",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"description": "基于原生JS的富文本编辑器核心库",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "vite",
|
|
14
|
+
"lib": "tsc && vite build",
|
|
15
|
+
"docs:dev": "vitepress dev docs",
|
|
16
|
+
"docs:build": "vitepress build docs"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"csstype": "^3.1.3",
|
|
20
|
+
"dap-util": "^1.5.9",
|
|
21
|
+
"highlight.js": "^11.10.0",
|
|
22
|
+
"interactjs": "^1.10.27",
|
|
23
|
+
"katex": "^0.16.11",
|
|
24
|
+
"vue": "^3.5.12"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/katex": "^0.16.7",
|
|
28
|
+
"@types/node": "^20.11.24",
|
|
29
|
+
"@vitejs/plugin-vue": "^5.0.4",
|
|
30
|
+
"less": "^3.0.4",
|
|
31
|
+
"less-loader": "^5.0.0",
|
|
32
|
+
"terser": "^5.16.9",
|
|
33
|
+
"typescript": "^5.6.3",
|
|
34
|
+
"vite": "^5.4.10",
|
|
35
|
+
"vite-plugin-css-injected-by-js": "^3.5.1",
|
|
36
|
+
"vite-plugin-dts": "^4.3.0",
|
|
37
|
+
"vitepress": "^1.5.0"
|
|
38
|
+
},
|
|
39
|
+
"browserslist": [
|
|
40
|
+
"> 1%",
|
|
41
|
+
"last 2 versions",
|
|
42
|
+
"not dead"
|
|
43
|
+
],
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "https://github.com/so-better/kaitify-core"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public",
|
|
50
|
+
"registry": "https://registry.npmjs.org"
|
|
51
|
+
}
|
|
52
52
|
}
|
package/examples/App.vue
DELETED
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="container">
|
|
3
|
-
<div class="left">
|
|
4
|
-
<fieldset>
|
|
5
|
-
<legend>自定义操作</legend>
|
|
6
|
-
<div class="toolbar">
|
|
7
|
-
<button>当前编辑器内容字数:{{ count }}</button>
|
|
8
|
-
<button @click="insertNode">插入节点</button>
|
|
9
|
-
</div>
|
|
10
|
-
</fieldset>
|
|
11
|
-
<fieldset>
|
|
12
|
-
<legend>编辑器设置</legend>
|
|
13
|
-
<div class="toolbar">
|
|
14
|
-
<button @click="editor?.setEditable(!editor.isEditable())">启用/禁用编辑功能</button>
|
|
15
|
-
<button @click="editor && (editor.allowCopy = !editor.allowCopy)">启用/禁用复制功能</button>
|
|
16
|
-
<button @click="editor && (editor.allowCut = !editor.allowCut)">启用/禁用剪切功能</button>
|
|
17
|
-
<button @click="editor && (editor.allowPaste = !editor.allowPaste)">启用/禁用粘贴功能</button>
|
|
18
|
-
<button @click="editor && (editor.allowPasteHtml = !editor.allowPasteHtml)">启用/禁用粘贴HTML功能</button>
|
|
19
|
-
<button @click="editor && (editor.priorityPasteFiles = !editor.priorityPasteFiles)">启用/禁用文件粘贴优先</button>
|
|
20
|
-
<button @click="editor?.commands.undo!()">撤销</button>
|
|
21
|
-
<button @click="editor?.commands.redo!()">重做</button>
|
|
22
|
-
<button @click="editor?.setDark(true)">深色模式</button>
|
|
23
|
-
<button @click="editor?.setDark(false)">浅色模式</button>
|
|
24
|
-
</div>
|
|
25
|
-
</fieldset>
|
|
26
|
-
<fieldset>
|
|
27
|
-
<legend>对齐方式</legend>
|
|
28
|
-
<div class="toolbar">
|
|
29
|
-
<button @click="editor?.commands.setAlign!('left')">左对齐</button>
|
|
30
|
-
<button @click="editor?.commands.setAlign!('right')">右对齐</button>
|
|
31
|
-
<button @click="editor?.commands.setAlign!('center')">居中对齐</button>
|
|
32
|
-
<button @click="editor?.commands.setAlign!('justify')">两端对齐</button>
|
|
33
|
-
<button @click="editor?.commands.unsetAlign!('left')">取消左对齐</button>
|
|
34
|
-
<button @click="editor?.commands.unsetAlign!('right')">取消右对齐</button>
|
|
35
|
-
<button @click="editor?.commands.unsetAlign!('center')">取消居中对齐</button>
|
|
36
|
-
<button @click="editor?.commands.unsetAlign!('justify')">取消两端对齐</button>
|
|
37
|
-
</div>
|
|
38
|
-
</fieldset>
|
|
39
|
-
<fieldset>
|
|
40
|
-
<legend>行高</legend>
|
|
41
|
-
<div class="toolbar">
|
|
42
|
-
<button @click="editor?.commands.setLineHeight!(3)">设置3行高</button>
|
|
43
|
-
<button @click="editor?.commands.unsetLineHeight!(3)">取消3行高</button>
|
|
44
|
-
</div>
|
|
45
|
-
</fieldset>
|
|
46
|
-
<fieldset>
|
|
47
|
-
<legend>链接</legend>
|
|
48
|
-
<div class="toolbar">
|
|
49
|
-
<button
|
|
50
|
-
@click="editor?.commands.setLink!({ href: 'https://www.baidu.com', newOpen: true, text: '百度一下,你就知道' })">插入链接</button>
|
|
51
|
-
<button @click="editor?.commands.unsetLink!()">取消链接</button>
|
|
52
|
-
<button @click="editor?.commands.updateLink!({ href: 'https://www.so-better.cn' })">更新链接</button>
|
|
53
|
-
</div>
|
|
54
|
-
</fieldset>
|
|
55
|
-
<fieldset>
|
|
56
|
-
<legend>缩进</legend>
|
|
57
|
-
<div class="toolbar">
|
|
58
|
-
<button @click="editor?.commands.setIncreaseIndent!()">增加缩进</button>
|
|
59
|
-
<button @click="editor?.commands.setDecreaseIndent!()">减少缩进</button>
|
|
60
|
-
</div>
|
|
61
|
-
</fieldset>
|
|
62
|
-
<fieldset>
|
|
63
|
-
<legend>列表</legend>
|
|
64
|
-
<div class="toolbar">
|
|
65
|
-
<button @click="editor?.commands.setList!({ ordered: true, listType: 'decimal' })">插入有序列表1</button>
|
|
66
|
-
<button @click="editor?.commands.setList!({ ordered: true, listType: 'cjk-ideographic' })">插入有序列表2</button>
|
|
67
|
-
<button @click="editor?.commands.setList!({ ordered: true, listType: 'lower-alpha' })">插入有序列表3</button>
|
|
68
|
-
<button @click="editor?.commands.setList!({ ordered: true, listType: 'lower-greek' })">插入有序列表4</button>
|
|
69
|
-
<button @click="editor?.commands.setList!({ ordered: true, listType: 'lower-roman' })">插入有序列表5</button>
|
|
70
|
-
<button @click="editor?.commands.setList!({ ordered: true, listType: 'upper-alpha' })">插入有序列表6</button>
|
|
71
|
-
<button @click="editor?.commands.setList!({ ordered: true, listType: 'upper-roman' })">插入有序列表6</button>
|
|
72
|
-
<button @click="editor?.commands.setList!({ ordered: false, listType: 'disc' })">插入无序列表1</button>
|
|
73
|
-
<button @click="editor?.commands.setList!({ ordered: false, listType: 'circle' })">插入无序列表2</button>
|
|
74
|
-
<button @click="editor?.commands.setList!({ ordered: false, listType: 'square' })">插入无序列表3</button>
|
|
75
|
-
</div>
|
|
76
|
-
</fieldset>
|
|
77
|
-
<fieldset>
|
|
78
|
-
<legend>待办列表</legend>
|
|
79
|
-
<div class="toolbar">
|
|
80
|
-
<button @click="editor?.commands.setTask!()">插入待办</button>
|
|
81
|
-
<button @click="editor?.commands.unsetTask!()">取消待办</button>
|
|
82
|
-
</div>
|
|
83
|
-
</fieldset>
|
|
84
|
-
<fieldset>
|
|
85
|
-
<legend>背景色</legend>
|
|
86
|
-
<div class="toolbar">
|
|
87
|
-
<button @click="editor?.commands.setBackColor!('#f30')">设置#f30背景色</button>
|
|
88
|
-
<button @click="editor?.commands.unsetBackColor!('#f30')">取消设置#f30背景色</button>
|
|
89
|
-
</div>
|
|
90
|
-
</fieldset>
|
|
91
|
-
<fieldset>
|
|
92
|
-
<legend>字体颜色</legend>
|
|
93
|
-
<div class="toolbar">
|
|
94
|
-
<button @click="editor?.commands.setColor!('#f30')">设置#f30字体颜色</button>
|
|
95
|
-
<button @click="editor?.commands.unsetColor!('#f30')">取消设置#f30字体颜色</button>
|
|
96
|
-
</div>
|
|
97
|
-
</fieldset>
|
|
98
|
-
<fieldset>
|
|
99
|
-
<legend>加粗</legend>
|
|
100
|
-
<div class="toolbar">
|
|
101
|
-
<button @click="editor?.commands.setBold!()">设置加粗</button>
|
|
102
|
-
<button @click="editor?.commands.unsetBold!()">取消加粗</button>
|
|
103
|
-
</div>
|
|
104
|
-
</fieldset>
|
|
105
|
-
<fieldset>
|
|
106
|
-
<legend>删除线</legend>
|
|
107
|
-
<div class="toolbar">
|
|
108
|
-
<button @click="editor?.commands.setStrikethrough!()">设置删除线</button>
|
|
109
|
-
<button @click="editor?.commands.unsetStrikethrough!()">取消删除线</button>
|
|
110
|
-
</div>
|
|
111
|
-
</fieldset>
|
|
112
|
-
<fieldset>
|
|
113
|
-
<legend>下划线</legend>
|
|
114
|
-
<div class="toolbar">
|
|
115
|
-
<button @click="editor?.commands.setUnderline!()">设置下划线</button>
|
|
116
|
-
<button @click="editor?.commands.unsetUnderline!()">取消下划线</button>
|
|
117
|
-
</div>
|
|
118
|
-
</fieldset>
|
|
119
|
-
<fieldset>
|
|
120
|
-
<legend>上标</legend>
|
|
121
|
-
<div class="toolbar">
|
|
122
|
-
<button @click="editor?.commands.setSuperscript!()">设置上标</button>
|
|
123
|
-
<button @click="editor?.commands.unsetSuperscript!()">取消上标</button>
|
|
124
|
-
</div>
|
|
125
|
-
</fieldset>
|
|
126
|
-
<fieldset>
|
|
127
|
-
<legend>下标</legend>
|
|
128
|
-
<div class="toolbar">
|
|
129
|
-
<button @click="editor?.commands.setSubscript!()">设置下标</button>
|
|
130
|
-
<button @click="editor?.commands.unsetSubscript!()">取消下标</button>
|
|
131
|
-
</div>
|
|
132
|
-
</fieldset>
|
|
133
|
-
<fieldset>
|
|
134
|
-
<legend>斜体</legend>
|
|
135
|
-
<div class="toolbar">
|
|
136
|
-
<button @click="editor?.commands.setItalic!()">设置斜体</button>
|
|
137
|
-
<button @click="editor?.commands.unsetItalic!()">取消斜体</button>
|
|
138
|
-
</div>
|
|
139
|
-
</fieldset>
|
|
140
|
-
<fieldset>
|
|
141
|
-
<legend>字体</legend>
|
|
142
|
-
<div class="toolbar">
|
|
143
|
-
<button @click="editor?.commands.setFontFamily!('楷体-简,楷体')">设置楷体字体</button>
|
|
144
|
-
<button @click="editor?.commands.unsetFontFamily!('楷体-简,楷体')">取消设置楷体字体</button>
|
|
145
|
-
</div>
|
|
146
|
-
</fieldset>
|
|
147
|
-
<fieldset>
|
|
148
|
-
<legend>字号</legend>
|
|
149
|
-
<div class="toolbar">
|
|
150
|
-
<button @click="editor?.commands.setFontSize!('28px')">设置28px字号</button>
|
|
151
|
-
<button @click="editor?.commands.unsetFontSize!('28px')">取消设置28px字号</button>
|
|
152
|
-
</div>
|
|
153
|
-
</fieldset>
|
|
154
|
-
<fieldset>
|
|
155
|
-
<legend>行内代码</legend>
|
|
156
|
-
<div class="toolbar">
|
|
157
|
-
<button @click="editor?.commands.setCode!()">设置行内代码</button>
|
|
158
|
-
<button @click="editor?.commands.unsetCode!()">取消行内代码</button>
|
|
159
|
-
</div>
|
|
160
|
-
</fieldset>
|
|
161
|
-
<fieldset>
|
|
162
|
-
<legend>图片</legend>
|
|
163
|
-
<div class="toolbar">
|
|
164
|
-
<button
|
|
165
|
-
@click="editor?.commands.setImage!({ src: 'https://bpic.588ku.com/back_origin_min_pic/24/07/20/e9c6eadf8dd571483c69372b7c21aaa5.jpg!/fh/333/quality/95/unsharp/true/compress/true', alt: '图片加载失败', width: '200px' })">插入图片</button>
|
|
166
|
-
</div>
|
|
167
|
-
</fieldset>
|
|
168
|
-
<fieldset>
|
|
169
|
-
<legend>视频</legend>
|
|
170
|
-
<div class="toolbar">
|
|
171
|
-
<button
|
|
172
|
-
@click="editor?.commands.setVideo!({ src: 'https://bpic.588ku.com/video_listen/588ku_preview/24/04/01/09/49/06/video660a12925fe74.mp4', width: '200px', autoplay: true })">插入视频</button>
|
|
173
|
-
<button @click="editor?.commands.updateVideo!({ controls: true, loop: true })">更新视频</button>
|
|
174
|
-
</div>
|
|
175
|
-
</fieldset>
|
|
176
|
-
<fieldset>
|
|
177
|
-
<legend>代码块</legend>
|
|
178
|
-
<div class="toolbar">
|
|
179
|
-
<button @click="editor?.commands.setCodeBlock!()">插入代码块</button>
|
|
180
|
-
<button @click="editor?.commands.unsetCodeBlock!()">取消代码块</button>
|
|
181
|
-
</div>
|
|
182
|
-
</fieldset>
|
|
183
|
-
<fieldset>
|
|
184
|
-
<legend>标题</legend>
|
|
185
|
-
<div class="toolbar">
|
|
186
|
-
<button @click="editor?.commands.setHeading!(1)">标题1</button>
|
|
187
|
-
<button @click="editor?.commands.setHeading!(2)">标题2</button>
|
|
188
|
-
<button @click="editor?.commands.setHeading!(3)">标题3</button>
|
|
189
|
-
<button @click="editor?.commands.setHeading!(4)">标题4</button>
|
|
190
|
-
<button @click="editor?.commands.setHeading!(5)">标题5</button>
|
|
191
|
-
<button @click="editor?.commands.setHeading!(6)">标题6</button>
|
|
192
|
-
<button @click="editor?.commands.unsetHeading!(1)">取消标题1</button>
|
|
193
|
-
<button @click="editor?.commands.unsetHeading!(2)">取消标题2</button>
|
|
194
|
-
<button @click="editor?.commands.unsetHeading!(3)">取消标题3</button>
|
|
195
|
-
<button @click="editor?.commands.unsetHeading!(4)">取消标题4</button>
|
|
196
|
-
<button @click="editor?.commands.unsetHeading!(5)">取消标题5</button>
|
|
197
|
-
<button @click="editor?.commands.unsetHeading!(6)">取消标题6</button>
|
|
198
|
-
</div>
|
|
199
|
-
</fieldset>
|
|
200
|
-
<fieldset>
|
|
201
|
-
<legend>引用</legend>
|
|
202
|
-
<div class="toolbar">
|
|
203
|
-
<button @click="editor?.commands.setBlockquote!()">插入引用</button>
|
|
204
|
-
<button @click="editor?.commands.unsetBlockquote!()">取消引用</button>
|
|
205
|
-
</div>
|
|
206
|
-
</fieldset>
|
|
207
|
-
<fieldset>
|
|
208
|
-
<legend>水平线</legend>
|
|
209
|
-
<div class="toolbar">
|
|
210
|
-
<button @click="editor?.commands.setHorizontal!()">插入水平线</button>
|
|
211
|
-
</div>
|
|
212
|
-
</fieldset>
|
|
213
|
-
<fieldset>
|
|
214
|
-
<legend>附件</legend>
|
|
215
|
-
<div class="toolbar">
|
|
216
|
-
<button
|
|
217
|
-
@click="editor?.commands.setAttachment!({ 'url': 'https://www.so-better.cn/static/attachments/QM6cgjq8GPzY1_c2Ol1GIS68.jpg', 'text': '附件图片' })">上传附件</button>
|
|
218
|
-
<button @click="editor?.commands.updateAttachment!({ 'url': '#', 'text': '附件2' })">更新附件</button>
|
|
219
|
-
</div>
|
|
220
|
-
</fieldset>
|
|
221
|
-
<fieldset>
|
|
222
|
-
<legend>Katex数学公式</legend>
|
|
223
|
-
<div class="toolbar">
|
|
224
|
-
<button @click="editor?.commands.setMath!('\\sum_{i=1}^{n} i = \\frac{n(n+1)}{2}')">插入数学公式1</button>
|
|
225
|
-
<button @click="editor?.commands.setMath!('x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}')">插入数学公式2</button>
|
|
226
|
-
</div>
|
|
227
|
-
</fieldset>
|
|
228
|
-
<fieldset>
|
|
229
|
-
<legend>表格</legend>
|
|
230
|
-
<div class="toolbar">
|
|
231
|
-
<button @click="editor?.commands.setTable!({ rows: 5, columns: 5 })">插入 5 x 5 表格</button>
|
|
232
|
-
<button @click="editor?.commands.unsetTable!()">删除表格</button>
|
|
233
|
-
<button @click="editor?.commands.addColumn!('right')">向右插入列</button>
|
|
234
|
-
<button @click="editor?.commands.addColumn!('left')">向左插入列</button>
|
|
235
|
-
<button @click="editor?.commands.addRow!('top')">向上插入行</button>
|
|
236
|
-
<button @click="editor?.commands.addRow!('bottom')">向下插入行</button>
|
|
237
|
-
<button @click="editor?.commands.mergeCell!('left')">向左合并单元格</button>
|
|
238
|
-
<button @click="editor?.commands.mergeCell!('right')">向右合并单元格</button>
|
|
239
|
-
<button @click="editor?.commands.mergeCell!('top')">向上合并单元格</button>
|
|
240
|
-
<button @click="editor?.commands.mergeCell!('bottom')">向下合并单元格</button>
|
|
241
|
-
<button @click="editor?.commands.deleteRow!()">删除行</button>
|
|
242
|
-
<button @click="editor?.commands.deleteColumn!()">删除列</button>
|
|
243
|
-
</div>
|
|
244
|
-
</fieldset>
|
|
245
|
-
</div>
|
|
246
|
-
<div class="right">
|
|
247
|
-
<div id="editor" style="height: 100%;"></div>
|
|
248
|
-
</div>
|
|
249
|
-
</div>
|
|
250
|
-
</template>
|
|
251
|
-
<script lang="ts" setup>
|
|
252
|
-
import { onMounted, ref } from 'vue'
|
|
253
|
-
import { Editor, KNode, AttachmentExtension } from '../src'
|
|
254
|
-
import { content } from "./content"
|
|
255
|
-
|
|
256
|
-
const count = ref<number>(0)
|
|
257
|
-
const editor = ref<Editor | null>(null)
|
|
258
|
-
|
|
259
|
-
onMounted(async () => {
|
|
260
|
-
const res = await fetch('https://www.so-better.cn/api/doc/getById', {
|
|
261
|
-
method: 'post',
|
|
262
|
-
headers: {
|
|
263
|
-
'Content-Type': 'application/json'
|
|
264
|
-
},
|
|
265
|
-
body: JSON.stringify({
|
|
266
|
-
docId: 237
|
|
267
|
-
})
|
|
268
|
-
}).then(res => res.json())
|
|
269
|
-
editor.value = await Editor.configure({
|
|
270
|
-
value: (res.data.docContent).replaceAll('data-editify-hljs', 'kaitify-hljs'),
|
|
271
|
-
extensions: [AttachmentExtension({ icon: 'https://www.so-better.cn/static/attachments/h9PNcA0uJkWOZx971URJzLvn.jpg' })],
|
|
272
|
-
el: '#editor',
|
|
273
|
-
editable: true,
|
|
274
|
-
allowPasteHtml: true,
|
|
275
|
-
placeholder: '请输入内容...',
|
|
276
|
-
afterUpdateView() {
|
|
277
|
-
count.value = this.getText().trim().length
|
|
278
|
-
},
|
|
279
|
-
})
|
|
280
|
-
})
|
|
281
|
-
|
|
282
|
-
const insertNode = () => {
|
|
283
|
-
editor.value!.selection.start!.node.getRootBlock().children = []
|
|
284
|
-
editor.value?.updateView()
|
|
285
|
-
}
|
|
286
|
-
</script>
|
|
287
|
-
<style lang="less">
|
|
288
|
-
html {
|
|
289
|
-
height: 100%;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
body {
|
|
293
|
-
height: 100%;
|
|
294
|
-
margin: 0;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
*,
|
|
298
|
-
*::before,
|
|
299
|
-
*::after {
|
|
300
|
-
box-sizing: border-box;
|
|
301
|
-
outline: none;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
#app {
|
|
305
|
-
height: 100%;
|
|
306
|
-
overflow-y: auto;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
.container {
|
|
310
|
-
display: flex;
|
|
311
|
-
justify-content: space-between;
|
|
312
|
-
align-items: flex-start;
|
|
313
|
-
width: 100%;
|
|
314
|
-
height: 100%;
|
|
315
|
-
|
|
316
|
-
.left,
|
|
317
|
-
.right {
|
|
318
|
-
display: block;
|
|
319
|
-
width: 60%;
|
|
320
|
-
position: relative;
|
|
321
|
-
height: 100%;
|
|
322
|
-
padding: 10px;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
.left {
|
|
326
|
-
overflow: auto;
|
|
327
|
-
width: 40%;
|
|
328
|
-
|
|
329
|
-
.toolbar {
|
|
330
|
-
display: flex;
|
|
331
|
-
justify-content: flex-start;
|
|
332
|
-
align-items: center;
|
|
333
|
-
flex-wrap: wrap;
|
|
334
|
-
width: 100%;
|
|
335
|
-
|
|
336
|
-
button {
|
|
337
|
-
margin: 5px;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
</style>
|