@portabletext/editor 1.23.0 → 1.25.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.
Files changed (71) hide show
  1. package/lib/_chunks-cjs/behavior.core.cjs +249 -62
  2. package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
  3. package/lib/_chunks-cjs/{selector.is-selection-collapsed.cjs → selector.is-active-style.cjs} +158 -3
  4. package/lib/_chunks-cjs/selector.is-active-style.cjs.map +1 -0
  5. package/lib/_chunks-cjs/util.slice-blocks.cjs +23 -9
  6. package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
  7. package/lib/_chunks-es/behavior.core.js +225 -38
  8. package/lib/_chunks-es/behavior.core.js.map +1 -1
  9. package/lib/_chunks-es/{selector.is-selection-collapsed.js → selector.is-active-style.js} +159 -4
  10. package/lib/_chunks-es/selector.is-active-style.js.map +1 -0
  11. package/lib/_chunks-es/util.slice-blocks.js +23 -9
  12. package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
  13. package/lib/behaviors/index.cjs +27 -27
  14. package/lib/behaviors/index.cjs.map +1 -1
  15. package/lib/behaviors/index.d.cts +2830 -139
  16. package/lib/behaviors/index.d.ts +2830 -139
  17. package/lib/behaviors/index.js +1 -1
  18. package/lib/index.cjs +695 -526
  19. package/lib/index.cjs.map +1 -1
  20. package/lib/index.d.cts +8950 -246
  21. package/lib/index.d.ts +8950 -246
  22. package/lib/index.js +696 -525
  23. package/lib/index.js.map +1 -1
  24. package/lib/selectors/index.cjs +24 -171
  25. package/lib/selectors/index.cjs.map +1 -1
  26. package/lib/selectors/index.d.cts +73 -0
  27. package/lib/selectors/index.d.ts +73 -0
  28. package/lib/selectors/index.js +3 -151
  29. package/lib/selectors/index.js.map +1 -1
  30. package/package.json +11 -10
  31. package/src/behavior-actions/behavior.action.data-transfer-set.ts +7 -0
  32. package/src/behavior-actions/behavior.action.insert-blocks.ts +61 -0
  33. package/src/behavior-actions/behavior.actions.ts +159 -83
  34. package/src/behaviors/behavior.core.annotations.ts +29 -0
  35. package/src/behaviors/behavior.core.block-objects.ts +13 -13
  36. package/src/behaviors/behavior.core.decorators.ts +19 -0
  37. package/src/behaviors/behavior.core.deserialize.ts +46 -0
  38. package/src/behaviors/behavior.core.lists.ts +57 -23
  39. package/src/behaviors/behavior.core.serialize.ts +44 -0
  40. package/src/behaviors/behavior.core.style.ts +19 -0
  41. package/src/behaviors/behavior.core.ts +19 -0
  42. package/src/behaviors/behavior.types.ts +126 -89
  43. package/src/converters/converter.json.ts +53 -0
  44. package/src/converters/converter.portable-text.deserialize.test.ts +686 -0
  45. package/src/converters/converter.portable-text.ts +59 -0
  46. package/src/converters/converter.text-html.deserialize.test.ts +349 -0
  47. package/src/converters/converter.text-html.serialize.test.ts +233 -0
  48. package/src/converters/converter.text-html.ts +61 -0
  49. package/src/converters/converter.text-plain.test.ts +241 -0
  50. package/src/converters/converter.text-plain.ts +91 -0
  51. package/src/converters/converter.ts +65 -0
  52. package/src/converters/converters.ts +11 -0
  53. package/src/editor/Editable.tsx +3 -13
  54. package/src/editor/create-editor.ts +48 -6
  55. package/src/editor/editor-machine.ts +56 -2
  56. package/src/editor/editor-selector.ts +1 -0
  57. package/src/editor/editor-snapshot.ts +5 -0
  58. package/src/editor/plugins/create-with-event-listeners.ts +82 -106
  59. package/src/internal-utils/asserters.ts +9 -0
  60. package/src/internal-utils/mime-type.ts +1 -0
  61. package/src/internal-utils/parse-blocks.ts +136 -0
  62. package/src/internal-utils/test-key-generator.ts +9 -0
  63. package/src/selectors/selector.get-selected-spans.test.ts +1 -0
  64. package/src/selectors/selector.get-selection-text.test.ts +1 -0
  65. package/src/selectors/selector.is-active-decorator.test.ts +1 -0
  66. package/src/utils/util.slice-blocks.test.ts +87 -0
  67. package/src/utils/util.slice-blocks.ts +27 -10
  68. package/lib/_chunks-cjs/selector.is-selection-collapsed.cjs.map +0 -1
  69. package/lib/_chunks-es/selector.is-selection-collapsed.js.map +0 -1
  70. package/src/editor/plugins/__tests__/createWithInsertData.test.tsx +0 -181
  71. package/src/editor/plugins/createWithInsertData.ts +0 -425
