@portabletext/plugin-markdown-shortcuts 8.0.44 → 8.0.46

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.js CHANGED
@@ -1,500 +1,396 @@
1
- import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
1
  import { c } from "react/compiler-runtime";
3
2
  import { useEditor } from "@portabletext/editor";
4
3
  import { CharacterPairDecoratorPlugin } from "@portabletext/plugin-character-pair-decorator";
5
- import { defineInputRule, InputRulePlugin } from "@portabletext/plugin-input-rule";
4
+ import { InputRulePlugin, defineInputRule } from "@portabletext/plugin-input-rule";
6
5
  import { useEffect } from "react";
7
6
  import { defineBehavior, raise } from "@portabletext/editor/behaviors";
8
7
  import * as selectors from "@portabletext/editor/selectors";
9
8
  import { getPreviousInlineObject } from "@portabletext/editor/selectors";
10
9
  import { getPathSubSchema } from "@portabletext/editor/traversal";
10
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
11
  function createMarkdownBehaviors(config) {
12
- const automaticHrOnPaste = defineBehavior({
13
- on: "clipboard.paste",
14
- guard: ({
15
- snapshot,
16
- event
17
- }) => {
18
- const text = event.originEvent.dataTransfer.getData("text/plain"), hrRegExp = /^(---)$|^(—-)$|^(___)$|^(\*\*\*)$/, hrCharacters = text.match(hrRegExp)?.[0], focusBlock = selectors.getFocusBlock(snapshot), focusTextBlock = selectors.getFocusTextBlock(snapshot);
19
- if (!focusBlock)
20
- return !1;
21
- const hrObject = config.horizontalRuleObject?.({
22
- context: {
23
- schema: getPathSubSchema(snapshot, focusBlock.path),
24
- keyGenerator: snapshot.context.keyGenerator
25
- }
26
- });
27
- return !hrCharacters || !hrObject ? !1 : {
28
- hrCharacters,
29
- hrObject,
30
- focusBlock,
31
- focusTextBlock
32
- };
33
- },
34
- actions: [(_, {
35
- hrCharacters
36
- }) => [raise({
37
- type: "insert.text",
38
- text: hrCharacters
39
- })], ({
40
- snapshot
41
- }, {
42
- hrObject,
43
- focusBlock,
44
- focusTextBlock
45
- }) => focusTextBlock ? [raise({
46
- type: "insert.block",
47
- block: {
48
- _type: snapshot.context.schema.block.name,
49
- children: focusTextBlock.node.children
50
- },
51
- placement: "after"
52
- }), raise({
53
- type: "insert.block",
54
- block: hrObject,
55
- placement: "after"
56
- }), raise({
57
- type: "delete.block",
58
- at: focusBlock.path
59
- })] : [raise({
60
- type: "insert.block",
61
- block: hrObject,
62
- placement: "after"
63
- })]]
64
- }), clearStyleOnBackspace = defineBehavior({
65
- on: "delete.backward",
66
- guard: ({
67
- snapshot
68
- }) => {
69
- const selectionCollapsed = selectors.isSelectionCollapsed(snapshot), focusTextBlock = selectors.getFocusTextBlock(snapshot), focusSpan = selectors.getFocusSpan(snapshot);
70
- if (!selectionCollapsed || !focusTextBlock || !focusSpan || !(focusTextBlock.node.children[0]._key === focusSpan.node._key && snapshot.context.selection?.focus.offset === 0))
71
- return !1;
72
- const subSchema = getPathSubSchema(snapshot, focusTextBlock.path), defaultStyle = config.defaultStyle?.({
73
- context: {
74
- schema: subSchema
75
- },
76
- schema: subSchema
77
- });
78
- return defaultStyle && focusTextBlock.node.style !== defaultStyle ? {
79
- defaultStyle,
80
- focusTextBlock
81
- } : !1;
82
- },
83
- actions: [(_, {
84
- defaultStyle,
85
- focusTextBlock
86
- }) => [raise({
87
- type: "block.set",
88
- props: {
89
- style: defaultStyle
90
- },
91
- at: focusTextBlock.path
92
- })]]
93
- });
94
- return [automaticHrOnPaste, clearStyleOnBackspace];
12
+ return [defineBehavior({
13
+ on: "clipboard.paste",
14
+ guard: ({ snapshot, event }) => {
15
+ let hrCharacters = event.originEvent.dataTransfer.getData("text/plain").match(/^(---)$|^(—-)$|^(___)$|^(\*\*\*)$/)?.[0], focusBlock = selectors.getFocusBlock(snapshot), focusTextBlock = selectors.getFocusTextBlock(snapshot);
16
+ if (!focusBlock) return !1;
17
+ let hrObject = config.horizontalRuleObject?.({ context: {
18
+ schema: getPathSubSchema(snapshot, focusBlock.path),
19
+ keyGenerator: snapshot.context.keyGenerator
20
+ } });
21
+ return !hrCharacters || !hrObject ? !1 : {
22
+ hrCharacters,
23
+ hrObject,
24
+ focusBlock,
25
+ focusTextBlock
26
+ };
27
+ },
28
+ actions: [(_, { hrCharacters }) => [raise({
29
+ type: "insert.text",
30
+ text: hrCharacters
31
+ })], ({ snapshot }, { hrObject, focusBlock, focusTextBlock }) => focusTextBlock ? [
32
+ raise({
33
+ type: "insert.block",
34
+ block: {
35
+ _type: snapshot.context.schema.block.name,
36
+ children: focusTextBlock.node.children
37
+ },
38
+ placement: "after"
39
+ }),
40
+ raise({
41
+ type: "insert.block",
42
+ block: hrObject,
43
+ placement: "after"
44
+ }),
45
+ raise({
46
+ type: "delete.block",
47
+ at: focusBlock.path
48
+ })
49
+ ] : [raise({
50
+ type: "insert.block",
51
+ block: hrObject,
52
+ placement: "after"
53
+ })]]
54
+ }), defineBehavior({
55
+ on: "delete.backward",
56
+ guard: ({ snapshot }) => {
57
+ let selectionCollapsed = selectors.isSelectionCollapsed(snapshot), focusTextBlock = selectors.getFocusTextBlock(snapshot), focusSpan = selectors.getFocusSpan(snapshot);
58
+ if (!selectionCollapsed || !focusTextBlock || !focusSpan || focusTextBlock.node.children[0]._key !== focusSpan.node._key || snapshot.context.selection?.focus.offset !== 0) return !1;
59
+ let subSchema = getPathSubSchema(snapshot, focusTextBlock.path), defaultStyle = config.defaultStyle?.({
60
+ context: { schema: subSchema },
61
+ schema: subSchema
62
+ });
63
+ return defaultStyle && focusTextBlock.node.style !== defaultStyle ? {
64
+ defaultStyle,
65
+ focusTextBlock
66
+ } : !1;
67
+ },
68
+ actions: [(_, { defaultStyle, focusTextBlock }) => [raise({
69
+ type: "block.set",
70
+ props: { style: defaultStyle },
71
+ at: focusTextBlock.path
72
+ })]]
73
+ })];
95
74
  }
