@portabletext/plugin-markdown-shortcuts 1.1.4 → 1.3.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/dist/index.cjs +224 -258
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +226 -259
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/src/behavior.markdown-shortcuts.ts +2 -370
- package/src/plugin.markdown-shortcuts.tsx +33 -15
- package/src/rule.blockquote.ts +53 -0
- package/src/rule.heading.ts +59 -0
- package/src/rule.horizontal-rule.ts +61 -0
- package/src/rule.ordered-list.ts +56 -0
- package/src/rule.unordered-list.ts +56 -0
package/dist/index.js
CHANGED
|
@@ -1,131 +1,20 @@
|
|
|
1
|
-
import { jsxs, Fragment
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react/compiler-runtime";
|
|
3
3
|
import { useEditor } from "@portabletext/editor";
|
|
4
4
|
import { CharacterPairDecoratorPlugin } from "@portabletext/plugin-character-pair-decorator";
|
|
5
|
+
import { defineInputRule, InputRulePlugin } from "@portabletext/plugin-input-rule";
|
|
5
6
|
import { useEffect } from "react";
|
|
6
|
-
import { defineBehavior, execute } from "@portabletext/editor/behaviors";
|
|
7
|
+
import { defineBehavior, execute, raise } from "@portabletext/editor/behaviors";
|
|
7
8
|
import * as selectors from "@portabletext/editor/selectors";
|
|
8
|
-
import
|
|
9
|
+
import { getPreviousInlineObject } from "@portabletext/editor/selectors";
|
|
9
10
|
function createMarkdownBehaviors(config) {
|
|
10
|
-
const
|
|
11
|
-
on: "insert.text",
|
|
12
|
-
guard: ({
|
|
13
|
-
snapshot,
|
|
14
|
-
event
|
|
15
|
-
}) => {
|
|
16
|
-
if (event.text !== " ")
|
|
17
|
-
return !1;
|
|
18
|
-
const selectionCollapsed = selectors.isSelectionCollapsed(snapshot), focusTextBlock = selectors.getFocusTextBlock(snapshot), focusSpan = selectors.getFocusSpan(snapshot);
|
|
19
|
-
if (!selectionCollapsed || !focusTextBlock || !focusSpan)
|
|
20
|
-
return !1;
|
|
21
|
-
const previousInlineObject = selectors.getPreviousInlineObject(snapshot), blockOffset = utils.spanSelectionPointToBlockOffset({
|
|
22
|
-
context: snapshot.context,
|
|
23
|
-
selectionPoint: {
|
|
24
|
-
path: [{
|
|
25
|
-
_key: focusTextBlock.node._key
|
|
26
|
-
}, "children", {
|
|
27
|
-
_key: focusSpan.node._key
|
|
28
|
-
}],
|
|
29
|
-
offset: snapshot.context.selection?.focus.offset ?? 0
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
if (previousInlineObject || !blockOffset)
|
|
33
|
-
return !1;
|
|
34
|
-
const blockText = utils.getTextBlockText(focusTextBlock.node), caretAtTheEndOfQuote = blockOffset.offset === 1, looksLikeMarkdownQuote = /^>/.test(blockText), blockquoteStyle = config.blockquoteStyle?.({
|
|
35
|
-
schema: snapshot.context.schema
|
|
36
|
-
});
|
|
37
|
-
return caretAtTheEndOfQuote && looksLikeMarkdownQuote && blockquoteStyle !== void 0 ? {
|
|
38
|
-
focusTextBlock,
|
|
39
|
-
style: blockquoteStyle
|
|
40
|
-
} : !1;
|
|
41
|
-
},
|
|
42
|
-
actions: [() => [execute({
|
|
43
|
-
type: "insert.text",
|
|
44
|
-
text: " "
|
|
45
|
-
})], (_, {
|
|
46
|
-
focusTextBlock,
|
|
47
|
-
style
|
|
48
|
-
}) => [execute({
|
|
49
|
-
type: "block.unset",
|
|
50
|
-
props: ["listItem", "level"],
|
|
51
|
-
at: focusTextBlock.path
|
|
52
|
-
}), execute({
|
|
53
|
-
type: "block.set",
|
|
54
|
-
props: {
|
|
55
|
-
style
|
|
56
|
-
},
|
|
57
|
-
at: focusTextBlock.path
|
|
58
|
-
}), execute({
|
|
59
|
-
type: "delete.text",
|
|
60
|
-
at: {
|
|
61
|
-
anchor: {
|
|
62
|
-
path: focusTextBlock.path,
|
|
63
|
-
offset: 0
|
|
64
|
-
},
|
|
65
|
-
focus: {
|
|
66
|
-
path: focusTextBlock.path,
|
|
67
|
-
offset: 2
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
})]]
|
|
71
|
-
}), automaticHr = defineBehavior({
|
|
72
|
-
on: "insert.text",
|
|
73
|
-
guard: ({
|
|
74
|
-
snapshot,
|
|
75
|
-
event
|
|
76
|
-
}) => {
|
|
77
|
-
const hrCharacter = event.text === "-" ? "-" : event.text === "*" ? "*" : event.text === "_" ? "_" : void 0;
|
|
78
|
-
if (hrCharacter === void 0)
|
|
79
|
-
return !1;
|
|
80
|
-
const hrObject = config.horizontalRuleObject?.({
|
|
81
|
-
schema: snapshot.context.schema
|
|
82
|
-
}), focusBlock = selectors.getFocusTextBlock(snapshot), selectionCollapsed = selectors.isSelectionCollapsed(snapshot);
|
|
83
|
-
if (!hrObject || !focusBlock || !selectionCollapsed)
|
|
84
|
-
return !1;
|
|
85
|
-
const previousInlineObject = selectors.getPreviousInlineObject(snapshot), textBefore = selectors.getBlockTextBefore(snapshot), hrBlockOffsets = {
|
|
86
|
-
anchor: {
|
|
87
|
-
path: focusBlock.path,
|
|
88
|
-
offset: 0
|
|
89
|
-
},
|
|
90
|
-
focus: {
|
|
91
|
-
path: focusBlock.path,
|
|
92
|
-
offset: 3
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
return !previousInlineObject && textBefore === `${hrCharacter}${hrCharacter}` ? {
|
|
96
|
-
hrObject,
|
|
97
|
-
focusBlock,
|
|
98
|
-
hrCharacter,
|
|
99
|
-
hrBlockOffsets
|
|
100
|
-
} : !1;
|
|
101
|
-
},
|
|
102
|
-
actions: [(_, {
|
|
103
|
-
hrCharacter
|
|
104
|
-
}) => [execute({
|
|
105
|
-
type: "insert.text",
|
|
106
|
-
text: hrCharacter
|
|
107
|
-
})], (_, {
|
|
108
|
-
hrObject,
|
|
109
|
-
hrBlockOffsets
|
|
110
|
-
}) => [execute({
|
|
111
|
-
type: "insert.block",
|
|
112
|
-
block: {
|
|
113
|
-
_type: hrObject.name,
|
|
114
|
-
...hrObject.value ?? {}
|
|
115
|
-
},
|
|
116
|
-
placement: "before",
|
|
117
|
-
select: "none"
|
|
118
|
-
}), execute({
|
|
119
|
-
type: "delete.text",
|
|
120
|
-
at: hrBlockOffsets
|
|
121
|
-
})]]
|
|
122
|
-
}), automaticHrOnPaste = defineBehavior({
|
|
11
|
+
const automaticHrOnPaste = defineBehavior({
|
|
123
12
|
on: "clipboard.paste",
|
|
124
13
|
guard: ({
|
|
125
14
|
snapshot,
|
|
126
15
|
event
|
|
127
16
|
}) => {
|
|
128
|
-
const text = event.originEvent.dataTransfer.getData("text/plain"), hrRegExp = /^(---)
|
|
17
|
+
const text = event.originEvent.dataTransfer.getData("text/plain"), hrRegExp = /^(---)$|^(—-)$|^(___)$|^(\*\*\*)$/, hrCharacters = text.match(hrRegExp)?.[0], hrObject = config.horizontalRuleObject?.({
|
|
129
18
|
schema: snapshot.context.schema
|
|
130
19
|
}), focusBlock = selectors.getFocusBlock(snapshot), focusTextBlock = selectors.getFocusTextBlock(snapshot);
|
|
131
20
|
return !hrCharacters || !hrObject || !focusBlock ? !1 : {
|
|
@@ -171,177 +60,233 @@ function createMarkdownBehaviors(config) {
|
|
|
171
60
|
},
|
|
172
61
|
placement: "after"
|
|
173
62
|
})]]
|
|
174
|
-
}),
|
|
175
|
-
on: "
|
|
63
|
+
}), clearStyleOnBackspace = defineBehavior({
|
|
64
|
+
on: "delete.backward",
|
|
176
65
|
guard: ({
|
|
177
|
-
snapshot
|
|
178
|
-
event
|
|
66
|
+
snapshot
|
|
179
67
|
}) => {
|
|
180
|
-
if (event.text !== " ")
|
|
181
|
-
return !1;
|
|
182
68
|
const selectionCollapsed = selectors.isSelectionCollapsed(snapshot), focusTextBlock = selectors.getFocusTextBlock(snapshot), focusSpan = selectors.getFocusSpan(snapshot);
|
|
183
69
|
if (!selectionCollapsed || !focusTextBlock || !focusSpan)
|
|
184
70
|
return !1;
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
selectionPoint: {
|
|
188
|
-
path: [{
|
|
189
|
-
_key: focusTextBlock.node._key
|
|
190
|
-
}, "children", {
|
|
191
|
-
_key: focusSpan.node._key
|
|
192
|
-
}],
|
|
193
|
-
offset: snapshot.context.selection?.focus.offset ?? 0
|
|
194
|
-
}
|
|
71
|
+
const atTheBeginningOfBLock = focusTextBlock.node.children[0]._key === focusSpan.node._key && snapshot.context.selection?.focus.offset === 0, defaultStyle = config.defaultStyle?.({
|
|
72
|
+
schema: snapshot.context.schema
|
|
195
73
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
74
|
+
return atTheBeginningOfBLock && defaultStyle && focusTextBlock.node.style !== defaultStyle ? {
|
|
75
|
+
defaultStyle,
|
|
76
|
+
focusTextBlock
|
|
77
|
+
} : !1;
|
|
78
|
+
},
|
|
79
|
+
actions: [(_, {
|
|
80
|
+
defaultStyle,
|
|
81
|
+
focusTextBlock
|
|
82
|
+
}) => [execute({
|
|
83
|
+
type: "block.set",
|
|
84
|
+
props: {
|
|
85
|
+
style: defaultStyle
|
|
86
|
+
},
|
|
87
|
+
at: focusTextBlock.path
|
|
88
|
+
})]]
|
|
89
|
+
});
|
|
90
|
+
return [automaticHrOnPaste, clearStyleOnBackspace];
|
|
91
|
+
}
|
|
92
|
+
function createBlockquoteRule(config) {
|
|
93
|
+
return defineInputRule({
|
|
94
|
+
on: /^> /,
|
|
95
|
+
guard: ({
|
|
96
|
+
snapshot,
|
|
97
|
+
event
|
|
98
|
+
}) => {
|
|
99
|
+
const style = config.blockquoteStyle({
|
|
100
|
+
schema: snapshot.context.schema
|
|
101
|
+
});
|
|
102
|
+
if (!style || getPreviousInlineObject(snapshot))
|
|
200
103
|
return !1;
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
level
|
|
204
|
-
}) : void 0;
|
|
205
|
-
return level !== void 0 && style !== void 0 ? {
|
|
206
|
-
focusTextBlock,
|
|
104
|
+
const match = event.matches.at(0);
|
|
105
|
+
return match ? {
|
|
207
106
|
style,
|
|
208
|
-
|
|
107
|
+
match
|
|
209
108
|
} : !1;
|
|
210
109
|
},
|
|
211
110
|
actions: [({
|
|
212
111
|
event
|
|
213
|
-
}
|
|
214
|
-
focusTextBlock,
|
|
112
|
+
}, {
|
|
215
113
|
style,
|
|
216
|
-
|
|
217
|
-
}) => [
|
|
114
|
+
match
|
|
115
|
+
}) => [raise({
|
|
218
116
|
type: "block.unset",
|
|
219
117
|
props: ["listItem", "level"],
|
|
220
|
-
at: focusTextBlock.path
|
|
221
|
-
}),
|
|
118
|
+
at: event.focusTextBlock.path
|
|
119
|
+
}), raise({
|
|
222
120
|
type: "block.set",
|
|
223
121
|
props: {
|
|
224
122
|
style
|
|
225
123
|
},
|
|
226
|
-
at: focusTextBlock.path
|
|
227
|
-
}),
|
|
228
|
-
type: "delete
|
|
229
|
-
at:
|
|
230
|
-
anchor: {
|
|
231
|
-
path: focusTextBlock.path,
|
|
232
|
-
offset: 0
|
|
233
|
-
},
|
|
234
|
-
focus: {
|
|
235
|
-
path: focusTextBlock.path,
|
|
236
|
-
offset: level + 1
|
|
237
|
-
}
|
|
238
|
-
}
|
|
124
|
+
at: event.focusTextBlock.path
|
|
125
|
+
}), raise({
|
|
126
|
+
type: "delete",
|
|
127
|
+
at: match.targetOffsets
|
|
239
128
|
})]]
|
|
240
|
-
})
|
|
241
|
-
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function createHeadingRule(config) {
|
|
132
|
+
return defineInputRule({
|
|
133
|
+
on: /^#+ /,
|
|
242
134
|
guard: ({
|
|
243
|
-
snapshot
|
|
135
|
+
snapshot,
|
|
136
|
+
event
|
|
244
137
|
}) => {
|
|
245
|
-
|
|
246
|
-
if (!selectionCollapsed || !focusTextBlock || !focusSpan)
|
|
138
|
+
if (getPreviousInlineObject(snapshot))
|
|
247
139
|
return !1;
|
|
248
|
-
const
|
|
249
|
-
|
|
140
|
+
const match = event.matches.at(0);
|
|
141
|
+
if (!match)
|
|
142
|
+
return !1;
|
|
143
|
+
const level = match.text.length - 1, style = config.headingStyle({
|
|
144
|
+
schema: snapshot.context.schema,
|
|
145
|
+
level
|
|
250
146
|
});
|
|
251
|
-
return
|
|
252
|
-
|
|
253
|
-
|
|
147
|
+
return style ? {
|
|
148
|
+
match,
|
|
149
|
+
style
|
|
254
150
|
} : !1;
|
|
255
151
|
},
|
|
256
|
-
actions: [(
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
152
|
+
actions: [({
|
|
153
|
+
event
|
|
154
|
+
}, {
|
|
155
|
+
match,
|
|
156
|
+
style
|
|
157
|
+
}) => [raise({
|
|
158
|
+
type: "block.unset",
|
|
159
|
+
props: ["listItem", "level"],
|
|
160
|
+
at: event.focusTextBlock.path
|
|
161
|
+
}), raise({
|
|
260
162
|
type: "block.set",
|
|
261
163
|
props: {
|
|
262
|
-
style
|
|
164
|
+
style
|
|
263
165
|
},
|
|
264
|
-
at: focusTextBlock.path
|
|
166
|
+
at: event.focusTextBlock.path
|
|
167
|
+
}), raise({
|
|
168
|
+
type: "delete",
|
|
169
|
+
at: match.targetOffsets
|
|
265
170
|
})]]
|
|
266
|
-
})
|
|
267
|
-
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function createHorizontalRuleRule(config) {
|
|
174
|
+
return defineInputRule({
|
|
175
|
+
on: /^(---)|^(—-)|^(___)|^(\*\*\*)/,
|
|
268
176
|
guard: ({
|
|
269
177
|
snapshot,
|
|
270
178
|
event
|
|
271
179
|
}) => {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
const selectionCollapsed = selectors.isSelectionCollapsed(snapshot), focusTextBlock = selectors.getFocusTextBlock(snapshot), focusSpan = selectors.getFocusSpan(snapshot);
|
|
275
|
-
if (!selectionCollapsed || !focusTextBlock || !focusSpan)
|
|
276
|
-
return !1;
|
|
277
|
-
const previousInlineObject = selectors.getPreviousInlineObject(snapshot), blockOffset = utils.spanSelectionPointToBlockOffset({
|
|
278
|
-
context: snapshot.context,
|
|
279
|
-
selectionPoint: {
|
|
280
|
-
path: [{
|
|
281
|
-
_key: focusTextBlock.node._key
|
|
282
|
-
}, "children", {
|
|
283
|
-
_key: focusSpan.node._key
|
|
284
|
-
}],
|
|
285
|
-
offset: snapshot.context.selection?.focus.offset ?? 0
|
|
286
|
-
}
|
|
180
|
+
const hrObject = config.horizontalRuleObject({
|
|
181
|
+
schema: snapshot.context.schema
|
|
287
182
|
});
|
|
288
|
-
if (
|
|
183
|
+
if (!hrObject || getPreviousInlineObject(snapshot))
|
|
289
184
|
return !1;
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
185
|
+
const match = event.matches.at(0);
|
|
186
|
+
return match ? {
|
|
187
|
+
hrObject,
|
|
188
|
+
match
|
|
189
|
+
} : !1;
|
|
190
|
+
},
|
|
191
|
+
actions: [(_, {
|
|
192
|
+
hrObject,
|
|
193
|
+
match
|
|
194
|
+
}) => [raise({
|
|
195
|
+
type: "insert.block",
|
|
196
|
+
block: {
|
|
197
|
+
_type: hrObject.name,
|
|
198
|
+
...hrObject.value ?? {}
|
|
199
|
+
},
|
|
200
|
+
placement: "before",
|
|
201
|
+
select: "none"
|
|
202
|
+
}), raise({
|
|
203
|
+
type: "delete",
|
|
204
|
+
at: match.targetOffsets
|
|
205
|
+
})]]
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function createOrderedListRule(config) {
|
|
209
|
+
return defineInputRule({
|
|
210
|
+
on: /^1\. /,
|
|
211
|
+
guard: ({
|
|
212
|
+
snapshot,
|
|
213
|
+
event
|
|
214
|
+
}) => {
|
|
215
|
+
const orderedList = config.orderedList({
|
|
303
216
|
schema: snapshot.context.schema
|
|
304
|
-
})
|
|
305
|
-
|
|
306
|
-
|
|
217
|
+
});
|
|
218
|
+
if (!orderedList || getPreviousInlineObject(snapshot))
|
|
219
|
+
return !1;
|
|
220
|
+
const match = event.matches.at(0);
|
|
221
|
+
return match ? {
|
|
222
|
+
match,
|
|
223
|
+
orderedList
|
|
224
|
+
} : !1;
|
|
225
|
+
},
|
|
226
|
+
actions: [({
|
|
227
|
+
event
|
|
228
|
+
}, {
|
|
229
|
+
match,
|
|
230
|
+
orderedList
|
|
231
|
+
}) => [raise({
|
|
232
|
+
type: "block.unset",
|
|
233
|
+
props: ["style"],
|
|
234
|
+
at: event.focusTextBlock.path
|
|
235
|
+
}), raise({
|
|
236
|
+
type: "block.set",
|
|
237
|
+
props: {
|
|
307
238
|
listItem: orderedList,
|
|
308
|
-
|
|
309
|
-
|
|
239
|
+
level: event.focusTextBlock.node.level ?? 1
|
|
240
|
+
},
|
|
241
|
+
at: event.focusTextBlock.path
|
|
242
|
+
}), raise({
|
|
243
|
+
type: "delete",
|
|
244
|
+
at: match.targetOffsets
|
|
245
|
+
})]]
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
function createUnorderedListRule(config) {
|
|
249
|
+
return defineInputRule({
|
|
250
|
+
on: /^(-|\*) /,
|
|
251
|
+
guard: ({
|
|
252
|
+
snapshot,
|
|
253
|
+
event
|
|
254
|
+
}) => {
|
|
255
|
+
const unorderedList = config.unorderedList({
|
|
256
|
+
schema: snapshot.context.schema
|
|
257
|
+
});
|
|
258
|
+
if (!unorderedList || getPreviousInlineObject(snapshot))
|
|
259
|
+
return !1;
|
|
260
|
+
const match = event.matches.at(0);
|
|
261
|
+
return match ? {
|
|
262
|
+
match,
|
|
263
|
+
unorderedList
|
|
310
264
|
} : !1;
|
|
311
265
|
},
|
|
312
266
|
actions: [({
|
|
313
267
|
event
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
268
|
+
}, {
|
|
269
|
+
match,
|
|
270
|
+
unorderedList
|
|
271
|
+
}) => [raise({
|
|
272
|
+
type: "block.unset",
|
|
273
|
+
props: ["style"],
|
|
274
|
+
at: event.focusTextBlock.path
|
|
275
|
+
}), raise({
|
|
320
276
|
type: "block.set",
|
|
321
277
|
props: {
|
|
322
|
-
listItem,
|
|
323
|
-
level: 1
|
|
324
|
-
style
|
|
278
|
+
listItem: unorderedList,
|
|
279
|
+
level: event.focusTextBlock.node.level ?? 1
|
|
325
280
|
},
|
|
326
|
-
at: focusTextBlock.path
|
|
327
|
-
}),
|
|
328
|
-
type: "delete
|
|
329
|
-
at:
|
|
330
|
-
anchor: {
|
|
331
|
-
path: focusTextBlock.path,
|
|
332
|
-
offset: 0
|
|
333
|
-
},
|
|
334
|
-
focus: {
|
|
335
|
-
path: focusTextBlock.path,
|
|
336
|
-
offset: listItemLength + 1
|
|
337
|
-
}
|
|
338
|
-
}
|
|
281
|
+
at: event.focusTextBlock.path
|
|
282
|
+
}), raise({
|
|
283
|
+
type: "delete",
|
|
284
|
+
at: match.targetOffsets
|
|
339
285
|
})]]
|
|
340
286
|
});
|
|
341
|
-
return [automaticBlockquoteOnSpace, automaticHeadingOnSpace, automaticHr, automaticHrOnPaste, clearStyleOnBackspace, automaticListOnSpace];
|
|
342
287
|
}
|
|
343
288
|
function MarkdownShortcutsPlugin(t0) {
|
|
344
|
-
const $ = c(
|
|
289
|
+
const $ = c(35), {
|
|
345
290
|
blockquoteStyle,
|
|
346
291
|
boldDecorator,
|
|
347
292
|
codeDecorator,
|
|
@@ -353,15 +298,10 @@ function MarkdownShortcutsPlugin(t0) {
|
|
|
353
298
|
strikeThroughDecorator,
|
|
354
299
|
unorderedList
|
|
355
300
|
} = t0, editor = useEditor();
|
|
356
|
-
let t1
|
|
357
|
-
$[0] !==
|
|
301
|
+
let t1;
|
|
302
|
+
$[0] !== defaultStyle || $[1] !== editor ? (t1 = () => {
|
|
358
303
|
const unregisterBehaviors = createMarkdownBehaviors({
|
|
359
|
-
|
|
360
|
-
defaultStyle,
|
|
361
|
-
headingStyle,
|
|
362
|
-
horizontalRuleObject,
|
|
363
|
-
orderedList,
|
|
364
|
-
unorderedList
|
|
304
|
+
defaultStyle
|
|
365
305
|
}).map((behavior) => editor.registerBehavior({
|
|
366
306
|
behavior
|
|
367
307
|
}));
|
|
@@ -369,9 +309,11 @@ function MarkdownShortcutsPlugin(t0) {
|
|
|
369
309
|
for (const unregisterBehavior of unregisterBehaviors)
|
|
370
310
|
unregisterBehavior();
|
|
371
311
|
};
|
|
372
|
-
},
|
|
312
|
+
}, $[0] = defaultStyle, $[1] = editor, $[2] = t1) : t1 = $[2];
|
|
313
|
+
let t2;
|
|
314
|
+
$[3] !== defaultStyle || $[4] !== editor || $[5] !== horizontalRuleObject ? (t2 = [defaultStyle, editor, horizontalRuleObject], $[3] = defaultStyle, $[4] = editor, $[5] = horizontalRuleObject, $[6] = t2) : t2 = $[6], useEffect(t1, t2);
|
|
373
315
|
let t3;
|
|
374
|
-
$[
|
|
316
|
+
$[7] !== boldDecorator ? (t3 = boldDecorator ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
375
317
|
/* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, { decorator: boldDecorator, pair: {
|
|
376
318
|
char: "*",
|
|
377
319
|
amount: 2
|
|
@@ -380,14 +322,14 @@ function MarkdownShortcutsPlugin(t0) {
|
|
|
380
322
|
char: "_",
|
|
381
323
|
amount: 2
|
|
382
324
|
} })
|
|
383
|
-
] }) : null, $[
|
|
325
|
+
] }) : null, $[7] = boldDecorator, $[8] = t3) : t3 = $[8];
|
|
384
326
|
let t4;
|
|
385
|
-
$[
|
|
327
|
+
$[9] !== codeDecorator ? (t4 = codeDecorator ? /* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, { decorator: codeDecorator, pair: {
|
|
386
328
|
char: "`",
|
|
387
329
|
amount: 1
|
|
388
|
-
} }) : null, $[
|
|
330
|
+
} }) : null, $[9] = codeDecorator, $[10] = t4) : t4 = $[10];
|
|
389
331
|
let t5;
|
|
390
|
-
$[
|
|
332
|
+
$[11] !== italicDecorator ? (t5 = italicDecorator ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
391
333
|
/* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, { decorator: italicDecorator, pair: {
|
|
392
334
|
char: "*",
|
|
393
335
|
amount: 1
|
|
@@ -396,19 +338,44 @@ function MarkdownShortcutsPlugin(t0) {
|
|
|
396
338
|
char: "_",
|
|
397
339
|
amount: 1
|
|
398
340
|
} })
|
|
399
|
-
] }) : null, $[
|
|
341
|
+
] }) : null, $[11] = italicDecorator, $[12] = t5) : t5 = $[12];
|
|
400
342
|
let t6;
|
|
401
|
-
$[
|
|
343
|
+
$[13] !== strikeThroughDecorator ? (t6 = strikeThroughDecorator ? /* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, { decorator: strikeThroughDecorator, pair: {
|
|
402
344
|
char: "~",
|
|
403
345
|
amount: 2
|
|
404
|
-
} }) : null, $[
|
|
346
|
+
} }) : null, $[13] = strikeThroughDecorator, $[14] = t6) : t6 = $[14];
|
|
405
347
|
let t7;
|
|
406
|
-
|
|
348
|
+
$[15] !== blockquoteStyle ? (t7 = blockquoteStyle ? /* @__PURE__ */ jsx(InputRulePlugin, { rules: [createBlockquoteRule({
|
|
349
|
+
blockquoteStyle
|
|
350
|
+
})] }) : null, $[15] = blockquoteStyle, $[16] = t7) : t7 = $[16];
|
|
351
|
+
let t8;
|
|
352
|
+
$[17] !== headingStyle ? (t8 = headingStyle ? /* @__PURE__ */ jsx(InputRulePlugin, { rules: [createHeadingRule({
|
|
353
|
+
headingStyle
|
|
354
|
+
})] }) : null, $[17] = headingStyle, $[18] = t8) : t8 = $[18];
|
|
355
|
+
let t9;
|
|
356
|
+
$[19] !== horizontalRuleObject ? (t9 = horizontalRuleObject ? /* @__PURE__ */ jsx(InputRulePlugin, { rules: [createHorizontalRuleRule({
|
|
357
|
+
horizontalRuleObject
|
|
358
|
+
})] }) : null, $[19] = horizontalRuleObject, $[20] = t9) : t9 = $[20];
|
|
359
|
+
let t10;
|
|
360
|
+
$[21] !== orderedList ? (t10 = orderedList ? /* @__PURE__ */ jsx(InputRulePlugin, { rules: [createOrderedListRule({
|
|
361
|
+
orderedList
|
|
362
|
+
})] }) : null, $[21] = orderedList, $[22] = t10) : t10 = $[22];
|
|
363
|
+
let t11;
|
|
364
|
+
$[23] !== unorderedList ? (t11 = unorderedList ? /* @__PURE__ */ jsx(InputRulePlugin, { rules: [createUnorderedListRule({
|
|
365
|
+
unorderedList
|
|
366
|
+
})] }) : null, $[23] = unorderedList, $[24] = t11) : t11 = $[24];
|
|
367
|
+
let t12;
|
|
368
|
+
return $[25] !== t10 || $[26] !== t11 || $[27] !== t3 || $[28] !== t4 || $[29] !== t5 || $[30] !== t6 || $[31] !== t7 || $[32] !== t8 || $[33] !== t9 ? (t12 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
407
369
|
t3,
|
|
408
370
|
t4,
|
|
409
371
|
t5,
|
|
410
|
-
t6
|
|
411
|
-
|
|
372
|
+
t6,
|
|
373
|
+
t7,
|
|
374
|
+
t8,
|
|
375
|
+
t9,
|
|
376
|
+
t10,
|
|
377
|
+
t11
|
|
378
|
+
] }), $[25] = t10, $[26] = t11, $[27] = t3, $[28] = t4, $[29] = t5, $[30] = t6, $[31] = t7, $[32] = t8, $[33] = t9, $[34] = t12) : t12 = $[34], t12;
|
|
412
379
|
}
|
|
413
380
|
export {
|
|
414
381
|
MarkdownShortcutsPlugin
|