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