96
75
  function createBlockquoteRule(config) {
97
- return defineInputRule({
98
- on: /^> /,
99
- guard: ({
100
- snapshot,
101
- event
102
- }) => {
103
- const subSchema = getPathSubSchema(snapshot, event.focusBlock.path), style = config.blockquoteStyle({
104
- context: {
105
- schema: subSchema
106
- },
107
- schema: subSchema
108
- });
109
- if (!style || getPreviousInlineObject(snapshot))
110
- return !1;
111
- const match = event.matches.at(0);
112
- return match ? {
113
- style,
114
- match
115
- } : !1;
116
- },
117
- actions: [({
118
- event
119
- }, {
120
- style,
121
- match
122
- }) => [raise({
123
- type: "block.unset",
124
- props: ["listItem", "level"],
125
- at: event.focusBlock.path
126
- }), raise({
127
- type: "block.set",
128
- props: {
129
- style
130
- },
131
- at: event.focusBlock.path
132
- }), raise({
133
- type: "delete",
134
- at: match.targetOffsets
135
- })]]
136
- });
76
+ return defineInputRule({
77
+ on: /^> /,
78
+ guard: ({ snapshot, event }) => {
79
+ let subSchema = getPathSubSchema(snapshot, event.focusBlock.path), style = config.blockquoteStyle({
80
+ context: { schema: subSchema },
81
+ schema: subSchema
82
+ });
83
+ if (!style || getPreviousInlineObject(snapshot)) return !1;
84
+ let match = event.matches.at(0);
85
+ return match ? {
86
+ style,
87
+ match
88
+ } : !1;
89
+ },
90
+ actions: [({ event }, { style, match }) => [
91
+ raise({
92
+ type: "block.unset",
93
+ props: ["listItem", "level"],
94
+ at: event.focusBlock.path
95
+ }),
96
+ raise({
97
+ type: "block.set",
98
+ props: { style },
99
+ at: event.focusBlock.path
100
+ }),
101
+ raise({
102
+ type: "delete",
103
+ at: match.targetOffsets
104
+ })
105
+ ]]
106
+ });
137
107
  }
