@kaitify/core 0.0.1-beta.1 → 0.0.1-beta.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/package.json +1 -1
- 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
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { KNodeStylesType } from '@/model'
|
|
2
|
-
import { splitNodeToNodes } from '@/model/config/function'
|
|
3
|
-
import { Extension } from '../Extension'
|
|
4
|
-
|
|
5
|
-
declare module '../../model' {
|
|
6
|
-
interface EditorCommandsType {
|
|
7
|
-
isStrikethrough?: () => boolean
|
|
8
|
-
setStrikethrough?: () => Promise<void>
|
|
9
|
-
unsetStrikethrough?: () => Promise<void>
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const StrikethroughExtension = () =>
|
|
14
|
-
Extension.create({
|
|
15
|
-
name: 'strikethrough',
|
|
16
|
-
pasteKeepStyles(node) {
|
|
17
|
-
const styles: KNodeStylesType = {}
|
|
18
|
-
if (node.isText() && node.hasStyles()) {
|
|
19
|
-
if (node.styles!.hasOwnProperty('textDecoration')) styles.textDecoration = node.styles!.textDecoration
|
|
20
|
-
if (node.styles!.hasOwnProperty('textDecorationLine')) styles.textDecorationLine = node.styles!.textDecorationLine
|
|
21
|
-
}
|
|
22
|
-
return styles
|
|
23
|
-
},
|
|
24
|
-
extraKeepTags: ['del'],
|
|
25
|
-
domParseNodeCallback(node) {
|
|
26
|
-
if (node.isMatch({ tag: 'del' })) {
|
|
27
|
-
node.type = 'inline'
|
|
28
|
-
}
|
|
29
|
-
return node
|
|
30
|
-
},
|
|
31
|
-
formatRules: [
|
|
32
|
-
({ editor, node }) => {
|
|
33
|
-
if (!node.isEmpty() && node.isMatch({ tag: 'del' })) {
|
|
34
|
-
const styles: KNodeStylesType = node.styles || {}
|
|
35
|
-
node.styles = {
|
|
36
|
-
...styles,
|
|
37
|
-
textDecorationLine: 'line-through'
|
|
38
|
-
}
|
|
39
|
-
node.tag = editor.textRenderTag
|
|
40
|
-
splitNodeToNodes.apply(editor, [node])
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
],
|
|
44
|
-
addCommands() {
|
|
45
|
-
/**
|
|
46
|
-
* 光标所在文本是否删除线
|
|
47
|
-
*/
|
|
48
|
-
const isStrikethrough = () => {
|
|
49
|
-
return this.commands.isTextStyle!('textDecoration', 'line-through') || this.commands.isTextStyle!('textDecorationLine', 'line-through')
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* 设置删除线
|
|
53
|
-
*/
|
|
54
|
-
const setStrikethrough = async () => {
|
|
55
|
-
if (isStrikethrough()) {
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
await this.commands.setTextStyle!({
|
|
59
|
-
textDecorationLine: 'line-through'
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* 取消删除线
|
|
64
|
-
*/
|
|
65
|
-
const unsetStrikethrough = async () => {
|
|
66
|
-
if (!isStrikethrough()) {
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
await this.commands.removeTextStyle!(['textDecoration', 'textDecorationLine'])
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
isStrikethrough,
|
|
74
|
-
setStrikethrough,
|
|
75
|
-
unsetStrikethrough
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
})
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { KNodeStylesType } from '@/model'
|
|
2
|
-
import { splitNodeToNodes } from '@/model/config/function'
|
|
3
|
-
import { Extension } from '../Extension'
|
|
4
|
-
|
|
5
|
-
declare module '../../model' {
|
|
6
|
-
interface EditorCommandsType {
|
|
7
|
-
isSubscript?: () => boolean
|
|
8
|
-
setSubscript?: () => Promise<void>
|
|
9
|
-
unsetSubscript?: () => Promise<void>
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const SubscriptExtension = () =>
|
|
14
|
-
Extension.create({
|
|
15
|
-
name: 'subscript',
|
|
16
|
-
pasteKeepStyles(node) {
|
|
17
|
-
const styles: KNodeStylesType = {}
|
|
18
|
-
if (node.isText() && node.hasStyles()) {
|
|
19
|
-
if (node.styles!.hasOwnProperty('verticalAlign')) styles.verticalAlign = node.styles!.verticalAlign
|
|
20
|
-
}
|
|
21
|
-
return styles
|
|
22
|
-
},
|
|
23
|
-
extraKeepTags: ['sub'],
|
|
24
|
-
domParseNodeCallback(node) {
|
|
25
|
-
if (node.isMatch({ tag: 'sub' })) {
|
|
26
|
-
node.type = 'inline'
|
|
27
|
-
}
|
|
28
|
-
return node
|
|
29
|
-
},
|
|
30
|
-
formatRules: [
|
|
31
|
-
({ editor, node }) => {
|
|
32
|
-
if (!node.isEmpty() && node.isMatch({ tag: 'sub' })) {
|
|
33
|
-
const styles: KNodeStylesType = node.styles || {}
|
|
34
|
-
node.styles = {
|
|
35
|
-
...styles,
|
|
36
|
-
verticalAlign: 'sub'
|
|
37
|
-
}
|
|
38
|
-
node.tag = editor.textRenderTag
|
|
39
|
-
splitNodeToNodes.apply(editor, [node])
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
addCommands() {
|
|
44
|
-
/**
|
|
45
|
-
* 光标所在文本是否下标
|
|
46
|
-
*/
|
|
47
|
-
const isSubscript = () => {
|
|
48
|
-
return this.commands.isTextStyle!('verticalAlign', 'sub')
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* 设置下标
|
|
52
|
-
*/
|
|
53
|
-
const setSubscript = async () => {
|
|
54
|
-
if (isSubscript()) {
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
await this.commands.setTextStyle!({
|
|
58
|
-
verticalAlign: 'sub'
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* 取消下标
|
|
63
|
-
*/
|
|
64
|
-
const unsetSubscript = async () => {
|
|
65
|
-
if (!isSubscript()) {
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
await this.commands.removeTextStyle!(['verticalAlign'])
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
isSubscript,
|
|
73
|
-
setSubscript,
|
|
74
|
-
unsetSubscript
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
})
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { KNodeStylesType } from '@/model'
|
|
2
|
-
import { splitNodeToNodes } from '@/model/config/function'
|
|
3
|
-
import { Extension } from '../Extension'
|
|
4
|
-
|
|
5
|
-
declare module '../../model' {
|
|
6
|
-
interface EditorCommandsType {
|
|
7
|
-
isSuperscript?: () => boolean
|
|
8
|
-
setSuperscript?: () => Promise<void>
|
|
9
|
-
unsetSuperscript?: () => Promise<void>
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const SuperscriptExtension = () =>
|
|
14
|
-
Extension.create({
|
|
15
|
-
name: 'superscript',
|
|
16
|
-
pasteKeepStyles(node) {
|
|
17
|
-
const styles: KNodeStylesType = {}
|
|
18
|
-
if (node.isText() && node.hasStyles()) {
|
|
19
|
-
if (node.styles!.hasOwnProperty('verticalAlign')) styles.verticalAlign = node.styles!.verticalAlign
|
|
20
|
-
}
|
|
21
|
-
return styles
|
|
22
|
-
},
|
|
23
|
-
extraKeepTags: ['sup'],
|
|
24
|
-
domParseNodeCallback(node) {
|
|
25
|
-
if (node.isMatch({ tag: 'sup' })) {
|
|
26
|
-
node.type = 'inline'
|
|
27
|
-
}
|
|
28
|
-
return node
|
|
29
|
-
},
|
|
30
|
-
formatRules: [
|
|
31
|
-
({ editor, node }) => {
|
|
32
|
-
if (!node.isEmpty() && node.isMatch({ tag: 'sup' })) {
|
|
33
|
-
const styles: KNodeStylesType = node.styles || {}
|
|
34
|
-
node.styles = {
|
|
35
|
-
...styles,
|
|
36
|
-
verticalAlign: 'super'
|
|
37
|
-
}
|
|
38
|
-
node.tag = editor.textRenderTag
|
|
39
|
-
splitNodeToNodes.apply(editor, [node])
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
addCommands() {
|
|
44
|
-
/**
|
|
45
|
-
* 光标所在文本是否上标
|
|
46
|
-
*/
|
|
47
|
-
const isSuperscript = () => {
|
|
48
|
-
return this.commands.isTextStyle!('verticalAlign', 'super')
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* 设置上标
|
|
52
|
-
*/
|
|
53
|
-
const setSuperscript = async () => {
|
|
54
|
-
if (isSuperscript()) {
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
await this.commands.setTextStyle!({
|
|
58
|
-
verticalAlign: 'super'
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* 取消上标
|
|
63
|
-
*/
|
|
64
|
-
const unsetSuperscript = async () => {
|
|
65
|
-
if (!isSuperscript()) {
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
await this.commands.removeTextStyle!(['verticalAlign'])
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
isSuperscript,
|
|
73
|
-
setSuperscript,
|
|
74
|
-
unsetSuperscript
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
})
|