@makeswift/runtime 0.8.6 → 0.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/LiveProvider.cjs.js +4 -3
  2. package/dist/LiveProvider.cjs.js.map +1 -1
  3. package/dist/LiveProvider.es.js +5 -4
  4. package/dist/LiveProvider.es.js.map +1 -1
  5. package/dist/PreviewProvider.cjs.js +4 -3
  6. package/dist/PreviewProvider.cjs.js.map +1 -1
  7. package/dist/PreviewProvider.es.js +5 -4
  8. package/dist/PreviewProvider.es.js.map +1 -1
  9. package/dist/actions.es.js +1 -1
  10. package/dist/constants.cjs.js +6 -2
  11. package/dist/constants.cjs.js.map +1 -1
  12. package/dist/constants.es.js +8 -4
  13. package/dist/constants.es.js.map +1 -1
  14. package/dist/index.cjs.js +83 -50
  15. package/dist/index.cjs.js.map +1 -1
  16. package/dist/index.cjs5.js +260 -106
  17. package/dist/index.cjs5.js.map +1 -1
  18. package/dist/index.cjs7.js.map +1 -1
  19. package/dist/index.es.js +86 -52
  20. package/dist/index.es.js.map +1 -1
  21. package/dist/index.es5.js +260 -106
  22. package/dist/index.es5.js.map +1 -1
  23. package/dist/index.es7.js +1 -1
  24. package/dist/index.es7.js.map +1 -1
  25. package/dist/leaf.es.js +1 -1
  26. package/dist/next.es.js +1 -1
  27. package/dist/state/breakpoints.cjs.js +44 -10
  28. package/dist/state/breakpoints.cjs.js.map +1 -1
  29. package/dist/state/breakpoints.es.js +44 -10
  30. package/dist/state/breakpoints.es.js.map +1 -1
  31. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  32. package/dist/types/src/next/api-handler/handlers/manifest.d.ts +1 -0
  33. package/dist/types/src/next/api-handler/handlers/manifest.d.ts.map +1 -1
  34. package/dist/types/src/next/client.d.ts +4 -1
  35. package/dist/types/src/next/client.d.ts.map +1 -1
  36. package/dist/types/src/next/index.d.ts +3 -1
  37. package/dist/types/src/next/index.d.ts.map +1 -1
  38. package/dist/types/src/runtimes/react/components/LiveProvider.d.ts +3 -1
  39. package/dist/types/src/runtimes/react/components/LiveProvider.d.ts.map +1 -1
  40. package/dist/types/src/runtimes/react/components/PreviewProvider.d.ts +3 -1
  41. package/dist/types/src/runtimes/react/components/PreviewProvider.d.ts.map +1 -1
  42. package/dist/types/src/runtimes/react/index.d.ts +19 -5
  43. package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
  44. package/dist/types/src/slate/BlockPlugin/clearBlockKeyForDevice.d.ts +2 -2
  45. package/dist/types/src/slate/BlockPlugin/clearBlockKeyForDevice.d.ts.map +1 -1
  46. package/dist/types/src/slate/BlockPlugin/index.d.ts +4 -0
  47. package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
  48. package/dist/types/src/slate/BlockPlugin/setBlockKeyForDevice.d.ts +7 -4
  49. package/dist/types/src/slate/BlockPlugin/setBlockKeyForDevice.d.ts.map +1 -1
  50. package/dist/types/src/slate/BlockPlugin/types.d.ts +2 -2
  51. package/dist/types/src/slate/BlockPlugin/types.d.ts.map +1 -1
  52. package/dist/types/src/slate/BlockPlugin/unwrapInline.d.ts +4 -0
  53. package/dist/types/src/slate/BlockPlugin/unwrapInline.d.ts.map +1 -0
  54. package/dist/types/src/slate/BlockPlugin/wrapInline.d.ts +4 -0
  55. package/dist/types/src/slate/BlockPlugin/wrapInline.d.ts.map +1 -0
  56. package/dist/types/src/slate/ListPlugin/toggleList.d.ts +2 -1
  57. package/dist/types/src/slate/ListPlugin/toggleList.d.ts.map +1 -1
  58. package/dist/types/src/slate/ListPlugin/unwrapList.d.ts +6 -2
  59. package/dist/types/src/slate/ListPlugin/unwrapList.d.ts.map +1 -1
  60. package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts +0 -1
  61. package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts.map +1 -1
  62. package/dist/types/src/slate/ListPlugin/wrapList.d.ts +2 -1
  63. package/dist/types/src/slate/ListPlugin/wrapList.d.ts.map +1 -1
  64. package/dist/types/src/slate/TypographyPlugin/clearActiveTypographyStyle.d.ts +6 -2
  65. package/dist/types/src/slate/TypographyPlugin/clearActiveTypographyStyle.d.ts.map +1 -1
  66. package/dist/types/src/slate/TypographyPlugin/clearDeviceActiveTypography.d.ts +6 -2
  67. package/dist/types/src/slate/TypographyPlugin/clearDeviceActiveTypography.d.ts.map +1 -1
  68. package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts +6 -2
  69. package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts.map +1 -1
  70. package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -1
  71. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyId.d.ts +6 -2
  72. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyId.d.ts.map +1 -1
  73. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyStyle.d.ts +6 -2
  74. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyStyle.d.ts.map +1 -1
  75. package/dist/types/src/slate/selectors.d.ts +19 -0
  76. package/dist/types/src/slate/selectors.d.ts.map +1 -0
  77. package/dist/types/src/slate/utils/editor.d.ts.map +1 -1
  78. package/dist/types/src/slate/utils/element.d.ts +2 -1
  79. package/dist/types/src/slate/utils/element.d.ts.map +1 -1
  80. package/dist/types/src/slate/utils/unhangRange.d.ts +10 -0
  81. package/dist/types/src/slate/utils/unhangRange.d.ts.map +1 -0
  82. package/dist/types/src/state/modules/breakpoints.d.ts +3 -4
  83. package/dist/types/src/state/modules/breakpoints.d.ts.map +1 -1
  84. package/dist/types/src/state/modules/breakpoints.test.d.ts +2 -0
  85. package/dist/types/src/state/modules/breakpoints.test.d.ts.map +1 -0
  86. package/dist/types/src/state/react-page.d.ts +2 -1
  87. package/dist/types/src/state/react-page.d.ts.map +1 -1
  88. package/dist/types/src/utils/isNonNullable.d.ts +2 -0
  89. package/dist/types/src/utils/isNonNullable.d.ts.map +1 -0
  90. package/package.json +1 -1