138
108
  function createHeadingRule(config) {
139
- return defineInputRule({
140
- on: /^#+ /,
141
- guard: ({
142
- snapshot,
143
- event
144
- }) => {
145
- if (getPreviousInlineObject(snapshot))
146
- return !1;
147
- const match = event.matches.at(0);
148
- if (!match)
149
- return !1;
150
- const level = match.text.length - 1, subSchema = getPathSubSchema(snapshot, event.focusBlock.path), style = config.headingStyle({
151
- context: {
152
- schema: subSchema
153
- },
154
- schema: subSchema,
155
- props: {
156
- level
157
- },
158
- level
159
- });
160
- return style ? {
161
- match,
162
- style
163
- } : !1;
164
- },
165
- actions: [({
166
- event
167
- }, {
168
- match,
169
- style
170
- }) => [raise({
171
- type: "block.unset",
172
- props: ["listItem", "level"],
173
- at: event.focusBlock.path
174
- }), raise({
175
- type: "block.set",
176
- props: {
177
- style
178
- },
179
- at: event.focusBlock.path
180
- }), raise({
181
- type: "delete",
182
- at: match.targetOffsets
183
- })]]
184
- });
109
+ return defineInputRule({
110
+ on: /^#+ /,
111
+ guard: ({ snapshot, event }) => {
112
+ if (getPreviousInlineObject(snapshot)) return !1;
113
+ let match = event.matches.at(0);
114
+ if (!match) return !1;
115
+ let level = match.text.length - 1, subSchema = getPathSubSchema(snapshot, event.focusBlock.path), style = config.headingStyle({
116
+ context: { schema: subSchema },
117
+ schema: subSchema,
118
+ props: { level },
119
+ level
120
+ });
121
+ return style ? {
122
+ match,
123
+ style
124
+ } : !1;
125
+ },
126
+ actions: [({ event }, { match, style }) => [
127
+ raise({
128
+ type: "block.unset",
129
+ props: ["listItem", "level"],
130
+ at: event.focusBlock.path
131
+ }),
132
+ raise({
133
+ type: "block.set",
134
+ props: { style },
135
+ at: event.focusBlock.path
136
+ }),
137
+ raise({
138
+ type: "delete",
139
+ at: match.targetOffsets
140
+ })
141
+ ]]
142
+ });
185
143
  }
186
144
  function createHorizontalRuleRule(config) {
187
- return defineInputRule({
188
- on: /^(---)|^(—-)|^(___)|^(\*\*\*)/,
189
- guard: ({
190
- snapshot,
191
- event
192
- }) => {
193
- const subSchema = getPathSubSchema(snapshot, event.focusBlock.path), hrObject = config.horizontalRuleObject({
194
- context: {
195
- schema: subSchema,
196
- keyGenerator: snapshot.context.keyGenerator
197
- }
198
- });
199
- if (!hrObject || getPreviousInlineObject(snapshot))
200
- return !1;
201
- const match = event.matches.at(0);
202
- return match ? {
203
- hrObject,
204
- match
205
- } : !1;
206
- },
207
- actions: [(_, {
208
- hrObject,
209
- match
210
- }) => [raise({
211
- type: "insert.block",
212
- block: hrObject,
213
- placement: "before",
214
- select: "none"
215
- }), raise({
216
- type: "delete",
217
- at: match.targetOffsets
218
- })]]
219
- });
145
+ return defineInputRule({
146
+ on: /^(---)|^(—-)|^(___)|^(\*\*\*)/,
147
+ guard: ({ snapshot, event }) => {
148
+ let subSchema = getPathSubSchema(snapshot, event.focusBlock.path), hrObject = config.horizontalRuleObject({ context: {
149
+ schema: subSchema,
150
+ keyGenerator: snapshot.context.keyGenerator
151
+ } });
152
+ if (!hrObject || getPreviousInlineObject(snapshot)) return !1;
153
+ let match = event.matches.at(0);
154
+ return match ? {
155
+ hrObject,
156
+ match
157
+ } : !1;
158
+ },
159
+ actions: [(_, { hrObject, match }) => [raise({
160
+ type: "insert.block",
161
+ block: hrObject,
162
+ placement: "before",
163
+ select: "none"
164
+ }), raise({
165
+ type: "delete",
166
+ at: match.targetOffsets
167
+ })]]
168
+ });
220
169
  }
