@milkdown/crepe 7.11.0 → 7.12.0
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/cjs/builder/builder.js +107 -0
- package/lib/cjs/builder/builder.js.map +1 -0
- package/lib/cjs/{index-oVztbsWz.js → feature/block-edit/index.js} +165 -61
- package/lib/cjs/feature/block-edit/index.js.map +1 -0
- package/lib/cjs/feature/code-mirror/index.js +161 -0
- package/lib/cjs/feature/code-mirror/index.js.map +1 -0
- package/lib/cjs/feature/cursor/index.js +57 -0
- package/lib/cjs/feature/cursor/index.js.map +1 -0
- package/lib/cjs/feature/image-block/index.js +123 -0
- package/lib/cjs/feature/image-block/index.js.map +1 -0
- package/lib/cjs/{index-DdWGHNC3.js → feature/latex/index.js} +111 -24
- package/lib/cjs/feature/latex/index.js.map +1 -0
- package/lib/cjs/feature/link-tooltip/index.js +124 -0
- package/lib/cjs/feature/link-tooltip/index.js.map +1 -0
- package/lib/cjs/{index-Dw6lXgs6.js → feature/list-item/index.js} +39 -8
- package/lib/cjs/feature/list-item/index.js.map +1 -0
- package/lib/cjs/{index-B91KhPew.js → feature/placeholder/index.js} +46 -6
- package/lib/cjs/feature/placeholder/index.js.map +1 -0
- package/lib/cjs/{index-DEs_IHHy.js → feature/table/index.js} +78 -16
- package/lib/cjs/feature/table/index.js.map +1 -0
- package/lib/cjs/{index-CqC8Inzm.js → feature/toolbar/index.js} +133 -31
- package/lib/cjs/feature/toolbar/index.js.map +1 -0
- package/lib/cjs/index/index.js +2464 -0
- package/lib/cjs/index/index.js.map +1 -0
- package/lib/esm/builder/builder.js +105 -0
- package/lib/esm/builder/builder.js.map +1 -0
- package/lib/esm/{index-BUOhiAN3.js → feature/block-edit/index.js} +161 -57
- package/lib/esm/feature/block-edit/index.js.map +1 -0
- package/lib/esm/feature/code-mirror/index.js +159 -0
- package/lib/esm/feature/code-mirror/index.js.map +1 -0
- package/lib/esm/feature/cursor/index.js +55 -0
- package/lib/esm/feature/cursor/index.js.map +1 -0
- package/lib/esm/feature/image-block/index.js +121 -0
- package/lib/esm/feature/image-block/index.js.map +1 -0
- package/lib/esm/{index-CQOlw1Xn.js → feature/latex/index.js} +107 -20
- package/lib/esm/feature/latex/index.js.map +1 -0
- package/lib/esm/feature/link-tooltip/index.js +122 -0
- package/lib/esm/feature/link-tooltip/index.js.map +1 -0
- package/lib/esm/{index-E8UgFLeN.js → feature/list-item/index.js} +39 -8
- package/lib/esm/feature/list-item/index.js.map +1 -0
- package/lib/esm/{index-BCvtgOeI.js → feature/placeholder/index.js} +45 -5
- package/lib/esm/feature/placeholder/index.js.map +1 -0
- package/lib/esm/{index-CwMVnVeI.js → feature/table/index.js} +78 -16
- package/lib/esm/feature/table/index.js.map +1 -0
- package/lib/esm/{index-B69WyZeK.js → feature/toolbar/index.js} +128 -26
- package/lib/esm/feature/toolbar/index.js.map +1 -0
- package/lib/esm/index/index.js +2458 -0
- package/lib/esm/index/index.js.map +1 -0
- package/lib/theme/common/code-mirror.css +69 -1
- package/lib/theme/common/style.css +1 -0
- package/lib/theme/crepe/style.css +0 -2
- package/lib/theme/crepe-dark/style.css +0 -2
- package/lib/theme/frame/style.css +0 -2
- package/lib/theme/frame-dark/style.css +0 -2
- package/lib/theme/nord/style.css +0 -2
- package/lib/theme/nord-dark/style.css +0 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/builder.d.ts +2 -0
- package/lib/types/builder.d.ts.map +1 -0
- package/lib/types/core/builder.d.ts +23 -0
- package/lib/types/core/builder.d.ts.map +1 -0
- package/lib/types/core/crepe.d.ts +4 -15
- package/lib/types/core/crepe.d.ts.map +1 -1
- package/lib/types/core/index.d.ts +2 -1
- package/lib/types/core/index.d.ts.map +1 -1
- package/lib/types/core/slice.d.ts +6 -4
- package/lib/types/core/slice.d.ts.map +1 -1
- package/lib/types/default-config/index.d.ts +3 -0
- package/lib/types/default-config/index.d.ts.map +1 -0
- package/lib/types/feature/block-edit/handle/component.d.ts +2 -3
- package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
- package/lib/types/feature/block-edit/index.d.ts +20 -20
- package/lib/types/feature/block-edit/index.d.ts.map +1 -1
- package/lib/types/feature/code-mirror/index.d.ts +7 -7
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/lib/types/feature/cursor/index.d.ts +1 -1
- package/lib/types/feature/cursor/index.d.ts.map +1 -1
- package/lib/types/feature/image-block/index.d.ts +9 -9
- package/lib/types/feature/image-block/index.d.ts.map +1 -1
- package/lib/types/feature/index.d.ts +2 -4
- package/lib/types/feature/index.d.ts.map +1 -1
- package/lib/types/feature/latex/index.d.ts +3 -3
- package/lib/types/feature/latex/index.d.ts.map +1 -1
- package/lib/types/feature/link-tooltip/index.d.ts +6 -6
- package/lib/types/feature/link-tooltip/index.d.ts.map +1 -1
- package/lib/types/feature/list-item/index.d.ts +5 -5
- package/lib/types/feature/list-item/index.d.ts.map +1 -1
- package/lib/types/feature/loader.d.ts +4 -0
- package/lib/types/feature/loader.d.ts.map +1 -0
- package/lib/types/feature/placeholder/index.d.ts +2 -2
- package/lib/types/feature/placeholder/index.d.ts.map +1 -1
- package/lib/types/feature/shared.d.ts +1 -2
- package/lib/types/feature/shared.d.ts.map +1 -1
- package/lib/types/feature/table/index.d.ts +11 -11
- package/lib/types/feature/table/index.d.ts.map +1 -1
- package/lib/types/feature/toolbar/index.d.ts +8 -8
- package/lib/types/feature/toolbar/index.d.ts.map +1 -1
- package/lib/types/icons/index.d.ts +1 -0
- package/lib/types/icons/index.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/utils/index.d.ts +0 -1
- package/lib/types/utils/index.d.ts.map +1 -1
- package/package.json +60 -3
- package/src/builder.ts +1 -0
- package/src/core/builder.ts +143 -0
- package/src/core/crepe.ts +23 -110
- package/src/core/index.ts +2 -1
- package/src/core/slice.ts +47 -7
- package/src/default-config/index.ts +25 -0
- package/src/feature/block-edit/handle/component.tsx +6 -8
- package/src/feature/block-edit/handle/index.ts +2 -2
- package/src/feature/block-edit/index.ts +23 -20
- package/src/feature/block-edit/menu/config.ts +19 -19
- package/src/feature/code-mirror/index.ts +32 -28
- package/src/feature/cursor/index.ts +10 -6
- package/src/feature/image-block/index.ts +19 -16
- package/src/feature/index.ts +24 -53
- package/src/feature/latex/index.ts +8 -10
- package/src/feature/latex/inline-tooltip/component.tsx +1 -1
- package/src/feature/link-tooltip/index.ts +13 -10
- package/src/feature/list-item/index.ts +11 -8
- package/src/feature/loader.ts +52 -0
- package/src/feature/placeholder/index.ts +5 -2
- package/src/feature/shared.ts +1 -3
- package/src/feature/table/index.ts +23 -23
- package/src/feature/toolbar/component.tsx +9 -9
- package/src/feature/toolbar/index.ts +14 -11
- package/src/icons/index.ts +1 -0
- package/src/index.ts +1 -1
- package/src/theme/common/code-mirror.css +61 -1
- package/src/theme/common/style.css +1 -0
- package/src/theme/crepe/style.css +0 -2
- package/src/theme/crepe-dark/style.css +0 -2
- package/src/theme/frame/style.css +0 -2
- package/src/theme/frame-dark/style.css +0 -2
- package/src/theme/nord/style.css +0 -2
- package/src/theme/nord-dark/style.css +0 -2
- package/src/utils/index.ts +0 -8
- package/lib/cjs/confirm-CNveM9QH.js +0 -26
- package/lib/cjs/confirm-CNveM9QH.js.map +0 -1
- package/lib/cjs/edit-BUtBJHpV.js +0 -24
- package/lib/cjs/edit-BUtBJHpV.js.map +0 -1
- package/lib/cjs/functions-BAY51plB.js +0 -39
- package/lib/cjs/functions-BAY51plB.js.map +0 -1
- package/lib/cjs/image-BXLkOVnO.js +0 -24
- package/lib/cjs/image-BXLkOVnO.js.map +0 -1
- package/lib/cjs/index-B91KhPew.js.map +0 -1
- package/lib/cjs/index-BsrJn8Jp.js +0 -41
- package/lib/cjs/index-BsrJn8Jp.js.map +0 -1
- package/lib/cjs/index-C2CAbC2F.js +0 -26
- package/lib/cjs/index-C2CAbC2F.js.map +0 -1
- package/lib/cjs/index-CqC8Inzm.js.map +0 -1
- package/lib/cjs/index-DEs_IHHy.js.map +0 -1
- package/lib/cjs/index-DLIudQKW.js +0 -126
- package/lib/cjs/index-DLIudQKW.js.map +0 -1
- package/lib/cjs/index-DRKcvY0k.js +0 -188
- package/lib/cjs/index-DRKcvY0k.js.map +0 -1
- package/lib/cjs/index-DdWGHNC3.js.map +0 -1
- package/lib/cjs/index-Dw6lXgs6.js.map +0 -1
- package/lib/cjs/index-oVztbsWz.js.map +0 -1
- package/lib/cjs/index-xbwf60wt.js +0 -15
- package/lib/cjs/index-xbwf60wt.js.map +0 -1
- package/lib/cjs/index-xbxqAqH2.js +0 -52
- package/lib/cjs/index-xbxqAqH2.js.map +0 -1
- package/lib/cjs/index.js +0 -20
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/inline-latex-D0G71cGk.js +0 -54
- package/lib/cjs/inline-latex-D0G71cGk.js.map +0 -1
- package/lib/cjs/plus-XLomtlXf.js +0 -24
- package/lib/cjs/plus-XLomtlXf.js.map +0 -1
- package/lib/cjs/remove-Ba-ypwBf.js +0 -17
- package/lib/cjs/remove-Ba-ypwBf.js.map +0 -1
- package/lib/esm/confirm-DtE-HkVd.js +0 -24
- package/lib/esm/confirm-DtE-HkVd.js.map +0 -1
- package/lib/esm/edit-D--t_JAb.js +0 -22
- package/lib/esm/edit-D--t_JAb.js.map +0 -1
- package/lib/esm/functions-DlJPkGmE.js +0 -36
- package/lib/esm/functions-DlJPkGmE.js.map +0 -1
- package/lib/esm/image-DoB1o1sl.js +0 -22
- package/lib/esm/image-DoB1o1sl.js.map +0 -1
- package/lib/esm/index-B69WyZeK.js.map +0 -1
- package/lib/esm/index-BCvtgOeI.js.map +0 -1
- package/lib/esm/index-BPG8iO8t.js +0 -12
- package/lib/esm/index-BPG8iO8t.js.map +0 -1
- package/lib/esm/index-BUBXHhHG.js +0 -39
- package/lib/esm/index-BUBXHhHG.js.map +0 -1
- package/lib/esm/index-BUOhiAN3.js.map +0 -1
- package/lib/esm/index-Bvz1Yyiz.js +0 -24
- package/lib/esm/index-Bvz1Yyiz.js.map +0 -1
- package/lib/esm/index-C1aVAv1l.js +0 -124
- package/lib/esm/index-C1aVAv1l.js.map +0 -1
- package/lib/esm/index-CQOlw1Xn.js.map +0 -1
- package/lib/esm/index-CdjziarM.js +0 -183
- package/lib/esm/index-CdjziarM.js.map +0 -1
- package/lib/esm/index-ChR5Qhyf.js +0 -50
- package/lib/esm/index-ChR5Qhyf.js.map +0 -1
- package/lib/esm/index-CwMVnVeI.js.map +0 -1
- package/lib/esm/index-E8UgFLeN.js.map +0 -1
- package/lib/esm/index.js +0 -12
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/inline-latex-C9IGAXXQ.js +0 -51
- package/lib/esm/inline-latex-C9IGAXXQ.js.map +0 -1
- package/lib/esm/plus-lrX0Q75O.js +0 -22
- package/lib/esm/plus-lrX0Q75O.js.map +0 -1
- package/lib/esm/remove-D3g0Cd6_.js +0 -15
- package/lib/esm/remove-D3g0Cd6_.js.map +0 -1
- /package/lib/theme/{_internal/classic-common.css → common/reset.css} +0 -0
- /package/src/theme/{_internal/classic-common.css → common/reset.css} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Editor } from '@milkdown/kit/core'
|
|
2
|
+
|
|
3
|
+
import { blockEdit } from './block-edit'
|
|
4
|
+
import { codeMirror } from './code-mirror'
|
|
5
|
+
import { cursor } from './cursor'
|
|
6
|
+
import { imageBlock } from './image-block'
|
|
7
|
+
import { CrepeFeature } from './index'
|
|
8
|
+
import { latex } from './latex'
|
|
9
|
+
import { linkTooltip } from './link-tooltip'
|
|
10
|
+
import { listItem } from './list-item'
|
|
11
|
+
import { placeholder } from './placeholder'
|
|
12
|
+
import { table } from './table'
|
|
13
|
+
import { toolbar } from './toolbar'
|
|
14
|
+
|
|
15
|
+
export function loadFeature(
|
|
16
|
+
feature: CrepeFeature,
|
|
17
|
+
editor: Editor,
|
|
18
|
+
config?: never
|
|
19
|
+
) {
|
|
20
|
+
switch (feature) {
|
|
21
|
+
case CrepeFeature.CodeMirror: {
|
|
22
|
+
return codeMirror(editor, config)
|
|
23
|
+
}
|
|
24
|
+
case CrepeFeature.ListItem: {
|
|
25
|
+
return listItem(editor, config)
|
|
26
|
+
}
|
|
27
|
+
case CrepeFeature.LinkTooltip: {
|
|
28
|
+
return linkTooltip(editor, config)
|
|
29
|
+
}
|
|
30
|
+
case CrepeFeature.ImageBlock: {
|
|
31
|
+
return imageBlock(editor, config)
|
|
32
|
+
}
|
|
33
|
+
case CrepeFeature.Cursor: {
|
|
34
|
+
return cursor(editor, config)
|
|
35
|
+
}
|
|
36
|
+
case CrepeFeature.BlockEdit: {
|
|
37
|
+
return blockEdit(editor, config)
|
|
38
|
+
}
|
|
39
|
+
case CrepeFeature.Placeholder: {
|
|
40
|
+
return placeholder(editor, config)
|
|
41
|
+
}
|
|
42
|
+
case CrepeFeature.Toolbar: {
|
|
43
|
+
return toolbar(editor, config)
|
|
44
|
+
}
|
|
45
|
+
case CrepeFeature.Table: {
|
|
46
|
+
return table(editor, config)
|
|
47
|
+
}
|
|
48
|
+
case CrepeFeature.Latex: {
|
|
49
|
+
return latex(editor, config)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -8,7 +8,9 @@ import { $ctx, $prose } from '@milkdown/kit/utils'
|
|
|
8
8
|
|
|
9
9
|
import type { DefineFeature } from '../shared'
|
|
10
10
|
|
|
11
|
+
import { crepeFeatureConfig } from '../../core/slice'
|
|
11
12
|
import { isInCodeBlock, isInList } from '../../utils'
|
|
13
|
+
import { CrepeFeature } from '../index'
|
|
12
14
|
|
|
13
15
|
function isDocEmpty(doc: Node) {
|
|
14
16
|
return doc.childCount <= 1 && !doc.firstChild?.content.size
|
|
@@ -41,7 +43,7 @@ interface PlaceholderConfig {
|
|
|
41
43
|
mode: 'doc' | 'block'
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
export type
|
|
46
|
+
export type PlaceholderFeatureConfig = Partial<PlaceholderConfig>
|
|
45
47
|
|
|
46
48
|
export const placeholderConfig = $ctx(
|
|
47
49
|
{
|
|
@@ -72,11 +74,12 @@ export const placeholderPlugin = $prose((ctx) => {
|
|
|
72
74
|
})
|
|
73
75
|
})
|
|
74
76
|
|
|
75
|
-
export const
|
|
77
|
+
export const placeholder: DefineFeature<PlaceholderFeatureConfig> = (
|
|
76
78
|
editor,
|
|
77
79
|
config
|
|
78
80
|
) => {
|
|
79
81
|
editor
|
|
82
|
+
.config(crepeFeatureConfig(CrepeFeature.Placeholder))
|
|
80
83
|
.config((ctx) => {
|
|
81
84
|
if (config) {
|
|
82
85
|
ctx.update(placeholderConfig.key, (prev) => {
|
package/src/feature/shared.ts
CHANGED
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
tableBlockConfig,
|
|
4
4
|
} from '@milkdown/kit/component/table-block'
|
|
5
5
|
|
|
6
|
-
import type { DefineFeature
|
|
6
|
+
import type { DefineFeature } from '../shared'
|
|
7
7
|
|
|
8
|
+
import { crepeFeatureConfig } from '../../core/slice'
|
|
8
9
|
import {
|
|
9
10
|
alignCenterIcon,
|
|
10
11
|
alignLeftIcon,
|
|
@@ -13,49 +14,48 @@ import {
|
|
|
13
14
|
plusIcon,
|
|
14
15
|
removeIcon,
|
|
15
16
|
} from '../../icons'
|
|
17
|
+
import { CrepeFeature } from '../index'
|
|
16
18
|
|
|
17
19
|
interface TableConfig {
|
|
18
|
-
addRowIcon:
|
|
19
|
-
addColIcon:
|
|
20
|
-
deleteRowIcon:
|
|
21
|
-
deleteColIcon:
|
|
22
|
-
alignLeftIcon:
|
|
23
|
-
alignCenterIcon:
|
|
24
|
-
alignRightIcon:
|
|
25
|
-
colDragHandleIcon:
|
|
26
|
-
rowDragHandleIcon:
|
|
20
|
+
addRowIcon: string
|
|
21
|
+
addColIcon: string
|
|
22
|
+
deleteRowIcon: string
|
|
23
|
+
deleteColIcon: string
|
|
24
|
+
alignLeftIcon: string
|
|
25
|
+
alignCenterIcon: string
|
|
26
|
+
alignRightIcon: string
|
|
27
|
+
colDragHandleIcon: string
|
|
28
|
+
rowDragHandleIcon: string
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
export type TableFeatureConfig = Partial<TableConfig>
|
|
30
32
|
|
|
31
|
-
export const
|
|
32
|
-
editor,
|
|
33
|
-
config
|
|
34
|
-
) => {
|
|
33
|
+
export const table: DefineFeature<TableFeatureConfig> = (editor, config) => {
|
|
35
34
|
editor
|
|
35
|
+
.config(crepeFeatureConfig(CrepeFeature.Table))
|
|
36
36
|
.config((ctx) => {
|
|
37
37
|
ctx.update(tableBlockConfig.key, (defaultConfig) => ({
|
|
38
38
|
...defaultConfig,
|
|
39
39
|
renderButton: (renderType) => {
|
|
40
40
|
switch (renderType) {
|
|
41
41
|
case 'add_row':
|
|
42
|
-
return config?.addRowIcon
|
|
42
|
+
return config?.addRowIcon ?? plusIcon
|
|
43
43
|
case 'add_col':
|
|
44
|
-
return config?.addColIcon
|
|
44
|
+
return config?.addColIcon ?? plusIcon
|
|
45
45
|
case 'delete_row':
|
|
46
|
-
return config?.deleteRowIcon
|
|
46
|
+
return config?.deleteRowIcon ?? removeIcon
|
|
47
47
|
case 'delete_col':
|
|
48
|
-
return config?.deleteColIcon
|
|
48
|
+
return config?.deleteColIcon ?? removeIcon
|
|
49
49
|
case 'align_col_left':
|
|
50
|
-
return config?.alignLeftIcon
|
|
50
|
+
return config?.alignLeftIcon ?? alignLeftIcon
|
|
51
51
|
case 'align_col_center':
|
|
52
|
-
return config?.alignCenterIcon
|
|
52
|
+
return config?.alignCenterIcon ?? alignCenterIcon
|
|
53
53
|
case 'align_col_right':
|
|
54
|
-
return config?.alignRightIcon
|
|
54
|
+
return config?.alignRightIcon ?? alignRightIcon
|
|
55
55
|
case 'col_drag_handle':
|
|
56
|
-
return config?.colDragHandleIcon
|
|
56
|
+
return config?.colDragHandleIcon ?? dragHandleIcon
|
|
57
57
|
case 'row_drag_handle':
|
|
58
|
-
return config?.rowDragHandleIcon
|
|
58
|
+
return config?.rowDragHandleIcon ?? dragHandleIcon
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
}))
|
|
@@ -27,8 +27,8 @@ import { defineComponent, type Ref, type ShallowRef, h, Fragment } from 'vue'
|
|
|
27
27
|
|
|
28
28
|
import type { ToolbarFeatureConfig } from '.'
|
|
29
29
|
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
30
|
+
import { useCrepeFeatures } from '../../core/slice'
|
|
31
|
+
import { CrepeFeature } from '../../feature'
|
|
32
32
|
import {
|
|
33
33
|
boldIcon,
|
|
34
34
|
codeIcon,
|
|
@@ -114,7 +114,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
|
|
|
114
114
|
return hasNode
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
const flags = ctx
|
|
117
|
+
const flags = useCrepeFeatures(ctx).get()
|
|
118
118
|
const isLatexEnabled = flags?.includes(CrepeFeature.Latex)
|
|
119
119
|
|
|
120
120
|
const toggleLatex = (ctx: Ctx) => {
|
|
@@ -172,7 +172,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
|
|
|
172
172
|
commands.call(toggleStrongCommand.key)
|
|
173
173
|
})}
|
|
174
174
|
>
|
|
175
|
-
<Icon icon={config?.boldIcon
|
|
175
|
+
<Icon icon={config?.boldIcon ?? boldIcon} />
|
|
176
176
|
</button>
|
|
177
177
|
<button
|
|
178
178
|
type="button"
|
|
@@ -185,7 +185,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
|
|
|
185
185
|
commands.call(toggleEmphasisCommand.key)
|
|
186
186
|
})}
|
|
187
187
|
>
|
|
188
|
-
<Icon icon={config?.italicIcon
|
|
188
|
+
<Icon icon={config?.italicIcon ?? italicIcon} />
|
|
189
189
|
</button>
|
|
190
190
|
<button
|
|
191
191
|
type="button"
|
|
@@ -198,7 +198,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
|
|
|
198
198
|
commands.call(toggleStrikethroughCommand.key)
|
|
199
199
|
})}
|
|
200
200
|
>
|
|
201
|
-
<Icon icon={config?.strikethroughIcon
|
|
201
|
+
<Icon icon={config?.strikethroughIcon ?? strikethroughIcon} />
|
|
202
202
|
</button>
|
|
203
203
|
<div class="divider"></div>
|
|
204
204
|
<button
|
|
@@ -212,7 +212,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
|
|
|
212
212
|
commands.call(toggleInlineCodeCommand.key)
|
|
213
213
|
})}
|
|
214
214
|
>
|
|
215
|
-
<Icon icon={config?.codeIcon
|
|
215
|
+
<Icon icon={config?.codeIcon ?? codeIcon} />
|
|
216
216
|
</button>
|
|
217
217
|
{isLatexEnabled && (
|
|
218
218
|
<button
|
|
@@ -223,7 +223,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
|
|
|
223
223
|
)}
|
|
224
224
|
onPointerdown={onClick(toggleLatex)}
|
|
225
225
|
>
|
|
226
|
-
<Icon icon={config?.latexIcon
|
|
226
|
+
<Icon icon={config?.latexIcon ?? functionsIcon} />
|
|
227
227
|
</button>
|
|
228
228
|
)}
|
|
229
229
|
<button
|
|
@@ -247,7 +247,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
|
|
|
247
247
|
hide?.()
|
|
248
248
|
})}
|
|
249
249
|
>
|
|
250
|
-
<Icon icon={config?.linkIcon
|
|
250
|
+
<Icon icon={config?.linkIcon ?? linkIcon} />
|
|
251
251
|
</button>
|
|
252
252
|
</>
|
|
253
253
|
)
|
|
@@ -10,22 +10,24 @@ import { TooltipProvider, tooltipFactory } from '@milkdown/kit/plugin/tooltip'
|
|
|
10
10
|
import { TextSelection } from '@milkdown/kit/prose/state'
|
|
11
11
|
import { createApp, ref, shallowRef, type App, type ShallowRef } from 'vue'
|
|
12
12
|
|
|
13
|
-
import type { DefineFeature
|
|
13
|
+
import type { DefineFeature } from '../shared'
|
|
14
14
|
|
|
15
|
+
import { crepeFeatureConfig } from '../../core/slice'
|
|
16
|
+
import { CrepeFeature } from '../../feature'
|
|
15
17
|
import { Toolbar } from './component'
|
|
16
18
|
|
|
17
19
|
interface ToolbarConfig {
|
|
18
|
-
boldIcon:
|
|
19
|
-
codeIcon:
|
|
20
|
-
italicIcon:
|
|
21
|
-
linkIcon:
|
|
22
|
-
strikethroughIcon:
|
|
23
|
-
latexIcon:
|
|
20
|
+
boldIcon: string
|
|
21
|
+
codeIcon: string
|
|
22
|
+
italicIcon: string
|
|
23
|
+
linkIcon: string
|
|
24
|
+
strikethroughIcon: string
|
|
25
|
+
latexIcon: string
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export type ToolbarFeatureConfig = Partial<ToolbarConfig>
|
|
27
29
|
|
|
28
|
-
const
|
|
30
|
+
const toolbarTooltip = tooltipFactory('CREPE_TOOLBAR')
|
|
29
31
|
|
|
30
32
|
class ToolbarView implements PluginView {
|
|
31
33
|
#tooltipProvider: TooltipProvider
|
|
@@ -108,15 +110,16 @@ class ToolbarView implements PluginView {
|
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
|
|
111
|
-
export const
|
|
113
|
+
export const toolbar: DefineFeature<ToolbarFeatureConfig> = (
|
|
112
114
|
editor,
|
|
113
115
|
config
|
|
114
116
|
) => {
|
|
115
117
|
editor
|
|
118
|
+
.config(crepeFeatureConfig(CrepeFeature.Toolbar))
|
|
116
119
|
.config((ctx) => {
|
|
117
|
-
ctx.set(
|
|
120
|
+
ctx.set(toolbarTooltip.key, {
|
|
118
121
|
view: (view) => new ToolbarView(ctx, view, config),
|
|
119
122
|
})
|
|
120
123
|
})
|
|
121
|
-
.use(
|
|
124
|
+
.use(toolbarTooltip)
|
|
122
125
|
}
|
package/src/icons/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { CrepeFeature } from './feature'
|
|
2
|
-
export
|
|
2
|
+
export * from './core'
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
padding-top: 10px;
|
|
11
11
|
width: max-content;
|
|
12
12
|
position: absolute;
|
|
13
|
-
z-index:
|
|
13
|
+
z-index: 999;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.hidden {
|
|
@@ -31,6 +31,66 @@
|
|
|
31
31
|
background: var(--crepe-color-surface);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
.cm-panel {
|
|
35
|
+
font-family: var(--crepe-font-default);
|
|
36
|
+
background: var(--crepe-color-surface);
|
|
37
|
+
color: var(--crepe-color-on-surface);
|
|
38
|
+
input {
|
|
39
|
+
caret-color: var(--crepe-color-outline);
|
|
40
|
+
border-radius: 4px;
|
|
41
|
+
background: var(--crepe-color-surface-low);
|
|
42
|
+
}
|
|
43
|
+
& > button {
|
|
44
|
+
text-transform: capitalize;
|
|
45
|
+
background: var(--crepe-color-surface-low);
|
|
46
|
+
color: var(--crepe-color-on-surface-variant);
|
|
47
|
+
border: 1px solid var(--crepe-color-outline);
|
|
48
|
+
font-weight: 600;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
border-radius: 4px;
|
|
51
|
+
&:hover {
|
|
52
|
+
background: var(--crepe-color-hover);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
& > label {
|
|
56
|
+
display: inline-flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
text-transform: capitalize;
|
|
59
|
+
input[type='checkbox'] {
|
|
60
|
+
border-radius: 4px;
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
appearance: none;
|
|
63
|
+
-webkit-appearance: none;
|
|
64
|
+
background: var(--crepe-color-surface-low);
|
|
65
|
+
width: 1.15em;
|
|
66
|
+
height: 1.15em;
|
|
67
|
+
border: 1px solid var(--crepe-color-outline);
|
|
68
|
+
display: grid;
|
|
69
|
+
place-content: center;
|
|
70
|
+
&::before {
|
|
71
|
+
content: '';
|
|
72
|
+
transform-origin: bottom left;
|
|
73
|
+
width: 0.65em;
|
|
74
|
+
height: 0.65em;
|
|
75
|
+
transform: scale(0);
|
|
76
|
+
transition: 120ms transform ease-in-out;
|
|
77
|
+
box-shadow: inset 1em 1em var(--crepe-color-outline);
|
|
78
|
+
clip-path: polygon(
|
|
79
|
+
14% 44%,
|
|
80
|
+
0 65%,
|
|
81
|
+
50% 100%,
|
|
82
|
+
100% 16%,
|
|
83
|
+
80% 0%,
|
|
84
|
+
43% 62%
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
&:checked::before {
|
|
88
|
+
transform: scale(1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
34
94
|
.tools {
|
|
35
95
|
display: flex;
|
|
36
96
|
justify-content: space-between;
|
package/src/theme/nord/style.css
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -9,11 +9,3 @@ export function isInList(selection: Selection) {
|
|
|
9
9
|
const type = selection.$from.node(selection.$from.depth - 1)?.type
|
|
10
10
|
return type?.name === 'list_item'
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
export function defIfNotExists(
|
|
14
|
-
tagName: string,
|
|
15
|
-
element: CustomElementConstructor
|
|
16
|
-
) {
|
|
17
|
-
if (customElements.get(tagName) == null)
|
|
18
|
-
customElements.define(tagName, element)
|
|
19
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const confirmIcon = `
|
|
4
|
-
<svg
|
|
5
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
-
width="24"
|
|
7
|
-
height="24"
|
|
8
|
-
viewBox="0 0 24 24"
|
|
9
|
-
fill="none"
|
|
10
|
-
>
|
|
11
|
-
<g clip-path="url(#clip0_1013_1606)">
|
|
12
|
-
<path
|
|
13
|
-
d="M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z"
|
|
14
|
-
fill="#817567"
|
|
15
|
-
/>
|
|
16
|
-
</g>
|
|
17
|
-
<defs>
|
|
18
|
-
<clipPath id="clip0_1013_1606">
|
|
19
|
-
<rect width="24" height="24" />
|
|
20
|
-
</clipPath>
|
|
21
|
-
</defs>
|
|
22
|
-
</svg>
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
exports.confirmIcon = confirmIcon;
|
|
26
|
-
//# sourceMappingURL=confirm-CNveM9QH.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"confirm-CNveM9QH.js","sources":["../../src/icons/confirm.ts"],"sourcesContent":["export const confirmIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n >\n <g clip-path=\"url(#clip0_1013_1606)\">\n <path\n d=\"M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z\"\n fill=\"#817567\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1013_1606\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n"],"names":[],"mappings":";;AAAO,MAAM,WAAc,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
|
package/lib/cjs/edit-BUtBJHpV.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const editIcon = `
|
|
4
|
-
<svg
|
|
5
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
-
width="24"
|
|
7
|
-
height="24"
|
|
8
|
-
viewBox="0 0 24 24"
|
|
9
|
-
>
|
|
10
|
-
<g clip-path="url(#clip0_1013_1585)">
|
|
11
|
-
<path
|
|
12
|
-
d="M14.06 9.02L14.98 9.94L5.92 19H5V18.08L14.06 9.02ZM17.66 3C17.41 3 17.15 3.1 16.96 3.29L15.13 5.12L18.88 8.87L20.71 7.04C21.1 6.65 21.1 6.02 20.71 5.63L18.37 3.29C18.17 3.09 17.92 3 17.66 3ZM14.06 6.19L3 17.25V21H6.75L17.81 9.94L14.06 6.19Z"
|
|
13
|
-
/>
|
|
14
|
-
</g>
|
|
15
|
-
<defs>
|
|
16
|
-
<clipPath id="clip0_1013_1585">
|
|
17
|
-
<rect width="24" height="24" />
|
|
18
|
-
</clipPath>
|
|
19
|
-
</defs>
|
|
20
|
-
</svg>
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
exports.editIcon = editIcon;
|
|
24
|
-
//# sourceMappingURL=edit-BUtBJHpV.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"edit-BUtBJHpV.js","sources":["../../src/icons/edit.ts"],"sourcesContent":["export const editIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_1013_1585)\">\n <path\n d=\"M14.06 9.02L14.98 9.94L5.92 19H5V18.08L14.06 9.02ZM17.66 3C17.41 3 17.15 3.1 16.96 3.29L15.13 5.12L18.88 8.87L20.71 7.04C21.1 6.65 21.1 6.02 20.71 5.63L18.37 3.29C18.17 3.09 17.92 3 17.66 3ZM14.06 6.19L3 17.25V21H6.75L17.81 9.94L14.06 6.19Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1013_1585\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n"],"names":[],"mappings":";;AAAO,MAAM,QAAW,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const codeIcon = `
|
|
4
|
-
<svg
|
|
5
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
-
width="24"
|
|
7
|
-
height="24"
|
|
8
|
-
viewBox="0 0 24 24"
|
|
9
|
-
>
|
|
10
|
-
<g clip-path="url(#clip0_977_8081)">
|
|
11
|
-
<path
|
|
12
|
-
d="M9.4 16.6L4.8 12L9.4 7.4L8 6L2 12L8 18L9.4 16.6ZM14.6 16.6L19.2 12L14.6 7.4L16 6L22 12L16 18L14.6 16.6Z"
|
|
13
|
-
/>
|
|
14
|
-
</g>
|
|
15
|
-
<defs>
|
|
16
|
-
<clipPath id="clip0_977_8081">
|
|
17
|
-
<rect width="24" height="24" />
|
|
18
|
-
</clipPath>
|
|
19
|
-
</defs>
|
|
20
|
-
</svg>
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
const functionsIcon = `
|
|
24
|
-
<svg
|
|
25
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
26
|
-
width="32"
|
|
27
|
-
height="32"
|
|
28
|
-
viewBox="0 0 24 24"
|
|
29
|
-
>
|
|
30
|
-
<path
|
|
31
|
-
fill="currentColor"
|
|
32
|
-
d="M7 19v-.808L13.096 12L7 5.808V5h10v1.25H9.102L14.727 12l-5.625 5.77H17V19z"
|
|
33
|
-
/>
|
|
34
|
-
</svg>
|
|
35
|
-
`;
|
|
36
|
-
|
|
37
|
-
exports.codeIcon = codeIcon;
|
|
38
|
-
exports.functionsIcon = functionsIcon;
|
|
39
|
-
//# sourceMappingURL=functions-BAY51plB.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"functions-BAY51plB.js","sources":["../../src/icons/code.ts","../../src/icons/functions.ts"],"sourcesContent":["export const codeIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_977_8081)\">\n <path\n d=\"M9.4 16.6L4.8 12L9.4 7.4L8 6L2 12L8 18L9.4 16.6ZM14.6 16.6L19.2 12L14.6 7.4L16 6L22 12L16 18L14.6 16.6Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_977_8081\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const functionsIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"32\"\n height=\"32\"\n viewBox=\"0 0 24 24\"\n >\n <path\n fill=\"currentColor\"\n d=\"M7 19v-.808L13.096 12L7 5.808V5h10v1.25H9.102L14.727 12l-5.625 5.77H17V19z\"\n />\n </svg>\n`\n"],"names":[],"mappings":";;AAAO,MAAM,QAAW,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;ACAjB,MAAM,aAAgB,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const imageIcon = `
|
|
4
|
-
<svg
|
|
5
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
-
width="24"
|
|
7
|
-
height="24"
|
|
8
|
-
viewBox="0 0 24 24"
|
|
9
|
-
>
|
|
10
|
-
<g clip-path="url(#clip0_977_8075)">
|
|
11
|
-
<path
|
|
12
|
-
d="M19 5V19H5V5H19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM14.14 11.86L11.14 15.73L9 13.14L6 17H18L14.14 11.86Z"
|
|
13
|
-
/>
|
|
14
|
-
</g>
|
|
15
|
-
<defs>
|
|
16
|
-
<clipPath id="clip0_977_8075">
|
|
17
|
-
<rect width="24" height="24" />
|
|
18
|
-
</clipPath>
|
|
19
|
-
</defs>
|
|
20
|
-
</svg>
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
exports.imageIcon = imageIcon;
|
|
24
|
-
//# sourceMappingURL=image-BXLkOVnO.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image-BXLkOVnO.js","sources":["../../src/icons/image.ts"],"sourcesContent":["export const imageIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_977_8075)\">\n <path\n d=\"M19 5V19H5V5H19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM14.14 11.86L11.14 15.73L9 13.14L6 17H18L14.14 11.86Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_977_8075\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n"],"names":[],"mappings":";;AAAO,MAAM,SAAY,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-B91KhPew.js","sources":["../../src/feature/placeholder/index.ts"],"sourcesContent":["import type { Node } from '@milkdown/kit/prose/model'\nimport type { EditorState } from '@milkdown/kit/prose/state'\n\nimport { findParent } from '@milkdown/kit/prose'\nimport { Plugin, PluginKey } from '@milkdown/kit/prose/state'\nimport { Decoration, DecorationSet } from '@milkdown/kit/prose/view'\nimport { $ctx, $prose } from '@milkdown/kit/utils'\n\nimport type { DefineFeature } from '../shared'\n\nimport { isInCodeBlock, isInList } from '../../utils'\n\nfunction isDocEmpty(doc: Node) {\n return doc.childCount <= 1 && !doc.firstChild?.content.size\n}\n\nfunction createPlaceholderDecoration(\n state: EditorState,\n placeholderText: string\n): Decoration | null {\n const { selection } = state\n if (!selection.empty) return null\n\n const $pos = selection.$anchor\n const node = $pos.parent\n if (node.content.size > 0) return null\n\n const inTable = findParent((node) => node.type.name === 'table')($pos)\n if (inTable) return null\n\n const before = $pos.before()\n\n return Decoration.node(before, before + node.nodeSize, {\n class: 'crepe-placeholder',\n 'data-placeholder': placeholderText,\n })\n}\n\ninterface PlaceholderConfig {\n text: string\n mode: 'doc' | 'block'\n}\n\nexport type PlaceHolderFeatureConfig = Partial<PlaceholderConfig>\n\nexport const placeholderConfig = $ctx(\n {\n text: 'Please enter...',\n mode: 'block',\n } as PlaceholderConfig,\n 'placeholderConfigCtx'\n)\n\nexport const placeholderPlugin = $prose((ctx) => {\n return new Plugin({\n key: new PluginKey('CREPE_PLACEHOLDER'),\n props: {\n decorations: (state) => {\n const config = ctx.get(placeholderConfig.key)\n if (config.mode === 'doc' && !isDocEmpty(state.doc)) return null\n\n if (isInCodeBlock(state.selection) || isInList(state.selection))\n return null\n\n const placeholderText = config.text ?? 'Please enter...'\n const deco = createPlaceholderDecoration(state, placeholderText)\n if (!deco) return null\n\n return DecorationSet.create(state.doc, [deco])\n },\n },\n })\n})\n\nexport const defineFeature: DefineFeature<PlaceHolderFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config((ctx) => {\n if (config) {\n ctx.update(placeholderConfig.key, (prev) => {\n return {\n ...prev,\n ...config,\n }\n })\n }\n })\n .use(placeholderPlugin)\n .use(placeholderConfig)\n}\n"],"names":["findParent","node","Decoration","$ctx","$prose","Plugin","PluginKey","isInCodeBlock","isInList","DecorationSet"],"mappings":";;;;;;;;AAYA,SAAS,WAAW,GAAW,EAAA;AAZ/B,EAAA,IAAA,EAAA;AAaE,EAAA,OAAO,IAAI,UAAc,IAAA,CAAA,IAAK,GAAC,EAAI,GAAA,GAAA,CAAA,UAAA,KAAJ,mBAAgB,OAAQ,CAAA,IAAA,CAAA;AACzD;AAEA,SAAS,2BAAA,CACP,OACA,eACmB,EAAA;AACnB,EAAM,MAAA,EAAE,WAAc,GAAA,KAAA;AACtB,EAAI,IAAA,CAAC,SAAU,CAAA,KAAA,EAAc,OAAA,IAAA;AAE7B,EAAA,MAAM,OAAO,SAAU,CAAA,OAAA;AACvB,EAAA,MAAM,OAAO,IAAK,CAAA,MAAA;AAClB,EAAA,IAAI,IAAK,CAAA,OAAA,CAAQ,IAAO,GAAA,CAAA,EAAU,OAAA,IAAA;AAElC,EAAM,MAAA,OAAA,GAAUA,iBAAW,CAACC,KAAAA,KAASA,MAAK,IAAK,CAAA,IAAA,KAAS,OAAO,CAAA,CAAE,IAAI,CAAA;AACrE,EAAA,IAAI,SAAgB,OAAA,IAAA;AAEpB,EAAM,MAAA,MAAA,GAAS,KAAK,MAAO,EAAA;AAE3B,EAAA,OAAOC,eAAW,CAAA,IAAA,CAAK,MAAQ,EAAA,MAAA,GAAS,KAAK,QAAU,EAAA;AAAA,IACrD,KAAO,EAAA,mBAAA;AAAA,IACP,kBAAoB,EAAA;AAAA,GACrB,CAAA;AACH;AASO,MAAM,iBAAoB,GAAAC,UAAA;AAAA,EAC/B;AAAA,IACE,IAAM,EAAA,iBAAA;AAAA,IACN,IAAM,EAAA;AAAA,GACR;AAAA,EACA;AACF;AAEa,MAAA,iBAAA,GAAoBC,YAAO,CAAA,CAAC,GAAQ,KAAA;AAC/C,EAAA,OAAO,IAAIC,YAAO,CAAA;AAAA,IAChB,GAAA,EAAK,IAAIC,eAAA,CAAU,mBAAmB,CAAA;AAAA,IACtC,KAAO,EAAA;AAAA,MACL,WAAA,EAAa,CAAC,KAAU,KAAA;AAzD9B,QAAA,IAAA,EAAA;AA0DQ,QAAA,MAAM,MAAS,GAAA,GAAA,CAAI,GAAI,CAAA,iBAAA,CAAkB,GAAG,CAAA;AAC5C,QAAI,IAAA,MAAA,CAAO,SAAS,KAAS,IAAA,CAAC,WAAW,KAAM,CAAA,GAAG,GAAU,OAAA,IAAA;AAE5D,QAAA,IAAIC,oBAAc,KAAM,CAAA,SAAS,CAAK,IAAAC,cAAA,CAAS,MAAM,SAAS,CAAA;AAC5D,UAAO,OAAA,IAAA;AAET,QAAM,MAAA,eAAA,GAAA,CAAkB,EAAO,GAAA,MAAA,CAAA,IAAA,KAAP,IAAe,GAAA,EAAA,GAAA,iBAAA;AACvC,QAAM,MAAA,IAAA,GAAO,2BAA4B,CAAA,KAAA,EAAO,eAAe,CAAA;AAC/D,QAAI,IAAA,CAAC,MAAa,OAAA,IAAA;AAElB,QAAA,OAAOC,mBAAc,MAAO,CAAA,KAAA,CAAM,GAAK,EAAA,CAAC,IAAI,CAAC,CAAA;AAAA;AAC/C;AACF,GACD,CAAA;AACH,CAAC;AAEY,MAAA,aAAA,GAAyD,CACpE,MAAA,EACA,MACG,KAAA;AACH,EACG,MAAA,CAAA,MAAA,CAAO,CAAC,GAAQ,KAAA;AACf,IAAA,IAAI,MAAQ,EAAA;AACV,MAAA,GAAA,CAAI,MAAO,CAAA,iBAAA,CAAkB,GAAK,EAAA,CAAC,IAAS,KAAA;AAC1C,QAAO,OAAA;AAAA,UACL,GAAG,IAAA;AAAA,UACH,GAAG;AAAA,SACL;AAAA,OACD,CAAA;AAAA;AACH,GACD,CACA,CAAA,GAAA,CAAI,iBAAiB,CAAA,CACrB,IAAI,iBAAiB,CAAA;AAC1B;;;;;;"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var linkTooltip = require('@milkdown/kit/component/link-tooltip');
|
|
4
|
-
var confirm = require('./confirm-CNveM9QH.js');
|
|
5
|
-
var edit = require('./edit-BUtBJHpV.js');
|
|
6
|
-
var remove = require('./remove-Ba-ypwBf.js');
|
|
7
|
-
|
|
8
|
-
const copyIcon = `
|
|
9
|
-
<svg
|
|
10
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
-
height="24px"
|
|
12
|
-
viewBox="0 -960 960 960"
|
|
13
|
-
width="24px"
|
|
14
|
-
fill="none"
|
|
15
|
-
>
|
|
16
|
-
<path
|
|
17
|
-
d="M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"
|
|
18
|
-
/>
|
|
19
|
-
</svg>
|
|
20
|
-
`;
|
|
21
|
-
|
|
22
|
-
const defineFeature = (editor, config) => {
|
|
23
|
-
editor.config(linkTooltip.configureLinkTooltip).config((ctx) => {
|
|
24
|
-
ctx.update(linkTooltip.linkTooltipConfig.key, (prev) => {
|
|
25
|
-
var _a, _b, _c, _d, _e, _f;
|
|
26
|
-
return {
|
|
27
|
-
...prev,
|
|
28
|
-
linkIcon: (_a = config == null ? void 0 : config.linkIcon) != null ? _a : () => copyIcon,
|
|
29
|
-
editButton: (_b = config == null ? void 0 : config.editButton) != null ? _b : () => edit.editIcon,
|
|
30
|
-
removeButton: (_c = config == null ? void 0 : config.removeButton) != null ? _c : () => remove.removeIcon,
|
|
31
|
-
confirmButton: (_d = config == null ? void 0 : config.confirmButton) != null ? _d : () => confirm.confirmIcon,
|
|
32
|
-
inputPlaceholder: (_e = config == null ? void 0 : config.inputPlaceholder) != null ? _e : "Paste link...",
|
|
33
|
-
onCopyLink: (_f = config == null ? void 0 : config.onCopyLink) != null ? _f : () => {
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
});
|
|
37
|
-
}).use(linkTooltip.linkTooltipPlugin);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
exports.defineFeature = defineFeature;
|
|
41
|
-
//# sourceMappingURL=index-BsrJn8Jp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-BsrJn8Jp.js","sources":["../../src/icons/copy.ts","../../src/feature/link-tooltip/index.ts"],"sourcesContent":["export const copyIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"24px\"\n viewBox=\"0 -960 960 960\"\n width=\"24px\"\n fill=\"none\"\n >\n <path\n d=\"M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z\"\n />\n </svg>\n`\n","import {\n configureLinkTooltip,\n linkTooltipConfig,\n linkTooltipPlugin,\n} from '@milkdown/kit/component/link-tooltip'\n\nimport type { DefineFeature, Icon } from '../shared'\n\nimport { copyIcon, editIcon, removeIcon, confirmIcon } from '../../icons'\n\ninterface LinkTooltipConfig {\n linkIcon: Icon\n editButton: Icon\n removeButton: Icon\n confirmButton: Icon\n inputPlaceholder: string\n onCopyLink: (link: string) => void\n}\n\nexport type LinkTooltipFeatureConfig = Partial<LinkTooltipConfig>\n\nexport const defineFeature: DefineFeature<LinkTooltipFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config(configureLinkTooltip)\n .config((ctx) => {\n ctx.update(linkTooltipConfig.key, (prev) => ({\n ...prev,\n linkIcon: config?.linkIcon ?? (() => copyIcon),\n editButton: config?.editButton ?? (() => editIcon),\n removeButton: config?.removeButton ?? (() => removeIcon),\n confirmButton: config?.confirmButton ?? (() => confirmIcon),\n inputPlaceholder: config?.inputPlaceholder ?? 'Paste link...',\n onCopyLink: config?.onCopyLink ?? (() => {}),\n }))\n })\n .use(linkTooltipPlugin)\n}\n"],"names":["configureLinkTooltip","linkTooltipConfig","editIcon","removeIcon","confirmIcon","linkTooltipPlugin"],"mappings":";;;;;;;AAAO,MAAM,QAAW,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACqBX,MAAA,aAAA,GAAyD,CACpE,MAAA,EACA,MACG,KAAA;AACH,EAAA,MAAA,CACG,MAAO,CAAAA,gCAAoB,CAC3B,CAAA,MAAA,CAAO,CAAC,GAAQ,KAAA;AACf,IAAA,GAAA,CAAI,MAAO,CAAAC,6BAAA,CAAkB,GAAK,EAAA,CAAC,IAAM,KAAA;AA5B/C,MAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AA4BmD,MAAA,OAAA;AAAA,QAC3C,GAAG,IAAA;AAAA,QACH,QAAU,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,QAAR,KAAA,IAAA,GAAA,EAAA,GAAqB,MAAM,QAAA;AAAA,QACrC,UAAY,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,UAAR,KAAA,IAAA,GAAA,EAAA,GAAuB,MAAMC,aAAA;AAAA,QACzC,YAAc,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,YAAR,KAAA,IAAA,GAAA,EAAA,GAAyB,MAAMC,iBAAA;AAAA,QAC7C,aAAe,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,aAAR,KAAA,IAAA,GAAA,EAAA,GAA0B,MAAMC,mBAAA;AAAA,QAC/C,gBAAA,EAAA,CAAkB,EAAQ,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,gBAAA,KAAR,IAA4B,GAAA,EAAA,GAAA,eAAA;AAAA,QAC9C,UAAY,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,UAAR,KAAA,IAAA,GAAA,EAAA,GAAuB,MAAM;AAAA;AAAC,OAC5C;AAAA,KAAE,CAAA;AAAA,GACH,CACA,CAAA,GAAA,CAAIC,6BAAiB,CAAA;AAC1B;;;;"}
|