@@ -30,11 +30,14 @@ var isHotkey__default = /* @__PURE__ */ _interopDefaultLegacy(isHotkey);
30
30
  const LIST_ITEM_CHILD_POSITION = 0;
31
31
  const LIST_ITEM_LIST_POSITION = 1;
32
32
  const ElementUtils = {
33
+ isRootBlock(node) {
34
+ return slate.Element.isElement(node) && (slate.Element.isElementType(node, descriptors.BlockType.Paragraph) || slate.Element.isElementType(node, descriptors.BlockType.Heading1) || slate.Element.isElementType(node, descriptors.BlockType.Heading2) || slate.Element.isElementType(node, descriptors.BlockType.Heading3) || slate.Element.isElementType(node, descriptors.BlockType.Heading3) || slate.Element.isElementType(node, descriptors.BlockType.Heading4) || slate.Element.isElementType(node, descriptors.BlockType.Heading5) || slate.Element.isElementType(node, descriptors.BlockType.Heading6) || slate.Element.isElementType(node, descriptors.BlockType.BlockQuote) || slate.Element.isElementType(node, descriptors.BlockType.UnorderedList) || slate.Element.isElementType(node, descriptors.BlockType.OrderedList));
35
+ },
33
36
  isBlock(node) {
34
- return slate.Element.isElement(node) && (slate.Element.isElementType(node, descriptors.BlockType.Paragraph) || slate.Element.isElementType(node, descriptors.BlockType.Heading1) || slate.Element.isElementType(node, descriptors.BlockType.Heading2) || slate.Element.isElementType(node, descriptors.BlockType.Heading3) || slate.Element.isElementType(node, descriptors.BlockType.Heading3) || slate.Element.isElementType(node, descriptors.BlockType.Heading4) || slate.Element.isElementType(node, descriptors.BlockType.Heading5) || slate.Element.isElementType(node, descriptors.BlockType.Heading6) || slate.Element.isElementType(node, descriptors.BlockType.BlockQuote) || slate.Element.isElementType(node, descriptors.BlockType.UnorderedList) || slate.Element.isElementType(node, descriptors.BlockType.OrderedList) || slate.Element.isElementType(node, descriptors.BlockType.ListItem) || slate.Element.isElementType(node, descriptors.BlockType.ListItemChild));
37
+ return slate.Element.isElement(node) && (this.isRootBlock(node) || slate.Element.isElementType(node, descriptors.BlockType.ListItem) || slate.Element.isElementType(node, descriptors.BlockType.ListItemChild));
35
38
  },
36
39
  isInline(node) {
37
- return slate.Element.isElement(node) && (slate.Element.isElementType(node, descriptors.InlineType.Link) || slate.Element.isElementType(node, descriptors.InlineType.Link) || slate.Element.isElementType(node, descriptors.InlineType.SubScript) || slate.Element.isElementType(node, descriptors.InlineType.SuperScript));
40
+ return slate.Element.isElementType(node, descriptors.InlineType.Code) || slate.Element.isElementType(node, descriptors.InlineType.Link) || slate.Element.isElementType(node, descriptors.InlineType.SubScript) || slate.Element.isElementType(node, descriptors.InlineType.SuperScript);
38
41
  },
39
42
  isConvertibleToListTextNode(node) {
40
43
  return !this.isList(node) && !this.isListItem(node) && !this.isListItemChild(node);
@@ -65,7 +68,7 @@ const ElementUtils = {
65
68
  },
66
69
  createListItem() {
67
70
  return {
68
- children: [this.createText()],
71
+ children: [this.createListItemChild()],
69
72
  type: descriptors.BlockType.ListItem
70
73
  };
71
74
  },
@@ -78,18 +81,26 @@ const ElementUtils = {
78
81
  };
79
82
  const EditorUtils = {
80
83
  getFirstAncestorList(editor, path) {
81
- const parentList = slate.Editor.above(editor, {
82
- at: path,
83
- match: (node) => ElementUtils.isList(node)
84
- });
85
- return parentList != null ? parentList : null;
84
+ try {
85
+ const parentList = slate.Editor.above(editor, {
86
+ at: path,
87
+ match: (node) => ElementUtils.isList(node)
88
+ });
89
+ return parentList != null ? parentList : null;
90
+ } catch (e) {
91
+ return null;
92
+ }
86
93
  },
87
94
  getFirstAncestorListItem(editor, path) {
88
- const parentListItem = slate.Editor.above(editor, {
89
- at: path,
90
- match: (node) => ElementUtils.isListItem(node)
91
- });
92
- return parentListItem != null ? parentListItem : null;
95
+ try {
96
+ const parentListItem = slate.Editor.above(editor, {
97
+ at: path,
98
+ match: (node) => ElementUtils.isListItem(node)
99
+ });
100
+ return parentListItem != null ? parentListItem : null;
101
+ } catch (e) {
102
+ return null;
103
+ }
93
104
  }
94
105
  };
95
106
  function filterForSubtreeRoots(entries) {
@@ -213,10 +224,17 @@ function unwrapPath(editor, listItemPath) {
213
224
  }
214
225
  });
215
226
  }