221
170
  function createMarkdownLinkRule(config) {
222
- return defineInputRule({
223
- on: /\[(?<text>[^[\]]+)]\((?<href>.+)\)/,
224
- // The rule annotates the text and deletes only the markers and the href
225
- // region, so an inline object inside the link TEXT is harmless and the
226
- // link must fire. The unlisted `href` group stays protected: deleting
227
- // `](href)` across an inline object would destroy it, and the captured
228
- // href text would silently omit it.
229
- inlineObjects: {
230
- allow: ["text"]
231
- },
232
- actions: [({
233
- snapshot,
234
- event
235
- }) => {
236
- const newText = event.textBefore + event.textInserted;
237
- let textLengthDelta = 0;
238
- const actions = [];
239
- for (const match of event.matches.reverse()) {
240
- const textMatch = match.groups.text, hrefMatch = match.groups.href;
241
- if (textMatch === void 0 || hrefMatch === void 0)
242
- continue;
243
- textLengthDelta = textLengthDelta - (match.targetOffsets.focus.offset - match.targetOffsets.anchor.offset - textMatch.text.length);
244
- const linkObject = config.linkObject({
245
- context: {
246
- schema: getPathSubSchema(snapshot, event.focusBlock.path),
247
- keyGenerator: snapshot.context.keyGenerator
248
- },
249
- props: {
250
- href: hrefMatch.text
251
- }
252
- });
253
- if (!linkObject)
254
- continue;
255
- const {
256
- _type,
257
- _key,
258
- ...value
259
- } = linkObject, leftSideOffsets = {
260
- anchor: match.targetOffsets.anchor,
261
- focus: textMatch.targetOffsets.anchor
262
- }, rightSideOffsets = {
263
- anchor: textMatch.targetOffsets.focus,
264
- focus: match.targetOffsets.focus
265
- };
266
- actions.push(raise({
267
- type: "select",
268
- at: textMatch.targetOffsets
269
- })), actions.push(raise({
270
- type: "annotation.add",
271
- annotation: {
272
- name: _type,
273
- _key,
274
- value
275
- }
276
- })), actions.push(raise({
277
- type: "delete",
278
- at: rightSideOffsets
279
- })), actions.push(raise({
280
- type: "delete",
281
- at: leftSideOffsets
282
- }));
283
- }
284
- if (actions.length === 0)
285
- return [];
286
- const endCaretPosition = {
287
- path: event.focusBlock.path,
288
- offset: newText.length - textLengthDelta * -1
289
- };
290
- return [...actions, raise({
291
- type: "select",
292
- at: {
293
- anchor: endCaretPosition,
294
- focus: endCaretPosition
295
- }
296
- })];
297
- }]
298
- });
171
+ return defineInputRule({
172
+ on: /\[(?<text>[^[\]]+)]\((?<href>.+)\)/,
173
+ inlineObjects: { allow: ["text"] },
174
+ actions: [({ snapshot, event }) => {
175
+ let newText = event.textBefore + event.textInserted, textLengthDelta = 0, actions = [];
176
+ for (let match of event.matches.reverse()) {
177
+ let textMatch = match.groups.text, hrefMatch = match.groups.href;
178
+ if (textMatch === void 0 || hrefMatch === void 0) continue;
179
+ textLengthDelta -= match.targetOffsets.focus.offset - match.targetOffsets.anchor.offset - textMatch.text.length;
180
+ let linkObject = config.linkObject({
181
+ context: {
182
+ schema: getPathSubSchema(snapshot, event.focusBlock.path),
183
+ keyGenerator: snapshot.context.keyGenerator
184
+ },
185
+ props: { href: hrefMatch.text }
186
+ });
187
+ if (!linkObject) continue;
188
+ let { _type, _key, ...value } = linkObject, leftSideOffsets = {
189
+ anchor: match.targetOffsets.anchor,
190
+ focus: textMatch.targetOffsets.anchor
191
+ }, rightSideOffsets = {
192
+ anchor: textMatch.targetOffsets.focus,
193
+ focus: match.targetOffsets.focus
194
+ };
195
+ actions.push(raise({
196
+ type: "select",
197
+ at: textMatch.targetOffsets
198
+ })), actions.push(raise({
199
+ type: "annotation.add",
200
+ annotation: {
201
+ name: _type,
202
+ _key,
203
+ value
204
+ }
205
+ })), actions.push(raise({
206
+ type: "delete",
207
+ at: rightSideOffsets
208
+ })), actions.push(raise({
209
+ type: "delete",
210
+ at: leftSideOffsets
211
+ }));
212
+ }
213
+ if (actions.length === 0) return [];
214
+ let endCaretPosition = {
215
+ path: event.focusBlock.path,
216
+ offset: newText.length - textLengthDelta * -1
217
+ };
218
+ return [...actions, raise({
219
+ type: "select",
220
+ at: {
221
+ anchor: endCaretPosition,
222
+ focus: endCaretPosition
223
+ }
224
+ })];
225
+ }]
226
+ });
299
227
  }
