@milkdown/crepe 7.5.6 → 7.5.8
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/{index-_mXHbJMH.js → index-3mj4YaCA.js} +5 -8
- package/lib/cjs/index-3mj4YaCA.js.map +1 -0
- package/lib/cjs/{index-wORIFtqa.js → index-A8IrOmzS.js} +33 -12
- package/lib/cjs/index-A8IrOmzS.js.map +1 -0
- package/lib/cjs/{index-z6pe2alg.js → index-AlHHvSR_.js} +1 -1
- package/lib/cjs/index-AlHHvSR_.js.map +1 -0
- package/lib/cjs/{index-YoPS8A3_.js → index-BIXWL4Or.js} +2 -2
- package/lib/cjs/index-BIXWL4Or.js.map +1 -0
- package/lib/cjs/{index-MLK151KV.js → index-BrCpWPcp.js} +2 -2
- package/lib/cjs/index-BrCpWPcp.js.map +1 -0
- package/lib/cjs/{index-uleaJDBC.js → index-BuSAwj4j.js} +1 -1
- package/lib/cjs/index-BuSAwj4j.js.map +1 -0
- package/lib/cjs/{index-vNNxr8yy.js → index-By3ewOiO.js} +173 -139
- package/lib/cjs/index-By3ewOiO.js.map +1 -0
- package/lib/cjs/{index-KeJUBENN.js → index-DmOOfQPi.js} +2 -2
- package/lib/cjs/index-DmOOfQPi.js.map +1 -0
- package/lib/cjs/index-Dt55rF23.js +35 -0
- package/lib/cjs/index-Dt55rF23.js.map +1 -0
- package/lib/cjs/{index-rFFAL9YA.js → index-Dub20F3z.js} +15 -17
- package/lib/cjs/index-Dub20F3z.js.map +1 -0
- package/lib/cjs/index.js +11 -13
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/todoList-V4JWO5-M.js +675 -0
- package/lib/cjs/todoList-V4JWO5-M.js.map +1 -0
- package/lib/esm/{index-HHuxH8Dm.js → index-6VoEpEnX.js} +2 -2
- package/lib/esm/index-6VoEpEnX.js.map +1 -0
- package/lib/esm/{index-RJV0C6Af.js → index-BB3Rq6BU.js} +5 -8
- package/lib/esm/index-BB3Rq6BU.js.map +1 -0
- package/lib/esm/{index-uThMsyF6.js → index-BDGHz9p-.js} +2 -2
- package/lib/esm/index-BDGHz9p-.js.map +1 -0
- package/lib/esm/{index-X2mjLDJS.js → index-BoTKwL_u.js} +2 -2
- package/lib/esm/index-BoTKwL_u.js.map +1 -0
- package/lib/esm/{index-6JoGWH2I.js → index-CxJ9fxJm.js} +1 -1
- package/lib/esm/index-CxJ9fxJm.js.map +1 -0
- package/lib/esm/{index-Jvxff1vU.js → index-D6fLMv29.js} +1 -1
- package/lib/esm/index-D6fLMv29.js.map +1 -0
- package/lib/esm/{index-CMGDOz11.js → index-DOrkOhki.js} +15 -17
- package/lib/esm/index-DOrkOhki.js.map +1 -0
- package/lib/esm/index-DlX33Dj0.js +33 -0
- package/lib/esm/index-DlX33Dj0.js.map +1 -0
- package/lib/esm/{index-eZXAY3yz.js → index-kGl7HgN2.js} +33 -12
- package/lib/esm/index-kGl7HgN2.js.map +1 -0
- package/lib/esm/{index-sE0tYrbc.js → index-zKiGjwHz.js} +173 -139
- package/lib/esm/index-zKiGjwHz.js.map +1 -0
- package/lib/esm/index.js +11 -13
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/todoList-CAbx4396.js +638 -0
- package/lib/esm/todoList-CAbx4396.js.map +1 -0
- package/lib/theme/_internal/classic-common.css +44 -19
- package/lib/theme/common/block-edit.css +12 -3
- package/lib/theme/common/code-mirror.css +1 -1
- package/lib/theme/common/cursor.css +7 -3
- package/lib/theme/common/image-block.css +28 -7
- package/lib/theme/common/link-tooltip.css +1 -0
- package/lib/theme/common/placeholder.css +5 -1
- package/lib/theme/common/prosemirror.css +1 -1
- package/lib/theme/common/style.css +10 -10
- package/lib/theme/common/table.css +17 -15
- package/lib/theme/common/toolbar.css +7 -3
- package/lib/theme/crepe/style.css +22 -20
- package/lib/theme/crepe-dark/style.css +25 -23
- package/lib/theme/frame/style.css +23 -20
- package/lib/theme/frame-dark/style.css +23 -20
- package/lib/theme/nord/style.css +25 -22
- package/lib/theme/nord-dark/style.css +23 -20
- package/lib/types/core/crepe.d.ts.map +1 -1
- package/lib/types/core/slice.d.ts +1 -1
- package/lib/types/core/slice.d.ts.map +1 -1
- package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
- package/lib/types/feature/block-edit/handle/index.d.ts.map +1 -1
- package/lib/types/feature/block-edit/index.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/component.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/config.d.ts +2 -7
- package/lib/types/feature/block-edit/menu/config.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/group-builder.d.ts +2 -2
- package/lib/types/feature/block-edit/menu/group-builder.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/index.d.ts +2 -2
- package/lib/types/feature/block-edit/menu/index.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/utils.d.ts.map +1 -1
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/lib/types/feature/cursor/index.d.ts.map +1 -1
- package/lib/types/feature/image-block/index.d.ts.map +1 -1
- package/lib/types/feature/index.d.ts.map +1 -1
- package/lib/types/feature/link-tooltip/index.d.ts.map +1 -1
- package/lib/types/feature/list-item/index.d.ts.map +1 -1
- 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.map +1 -1
- package/lib/types/feature/table/index.d.ts.map +1 -1
- package/lib/types/feature/toolbar/component.d.ts.map +1 -1
- package/lib/types/feature/toolbar/index.d.ts.map +1 -1
- package/lib/types/icons/alignCenter.d.ts.map +1 -1
- package/lib/types/icons/alignLeft.d.ts.map +1 -1
- package/lib/types/icons/alignRight.d.ts.map +1 -1
- package/lib/types/icons/bold.d.ts.map +1 -1
- package/lib/types/icons/bullet.d.ts.map +1 -1
- package/lib/types/icons/bulletList.d.ts.map +1 -1
- package/lib/types/icons/caption.d.ts.map +1 -1
- package/lib/types/icons/checkBoxChecked.d.ts.map +1 -1
- package/lib/types/icons/checkBoxUnchecked.d.ts.map +1 -1
- package/lib/types/icons/chevronDown.d.ts.map +1 -1
- package/lib/types/icons/clear.d.ts.map +1 -1
- package/lib/types/icons/code.d.ts.map +1 -1
- package/lib/types/icons/confirm.d.ts.map +1 -1
- package/lib/types/icons/divider.d.ts.map +1 -1
- package/lib/types/icons/dragHandle.d.ts.map +1 -1
- package/lib/types/icons/edit.d.ts.map +1 -1
- package/lib/types/icons/h1.d.ts.map +1 -1
- package/lib/types/icons/h2.d.ts.map +1 -1
- package/lib/types/icons/h3.d.ts.map +1 -1
- package/lib/types/icons/h4.d.ts.map +1 -1
- package/lib/types/icons/h5.d.ts.map +1 -1
- package/lib/types/icons/h6.d.ts.map +1 -1
- package/lib/types/icons/image.d.ts.map +1 -1
- package/lib/types/icons/italic.d.ts.map +1 -1
- package/lib/types/icons/link.d.ts.map +1 -1
- package/lib/types/icons/menu.d.ts.map +1 -1
- package/lib/types/icons/orderedList.d.ts.map +1 -1
- package/lib/types/icons/plus.d.ts.map +1 -1
- package/lib/types/icons/quote.d.ts.map +1 -1
- package/lib/types/icons/remove.d.ts.map +1 -1
- package/lib/types/icons/search.d.ts.map +1 -1
- package/lib/types/icons/strikethrough.d.ts.map +1 -1
- package/lib/types/icons/table.d.ts.map +1 -1
- package/lib/types/icons/text.d.ts.map +1 -1
- package/lib/types/icons/todoList.d.ts.map +1 -1
- package/lib/types/utils/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/core/crepe.ts +18 -12
- package/src/feature/block-edit/handle/component.ts +7 -4
- package/src/feature/block-edit/handle/index.ts +14 -11
- package/src/feature/block-edit/index.ts +6 -3
- package/src/feature/block-edit/menu/component.ts +138 -117
- package/src/feature/block-edit/menu/config.ts +42 -23
- package/src/feature/block-edit/menu/group-builder.ts +2 -3
- package/src/feature/block-edit/menu/index.ts +25 -15
- package/src/feature/block-edit/menu/utils.ts +45 -25
- package/src/feature/code-mirror/index.ts +20 -12
- package/src/feature/cursor/index.ts +4 -1
- package/src/feature/image-block/index.ts +20 -8
- package/src/feature/index.ts +5 -1
- package/src/feature/link-tooltip/index.ts +10 -3
- package/src/feature/list-item/index.ts +25 -8
- package/src/feature/placeholder/index.ts +19 -18
- package/src/feature/shared.ts +4 -1
- package/src/feature/table/index.ts +37 -29
- package/src/feature/toolbar/component.ts +40 -10
- package/src/feature/toolbar/index.ts +15 -9
- package/src/icons/alignCenter.ts +9 -2
- package/src/icons/alignLeft.ts +9 -2
- package/src/icons/alignRight.ts +9 -2
- package/src/icons/bold.ts +9 -2
- package/src/icons/bullet.ts +8 -3
- package/src/icons/bulletList.ts +10 -3
- package/src/icons/caption.ts +10 -2
- package/src/icons/checkBoxChecked.ts +10 -3
- package/src/icons/checkBoxUnchecked.ts +10 -3
- package/src/icons/chevronDown.ts +13 -2
- package/src/icons/clear.ts +10 -3
- package/src/icons/code.ts +10 -3
- package/src/icons/confirm.ts +11 -2
- package/src/icons/divider.ts +12 -3
- package/src/icons/dragHandle.ts +9 -2
- package/src/icons/edit.ts +10 -3
- package/src/icons/h1.ts +10 -3
- package/src/icons/h2.ts +10 -3
- package/src/icons/h3.ts +10 -3
- package/src/icons/h4.ts +10 -3
- package/src/icons/h5.ts +10 -3
- package/src/icons/h6.ts +10 -3
- package/src/icons/image.ts +10 -3
- package/src/icons/italic.ts +9 -2
- package/src/icons/link.ts +9 -2
- package/src/icons/menu.ts +10 -3
- package/src/icons/orderedList.ts +10 -3
- package/src/icons/plus.ts +10 -3
- package/src/icons/quote.ts +10 -3
- package/src/icons/remove.ts +9 -2
- package/src/icons/search.ts +13 -2
- package/src/icons/strikethrough.ts +9 -2
- package/src/icons/table.ts +10 -3
- package/src/icons/text.ts +10 -3
- package/src/icons/todoList.ts +9 -2
- package/src/theme/_internal/classic-common.css +39 -14
- package/src/theme/common/block-edit.css +12 -3
- package/src/theme/common/code-mirror.css +1 -1
- package/src/theme/common/cursor.css +7 -3
- package/src/theme/common/image-block.css +28 -7
- package/src/theme/common/link-tooltip.css +1 -0
- package/src/theme/common/placeholder.css +5 -1
- package/src/theme/common/prosemirror.css +1 -1
- package/src/theme/common/style.css +10 -10
- package/src/theme/common/table.css +17 -14
- package/src/theme/common/toolbar.css +7 -3
- package/src/theme/crepe/style.css +22 -20
- package/src/theme/crepe-dark/style.css +25 -23
- package/src/theme/frame/style.css +23 -20
- package/src/theme/frame-dark/style.css +23 -20
- package/src/theme/nord/style.css +25 -22
- package/src/theme/nord-dark/style.css +23 -20
- package/src/utils/index.ts +4 -1
- package/lib/cjs/index-9Lsv_-NW.js +0 -28
- package/lib/cjs/index-9Lsv_-NW.js.map +0 -1
- package/lib/cjs/index-KeJUBENN.js.map +0 -1
- package/lib/cjs/index-MLK151KV.js.map +0 -1
- package/lib/cjs/index-YoPS8A3_.js.map +0 -1
- package/lib/cjs/index-_mXHbJMH.js.map +0 -1
- package/lib/cjs/index-rFFAL9YA.js.map +0 -1
- package/lib/cjs/index-uleaJDBC.js.map +0 -1
- package/lib/cjs/index-vNNxr8yy.js.map +0 -1
- package/lib/cjs/index-wORIFtqa.js.map +0 -1
- package/lib/cjs/index-z6pe2alg.js.map +0 -1
- package/lib/cjs/todoList-Qb2JsRGC.js +0 -419
- package/lib/cjs/todoList-Qb2JsRGC.js.map +0 -1
- package/lib/esm/index-6JoGWH2I.js.map +0 -1
- package/lib/esm/index-CMGDOz11.js.map +0 -1
- package/lib/esm/index-HHuxH8Dm.js.map +0 -1
- package/lib/esm/index-J3c6JQEf.js +0 -26
- package/lib/esm/index-J3c6JQEf.js.map +0 -1
- package/lib/esm/index-Jvxff1vU.js.map +0 -1
- package/lib/esm/index-RJV0C6Af.js.map +0 -1
- package/lib/esm/index-X2mjLDJS.js.map +0 -1
- package/lib/esm/index-eZXAY3yz.js.map +0 -1
- package/lib/esm/index-sE0tYrbc.js.map +0 -1
- package/lib/esm/index-uThMsyF6.js.map +0 -1
- package/lib/esm/todoList-eAxCDaQj.js +0 -382
- package/lib/esm/todoList-eAxCDaQj.js.map +0 -1
|
@@ -61,7 +61,9 @@ export function getGroups(filter?: string, config?: BlockEditFeatureConfig) {
|
|
|
61
61
|
const view = ctx.get(editorViewCtx)
|
|
62
62
|
const { dispatch, state } = view
|
|
63
63
|
|
|
64
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), {
|
|
64
|
+
const command = clearContentAndSetBlockType(headingSchema.type(ctx), {
|
|
65
|
+
level: 1,
|
|
66
|
+
})
|
|
65
67
|
command(state, dispatch)
|
|
66
68
|
},
|
|
67
69
|
})
|
|
@@ -72,7 +74,9 @@ export function getGroups(filter?: string, config?: BlockEditFeatureConfig) {
|
|
|
72
74
|
const view = ctx.get(editorViewCtx)
|
|
73
75
|
const { dispatch, state } = view
|
|
74
76
|
|
|
75
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), {
|
|
77
|
+
const command = clearContentAndSetBlockType(headingSchema.type(ctx), {
|
|
78
|
+
level: 2,
|
|
79
|
+
})
|
|
76
80
|
command(state, dispatch)
|
|
77
81
|
},
|
|
78
82
|
})
|
|
@@ -83,7 +87,9 @@ export function getGroups(filter?: string, config?: BlockEditFeatureConfig) {
|
|
|
83
87
|
const view = ctx.get(editorViewCtx)
|
|
84
88
|
const { dispatch, state } = view
|
|
85
89
|
|
|
86
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), {
|
|
90
|
+
const command = clearContentAndSetBlockType(headingSchema.type(ctx), {
|
|
91
|
+
level: 3,
|
|
92
|
+
})
|
|
87
93
|
command(state, dispatch)
|
|
88
94
|
},
|
|
89
95
|
})
|
|
@@ -94,7 +100,9 @@ export function getGroups(filter?: string, config?: BlockEditFeatureConfig) {
|
|
|
94
100
|
const view = ctx.get(editorViewCtx)
|
|
95
101
|
const { dispatch, state } = view
|
|
96
102
|
|
|
97
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), {
|
|
103
|
+
const command = clearContentAndSetBlockType(headingSchema.type(ctx), {
|
|
104
|
+
level: 4,
|
|
105
|
+
})
|
|
98
106
|
command(state, dispatch)
|
|
99
107
|
},
|
|
100
108
|
})
|
|
@@ -105,7 +113,9 @@ export function getGroups(filter?: string, config?: BlockEditFeatureConfig) {
|
|
|
105
113
|
const view = ctx.get(editorViewCtx)
|
|
106
114
|
const { dispatch, state } = view
|
|
107
115
|
|
|
108
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), {
|
|
116
|
+
const command = clearContentAndSetBlockType(headingSchema.type(ctx), {
|
|
117
|
+
level: 5,
|
|
118
|
+
})
|
|
109
119
|
command(state, dispatch)
|
|
110
120
|
},
|
|
111
121
|
})
|
|
@@ -116,7 +126,9 @@ export function getGroups(filter?: string, config?: BlockEditFeatureConfig) {
|
|
|
116
126
|
const view = ctx.get(editorViewCtx)
|
|
117
127
|
const { dispatch, state } = view
|
|
118
128
|
|
|
119
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), {
|
|
129
|
+
const command = clearContentAndSetBlockType(headingSchema.type(ctx), {
|
|
130
|
+
level: 6,
|
|
131
|
+
})
|
|
120
132
|
command(state, dispatch)
|
|
121
133
|
},
|
|
122
134
|
})
|
|
@@ -127,7 +139,9 @@ export function getGroups(filter?: string, config?: BlockEditFeatureConfig) {
|
|
|
127
139
|
const view = ctx.get(editorViewCtx)
|
|
128
140
|
const { dispatch, state } = view
|
|
129
141
|
|
|
130
|
-
const command = clearContentAndWrapInBlockType(
|
|
142
|
+
const command = clearContentAndWrapInBlockType(
|
|
143
|
+
blockquoteSchema.type(ctx)
|
|
144
|
+
)
|
|
131
145
|
command(state, dispatch)
|
|
132
146
|
},
|
|
133
147
|
})
|
|
@@ -143,7 +157,8 @@ export function getGroups(filter?: string, config?: BlockEditFeatureConfig) {
|
|
|
143
157
|
},
|
|
144
158
|
})
|
|
145
159
|
|
|
146
|
-
groupBuilder
|
|
160
|
+
groupBuilder
|
|
161
|
+
.addGroup('list', config?.slashMenuListGroupLabel ?? 'List')
|
|
147
162
|
.addItem('bullet-list', {
|
|
148
163
|
label: config?.slashMenuBulletListLabel ?? 'Bullet List',
|
|
149
164
|
icon: config?.slashMenuBulletListIcon?.() ?? bulletListIcon,
|
|
@@ -151,7 +166,9 @@ export function getGroups(filter?: string, config?: BlockEditFeatureConfig) {
|
|
|
151
166
|
const view = ctx.get(editorViewCtx)
|
|
152
167
|
const { dispatch, state } = view
|
|
153
168
|
|
|
154
|
-
const command = clearContentAndWrapInBlockType(
|
|
169
|
+
const command = clearContentAndWrapInBlockType(
|
|
170
|
+
bulletListSchema.type(ctx)
|
|
171
|
+
)
|
|
155
172
|
command(state, dispatch)
|
|
156
173
|
},
|
|
157
174
|
})
|
|
@@ -162,7 +179,9 @@ export function getGroups(filter?: string, config?: BlockEditFeatureConfig) {
|
|
|
162
179
|
const view = ctx.get(editorViewCtx)
|
|
163
180
|
const { dispatch, state } = view
|
|
164
181
|
|
|
165
|
-
const command = clearContentAndWrapInBlockType(
|
|
182
|
+
const command = clearContentAndWrapInBlockType(
|
|
183
|
+
orderedListSchema.type(ctx)
|
|
184
|
+
)
|
|
166
185
|
command(state, dispatch)
|
|
167
186
|
},
|
|
168
187
|
})
|
|
@@ -173,12 +192,16 @@ export function getGroups(filter?: string, config?: BlockEditFeatureConfig) {
|
|
|
173
192
|
const view = ctx.get(editorViewCtx)
|
|
174
193
|
const { dispatch, state } = view
|
|
175
194
|
|
|
176
|
-
const command = clearContentAndWrapInBlockType(
|
|
195
|
+
const command = clearContentAndWrapInBlockType(
|
|
196
|
+
listItemSchema.type(ctx),
|
|
197
|
+
{ checked: false }
|
|
198
|
+
)
|
|
177
199
|
command(state, dispatch)
|
|
178
200
|
},
|
|
179
201
|
})
|
|
180
202
|
|
|
181
|
-
groupBuilder
|
|
203
|
+
groupBuilder
|
|
204
|
+
.addGroup('advanced', config?.slashMenuAdvancedGroupLabel ?? 'Advanced')
|
|
182
205
|
.addItem('image', {
|
|
183
206
|
label: config?.slashMenuImageLabel ?? 'Image',
|
|
184
207
|
icon: config?.slashMenuImageIcon?.() ?? imageIcon,
|
|
@@ -227,26 +250,22 @@ export function getGroups(filter?: string, config?: BlockEditFeatureConfig) {
|
|
|
227
250
|
if (filter) {
|
|
228
251
|
groups = groups
|
|
229
252
|
.map((group) => {
|
|
230
|
-
const items = group
|
|
231
|
-
.
|
|
232
|
-
|
|
233
|
-
item
|
|
234
|
-
.label
|
|
235
|
-
.toLowerCase()
|
|
236
|
-
.includes(filter.toLowerCase()))
|
|
253
|
+
const items = group.items.filter((item) =>
|
|
254
|
+
item.label.toLowerCase().includes(filter.toLowerCase())
|
|
255
|
+
)
|
|
237
256
|
|
|
238
257
|
return {
|
|
239
258
|
...group,
|
|
240
259
|
items,
|
|
241
260
|
}
|
|
242
261
|
})
|
|
243
|
-
.filter(group => group.items.length > 0)
|
|
262
|
+
.filter((group) => group.items.length > 0)
|
|
244
263
|
}
|
|
245
264
|
|
|
246
|
-
const items = groups.flatMap(groups => groups.items)
|
|
247
|
-
items.forEach((
|
|
265
|
+
const items = groups.flatMap((groups) => groups.items)
|
|
266
|
+
items.forEach((item, index) => {
|
|
248
267
|
Object.assign(item, { index })
|
|
249
|
-
})
|
|
268
|
+
})
|
|
250
269
|
|
|
251
270
|
groups.reduce((acc, group) => {
|
|
252
271
|
const end = acc + group.items.length
|
|
@@ -37,9 +37,8 @@ export class GroupBuilder {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
getGroup = (key: string) => {
|
|
40
|
-
const group = this.#groups.find(group => group.key === key)
|
|
41
|
-
if (!group)
|
|
42
|
-
throw new Error(`Group with key ${key} not found`)
|
|
40
|
+
const group = this.#groups.find((group) => group.key === key)
|
|
41
|
+
if (!group) throw new Error(`Group with key ${key} not found`)
|
|
43
42
|
|
|
44
43
|
return this.#getGroupInstance(group)
|
|
45
44
|
}
|
|
@@ -16,15 +16,18 @@ export interface MenuAPI {
|
|
|
16
16
|
hide: () => void
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export const menuAPI = $ctx(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
export const menuAPI = $ctx(
|
|
20
|
+
{
|
|
21
|
+
show: () => {},
|
|
22
|
+
hide: () => {},
|
|
23
|
+
} as MenuAPI,
|
|
24
|
+
'menuAPICtx'
|
|
25
|
+
)
|
|
23
26
|
|
|
24
27
|
defIfNotExists('milkdown-slash-menu', MenuElement)
|
|
25
28
|
export function configureMenu(ctx: Ctx, config?: BlockEditFeatureConfig) {
|
|
26
29
|
ctx.set(menu.key, {
|
|
27
|
-
view: view => new MenuView(ctx, view, config),
|
|
30
|
+
view: (view) => new MenuView(ctx, view, config),
|
|
28
31
|
})
|
|
29
32
|
}
|
|
30
33
|
|
|
@@ -44,21 +47,29 @@ class MenuView implements PluginView {
|
|
|
44
47
|
content: this.#content,
|
|
45
48
|
debounce: 20,
|
|
46
49
|
shouldShow(this: SlashProvider, view: EditorView) {
|
|
47
|
-
if (
|
|
50
|
+
if (
|
|
51
|
+
isInCodeBlock(view.state.selection) ||
|
|
52
|
+
isInList(view.state.selection)
|
|
53
|
+
)
|
|
48
54
|
return false
|
|
49
55
|
|
|
50
|
-
const currentText = this.getContent(view, node =>
|
|
51
|
-
['paragraph', 'heading'].includes(node.type.name)
|
|
56
|
+
const currentText = this.getContent(view, (node) =>
|
|
57
|
+
['paragraph', 'heading'].includes(node.type.name)
|
|
58
|
+
)
|
|
52
59
|
|
|
53
|
-
if (currentText == null)
|
|
54
|
-
return false
|
|
60
|
+
if (currentText == null) return false
|
|
55
61
|
|
|
56
62
|
const pos = self.#programmaticallyPos
|
|
57
63
|
|
|
58
|
-
self.#content.filter = currentText.startsWith('/')
|
|
64
|
+
self.#content.filter = currentText.startsWith('/')
|
|
65
|
+
? currentText.slice(1)
|
|
66
|
+
: currentText
|
|
59
67
|
|
|
60
68
|
if (typeof pos === 'number') {
|
|
61
|
-
if (
|
|
69
|
+
if (
|
|
70
|
+
view.state.doc.resolve(pos).node() !==
|
|
71
|
+
view.state.doc.resolve(view.state.selection.from).node()
|
|
72
|
+
) {
|
|
62
73
|
self.#programmaticallyPos = null
|
|
63
74
|
|
|
64
75
|
return false
|
|
@@ -67,8 +78,7 @@ class MenuView implements PluginView {
|
|
|
67
78
|
return true
|
|
68
79
|
}
|
|
69
80
|
|
|
70
|
-
if (!currentText.startsWith('/'))
|
|
71
|
-
return false
|
|
81
|
+
if (!currentText.startsWith('/')) return false
|
|
72
82
|
|
|
73
83
|
return true
|
|
74
84
|
},
|
|
@@ -84,7 +94,7 @@ class MenuView implements PluginView {
|
|
|
84
94
|
this.update(view)
|
|
85
95
|
|
|
86
96
|
ctx.set(menuAPI.key, {
|
|
87
|
-
show: pos => this.show(pos),
|
|
97
|
+
show: (pos) => this.show(pos),
|
|
88
98
|
hide: () => this.hide(),
|
|
89
99
|
})
|
|
90
100
|
}
|
|
@@ -12,13 +12,18 @@ export interface MenuItem {
|
|
|
12
12
|
onRun: (ctx: Ctx) => void
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
type WithRange<T, HasIndex extends true | false = true> = HasIndex extends true
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
type WithRange<T, HasIndex extends true | false = true> = HasIndex extends true
|
|
16
|
+
? T & { range: [start: number, end: number] }
|
|
17
|
+
: T
|
|
18
|
+
|
|
19
|
+
export type MenuItemGroup<HasIndex extends true | false = true> = WithRange<
|
|
20
|
+
{
|
|
21
|
+
key: string
|
|
22
|
+
label: string
|
|
23
|
+
items: HasIndex extends true ? MenuItem[] : Omit<MenuItem, 'index'>[]
|
|
24
|
+
},
|
|
25
|
+
HasIndex
|
|
26
|
+
>
|
|
22
27
|
|
|
23
28
|
export function clearRange(tr: Transaction) {
|
|
24
29
|
const { $from, $to } = tr.selection
|
|
@@ -28,31 +33,44 @@ export function clearRange(tr: Transaction) {
|
|
|
28
33
|
return tr
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
export function setBlockType(
|
|
36
|
+
export function setBlockType(
|
|
37
|
+
tr: Transaction,
|
|
38
|
+
nodeType: NodeType,
|
|
39
|
+
attrs: Attrs | null = null
|
|
40
|
+
) {
|
|
32
41
|
const { from, to } = tr.selection
|
|
33
42
|
return tr.setBlockType(from, to, nodeType, attrs)
|
|
34
43
|
}
|
|
35
44
|
|
|
36
|
-
export function wrapInBlockType(
|
|
45
|
+
export function wrapInBlockType(
|
|
46
|
+
tr: Transaction,
|
|
47
|
+
nodeType: NodeType,
|
|
48
|
+
attrs: Attrs | null = null
|
|
49
|
+
) {
|
|
37
50
|
const { $from, $to } = tr.selection
|
|
38
51
|
|
|
39
52
|
const range = $from.blockRange($to)
|
|
40
53
|
const wrapping = range && findWrapping(range, nodeType, attrs)
|
|
41
|
-
if (!wrapping)
|
|
42
|
-
return null
|
|
54
|
+
if (!wrapping) return null
|
|
43
55
|
|
|
44
56
|
return tr.wrap(range, wrapping)
|
|
45
57
|
}
|
|
46
58
|
|
|
47
|
-
export function addBlockType(
|
|
59
|
+
export function addBlockType(
|
|
60
|
+
tr: Transaction,
|
|
61
|
+
nodeType: NodeType,
|
|
62
|
+
attrs: Attrs | null = null
|
|
63
|
+
) {
|
|
48
64
|
const node = nodeType.createAndFill(attrs)
|
|
49
|
-
if (!node)
|
|
50
|
-
return null
|
|
65
|
+
if (!node) return null
|
|
51
66
|
|
|
52
67
|
return tr.replaceSelectionWith(node)
|
|
53
68
|
}
|
|
54
69
|
|
|
55
|
-
export function clearContentAndSetBlockType(
|
|
70
|
+
export function clearContentAndSetBlockType(
|
|
71
|
+
nodeType: NodeType,
|
|
72
|
+
attrs: Attrs | null = null
|
|
73
|
+
): Command {
|
|
56
74
|
return (state, dispatch) => {
|
|
57
75
|
if (dispatch) {
|
|
58
76
|
const tr = setBlockType(clearRange(state.tr), nodeType, attrs)
|
|
@@ -62,27 +80,29 @@ export function clearContentAndSetBlockType(nodeType: NodeType, attrs: Attrs | n
|
|
|
62
80
|
}
|
|
63
81
|
}
|
|
64
82
|
|
|
65
|
-
export function clearContentAndWrapInBlockType(
|
|
83
|
+
export function clearContentAndWrapInBlockType(
|
|
84
|
+
nodeType: NodeType,
|
|
85
|
+
attrs: Attrs | null = null
|
|
86
|
+
): Command {
|
|
66
87
|
return (state, dispatch) => {
|
|
67
88
|
const tr = wrapInBlockType(clearRange(state.tr), nodeType, attrs)
|
|
68
|
-
if (!tr)
|
|
69
|
-
return false
|
|
89
|
+
if (!tr) return false
|
|
70
90
|
|
|
71
|
-
if (dispatch)
|
|
72
|
-
dispatch(tr.scrollIntoView())
|
|
91
|
+
if (dispatch) dispatch(tr.scrollIntoView())
|
|
73
92
|
|
|
74
93
|
return true
|
|
75
94
|
}
|
|
76
95
|
}
|
|
77
96
|
|
|
78
|
-
export function clearContentAndAddBlockType(
|
|
97
|
+
export function clearContentAndAddBlockType(
|
|
98
|
+
nodeType: NodeType,
|
|
99
|
+
attrs: Attrs | null = null
|
|
100
|
+
): Command {
|
|
79
101
|
return (state, dispatch) => {
|
|
80
102
|
const tr = addBlockType(clearRange(state.tr), nodeType, attrs)
|
|
81
|
-
if (!tr)
|
|
82
|
-
return false
|
|
103
|
+
if (!tr) return false
|
|
83
104
|
|
|
84
|
-
if (dispatch)
|
|
85
|
-
dispatch(tr.scrollIntoView())
|
|
105
|
+
if (dispatch) dispatch(tr.scrollIntoView())
|
|
86
106
|
|
|
87
107
|
return true
|
|
88
108
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
codeBlockComponent,
|
|
3
|
+
codeBlockConfig,
|
|
4
|
+
} from '@milkdown/kit/component/code-block'
|
|
2
5
|
import type { LanguageDescription } from '@codemirror/language'
|
|
3
6
|
import type { Extension } from '@codemirror/state'
|
|
4
7
|
import { basicSetup } from 'codemirror'
|
|
@@ -20,31 +23,36 @@ interface CodeMirrorConfig {
|
|
|
20
23
|
searchPlaceholder: string
|
|
21
24
|
noResultText: string
|
|
22
25
|
|
|
23
|
-
renderLanguage: (
|
|
26
|
+
renderLanguage: (
|
|
27
|
+
language: string,
|
|
28
|
+
selected: boolean
|
|
29
|
+
) => ReturnType<typeof html> | string | HTMLElement
|
|
24
30
|
}
|
|
25
31
|
export type CodeMirrorFeatureConfig = Partial<CodeMirrorConfig>
|
|
26
32
|
|
|
27
|
-
export const defineFeature: DefineFeature<CodeMirrorFeatureConfig> = (
|
|
33
|
+
export const defineFeature: DefineFeature<CodeMirrorFeatureConfig> = (
|
|
34
|
+
editor,
|
|
35
|
+
config = {}
|
|
36
|
+
) => {
|
|
28
37
|
editor
|
|
29
38
|
.config(async (ctx) => {
|
|
30
|
-
let {
|
|
31
|
-
languages,
|
|
32
|
-
theme,
|
|
33
|
-
} = config
|
|
39
|
+
let { languages, theme } = config
|
|
34
40
|
if (!languages) {
|
|
35
|
-
const { languages: langList } = await import(
|
|
41
|
+
const { languages: langList } = await import(
|
|
42
|
+
'@codemirror/language-data'
|
|
43
|
+
)
|
|
36
44
|
languages = langList
|
|
37
45
|
}
|
|
38
46
|
if (!theme) {
|
|
39
|
-
const {
|
|
40
|
-
theme =
|
|
47
|
+
const { oneDark } = await import('@codemirror/theme-one-dark')
|
|
48
|
+
theme = oneDark
|
|
41
49
|
}
|
|
42
|
-
ctx.update(codeBlockConfig.key, defaultConfig => ({
|
|
50
|
+
ctx.update(codeBlockConfig.key, (defaultConfig) => ({
|
|
43
51
|
extensions: [
|
|
44
52
|
keymap.of(defaultKeymap.concat(indentWithTab)),
|
|
45
53
|
basicSetup,
|
|
46
54
|
theme,
|
|
47
|
-
...config?.extensions ?? [],
|
|
55
|
+
...(config?.extensions ?? []),
|
|
48
56
|
],
|
|
49
57
|
languages,
|
|
50
58
|
|
|
@@ -8,7 +8,10 @@ interface CursorConfig {
|
|
|
8
8
|
}
|
|
9
9
|
export type CursorFeatureConfig = Partial<CursorConfig>
|
|
10
10
|
|
|
11
|
-
export const defineFeature: DefineFeature<CursorFeatureConfig> = (
|
|
11
|
+
export const defineFeature: DefineFeature<CursorFeatureConfig> = (
|
|
12
|
+
editor,
|
|
13
|
+
config
|
|
14
|
+
) => {
|
|
12
15
|
editor
|
|
13
16
|
.config((ctx) => {
|
|
14
17
|
ctx.update(dropCursorConfig.key, () => ({
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
imageBlockComponent,
|
|
3
|
+
imageBlockConfig,
|
|
4
|
+
} from '@milkdown/kit/component/image-block'
|
|
5
|
+
import {
|
|
6
|
+
imageInlineComponent,
|
|
7
|
+
inlineImageConfig,
|
|
8
|
+
} from '@milkdown/kit/component/image-inline'
|
|
3
9
|
import type { DefineFeature, Icon } from '../shared'
|
|
4
10
|
import { captionIcon, confirmIcon, imageIcon } from '../../icons'
|
|
5
11
|
|
|
@@ -23,23 +29,29 @@ interface ImageBlockConfig {
|
|
|
23
29
|
|
|
24
30
|
export type ImageBlockFeatureConfig = Partial<ImageBlockConfig>
|
|
25
31
|
|
|
26
|
-
export const defineFeature: DefineFeature<ImageBlockFeatureConfig> = (
|
|
32
|
+
export const defineFeature: DefineFeature<ImageBlockFeatureConfig> = (
|
|
33
|
+
editor,
|
|
34
|
+
config
|
|
35
|
+
) => {
|
|
27
36
|
editor
|
|
28
37
|
.config((ctx) => {
|
|
29
|
-
ctx.update(inlineImageConfig.key, value => ({
|
|
38
|
+
ctx.update(inlineImageConfig.key, (value) => ({
|
|
30
39
|
uploadButton: config?.inlineUploadButton ?? (() => 'Upload'),
|
|
31
40
|
imageIcon: config?.inlineImageIcon ?? (() => imageIcon),
|
|
32
41
|
confirmButton: config?.inlineConfirmButton ?? (() => confirmIcon),
|
|
33
|
-
uploadPlaceholderText:
|
|
42
|
+
uploadPlaceholderText:
|
|
43
|
+
config?.inlineUploadPlaceholderText ?? 'or paste link',
|
|
34
44
|
onUpload: config?.inlineOnUpload ?? config?.onUpload ?? value.onUpload,
|
|
35
45
|
}))
|
|
36
|
-
ctx.update(imageBlockConfig.key, value => ({
|
|
46
|
+
ctx.update(imageBlockConfig.key, (value) => ({
|
|
37
47
|
uploadButton: config?.blockUploadButton ?? (() => 'Upload file'),
|
|
38
48
|
imageIcon: config?.blockImageIcon ?? (() => imageIcon),
|
|
39
49
|
captionIcon: config?.blockCaptionIcon ?? (() => captionIcon),
|
|
40
50
|
confirmButton: config?.blockConfirmButton ?? (() => 'Confirm'),
|
|
41
|
-
captionPlaceholderText:
|
|
42
|
-
|
|
51
|
+
captionPlaceholderText:
|
|
52
|
+
config?.blockCaptionPlaceholderText ?? 'Write Image Caption',
|
|
53
|
+
uploadPlaceholderText:
|
|
54
|
+
config?.blockUploadPlaceholderText ?? 'or paste link',
|
|
43
55
|
onUpload: config?.blockOnUpload ?? config?.onUpload ?? value.onUpload,
|
|
44
56
|
}))
|
|
45
57
|
})
|
package/src/feature/index.ts
CHANGED
|
@@ -45,7 +45,11 @@ export const defaultFeatures: Record<CrepeFeature, boolean> = {
|
|
|
45
45
|
[CrepeFeature.Table]: true,
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export async function loadFeature(
|
|
48
|
+
export async function loadFeature(
|
|
49
|
+
feature: CrepeFeature,
|
|
50
|
+
editor: Editor,
|
|
51
|
+
config?: never
|
|
52
|
+
) {
|
|
49
53
|
switch (feature) {
|
|
50
54
|
case CrepeFeature.CodeMirror: {
|
|
51
55
|
const { defineFeature } = await import('./code-mirror')
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
configureLinkTooltip,
|
|
3
|
+
linkTooltipConfig,
|
|
4
|
+
linkTooltipPlugin,
|
|
5
|
+
} from '@milkdown/kit/component/link-tooltip'
|
|
2
6
|
import type { DefineFeature, Icon } from '../shared'
|
|
3
7
|
import { confirmIcon, copyIcon, editIcon, removeIcon } from '../../icons'
|
|
4
8
|
|
|
@@ -13,11 +17,14 @@ interface LinkTooltipConfig {
|
|
|
13
17
|
|
|
14
18
|
export type LinkTooltipFeatureConfig = Partial<LinkTooltipConfig>
|
|
15
19
|
|
|
16
|
-
export const defineFeature: DefineFeature<LinkTooltipFeatureConfig> = (
|
|
20
|
+
export const defineFeature: DefineFeature<LinkTooltipFeatureConfig> = (
|
|
21
|
+
editor,
|
|
22
|
+
config
|
|
23
|
+
) => {
|
|
17
24
|
editor
|
|
18
25
|
.config(configureLinkTooltip)
|
|
19
26
|
.config((ctx) => {
|
|
20
|
-
ctx.update(linkTooltipConfig.key, prev => ({
|
|
27
|
+
ctx.update(linkTooltipConfig.key, (prev) => ({
|
|
21
28
|
...prev,
|
|
22
29
|
linkIcon: config?.linkIcon ?? (() => copyIcon),
|
|
23
30
|
editButton: config?.editButton ?? (() => editIcon),
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { Ctx } from '@milkdown/kit/ctx'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
listItemBlockComponent,
|
|
4
|
+
listItemBlockConfig,
|
|
5
|
+
} from '@milkdown/kit/component/list-item-block'
|
|
3
6
|
import { html } from 'atomico'
|
|
4
7
|
import clsx from 'clsx'
|
|
5
8
|
import type { DefineFeature, Icon } from '../shared'
|
|
6
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
bulletIcon,
|
|
11
|
+
checkBoxCheckedIcon,
|
|
12
|
+
checkBoxUncheckedIcon,
|
|
13
|
+
} from '../../icons'
|
|
7
14
|
|
|
8
15
|
export interface ListItemConfig {
|
|
9
16
|
bulletIcon: Icon
|
|
@@ -18,21 +25,31 @@ function configureListItem(ctx: Ctx, config?: ListItemFeatureConfig) {
|
|
|
18
25
|
renderLabel: ({ label, listType, checked, readonly }) => {
|
|
19
26
|
if (checked == null) {
|
|
20
27
|
if (listType === 'bullet')
|
|
21
|
-
return html`<span class=
|
|
28
|
+
return html`<span class="label"
|
|
29
|
+
>${config?.bulletIcon?.() ?? bulletIcon}</span
|
|
30
|
+
>`
|
|
22
31
|
|
|
23
|
-
return html`<span class=
|
|
32
|
+
return html`<span class="label">${label}</span>`
|
|
24
33
|
}
|
|
25
34
|
|
|
26
35
|
if (checked)
|
|
27
|
-
return html`<span
|
|
36
|
+
return html`<span
|
|
37
|
+
class=${clsx('label checkbox', readonly && 'readonly')}
|
|
38
|
+
>${config?.checkBoxCheckedIcon?.() ?? checkBoxCheckedIcon}</span
|
|
39
|
+
>`
|
|
28
40
|
|
|
29
|
-
return html`<span class=${clsx('label checkbox', readonly && 'readonly')}
|
|
41
|
+
return html`<span class=${clsx('label checkbox', readonly && 'readonly')}
|
|
42
|
+
>${config?.checkBoxUncheckedIcon?.() ?? checkBoxUncheckedIcon}</span
|
|
43
|
+
>`
|
|
30
44
|
},
|
|
31
45
|
})
|
|
32
46
|
}
|
|
33
47
|
|
|
34
|
-
export const defineFeature: DefineFeature<ListItemFeatureConfig> = (
|
|
48
|
+
export const defineFeature: DefineFeature<ListItemFeatureConfig> = (
|
|
49
|
+
editor,
|
|
50
|
+
config
|
|
51
|
+
) => {
|
|
35
52
|
editor
|
|
36
|
-
.config(ctx => configureListItem(ctx, config))
|
|
53
|
+
.config((ctx) => configureListItem(ctx, config))
|
|
37
54
|
.use(listItemBlockComponent)
|
|
38
55
|
}
|
|
@@ -13,25 +13,22 @@ function isDocEmpty(doc: Node) {
|
|
|
13
13
|
|
|
14
14
|
function createPlaceholderDecoration(
|
|
15
15
|
state: EditorState,
|
|
16
|
-
placeholderText: string
|
|
16
|
+
placeholderText: string
|
|
17
17
|
): Decoration | null {
|
|
18
18
|
const { selection } = state
|
|
19
|
-
if (!selection.empty)
|
|
20
|
-
return null
|
|
19
|
+
if (!selection.empty) return null
|
|
21
20
|
|
|
22
21
|
const $pos = selection.$anchor
|
|
23
22
|
const node = $pos.parent
|
|
24
|
-
if (node.content.size > 0)
|
|
25
|
-
return null
|
|
23
|
+
if (node.content.size > 0) return null
|
|
26
24
|
|
|
27
|
-
const inTable = findParent(node => node.type.name === 'table')($pos)
|
|
28
|
-
if (inTable)
|
|
29
|
-
return null
|
|
25
|
+
const inTable = findParent((node) => node.type.name === 'table')($pos)
|
|
26
|
+
if (inTable) return null
|
|
30
27
|
|
|
31
28
|
const before = $pos.before()
|
|
32
29
|
|
|
33
30
|
return Decoration.node(before, before + node.nodeSize, {
|
|
34
|
-
|
|
31
|
+
class: 'crepe-placeholder',
|
|
35
32
|
'data-placeholder': placeholderText,
|
|
36
33
|
})
|
|
37
34
|
}
|
|
@@ -43,10 +40,13 @@ interface PlaceholderConfig {
|
|
|
43
40
|
|
|
44
41
|
export type PlaceHolderFeatureConfig = Partial<PlaceholderConfig>
|
|
45
42
|
|
|
46
|
-
export const placeholderConfig = $ctx(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
export const placeholderConfig = $ctx(
|
|
44
|
+
{
|
|
45
|
+
text: 'Please enter...',
|
|
46
|
+
mode: 'block',
|
|
47
|
+
} as PlaceholderConfig,
|
|
48
|
+
'placeholderConfigCtx'
|
|
49
|
+
)
|
|
50
50
|
|
|
51
51
|
export const placeholderPlugin = $prose((ctx) => {
|
|
52
52
|
return new Plugin({
|
|
@@ -54,16 +54,14 @@ export const placeholderPlugin = $prose((ctx) => {
|
|
|
54
54
|
props: {
|
|
55
55
|
decorations: (state) => {
|
|
56
56
|
const config = ctx.get(placeholderConfig.key)
|
|
57
|
-
if (config.mode === 'doc' && !isDocEmpty(state.doc))
|
|
58
|
-
return null
|
|
57
|
+
if (config.mode === 'doc' && !isDocEmpty(state.doc)) return null
|
|
59
58
|
|
|
60
59
|
if (isInCodeBlock(state.selection) || isInList(state.selection))
|
|
61
60
|
return null
|
|
62
61
|
|
|
63
62
|
const placeholderText = config.text ?? 'Please enter...'
|
|
64
63
|
const deco = createPlaceholderDecoration(state, placeholderText)
|
|
65
|
-
if (!deco)
|
|
66
|
-
return null
|
|
64
|
+
if (!deco) return null
|
|
67
65
|
|
|
68
66
|
return DecorationSet.create(state.doc, [deco])
|
|
69
67
|
},
|
|
@@ -71,7 +69,10 @@ export const placeholderPlugin = $prose((ctx) => {
|
|
|
71
69
|
})
|
|
72
70
|
})
|
|
73
71
|
|
|
74
|
-
export const defineFeature: DefineFeature<PlaceHolderFeatureConfig> = (
|
|
72
|
+
export const defineFeature: DefineFeature<PlaceHolderFeatureConfig> = (
|
|
73
|
+
editor,
|
|
74
|
+
config
|
|
75
|
+
) => {
|
|
75
76
|
editor
|
|
76
77
|
.config((ctx) => {
|
|
77
78
|
if (config) {
|
package/src/feature/shared.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Editor } from '@milkdown/kit/core'
|
|
2
2
|
import type { html } from 'atomico'
|
|
3
3
|
|
|
4
|
-
export type DefineFeature<Config = unknown> = (
|
|
4
|
+
export type DefineFeature<Config = unknown> = (
|
|
5
|
+
editor: Editor,
|
|
6
|
+
config?: Config
|
|
7
|
+
) => void | Promise<void>
|
|
5
8
|
|
|
6
9
|
export type Icon = () => HTMLElement | ReturnType<typeof html> | string | null
|