216
- function unwrapList(editor) {
217
- if (!editor.selection)
227
+ function unwrapList(editor, options) {
228
+ var _a;
229
+ const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
230
+ if (!at)
218
231
  return;
219
- const listItems = getSelectedListItems(editor);
232
+ const listItems = Array.from(slate.Editor.nodes(editor, {
233
+ at,
234
+ match: (node) => {
235
+ return slate.Element.isElement(node) && ElementUtils.isListItem(node);
236
+ }
237
+ }));
220
238
  const subRoots = filterForSubtreeRoots(listItems);
221
239
  const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
222
240
  refs.forEach((ref) => {
@@ -227,10 +245,12 @@ function unwrapList(editor) {
227
245
  });
228
246
  }
229
247
  function wrapList(editor, options = { type: descriptors.BlockType.UnorderedList }) {
230
- if (!editor.selection)
248
+ var _a;
249
+ const at = (_a = options.at) != null ? _a : editor.selection;
250
+ if (!at)
231
251
  return;
232
252
  const nonListEntries = Array.from(slate.Editor.nodes(editor, {
233
- at: editor.selection,
253
+ at,
234
254
  match: (node) => {
235
255
  return slate.Element.isElement(node) && ElementUtils.isConvertibleToListTextNode(node);
236
256
  }
@@ -244,6 +264,7 @@ function wrapList(editor, options = { type: descriptors.BlockType.UnorderedList
244
264
  at: path
245
265
  });
246
266
  slate.Transforms.wrapNodes(editor, ElementUtils.createListItem(), {
267
+ match: (node) => ElementUtils.isListItemChild(node),
247
268
  at: path
248
269
  });
249
270
  slate.Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {
@@ -255,18 +276,20 @@ function wrapList(editor, options = { type: descriptors.BlockType.UnorderedList
255
276
  });
256
277
  }
257
278
  function toggleList(editor, options = { type: descriptors.BlockType.UnorderedList }) {
258
- if (!editor.selection)
279
+ var _a;
280
+ const at = (_a = options.at) != null ? _a : editor.selection;
281
+ if (at == null)
259
282
  return;
260
- const start = LocationUtils.getStartPath(editor.selection);
283
+ const start = LocationUtils.getStartPath(at);
261
284
  const ancestorPath = slate.Path.ancestors(start).at(1);
262
285
  if (!ancestorPath || !slate.Node.has(editor, ancestorPath))
263
286
  return;
264
287
  const ancestor = slate.Node.get(editor, ancestorPath);
265
288
  if (!ElementUtils.isList(ancestor)) {
266
- return wrapList(editor, { type: options.type });
289
+ return wrapList(editor, { type: options.type, at });
267
290
  }
268
291
  if (ancestor.type === options.type) {
269
- unwrapList(editor);
292
+ unwrapList(editor, { at });
270
293
  } else {
271
294
  slate.Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath });
272
295
  }
@@ -377,10 +400,10 @@ function withList(editor) {
377
400
  const nodeChildren = Array.from(slate.Node.children(editor, nodePath));
378
401
  const childrenToBeMerged = Array.from(slate.Node.children(editor, nodeToBeMergedPath));
379
402
  slate.Editor.withoutNormalizing(editor, () => {
380
- childrenToBeMerged.forEach(([_, childPath], index) => {
403
+ childrenToBeMerged.reverse().forEach(([_, childPath]) => {
381
404
  slate.Transforms.moveNodes(editor, {
382
405
  at: childPath,
383
- to: [...nodePath, nodeChildren.length + index]
406
+ to: [...nodePath, nodeChildren.length]
384
407
  });
385
408
  });
386
409
  slate.Transforms.removeNodes(editor, { at: nodeToBeMergedPath });
@@ -395,94 +418,168 @@ function withList(editor) {
395
418
  };
396
419
  return editor;
397
420
  }
398
- function clearActiveTypographyStyle(editor) {
399
- if (!editor.selection)
400
- return;
401
- const textNodes = slate.Editor.nodes(editor, {
402
- at: editor.selection,
403
- match: (node) => slate.Text.isText(node)
404
- });
405
- for (const [node, path] of textNodes) {
406
- if (slate.Text.isText(node)) {
407
- const typography = __spreadProps(__spreadValues({}, node.typography), {
408
- style: []
409
- });
421
+ function clearActiveTypographyStyle(editor, options) {
422
+ slate.Editor.withoutNormalizing(editor, () => {
423
+ var _a;
424
+ const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
425
+ if (!at)
426
+ return;
427
+ const atRef = slate.Editor.rangeRef(editor, at);
428
+ if (atRef.current) {
410
429
  slate.Transforms.setNodes(editor, {
411
- typography
412
- }, { at: path });
430
+ slice: true
431
+ }, {
432
+ at: atRef.current,
433
+ match: (node) => slate.Text.isText(node),
434
+ split: slate.Range.isExpanded(atRef.current)
435
+ });
413
436
  }
414
- }
415
- }
416
- function clearDeviceActiveTypography(editor, currentDeviceId) {
417
- var _a, _b;
418
- if (!editor.selection)
419
- return;
420
- const textNodes = slate.Editor.nodes(editor, {
421
- at: editor.selection,
422
- match: (node) => slate.Text.isText(node)
437
+ if (atRef.current) {
438
+ const textNodes = Array.from(slate.Editor.nodes(editor, {
439
+ at: atRef.current,
440
+ match: (node) => slate.Text.isText(node) && node.slice === true
441
+ }));
442
+ for (const [node, path] of textNodes) {
443
+ if (slate.Text.isText(node)) {
444
+ const typography = __spreadProps(__spreadValues({}, node.typography), {
445
+ style: []
446
+ });
447
+ slate.Transforms.setNodes(editor, {
448
+ typography
449
+ }, { at: path });
450
+ }
451
+ }
452
+ }
453
+ atRef.unref();
423
454
  });
424
- for (const [node, path] of textNodes) {
425
- if (slate.Text.isText(node)) {
426
- const typography = __spreadProps(__spreadValues({}, node.typography), {
427
- style: (_b = (_a = node == null ? void 0 : node.typography) == null ? void 0 : _a.style.filter(({ deviceId }) => deviceId !== currentDeviceId)) != null ? _b : []
428
- });
455
+ }
456
+ function clearDeviceActiveTypography(editor, currentDeviceId, options) {
457
+ slate.Editor.withoutNormalizing(editor, () => {
458
+ var _a, _b, _c;
459
+ const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
460
+ if (!at)
461
+ return;
462
+ const atRef = slate.Editor.rangeRef(editor, at);
463
+ if (atRef.current) {
429
464
  slate.Transforms.setNodes(editor, {
430
- typography
431
- }, { at: path });
465
+ slice: true
466
+ }, {
467
+ at: atRef.current,
468
+ match: (node) => slate.Text.isText(node),
469
+ split: slate.Range.isExpanded(atRef.current)
470
+ });
432
471
  }
433
- }
472
+ if (atRef.current) {
473
+ const textNodes = Array.from(slate.Editor.nodes(editor, {
474
+ at: atRef.current,
475
+ match: (node) => slate.Text.isText(node) && node.slice === true
476
+ }));
477
+ for (const [node, path] of textNodes) {
478
+ if (slate.Text.isText(node)) {
479
+ const typography = __spreadProps(__spreadValues({}, node.typography), {
480
+ style: (_c = (_b = node == null ? void 0 : node.typography) == null ? void 0 : _b.style.filter(({ deviceId }) => deviceId !== currentDeviceId)) != null ? _c : []
481
+ });
482
+ slate.Transforms.setNodes(editor, {
483
+ typography
484
+ }, { at: path });
485
+ }
486
+ }
487
+ }
488
+ atRef.unref();
489
+ });
434
490
  }
435
- function detachActiveTypography(editor, value) {
436
- if (!editor.selection)
437
- return;
438
- const textNodes = Array.from(slate.Editor.nodes(editor, {
439
- at: editor.selection,
440
- match: (node) => slate.Text.isText(node)
441
- }));
442
- textNodes.forEach(([node, path]) => {
443
- if (slate.Text.isText(node)) {
491
+ function detachActiveTypography(editor, value, options) {
492
+ slate.Editor.withoutNormalizing(editor, () => {
493
+ var _a;
494
+ const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
495
+ if (!at)
496
+ return;
497
+ const atRef = slate.Editor.rangeRef(editor, at);
498
+ if (atRef.current) {
444
499
  slate.Transforms.setNodes(editor, {
445
- typography: {
446
- style: value
500
+ slice: true
501
+ }, {
502
+ at: atRef.current,
503
+ match: (node) => slate.Text.isText(node),
504
+ split: slate.Range.isExpanded(atRef.current)
505
+ });
506
+ }
507
+ if (atRef.current) {
508
+ const textNodes = Array.from(slate.Editor.nodes(editor, {
509
+ at: atRef.current,
510
+ match: (node) => slate.Text.isText(node) && node.slice === true
511
+ }));
512
+ for (const [node, path] of textNodes) {
513
+ if (slate.Text.isText(node)) {
514
+ slate.Transforms.setNodes(editor, {
515
+ typography: {
516
+ style: value
517
+ }
518
+ }, { at: path });
447
519
  }
448
- }, { at: path });
520
+ }
449
521
  }
522
+ atRef.unref();
450
523
  });
451
524
  }
452
- function setActiveTypographyId(editor, id) {
525
+ function setActiveTypographyId(editor, id, options) {
526
+ var _a;
527
+ const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
528
+ if (!at)
529
+ return;
453
530
  slate.Transforms.setNodes(editor, {
454
531
  typography: {
455
532
  id,
456
533
  style: []
457
534
  }
458
535
  }, {
459
- match: (node) => slate.Text.isText(node)
536
+ at,
537
+ match: (node) => slate.Text.isText(node),
538
+ split: slate.Range.isExpanded(at)
460
539
  });
461
540
  }
462
- function setActiveTypographyStyle(editor, breakpoints, deviceId, prop, value) {
463
- var _a, _b;
464
- if (!editor.selection)
465
- return;
466
- const textNodes = slate.Editor.nodes(editor, {
467
- at: editor.selection,
468
- match: (node) => slate.Text.isText(node)
469
- });
470
- for (const [node, path] of textNodes) {
471
- if (slate.Text.isText(node)) {
472
- const deviceOverrides = (_b = (_a = node == null ? void 0 : node.typography) == null ? void 0 : _a.style) != null ? _b : [];
473
- const deviceStyle = state_breakpoints.findBreakpointOverride(breakpoints, deviceOverrides, deviceId, (v) => v) || { value: {} };
474
- const nextDeviceStyle = {
475
- deviceId,
476
- value: __spreadProps(__spreadValues({}, deviceStyle.value), { [prop]: value })
477
- };
478
- const nextTypography = __spreadProps(__spreadValues({}, node.typography), {
479
- style: [...deviceOverrides.filter((v) => v.deviceId !== deviceId), nextDeviceStyle]
480
- });
541
+ function setActiveTypographyStyle(editor, breakpoints, deviceId, prop, value, options) {
542
+ slate.Editor.withoutNormalizing(editor, () => {
543
+ var _a, _b, _c;
544
+ const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
545
+ if (!at)
546
+ return;
547
+ const atRef = slate.Editor.rangeRef(editor, at);
548
+ if (atRef.current) {
481
549
  slate.Transforms.setNodes(editor, {
482
- typography: nextTypography
483
- }, { at: path });
550
+ slice: true
551
+ }, {
552
+ at: atRef.current,
553
+ match: (node) => slate.Text.isText(node),
554
+ split: slate.Range.isExpanded(atRef.current)
555
+ });
484
556
  }
485
- }
557
+ if (atRef.current) {
558
+ const textNodes = Array.from(slate.Editor.nodes(editor, {
559
+ at: atRef.current,
560
+ match: (node) => slate.Text.isText(node) && node.slice === true
561
+ }));
562
+ for (const [node, path] of textNodes) {
563
+ if (slate.Text.isText(node)) {
564
+ const deviceOverrides = (_c = (_b = node == null ? void 0 : node.typography) == null ? void 0 : _b.style) != null ? _c : [];
565
+ const deviceStyle = state_breakpoints.findBreakpointOverride(breakpoints, deviceOverrides, deviceId, (v) => v) || {
566
+ value: {}
567
+ };
568
+ const nextDeviceStyle = {
569
+ deviceId,
570
+ value: __spreadProps(__spreadValues({}, deviceStyle.value), { [prop]: value })
571
+ };
572
+ const nextTypography = __spreadProps(__spreadValues({}, node.typography), {
573
+ style: [...deviceOverrides.filter((v) => v.deviceId !== deviceId), nextDeviceStyle]
574
+ });
575
+ slate.Transforms.setNodes(editor, {
576
+ typography: nextTypography
577
+ }, { at: path });
578
+ }
579
+ }
580
+ }
581
+ atRef.unref();
582
+ });
486
583
  }
487
584
  const Typography = {
488
585
  setActiveTypographyId,
@@ -500,21 +597,66 @@ function withTypography(editor) {
500
597
  slate.Transforms.unsetNodes(editor, "typography", { at: normalizationPath });
501
598
  return;
502
599
  }
600
+ if (slate.Text.isText(normalizationNode) && (normalizationNode == null ? void 0 : normalizationNode.slice) != null) {
601
+ slate.Transforms.unsetNodes(editor, "slice", { at: normalizationPath });
602
+ return;
603
+ }
503
604
  normalizeNode(entry);
504
605
  };
505
606
  return editor;
506
607
  }
507
- function setBlockKeyForDevice(editor, breakpoints, deviceId, key, value) {
508
- var _a;
509
- if (!editor.selection)
510
- return;
511
- const rootElements = slate.Editor.nodes(editor, {
512
- match: (_, path) => path.length === 1,
513
- at: slate.Editor.unhangRange(editor, editor.selection)
608
+ function unhangRange(editor, range) {
609
+ let [start, end] = slate.Range.edges(range);
610
+ if (start.offset !== 0 || end.offset !== 0 || slate.Range.isCollapsed(range)) {
611
+ return range;
612
+ }
613
+ const endBlock = slate.Editor.above(editor, {
614
+ at: end,
615
+ match: (n) => slate.Element.isElement(n) && slate.Editor.isBlock(editor, n)
514
616
  });
617
+ const blockPath = endBlock ? endBlock[1] : [];
618
+ const first = slate.Editor.start(editor, start);
619
+ const before = { anchor: first, focus: end };
620
+ let skip = true;
621
+ for (const [node, path] of slate.Editor.nodes(editor, {
622
+ at: before,
623
+ match: slate.Text.isText,
624
+ reverse: true
625
+ })) {
626
+ if (skip) {
627
+ skip = false;
628
+ continue;
629
+ }
630
+ if (node.text !== "" || slate.Path.isBefore(path, blockPath)) {
631
+ end = { path, offset: node.text.length };
632
+ break;
633
+ }
634
+ }
635
+ return { anchor: start, focus: end };
636
+ }
637
+ function getSelection(editor) {
638
+ if (editor.selection)
639
+ return unhangRange(editor, editor.selection);
640
+ return {
641
+ anchor: slate.Editor.start(editor, []),
642
+ focus: slate.Editor.end(editor, [])
643
+ };
644
+ }
645
+ function getBlocksInSelection(editor) {
646
+ return Array.from(slate.Editor.nodes(editor, {
647
+ at: getSelection(editor),
648
+ match: (node) => ElementUtils.isRootBlock(node)
649
+ })).filter((entry) => ElementUtils.isRootBlock(entry[0]));
650
+ }
651
+ function setBlockKeyForDevice(editor, breakpoints, deviceId, key, value, options) {
652
+ var _a, _b;
653
+ const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
654
+ if (!at)
655
+ return;
656
+ const rootElements = getBlocksInSelection(editor);
515
657
  for (const [node, path] of rootElements) {
516
658
  if (ElementUtils.isBlock(node)) {
517
- const deviceValues = (_a = node[key]) != null ? _a : [];
659
+ const deviceValues = (_b = node[key]) != null ? _b : [];
518
660
  const currentDeviceValue = state_breakpoints.findBreakpointOverride(breakpoints, deviceValues, deviceId, (v) => v);
519
661
  const nextDeviceValue = __spreadProps(__spreadValues({}, currentDeviceValue), {
520
662
  deviceId,
@@ -528,12 +670,7 @@ function setBlockKeyForDevice(editor, breakpoints, deviceId, key, value) {
528
670
  }
529
671
  function clearBlockKeyForDevice(editor, deviceId, key) {
530
672
  var _a;
531
- if (!editor.selection)
532
- return;
533
- const rootElements = slate.Editor.nodes(editor, {
534
- match: (_, path) => path.length === 1,
535
- at: slate.Editor.unhangRange(editor, editor.selection)
536
- });
673
+ const rootElements = getBlocksInSelection(editor);
537
674
  for (const [node, path] of rootElements) {
538
675
  if (ElementUtils.isBlock(node)) {
539
676
  const deviceOverrides = (_a = node[key]) != null ? _a : [];
@@ -543,12 +680,29 @@ function clearBlockKeyForDevice(editor, deviceId, key) {
543
680
  }
544
681
  }
545
682
  }
683
+ function wrapInline(editor, inline) {
684
+ slate.Transforms.wrapNodes(editor, inline, {
685
+ at: getSelection(editor),
686
+ split: true
687
+ });
688
+ }
689
+ function unwrapInline(editor, type) {
690
+ slate.Transforms.unwrapNodes(editor, {
691
+ match: (node) => ElementUtils.isInline(node) && node.type === type,
692
+ at: getSelection(editor)
693
+ });
694
+ }
546
695
  const Block = {
547
696
  setBlockKeyForDevice,
548
- clearBlockKeyForDevice
697
+ clearBlockKeyForDevice,
698
+ wrapInline,
699
+ unwrapInline
549
700
  };
550
701
  function withBlock(editor) {
551
702
  const { normalizeNode } = editor;
703
+ editor.isInline = (entry) => {
704
+ return ElementUtils.isInline(entry);
705
+ };
552
706
  editor.normalizeNode = (entry) => {
553
707
  var _a;
554
708
  const [normalizationNode, normalizationPath] = entry;