300
228
  function createOrderedListRule(config) {
301
- return defineInputRule({
302
- on: /^1\. /,
303
- guard: ({
304
- snapshot,
305
- event
306
- }) => {
307
- const subSchema = getPathSubSchema(snapshot, event.focusBlock.path), orderedList = config.orderedList({
308
- context: {
309
- schema: subSchema
310
- },
311
- schema: subSchema
312
- });
313
- if (!orderedList || getPreviousInlineObject(snapshot))
314
- return !1;
315
- const match = event.matches.at(0);
316
- return match ? {
317
- match,
318
- orderedList
319
- } : !1;
320
- },
321
- actions: [({
322
- event
323
- }, {
324
- match,
325
- orderedList
326
- }) => [raise({
327
- type: "block.unset",
328
- props: ["style"],
329
- at: event.focusBlock.path
330
- }), raise({
331
- type: "block.set",
332
- props: {
333
- listItem: orderedList,
334
- level: event.focusBlock.node.level ?? 1
335
- },
336
- at: event.focusBlock.path
337
- }), raise({
338
- type: "delete",
339
- at: match.targetOffsets
340
- })]]
341
- });
229
+ return defineInputRule({
230
+ on: /^1\. /,
231
+ guard: ({ snapshot, event }) => {
232
+ let subSchema = getPathSubSchema(snapshot, event.focusBlock.path), orderedList = config.orderedList({
233
+ context: { schema: subSchema },
234
+ schema: subSchema
235
+ });
236
+ if (!orderedList || getPreviousInlineObject(snapshot)) return !1;
237
+ let match = event.matches.at(0);
238
+ return match ? {
239
+ match,
240
+ orderedList
241
+ } : !1;
242
+ },
243
+ actions: [({ event }, { match, orderedList }) => [
244
+ raise({
245
+ type: "block.unset",
246
+ props: ["style"],
247
+ at: event.focusBlock.path
248
+ }),
249
+ raise({
250
+ type: "block.set",
251
+ props: {
252
+ listItem: orderedList,
253
+ level: event.focusBlock.node.level ?? 1
254
+ },
255
+ at: event.focusBlock.path
256
+ }),
257
+ raise({
258
+ type: "delete",
259
+ at: match.targetOffsets
260
+ })
261
+ ]]
262
+ });
342
263
  }
