@milkdown/crepe 7.11.1 → 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-CtTpZYVe.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-2icTTGim.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-k3lGvKiX.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-BEe1TpeS.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-ZGfGszIQ.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-CTBg0aec.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/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 +14 -130
- package/src/core/index.ts +2 -1
- package/src/core/slice.ts +37 -8
- 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 +2 -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/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-2icTTGim.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-CtTpZYVe.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-Dw6lXgs6.js.map +0 -1
- package/lib/cjs/index-k3lGvKiX.js.map +0 -1
- package/lib/cjs/index-urTgNBfI.js +0 -202
- package/lib/cjs/index-urTgNBfI.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-BCvtgOeI.js.map +0 -1
- package/lib/esm/index-BEe1TpeS.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-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-CTBg0aec.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-CshFzSt2.js +0 -197
- package/lib/esm/index-CshFzSt2.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-ZGfGszIQ.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
|
@@ -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'
|
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-2icTTGim.js","sources":["../../src/feature/latex/block-latex.ts","../../src/feature/latex/inline-tooltip/tooltip.ts","../../src/feature/latex/inline-tooltip/component.tsx","../../src/feature/latex/inline-tooltip/view.ts","../../src/feature/latex/input-rule.ts","../../src/feature/latex/remark.ts","../../src/feature/latex/index.ts"],"sourcesContent":["import { codeBlockSchema } from '@milkdown/kit/preset/commonmark'\n\nexport const blockLatexSchema = codeBlockSchema.extendSchema((prev) => {\n return (ctx) => {\n const baseSchema = prev(ctx)\n return {\n ...baseSchema,\n toMarkdown: {\n match: baseSchema.toMarkdown.match,\n runner: (state, node) => {\n const language = node.attrs.language ?? ''\n if (language.toLowerCase() === 'latex') {\n state.addNode(\n 'math',\n undefined,\n node.content.firstChild?.text || ''\n )\n } else {\n return baseSchema.toMarkdown.runner(state, node)\n }\n },\n },\n }\n }\n})\n","import { tooltipFactory } from '@milkdown/kit/plugin/tooltip'\n\nexport const inlineLatexTooltip = tooltipFactory('INLINE_LATEX')\n","import type { EditorView } from '@milkdown/kit/prose/view'\n\nimport { Icon } from '@milkdown/kit/component'\nimport { defineComponent, type ShallowRef, type VNodeRef, h } from 'vue'\n\nimport type { LatexConfig } from '..'\n\ntype LatexTooltipProps = {\n config: Partial<LatexConfig>\n innerView: ShallowRef<EditorView | null>\n updateValue: ShallowRef<() => void>\n}\n\nh\n\nexport const LatexTooltip = defineComponent<LatexTooltipProps>({\n props: {\n config: {\n type: Object,\n required: true,\n },\n innerView: {\n type: Object,\n required: true,\n },\n updateValue: {\n type: Object,\n required: true,\n },\n },\n setup(props) {\n const innerViewRef: VNodeRef = (el) => {\n if (!el || !(el instanceof HTMLElement)) return\n while (el.firstChild) {\n el.removeChild(el.firstChild)\n }\n if (props.innerView.value) {\n el.appendChild(props.innerView.value.dom)\n }\n }\n const onUpdate = (e: Event) => {\n e.preventDefault()\n props.updateValue.value()\n }\n\n return () => {\n return (\n <div class=\"container\">\n {props.innerView && <div ref={innerViewRef} />}\n <button onPointerdown={onUpdate}>\n <Icon icon={props.config.inlineEditConfirm?.()} />\n </button>\n </div>\n )\n }\n },\n})\n","import type { Ctx } from '@milkdown/kit/ctx'\nimport type { PluginView } from '@milkdown/kit/prose/state'\n\nimport { TooltipProvider } from '@milkdown/kit/plugin/tooltip'\nimport { redo, undo } from '@milkdown/kit/prose/history'\nimport { keymap } from '@milkdown/kit/prose/keymap'\nimport { Schema } from '@milkdown/kit/prose/model'\nimport { EditorState, NodeSelection } from '@milkdown/kit/prose/state'\nimport { EditorView } from '@milkdown/kit/prose/view'\nimport { createApp, shallowRef, type App, type ShallowRef } from 'vue'\n\nimport type { LatexConfig } from '..'\n\nimport { mathInlineId } from '../inline-latex'\nimport { LatexTooltip } from './component'\n\nexport class LatexInlineTooltip implements PluginView {\n #content: HTMLElement\n #provider: TooltipProvider\n #dom: HTMLElement\n #innerView: ShallowRef<EditorView | null> = shallowRef(null)\n #updateValue: ShallowRef<() => void> = shallowRef(() => {})\n #app: App\n\n constructor(\n readonly ctx: Ctx,\n view: EditorView,\n config: Partial<LatexConfig>\n ) {\n const content = document.createElement('div')\n content.className = 'milkdown-latex-inline-edit'\n this.#content = content\n this.#app = createApp(LatexTooltip, {\n config,\n innerView: this.#innerView,\n updateValue: this.#updateValue,\n })\n this.#app.mount(content)\n this.#provider = new TooltipProvider({\n debounce: 0,\n content: this.#content,\n shouldShow: this.#shouldShow,\n offset: 10,\n floatingUIOptions: {\n placement: 'bottom',\n },\n })\n this.#provider.update(view)\n this.#dom = document.createElement('div')\n }\n\n #onHide = () => {\n if (this.#innerView.value) {\n this.#innerView.value.destroy()\n this.#innerView.value = null\n }\n }\n\n #shouldShow = (view: EditorView) => {\n const shouldShow = () => {\n const { selection, schema } = view.state\n if (selection.empty) return false\n if (!(selection instanceof NodeSelection)) return false\n const node = selection.node\n if (node.type.name !== mathInlineId) return false\n\n const textFrom = selection.from\n\n const paragraph = schema.nodes.paragraph!.create(\n null,\n schema.text(node.attrs.value)\n )\n\n const innerView = new EditorView(this.#dom, {\n state: EditorState.create({\n doc: paragraph,\n schema: new Schema({\n nodes: {\n doc: {\n content: 'block+',\n },\n paragraph: {\n content: 'inline*',\n group: 'block',\n parseDOM: [{ tag: 'p' }],\n toDOM() {\n return ['p', 0]\n },\n },\n text: {\n group: 'inline',\n },\n },\n }),\n plugins: [\n keymap({\n 'Mod-z': undo,\n 'Mod-Z': redo,\n 'Mod-y': redo,\n Enter: () => {\n this.#updateValue.value()\n return true\n },\n }),\n ],\n }),\n })\n\n this.#innerView.value = innerView\n this.#updateValue.value = () => {\n const { tr } = view.state\n tr.setNodeAttribute(textFrom, 'value', innerView.state.doc.textContent)\n view.dispatch(tr)\n requestAnimationFrame(() => {\n view.focus()\n })\n }\n return true\n }\n\n const show = shouldShow()\n if (!show) this.#onHide()\n return show\n }\n\n update = (view: EditorView, prevState?: EditorState) => {\n this.#provider.update(view, prevState)\n }\n\n destroy = () => {\n this.#app.unmount()\n this.#provider.destroy()\n this.#content.remove()\n }\n}\n","import { codeBlockSchema } from '@milkdown/kit/preset/commonmark'\nimport { nodeRule } from '@milkdown/kit/prose'\nimport { textblockTypeInputRule } from '@milkdown/kit/prose/inputrules'\nimport { $inputRule } from '@milkdown/kit/utils'\n\nimport { mathInlineSchema } from './inline-latex'\n\n/// Input rule for inline math.\n/// When you type $E=MC^2$, it will create an inline math node.\nexport const mathInlineInputRule = $inputRule((ctx) =>\n nodeRule(/(?:\\$)([^$]+)(?:\\$)$/, mathInlineSchema.type(ctx), {\n getAttr: (match) => {\n return {\n value: match[1] ?? '',\n }\n },\n })\n)\n\n/// A input rule for creating block math.\n/// For example, `$$ ` will create a code block with language javascript.\nexport const mathBlockInputRule = $inputRule((ctx) =>\n textblockTypeInputRule(/^\\$\\$[\\s\\n]$/, codeBlockSchema.type(ctx), () => ({\n language: 'LaTeX',\n }))\n)\n","import type { Node } from '@milkdown/kit/transformer'\n\nimport { $remark } from '@milkdown/kit/utils'\nimport remarkMath from 'remark-math'\nimport { visit } from 'unist-util-visit'\n\nexport const remarkMathPlugin = $remark<'remarkMath', undefined>(\n 'remarkMath',\n () => remarkMath\n)\n\nfunction visitMathBlock(ast: Node) {\n return visit(\n ast,\n 'math',\n (\n node: Node & { value: string },\n index: number,\n parent: Node & { children: Node[] }\n ) => {\n const { value } = node as Node & { value: string }\n const newNode = {\n type: 'code',\n lang: 'LaTeX',\n value,\n }\n parent.children.splice(index, 1, newNode)\n }\n )\n}\n\n/// Turn math block into code block with language LaTeX.\nexport const remarkMathBlockPlugin = $remark(\n 'remarkMathBlock',\n () => () => visitMathBlock\n)\n","import type { KatexOptions } from 'katex'\n\nimport { codeBlockConfig } from '@milkdown/kit/component/code-block'\nimport katex from 'katex'\n\nimport type { DefineFeature, Icon } from '../shared'\n\nimport { CrepeFeature } from '../..'\nimport { FeaturesCtx } from '../../core/slice'\nimport { confirmIcon } from '../../icons'\nimport { blockLatexSchema } from './block-latex'\nimport { mathInlineSchema } from './inline-latex'\nimport { inlineLatexTooltip } from './inline-tooltip/tooltip'\nimport { LatexInlineTooltip } from './inline-tooltip/view'\nimport { mathBlockInputRule, mathInlineInputRule } from './input-rule'\nimport { remarkMathBlockPlugin, remarkMathPlugin } from './remark'\n\nexport interface LatexConfig {\n katexOptions: KatexOptions\n inlineEditConfirm: Icon\n}\n\nexport type LatexFeatureConfig = Partial<LatexConfig>\n\nexport const defineFeature: DefineFeature<LatexFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config((ctx) => {\n const flags = ctx.get(FeaturesCtx)\n const isCodeMirrorEnabled = flags.includes(CrepeFeature.CodeMirror)\n if (!isCodeMirrorEnabled) {\n throw new Error('You need to enable CodeMirror to use LaTeX feature')\n }\n\n ctx.update(codeBlockConfig.key, (prev) => ({\n ...prev,\n renderPreview: (language, content) => {\n if (language.toLowerCase() === 'latex' && content.length > 0) {\n return renderLatex(content, config?.katexOptions)\n }\n const renderPreview = prev.renderPreview\n return renderPreview(language, content)\n },\n }))\n\n ctx.set(inlineLatexTooltip.key, {\n view: (view) => {\n return new LatexInlineTooltip(ctx, view, {\n inlineEditConfirm: config?.inlineEditConfirm ?? (() => confirmIcon),\n ...config,\n })\n },\n })\n })\n .use(remarkMathPlugin)\n .use(remarkMathBlockPlugin)\n .use(mathInlineSchema)\n .use(inlineLatexTooltip)\n .use(mathInlineInputRule)\n .use(mathBlockInputRule)\n .use(blockLatexSchema)\n}\n\nfunction renderLatex(content: string, options?: KatexOptions) {\n const html = katex.renderToString(content, {\n ...options,\n throwOnError: false,\n displayMode: true,\n })\n return html\n}\n"],"names":["codeBlockSchema","tooltipFactory","defineComponent","h","Icon","view","shallowRef","NodeSelection","mathInlineId","EditorView","EditorState","Schema","keymap","undo","redo","createApp","TooltipProvider","$inputRule","nodeRule","mathInlineSchema","textblockTypeInputRule","$remark","visit","FeaturesCtx","CrepeFeature","codeBlockConfig","confirmIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAM,gBAAmB,GAAAA,0BAAA,CAAgB,YAAa,CAAA,CAAC,IAAS,KAAA;AACrE,EAAA,OAAO,CAAC,GAAQ,KAAA;AACd,IAAM,MAAA,UAAA,GAAa,KAAK,GAAG,CAAA;AAC3B,IAAO,OAAA;AAAA,MACL,GAAG,UAAA;AAAA,MACH,UAAY,EAAA;AAAA,QACV,KAAA,EAAO,WAAW,UAAW,CAAA,KAAA;AAAA,QAC7B,MAAA,EAAQ,CAAC,KAAA,EAAO,IAAS,KAAA;AATjC,UAAA,IAAA,EAAA,EAAA,EAAA;AAUU,UAAA,MAAM,QAAW,GAAA,CAAA,EAAA,GAAA,IAAA,CAAK,KAAM,CAAA,QAAA,KAAX,IAAuB,GAAA,EAAA,GAAA,EAAA;AACxC,UAAI,IAAA,QAAA,CAAS,WAAY,EAAA,KAAM,OAAS,EAAA;AACtC,YAAM,KAAA,CAAA,OAAA;AAAA,cACJ,MAAA;AAAA,cACA,MAAA;AAAA,cAAA,CAAA,CACA,EAAK,GAAA,IAAA,CAAA,OAAA,CAAQ,UAAb,KAAA,IAAA,GAAA,MAA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AI,CAAAP,4BAAgB,EACpB,GAAI,CAAA,kBAAkB,EACtB,GAAI,CAAA,mBAAmB,EACvB,GAAI,CAAA,kBAAkB,CACtB,CAAA,GAAA,CAAI,gBAAgB,CAAA;AACzB;AAEA,SAAS,WAAA,CAAY,SAAiB,OAAwB,EAAA;AAC5D,EAAM,MAAA,IAAA,GAAO,KAAM,CAAA,cAAA,CAAe,OAAS,EAAA;AAAA,IACzC,GAAG,OAAA;AAAA,IACH,YAAc,EAAA,KAAA;AAAA,IACd,WAAa,EAAA;AAAA,GACd,CAAA;AACD,EAAO,OAAA,IAAA;AACT;;;;"}
|
|
@@ -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;AAC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;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;;;;"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var cursor = require('@milkdown/kit/plugin/cursor');
|
|
4
|
-
var utils = require('@milkdown/kit/utils');
|
|
5
|
-
var prosemirrorVirtualCursor = require('prosemirror-virtual-cursor');
|
|
6
|
-
|
|
7
|
-
const defineFeature = (editor, config) => {
|
|
8
|
-
editor.config((ctx) => {
|
|
9
|
-
ctx.update(cursor.dropCursorConfig.key, () => {
|
|
10
|
-
var _a, _b;
|
|
11
|
-
return {
|
|
12
|
-
class: "crepe-drop-cursor",
|
|
13
|
-
width: (_a = config == null ? void 0 : config.width) != null ? _a : 4,
|
|
14
|
-
color: (_b = config == null ? void 0 : config.color) != null ? _b : false
|
|
15
|
-
};
|
|
16
|
-
});
|
|
17
|
-
}).use(cursor.cursor);
|
|
18
|
-
if ((config == null ? void 0 : config.virtual) === false) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const virtualCursor = prosemirrorVirtualCursor.createVirtualCursor();
|
|
22
|
-
editor.use(utils.$prose(() => virtualCursor));
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
exports.defineFeature = defineFeature;
|
|
26
|
-
//# sourceMappingURL=index-C2CAbC2F.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-C2CAbC2F.js","sources":["../../src/feature/cursor/index.ts"],"sourcesContent":["import { cursor, dropCursorConfig } from '@milkdown/kit/plugin/cursor'\nimport { $prose } from '@milkdown/kit/utils'\nimport { createVirtualCursor } from 'prosemirror-virtual-cursor'\n\nimport type { DefineFeature } from '../shared'\n\ninterface CursorConfig {\n color: string | false\n width: number\n virtual: boolean\n}\nexport type CursorFeatureConfig = Partial<CursorConfig>\n\nexport const defineFeature: DefineFeature<CursorFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config((ctx) => {\n ctx.update(dropCursorConfig.key, () => ({\n class: 'crepe-drop-cursor',\n width: config?.width ?? 4,\n color: config?.color ?? false,\n }))\n })\n .use(cursor)\n\n if (config?.virtual === false) {\n return\n }\n\n const virtualCursor = createVirtualCursor()\n editor.use($prose(() => virtualCursor))\n}\n"],"names":["dropCursorConfig","cursor","createVirtualCursor","$prose"],"mappings":";;;;;;AAaa,MAAA,aAAA,GAAoD,CAC/D,MAAA,EACA,MACG,KAAA;AACH,EACG,MAAA,CAAA,MAAA,CAAO,CAAC,GAAQ,KAAA;AACf,IAAI,GAAA,CAAA,MAAA,CAAOA,uBAAiB,CAAA,GAAA,EAAK,MAAG;AAnB1C,MAAA,IAAA,EAAA,EAAA,EAAA;AAmB8C,MAAA,OAAA;AAAA,QACtC,KAAO,EAAA,mBAAA;AAAA,QACP,KAAA,EAAA,CAAO,EAAQ,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,KAAA,KAAR,IAAiB,GAAA,EAAA,GAAA,CAAA;AAAA,QACxB,KAAA,EAAA,CAAO,EAAQ,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,KAAA,KAAR,IAAiB,GAAA,EAAA,GAAA;AAAA,OAC1B;AAAA,KAAE,CAAA;AAAA,GACH,CACA,CAAA,GAAA,CAAIC,aAAM,CAAA;AAEb,EAAI,IAAA,CAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,aAAY,KAAO,EAAA;AAC7B,IAAA;AAAA;AAGF,EAAA,MAAM,gBAAgBC,4CAAoB,EAAA;AAC1C,EAAA,MAAA,CAAO,GAAI,CAAAC,YAAA,CAAO,MAAM,aAAa,CAAC,CAAA;AACxC;;;;"}
|