@@ -1,6 +1,49 @@
1
1
  "use strict";
2
- var types = require("@sanity/types"), selector_isSelectionCollapsed = require("./selector.is-selection-collapsed.cjs"), util_isEmptyTextBlock = require("./util.is-empty-text-block.cjs");
3
- const IS_MAC = typeof window < "u" && /Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent), modifiers = {
2
+ var selector_isActiveStyle = require("./selector.is-active-style.cjs"), types = require("@sanity/types"), util_isEmptyTextBlock = require("./util.is-empty-text-block.cjs");
3
+ function isCustomBehaviorEvent(event) {
4
+ return event.type.startsWith("custom.");
5
+ }
6
+ function raise(event) {
7
+ return {
8
+ type: "raise",
9
+ event
10
+ };
11
+ }
12
+ function defineBehavior(behavior) {
13
+ return behavior;
14
+ }
15
+ const toggleAnnotationOff = {
16
+ on: "annotation.toggle",
17
+ guard: ({
18
+ context,
19
+ event
20
+ }) => selector_isActiveStyle.isActiveAnnotation(event.annotation.name)({
21
+ context
22
+ }),
23
+ actions: [({
24
+ event
25
+ }) => [raise({
26
+ type: "annotation.remove",
27
+ annotation: event.annotation
28
+ })]]
29
+ }, toggleAnnotationOn = {
30
+ on: "annotation.toggle",
31
+ guard: ({
32
+ context,
33
+ event
34
+ }) => !selector_isActiveStyle.isActiveAnnotation(event.annotation.name)({
35
+ context
36
+ }),
37
+ actions: [({
38
+ event
39
+ }) => [raise({
40
+ type: "annotation.add",
41
+ annotation: event.annotation
42
+ })]]
43
+ }, coreAnnotationBehaviors = {
44
+ toggleAnnotationOff,
45
+ toggleAnnotationOn
46
+ }, IS_MAC = typeof window < "u" && /Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent), modifiers = {
4
47
  alt: "altKey",
5
48
  control: "ctrlKey",
6
49
  meta: "metaKey",
@@ -112,80 +155,68 @@ function toKeyName(name) {
112
155
  const keyName = name.toLowerCase();
113
156
  return aliases[keyName] ?? keyName;
114
157
  }
115
- function isCustomBehaviorEvent(event) {
116
- return event.type.startsWith("custom.");
117
- }
118
- function raise(event) {
119
- return {
120
- type: "raise",
121
- event
122
- };
123
- }
124
- function defineBehavior(behavior) {
125
- return behavior;
126
- }
127
158
  const arrowDownOnLonelyBlockObject = {
128
159
  on: "key.down",
129
160
  guard: ({
130
161
  context,
131
162
  event
132
163
  }) => {
133
- const isArrowDown = isHotkey("ArrowDown", event.keyboardEvent), focusBlockObject = selector_isSelectionCollapsed.getFocusBlockObject({
164
+ const isArrowDown = isHotkey("ArrowDown", event.keyboardEvent), focusBlockObject = selector_isActiveStyle.getFocusBlockObject({
134
165
  context
135
- }), nextBlock = selector_isSelectionCollapsed.getNextBlock({
166
+ }), nextBlock = selector_isActiveStyle.getNextBlock({
136
167
  context
137
168
  });
138
169
  return isArrowDown && focusBlockObject && !nextBlock;
139
170
  },
140
- actions: [() => [{
171
+ actions: [() => [raise({
141
172
  type: "insert.text block",
142
173
  placement: "after"
143
- }]]
174
+ })]]
144
175
  }, arrowUpOnLonelyBlockObject = {
145
176
  on: "key.down",
146
177
  guard: ({
147
178
  context,
148
179
  event
149
180
  }) => {
150
- const isArrowUp = isHotkey("ArrowUp", event.keyboardEvent), focusBlockObject = selector_isSelectionCollapsed.getFocusBlockObject({
181
+ const isArrowUp = isHotkey("ArrowUp", event.keyboardEvent), focusBlockObject = selector_isActiveStyle.getFocusBlockObject({
151
182
  context
152
- }), previousBlock = selector_isSelectionCollapsed.getPreviousBlock({
183
+ }), previousBlock = selector_isActiveStyle.getPreviousBlock({
153
184
  context
154
185
  });
155
186
  return isArrowUp && focusBlockObject && !previousBlock;
156
187
  },
157
- actions: [() => [{
188
+ actions: [() => [raise({
158
189
  type: "insert.text block",
159
190
  placement: "before"
160
- }, {
191
+ }), raise({
161
192
  type: "select.previous block"
162
- }]]
193
+ })]]
163
194
  }, breakingBlockObject = {
164
195
  on: "insert.break",
165
196
  guard: ({
166
197
  context
167
198
  }) => {
168
- const focusBlockObject = selector_isSelectionCollapsed.getFocusBlockObject({
199
+ const focusBlockObject = selector_isActiveStyle.getFocusBlockObject({
169
200
  context
170
201
  });
171
- return selector_isSelectionCollapsed.isSelectionCollapsed({
202
+ return selector_isActiveStyle.isSelectionCollapsed({
172
203
  context
173
204
  }) && focusBlockObject !== void 0;
174
205
  },
175
- actions: [() => [{
206
+ actions: [() => [raise({
176
207
  type: "insert.text block",
177
208
  placement: "after"
178
- }]]
209
+ })]]
179
210
  }, deletingEmptyTextBlockAfterBlockObject = {
180
211
  on: "delete.backward",
181
212
  guard: ({
182
213
  context
183
214
  }) => {
184
- const focusTextBlock = selector_isSelectionCollapsed.getFocusTextBlock({
215
+ const focusTextBlock = selector_isActiveStyle.getFocusTextBlock({
185
216
  context
186
- }), selectionCollapsed = selector_isSelectionCollapsed.isSelectionCollapsed({
217
+ }), selectionCollapsed = selector_isActiveStyle.isSelectionCollapsed({
187
218
  context
188
- }), previousBlock = selector_isSelectionCollapsed.getPreviousBlock({
219
+ }), previousBlock = selector_isActiveStyle.getPreviousBlock({
189
220
  context
190
221
  });
191
222
  return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : util_isEmptyTextBlock.isEmptyTextBlock(focusTextBlock.node) && !types.isPortableTextTextBlock(previousBlock.node) ? {
@@ -196,10 +227,10 @@ const arrowDownOnLonelyBlockObject = {
196
227
  actions: [(_, {
197
228
  focusTextBlock,
198
229
  previousBlock
199
- }) => [{
230
+ }) => [raise({
200
231
  type: "delete.block",
201
232
  blockPath: focusTextBlock.path
202
- }, {
233
+ }), raise({
203
234
  type: "select",
204
235
  selection: {
205
236
  anchor: {
@@ -211,17 +242,17 @@ const arrowDownOnLonelyBlockObject = {
211
242
  offset: 0
212
243
  }
213
244
  }
214
- }]]
245
+ })]]
215
246
  }, deletingEmptyTextBlockBeforeBlockObject = {
216
247
  on: "delete.forward",
217
248
  guard: ({
218
249
  context
219
250
  }) => {
220
- const focusTextBlock = selector_isSelectionCollapsed.getFocusTextBlock({
251
+ const focusTextBlock = selector_isActiveStyle.getFocusTextBlock({
221
252
  context
222
- }), selectionCollapsed = selector_isSelectionCollapsed.isSelectionCollapsed({
253
+ }), selectionCollapsed = selector_isActiveStyle.isSelectionCollapsed({
223
254
  context
224
- }), nextBlock = selector_isSelectionCollapsed.getNextBlock({
255
+ }), nextBlock = selector_isActiveStyle.getNextBlock({
225
256
  context
226
257
  });
227
258
  return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : util_isEmptyTextBlock.isEmptyTextBlock(focusTextBlock.node) && !types.isPortableTextTextBlock(nextBlock.node) ? {
@@ -232,10 +263,10 @@ const arrowDownOnLonelyBlockObject = {
232
263
  actions: [(_, {
233
264
  focusTextBlock,
234
265
  nextBlock
235
- }) => [{
266
+ }) => [raise({
236
267
  type: "delete.block",
237
268
  blockPath: focusTextBlock.path
238
- }, {
269
+ }), raise({
239
270
  type: "select",
240
271
  selection: {
241
272
  anchor: {
@@ -247,7 +278,7 @@ const arrowDownOnLonelyBlockObject = {
247
278
  offset: 0
248
279
  }
249
280
  }
250
- }]]
281
+ })]]
251
282
  }, coreBlockObjectBehaviors = {
252
283
  arrowDownOnLonelyBlockObject,
253
284
  arrowUpOnLonelyBlockObject,
@@ -255,6 +286,36 @@ const arrowDownOnLonelyBlockObject = {
255
286
  deletingEmptyTextBlockAfterBlockObject,
256
287
  deletingEmptyTextBlockBeforeBlockObject
257
288
  }, coreDecoratorBehaviors = {
289
+ toggleDecoratorOff: {
290
+ on: "decorator.toggle",
291
+ guard: ({
292
+ context,
293
+ event
294
+ }) => selector_isActiveStyle.isActiveDecorator(event.decorator)({
295
+ context
296
+ }),
297
+ actions: [({
298
+ event
299
+ }) => [raise({
300
+ type: "decorator.remove",
301
+ decorator: event.decorator
302
+ })]]
303
+ },
304
+ toggleDecoratorOn: {
305
+ on: "decorator.toggle",
306
+ guard: ({
307
+ context,
308
+ event
309
+ }) => !selector_isActiveStyle.isActiveDecorator(event.decorator)({
310
+ context
311
+ }),
312
+ actions: [({
313
+ event
314
+ }) => [raise({
315
+ type: "decorator.add",
316
+ decorator: event.decorator
317
+ })]]
318
+ },
258
319
  strongShortcut: {
259
320
  on: "key.down",
260
321
  guard: ({
@@ -299,16 +360,72 @@ const arrowDownOnLonelyBlockObject = {
299
360
  decorator: "code"
300
361
  })]]
301
362
  }
302
- }, MAX_LIST_LEVEL = 10, clearListOnBackspace = {
363
+ }, coreDeserializeBehavior = {
364
+ on: "deserialize",
365
+ guard: ({
366
+ context,
367
+ event
368
+ }) => {
369
+ const deserializeEvents = context.converters.flatMap((converter) => {
370
+ const data = event.dataTransfer.getData(converter.mimeType);
371
+ return data ? [converter.deserialize({
372
+ context,
373
+ event: {
374
+ type: "deserialize",
375
+ data
376
+ }
377
+ })] : [];
378
+ });
379
+ return deserializeEvents.find((deserializeEvent) => deserializeEvent.type === "deserialization.success") || {
380
+ type: "deserialization.failure",
381
+ mimeType: "*/*",
382
+ reason: deserializeEvents.map((deserializeEvent) => deserializeEvent.type === "deserialization.failure" ? deserializeEvent.reason : "").join(", ")
383
+ };
384
+ },
385
+ actions: [({
386
+ event
387
+ }, deserializeEvent) => [raise({
388
+ ...deserializeEvent,
389
+ dataTransfer: event.dataTransfer
390
+ })]]
391
+ }, MAX_LIST_LEVEL = 10, toggleListItemOff = {
392
+ on: "list item.toggle",
393
+ guard: ({
394
+ context,
395
+ event
396
+ }) => selector_isActiveStyle.isActiveListItem(event.listItem)({
397
+ context
398
+ }),
399
+ actions: [({
400
+ event
401
+ }) => [raise({
402
+ type: "list item.remove",
403
+ listItem: event.listItem
404
+ })]]
405
+ }, toggleListItemOn = {
406
+ on: "list item.toggle",
407
+ guard: ({
408
+ context,
409
+ event
410
+ }) => !selector_isActiveStyle.isActiveListItem(event.listItem)({
411
+ context
412
+ }),
413
+ actions: [({
414
+ event
415
+ }) => [raise({
416
+ type: "list item.add",
417
+ listItem: event.listItem
418
+ })]]
419
+ }, clearListOnBackspace = {
303
420
  on: "delete.backward",
304
421
  guard: ({
305
422
  context
306
423
  }) => {
307
- const selectionCollapsed = selector_isSelectionCollapsed.isSelectionCollapsed({
424
+ const selectionCollapsed = selector_isActiveStyle.isSelectionCollapsed({
308
425
  context
309
- }), focusTextBlock = selector_isSelectionCollapsed.getFocusTextBlock({
426
+ }), focusTextBlock = selector_isActiveStyle.getFocusTextBlock({
310
427
  context
311
- }), focusSpan = selector_isSelectionCollapsed.getFocusSpan({
428
+ }), focusSpan = selector_isActiveStyle.getFocusSpan({
312
429
  context
313
430
  });
314
431
  return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && context.selection?.focus.offset === 0 && focusTextBlock.node.level === 1 ? {
@@ -317,21 +434,21 @@ const arrowDownOnLonelyBlockObject = {
317
434
  },
318
435
  actions: [(_, {
319
436
  focusTextBlock
320
- }) => [{
437
+ }) => [raise({
321
438
  type: "text block.unset",
322
439
  props: ["listItem", "level"],
323
440
  at: focusTextBlock.path
324
- }]]
441
+ })]]
325
442
  }, unindentListOnBackspace = {
326
443
  on: "delete.backward",
327
444
  guard: ({
328
445
  context
329
446
  }) => {
330
- const selectionCollapsed = selector_isSelectionCollapsed.isSelectionCollapsed({
447
+ const selectionCollapsed = selector_isActiveStyle.isSelectionCollapsed({
331
448
  context
332
- }), focusTextBlock = selector_isSelectionCollapsed.getFocusTextBlock({
449
+ }), focusTextBlock = selector_isActiveStyle.getFocusTextBlock({
333
450
  context
334
- }), focusSpan = selector_isSelectionCollapsed.getFocusSpan({
451
+ }), focusSpan = selector_isActiveStyle.getFocusSpan({
335
452
  context
336
453
  });
337
454
  return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && context.selection?.focus.offset === 0 && focusTextBlock.node.level !== void 0 && focusTextBlock.node.level > 1 ? {
@@ -342,19 +459,19 @@ const arrowDownOnLonelyBlockObject = {
342
459
  actions: [(_, {
343
460
  focusTextBlock,
344
461
  level
345
- }) => [{
462
+ }) => [raise({
346
463
  type: "text block.set",
347
464
  level,
348
465
  at: focusTextBlock.path
349
- }]]
466
+ })]]
350
467
  }, clearListOnEnter = {
351
468
  on: "insert.break",
352
469
  guard: ({
353
470
  context
354
471
  }) => {
355
- const selectionCollapsed = selector_isSelectionCollapsed.isSelectionCollapsed({
472
+ const selectionCollapsed = selector_isActiveStyle.isSelectionCollapsed({
356
473
  context
357
- }), focusListBlock = selector_isSelectionCollapsed.getFocusListBlock({
474
+ }), focusListBlock = selector_isActiveStyle.getFocusListBlock({
358
475
  context
359
476
  });
360
477
  return !selectionCollapsed || !focusListBlock || !util_isEmptyTextBlock.isEmptyTextBlock(focusListBlock.node) ? !1 : {
@@ -363,11 +480,11 @@ const arrowDownOnLonelyBlockObject = {
363
480
  },
364
481
  actions: [(_, {
365
482
  focusListBlock
366
- }) => [{
483
+ }) => [raise({
367
484
  type: "text block.unset",
368
485
  props: ["listItem", "level"],
369
486
  at: focusListBlock.path
370
- }]]
487
+ })]]
371
488
  }, indentListOnTab = {
372
489
  on: "key.down",
373
490
  guard: ({
@@ -376,9 +493,9 @@ const arrowDownOnLonelyBlockObject = {
376
493
  }) => {
377
494
  if (!isHotkey("Tab", event.keyboardEvent))
378
495
  return !1;
379
- const selectedBlocks = selector_isSelectionCollapsed.getSelectedBlocks({
496
+ const selectedBlocks = selector_isActiveStyle.getSelectedBlocks({
380
497
  context
381
- }), guards = selector_isSelectionCollapsed.createGuards(context), selectedListBlocks = selectedBlocks.flatMap((block) => guards.isListBlock(block.node) ? [{
498
+ }), guards = selector_isActiveStyle.createGuards(context), selectedListBlocks = selectedBlocks.flatMap((block) => guards.isListBlock(block.node) ? [{
382
499
  node: block.node,
383
500
  path: block.path
384
501
  }] : []);
@@ -388,7 +505,7 @@ const arrowDownOnLonelyBlockObject = {
388
505
  },
389
506
  actions: [(_, {
390
507
  selectedListBlocks
391
- }) => selectedListBlocks.map((selectedListBlock) => ({
508
+ }) => selectedListBlocks.map((selectedListBlock) => raise({
392
509
  type: "text block.set",
393
510
  level: Math.min(MAX_LIST_LEVEL, Math.max(1, selectedListBlock.node.level + 1)),
394
511
  at: selectedListBlock.path
@@ -401,9 +518,9 @@ const arrowDownOnLonelyBlockObject = {
401
518
  }) => {
402
519
  if (!isHotkey("Shift+Tab", event.keyboardEvent))
403
520
  return !1;
404
- const selectedBlocks = selector_isSelectionCollapsed.getSelectedBlocks({
521
+ const selectedBlocks = selector_isActiveStyle.getSelectedBlocks({
405
522
  context
406
- }), guards = selector_isSelectionCollapsed.createGuards(context), selectedListBlocks = selectedBlocks.flatMap((block) => guards.isListBlock(block.node) ? [{
523
+ }), guards = selector_isActiveStyle.createGuards(context), selectedListBlocks = selectedBlocks.flatMap((block) => guards.isListBlock(block.node) ? [{
407
524
  node: block.node,
408
525
  path: block.path
409
526
  }] : []);
@@ -413,17 +530,83 @@ const arrowDownOnLonelyBlockObject = {
413
530
  },
414
531
  actions: [(_, {
415
532
  selectedListBlocks
416
- }) => selectedListBlocks.map((selectedListBlock) => ({
533
+ }) => selectedListBlocks.map((selectedListBlock) => raise({
417
534
  type: "text block.set",
418
535
  level: Math.min(MAX_LIST_LEVEL, Math.max(1, selectedListBlock.node.level - 1)),
419
536
  at: selectedListBlock.path
420
537
  }))]
421
538
  }, coreListBehaviors = {
539
+ toggleListItemOff,
540
+ toggleListItemOn,
422
541
  clearListOnBackspace,
423
542
  unindentListOnBackspace,
424
543
  clearListOnEnter,
425
544
  indentListOnTab,
426
545
  unindentListOnShiftTab
546
+ }, coreSerializeBehaviors = {
547
+ serialize: {
548
+ on: "serialize",
549
+ guard: ({
550
+ context,
551
+ event
552
+ }) => {
553
+ if (context.converters.length === 0)
554
+ return !1;
555
+ const serializeEvents = context.converters.map((converter) => converter.serialize({
556
+ context,
557
+ event
558
+ }));
559
+ return serializeEvents.length === 0 ? !1 : serializeEvents;
560
+ },
561
+ actions: [({
562
+ event
563
+ }, serializeEvents) => serializeEvents.map((serializeEvent) => raise({
564
+ ...serializeEvent,
565
+ dataTransfer: event.dataTransfer
566
+ }))]
567
+ },
568
+ "serialization.success": {
569
+ on: "serialization.success",
570
+ actions: [({
571
+ event
572
+ }) => [raise({
573
+ type: "data transfer.set",
574
+ data: event.data,
575
+ dataTransfer: event.dataTransfer,
576
+ mimeType: event.mimeType
577
+ })]]
578
+ }
579
+ }, toggleStyleOff = {
580
+ on: "style.toggle",
581
+ guard: ({
582
+ context,
583
+ event
584
+ }) => selector_isActiveStyle.isActiveStyle(event.style)({
585
+ context
586
+ }),
587
+ actions: [({
588
+ event
589
+ }) => [raise({
590
+ type: "style.remove",
591
+ style: event.style
592
+ })]]
593
+ }, toggleStyleOn = {
594
+ on: "style.toggle",
595
+ guard: ({
596
+ context,
597
+ event
598
+ }) => !selector_isActiveStyle.isActiveStyle(event.style)({
599
+ context
600
+ }),
601
+ actions: [({
602
+ event
603
+ }) => [raise({
604
+ type: "style.add",
605
+ style: event.style
606
+ })]]
607
+ }, coreStyleBehaviors = {
608
+ toggleStyleOff,
609
+ toggleStyleOn
427
610
  }, softReturn = {
428
611
  on: "insert.soft break",
429
612
  actions: [() => [{
@@ -431,11 +614,15 @@ const arrowDownOnLonelyBlockObject = {
431
614
  text: `
432
615
  `
433
616
  }]]
434
- }, coreBehaviors = [softReturn, coreDecoratorBehaviors.strongShortcut, coreDecoratorBehaviors.emShortcut, coreDecoratorBehaviors.underlineShortcut, coreDecoratorBehaviors.codeShortcut, coreBlockObjectBehaviors.arrowDownOnLonelyBlockObject, coreBlockObjectBehaviors.arrowUpOnLonelyBlockObject, coreBlockObjectBehaviors.breakingBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockAfterBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockBeforeBlockObject, coreListBehaviors.clearListOnBackspace, coreListBehaviors.unindentListOnBackspace, coreListBehaviors.clearListOnEnter, coreListBehaviors.indentListOnTab, coreListBehaviors.unindentListOnShiftTab], coreBehavior = {
617
+ }, coreBehaviors = [softReturn, coreAnnotationBehaviors.toggleAnnotationOff, coreAnnotationBehaviors.toggleAnnotationOn, coreDecoratorBehaviors.toggleDecoratorOff, coreDecoratorBehaviors.toggleDecoratorOn, coreDecoratorBehaviors.strongShortcut, coreDecoratorBehaviors.emShortcut, coreDecoratorBehaviors.underlineShortcut, coreDecoratorBehaviors.codeShortcut, coreDeserializeBehavior, coreBlockObjectBehaviors.arrowDownOnLonelyBlockObject, coreBlockObjectBehaviors.arrowUpOnLonelyBlockObject, coreBlockObjectBehaviors.breakingBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockAfterBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockBeforeBlockObject, coreListBehaviors.toggleListItemOff, coreListBehaviors.toggleListItemOn, coreListBehaviors.clearListOnBackspace, coreListBehaviors.unindentListOnBackspace, coreListBehaviors.clearListOnEnter, coreListBehaviors.indentListOnTab, coreListBehaviors.unindentListOnShiftTab, coreSerializeBehaviors.serialize, coreSerializeBehaviors["serialization.success"], coreStyleBehaviors.toggleStyleOff, coreStyleBehaviors.toggleStyleOn], coreBehavior = {
435
618
  softReturn,
619
+ annotation: coreAnnotationBehaviors,
436
620
  decorators: coreDecoratorBehaviors,
621
+ deserialize: coreDeserializeBehavior,
437
622
  blockObjects: coreBlockObjectBehaviors,
438
- lists: coreListBehaviors
623
+ lists: coreListBehaviors,
624
+ ...coreSerializeBehaviors,
625
+ style: coreSerializeBehaviors
439
626
  };
440
627
  exports.coreBehavior = coreBehavior;
441
628
  exports.coreBehaviors = coreBehaviors;