343
264
  function createUnorderedListRule(config) {
344
- return defineInputRule({
345
- on: /^(-|\*) /,
346
- guard: ({
347
- snapshot,
348
- event
349
- }) => {
350
- const subSchema = getPathSubSchema(snapshot, event.focusBlock.path), unorderedList = config.unorderedList({
351
- context: {
352
- schema: subSchema
353
- },
354
- schema: subSchema
355
- });
356
- if (!unorderedList || getPreviousInlineObject(snapshot))
357
- return !1;
358
- const match = event.matches.at(0);
359
- return match ? {
360
- match,
361
- unorderedList
362
- } : !1;
363
- },
364
- actions: [({
365
- event
366
- }, {
367
- match,
368
- unorderedList
369
- }) => [raise({
370
- type: "block.unset",
371
- props: ["style"],
372
- at: event.focusBlock.path
373
- }), raise({
374
- type: "block.set",
375
- props: {
376
- listItem: unorderedList,
377
- level: event.focusBlock.node.level ?? 1
378
- },
379
- at: event.focusBlock.path
380
- }), raise({
381
- type: "delete",
382
- at: match.targetOffsets
383
- })]]
384
- });
265
+ return defineInputRule({
266
+ on: /^(-|\*) /,
267
+ guard: ({ snapshot, event }) => {
268
+ let subSchema = getPathSubSchema(snapshot, event.focusBlock.path), unorderedList = config.unorderedList({
269
+ context: { schema: subSchema },
270
+ schema: subSchema
271
+ });
272
+ if (!unorderedList || getPreviousInlineObject(snapshot)) return !1;
273
+ let match = event.matches.at(0);
274
+ return match ? {
275
+ match,
276
+ unorderedList
277
+ } : !1;
278
+ },
279
+ actions: [({ event }, { match, unorderedList }) => [
280
+ raise({
281
+ type: "block.unset",
282
+ props: ["style"],
283
+ at: event.focusBlock.path
284
+ }),
285
+ raise({
286
+ type: "block.set",
287
+ props: {
288
+ listItem: unorderedList,
289
+ level: event.focusBlock.node.level ?? 1
290
+ },
291
+ at: event.focusBlock.path
292
+ }),
293
+ raise({
294
+ type: "delete",
295
+ at: match.targetOffsets
296
+ })
297
+ ]]
298
+ });
385
299
  }
300
+ /**
301
+ * @public
302
+ */
386
303
  function MarkdownShortcutsPlugin(t0) {
387
- const $ = c(39), {
388
- blockquoteStyle,
389
- boldDecorator,
390
- codeDecorator,
391
- defaultStyle,
392
- headingStyle,
393
- horizontalRuleObject,
394
- linkObject,
395
- italicDecorator,
396
- orderedList,
397
- strikeThroughDecorator,
398
- unorderedList
399
- } = t0, editor = useEditor();
400
- let t1, t2;
401
- $[0] !== defaultStyle || $[1] !== editor ? (t1 = () => {
402
- const unregisterBehaviors = createMarkdownBehaviors({
403
- defaultStyle
404
- }).map((behavior) => editor.registerBehavior({
405
- behavior
406
- }));
407
- return () => {
408
- for (const unregisterBehavior of unregisterBehaviors)
409
- unregisterBehavior();
410
- };
411
- }, t2 = [defaultStyle, editor], $[0] = defaultStyle, $[1] = editor, $[2] = t1, $[3] = t2) : (t1 = $[2], t2 = $[3]), useEffect(t1, t2);
412
- let rules;
413
- if ($[4] !== blockquoteStyle || $[5] !== headingStyle || $[6] !== horizontalRuleObject || $[7] !== linkObject || $[8] !== orderedList || $[9] !== unorderedList) {
414
- if (rules = [], blockquoteStyle) {
415
- let t32;
416
- $[11] !== blockquoteStyle ? (t32 = createBlockquoteRule({
417
- blockquoteStyle
418
- }), $[11] = blockquoteStyle, $[12] = t32) : t32 = $[12], rules.push(t32);
419
- }
420
- if (headingStyle) {
421
- let t32;
422
- $[13] !== headingStyle ? (t32 = createHeadingRule({
423
- headingStyle
424
- }), $[13] = headingStyle, $[14] = t32) : t32 = $[14], rules.push(t32);
425
- }
426
- if (horizontalRuleObject) {
427
- let t32;
428
- $[15] !== horizontalRuleObject ? (t32 = createHorizontalRuleRule({
429
- horizontalRuleObject
430
- }), $[15] = horizontalRuleObject, $[16] = t32) : t32 = $[16], rules.push(t32);
431
- }
432
- if (linkObject) {
433
- let t32;
434
- $[17] !== linkObject ? (t32 = createMarkdownLinkRule({
435
- linkObject
436
- }), $[17] = linkObject, $[18] = t32) : t32 = $[18], rules.push(t32);
437
- }
438
- if (orderedList) {
439
- let t32;
440
- $[19] !== orderedList ? (t32 = createOrderedListRule({
441
- orderedList
442
- }), $[19] = orderedList, $[20] = t32) : t32 = $[20], rules.push(t32);
443
- }
444
- if (unorderedList) {
445
- let t32;
446
- $[21] !== unorderedList ? (t32 = createUnorderedListRule({
447
- unorderedList
448
- }), $[21] = unorderedList, $[22] = t32) : t32 = $[22], rules.push(t32);
449
- }
450
- $[4] = blockquoteStyle, $[5] = headingStyle, $[6] = horizontalRuleObject, $[7] = linkObject, $[8] = orderedList, $[9] = unorderedList, $[10] = rules;
451
- } else
452
- rules = $[10];
453
- const inputRules = rules.length > 0 ? rules : null;
454
- let t3;
455
- $[23] !== boldDecorator ? (t3 = boldDecorator ? /* @__PURE__ */ jsxs(Fragment, { children: [
456
- /* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, { decorator: boldDecorator, pair: {
457
- char: "*",
458
- amount: 2
459
- } }),
460
- /* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, { decorator: boldDecorator, pair: {
461
- char: "_",
462
- amount: 2
463
- } })
464
- ] }) : null, $[23] = boldDecorator, $[24] = t3) : t3 = $[24];
465
- let t4;
466
- $[25] !== codeDecorator ? (t4 = codeDecorator ? /* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, { decorator: codeDecorator, pair: {
467
- char: "`",
468
- amount: 1
469
- } }) : null, $[25] = codeDecorator, $[26] = t4) : t4 = $[26];
470
- let t5;
471
- $[27] !== italicDecorator ? (t5 = italicDecorator ? /* @__PURE__ */ jsxs(Fragment, { children: [
472
- /* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, { decorator: italicDecorator, pair: {
473
- char: "*",
474
- amount: 1
475
- } }),
476
- /* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, { decorator: italicDecorator, pair: {
477
- char: "_",
478
- amount: 1
479
- } })
480
- ] }) : null, $[27] = italicDecorator, $[28] = t5) : t5 = $[28];
481
- let t6;
482
- $[29] !== strikeThroughDecorator ? (t6 = strikeThroughDecorator ? /* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, { decorator: strikeThroughDecorator, pair: {
483
- char: "~",
484
- amount: 2
485
- } }) : null, $[29] = strikeThroughDecorator, $[30] = t6) : t6 = $[30];
486
- let t7;
487
- $[31] !== inputRules ? (t7 = inputRules ? /* @__PURE__ */ jsx(InputRulePlugin, { rules: inputRules }) : null, $[31] = inputRules, $[32] = t7) : t7 = $[32];
488
- let t8;
489
- return $[33] !== t3 || $[34] !== t4 || $[35] !== t5 || $[36] !== t6 || $[37] !== t7 ? (t8 = /* @__PURE__ */ jsxs(Fragment, { children: [
490
- t3,
491
- t4,
492
- t5,
493
- t6,
494
- t7
495
- ] }), $[33] = t3, $[34] = t4, $[35] = t5, $[36] = t6, $[37] = t7, $[38] = t8) : t8 = $[38], t8;
304
+ let $ = c(39), { blockquoteStyle, boldDecorator, codeDecorator, defaultStyle, headingStyle, horizontalRuleObject, linkObject, italicDecorator, orderedList, strikeThroughDecorator, unorderedList } = t0, editor = useEditor(), t1, t2;
305
+ $[0] !== defaultStyle || $[1] !== editor ? (t1 = () => {
306
+ let unregisterBehaviors = createMarkdownBehaviors({ defaultStyle }).map((behavior) => editor.registerBehavior({ behavior }));
307
+ return () => {
308
+ for (let unregisterBehavior of unregisterBehaviors) unregisterBehavior();
309
+ };
310
+ }, t2 = [defaultStyle, editor], $[0] = defaultStyle, $[1] = editor, $[2] = t1, $[3] = t2) : (t1 = $[2], t2 = $[3]), useEffect(t1, t2);
311
+ let rules;
312
+ if ($[4] !== blockquoteStyle || $[5] !== headingStyle || $[6] !== horizontalRuleObject || $[7] !== linkObject || $[8] !== orderedList || $[9] !== unorderedList) {
313
+ if (rules = [], blockquoteStyle) {
314
+ let t3;
315
+ $[11] === blockquoteStyle ? t3 = $[12] : (t3 = createBlockquoteRule({ blockquoteStyle }), $[11] = blockquoteStyle, $[12] = t3), rules.push(t3);
316
+ }
317
+ if (headingStyle) {
318
+ let t3;
319
+ $[13] === headingStyle ? t3 = $[14] : (t3 = createHeadingRule({ headingStyle }), $[13] = headingStyle, $[14] = t3), rules.push(t3);
320
+ }
321
+ if (horizontalRuleObject) {
322
+ let t3;
323
+ $[15] === horizontalRuleObject ? t3 = $[16] : (t3 = createHorizontalRuleRule({ horizontalRuleObject }), $[15] = horizontalRuleObject, $[16] = t3), rules.push(t3);
324
+ }
325
+ if (linkObject) {
326
+ let t3;
327
+ $[17] === linkObject ? t3 = $[18] : (t3 = createMarkdownLinkRule({ linkObject }), $[17] = linkObject, $[18] = t3), rules.push(t3);
328
+ }
329
+ if (orderedList) {
330
+ let t3;
331
+ $[19] === orderedList ? t3 = $[20] : (t3 = createOrderedListRule({ orderedList }), $[19] = orderedList, $[20] = t3), rules.push(t3);
332
+ }
333
+ if (unorderedList) {
334
+ let t3;
335
+ $[21] === unorderedList ? t3 = $[22] : (t3 = createUnorderedListRule({ unorderedList }), $[21] = unorderedList, $[22] = t3), rules.push(t3);
336
+ }
337
+ $[4] = blockquoteStyle, $[5] = headingStyle, $[6] = horizontalRuleObject, $[7] = linkObject, $[8] = orderedList, $[9] = unorderedList, $[10] = rules;
338
+ } else rules = $[10];
339
+ let inputRules = rules.length > 0 ? rules : null, t3;
340
+ $[23] === boldDecorator ? t3 = $[24] : (t3 = boldDecorator ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, {
341
+ decorator: boldDecorator,
342
+ pair: {
343
+ char: "*",
344
+ amount: 2
345
+ }
346
+ }), /* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, {
347
+ decorator: boldDecorator,
348
+ pair: {
349
+ char: "_",
350
+ amount: 2
351
+ }
352
+ })] }) : null, $[23] = boldDecorator, $[24] = t3);
353
+ let t4;
354
+ $[25] === codeDecorator ? t4 = $[26] : (t4 = codeDecorator ? /* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, {
355
+ decorator: codeDecorator,
356
+ pair: {
357
+ char: "`",
358
+ amount: 1
359
+ }
360
+ }) : null, $[25] = codeDecorator, $[26] = t4);
361
+ let t5;
362
+ $[27] === italicDecorator ? t5 = $[28] : (t5 = italicDecorator ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, {
363
+ decorator: italicDecorator,
364
+ pair: {
365
+ char: "*",
366
+ amount: 1
367
+ }
368
+ }), /* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, {
369
+ decorator: italicDecorator,
370
+ pair: {
371
+ char: "_",
372
+ amount: 1
373
+ }
374
+ })] }) : null, $[27] = italicDecorator, $[28] = t5);
375
+ let t6;
376
+ $[29] === strikeThroughDecorator ? t6 = $[30] : (t6 = strikeThroughDecorator ? /* @__PURE__ */ jsx(CharacterPairDecoratorPlugin, {
377
+ decorator: strikeThroughDecorator,
378
+ pair: {
379
+ char: "~",
380
+ amount: 2
381
+ }
382
+ }) : null, $[29] = strikeThroughDecorator, $[30] = t6);
383
+ let t7;
384
+ $[31] === inputRules ? t7 = $[32] : (t7 = inputRules ? /* @__PURE__ */ jsx(InputRulePlugin, { rules: inputRules }) : null, $[31] = inputRules, $[32] = t7);
385
+ let t8;
386
+ return $[33] !== t3 || $[34] !== t4 || $[35] !== t5 || $[36] !== t6 || $[37] !== t7 ? (t8 = /* @__PURE__ */ jsxs(Fragment, { children: [
387
+ t3,
388
+ t4,
389
+ t5,
390
+ t6,
391
+ t7
392
+ ] }), $[33] = t3, $[34] = t4, $[35] = t5, $[36] = t6, $[37] = t7, $[38] = t8) : t8 = $[38], t8;
496
393
  }
497
- export {
498
- MarkdownShortcutsPlugin
499
- };
500
- //# sourceMappingURL=index.js.map
394
+ export { MarkdownShortcutsPlugin };
395
+
396
+ //# sourceMappingURL=index.js.map