@makeswift/runtime 0.7.7 → 0.7.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 (263) hide show
  1. package/dist/Box.cjs.js +2 -0
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +2 -0
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +2 -0
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +2 -0
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +2 -0
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +2 -0
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +2 -0
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +2 -0
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +2 -0
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +2 -0
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/Embed.cjs.js +2 -0
  22. package/dist/Embed.cjs.js.map +1 -1
  23. package/dist/Embed.es.js +2 -0
  24. package/dist/Embed.es.js.map +1 -1
  25. package/dist/Form.cjs.js +3 -1
  26. package/dist/Form.cjs.js.map +1 -1
  27. package/dist/Form.es.js +3 -1
  28. package/dist/Form.es.js.map +1 -1
  29. package/dist/Image.cjs.js +2 -0
  30. package/dist/Image.cjs.js.map +1 -1
  31. package/dist/Image.es.js +2 -0
  32. package/dist/Image.es.js.map +1 -1
  33. package/dist/LiveProvider.cjs.js +2 -0
  34. package/dist/LiveProvider.cjs.js.map +1 -1
  35. package/dist/LiveProvider.es.js +3 -1
  36. package/dist/LiveProvider.es.js.map +1 -1
  37. package/dist/Navigation.cjs.js +2 -0
  38. package/dist/Navigation.cjs.js.map +1 -1
  39. package/dist/Navigation.es.js +2 -0
  40. package/dist/Navigation.es.js.map +1 -1
  41. package/dist/PreviewProvider.cjs.js +29 -0
  42. package/dist/PreviewProvider.cjs.js.map +1 -1
  43. package/dist/PreviewProvider.es.js +33 -3
  44. package/dist/PreviewProvider.es.js.map +1 -1
  45. package/dist/ReadOnlyText.cjs.js +185 -153
  46. package/dist/ReadOnlyText.cjs.js.map +1 -1
  47. package/dist/ReadOnlyText.es.js +182 -153
  48. package/dist/ReadOnlyText.es.js.map +1 -1
  49. package/dist/Root.cjs.js +2 -0
  50. package/dist/Root.cjs.js.map +1 -1
  51. package/dist/Root.es.js +2 -0
  52. package/dist/Root.es.js.map +1 -1
  53. package/dist/SocialLinks.cjs.js +2 -0
  54. package/dist/SocialLinks.cjs.js.map +1 -1
  55. package/dist/SocialLinks.es.js +2 -0
  56. package/dist/SocialLinks.es.js.map +1 -1
  57. package/dist/Text.cjs.js +3 -1
  58. package/dist/Text.cjs.js.map +1 -1
  59. package/dist/Text.es.js +3 -1
  60. package/dist/Text.es.js.map +1 -1
  61. package/dist/Video.cjs.js +2 -0
  62. package/dist/Video.cjs.js.map +1 -1
  63. package/dist/Video.es.js +2 -0
  64. package/dist/Video.es.js.map +1 -1
  65. package/dist/actions.cjs.js +1 -0
  66. package/dist/actions.cjs.js.map +1 -1
  67. package/dist/actions.es.js +1 -1
  68. package/dist/builder.cjs.js +2 -0
  69. package/dist/builder.cjs.js.map +1 -1
  70. package/dist/builder.es.js +2 -0
  71. package/dist/builder.es.js.map +1 -1
  72. package/dist/compare.cjs.js +126 -0
  73. package/dist/compare.cjs.js.map +1 -0
  74. package/dist/compare.es.js +124 -0
  75. package/dist/compare.es.js.map +1 -0
  76. package/dist/components.cjs.js +2 -0
  77. package/dist/components.cjs.js.map +1 -1
  78. package/dist/components.es.js +2 -0
  79. package/dist/components.es.js.map +1 -1
  80. package/dist/constants.cjs.js +2 -0
  81. package/dist/constants.cjs.js.map +1 -1
  82. package/dist/constants.es.js +2 -0
  83. package/dist/constants.es.js.map +1 -1
  84. package/dist/control-serialization.cjs.js +29 -0
  85. package/dist/control-serialization.cjs.js.map +1 -1
  86. package/dist/control-serialization.es.js +30 -0
  87. package/dist/control-serialization.es.js.map +1 -1
  88. package/dist/controls.cjs.js +13 -0
  89. package/dist/controls.cjs.js.map +1 -1
  90. package/dist/controls.es.js +4 -1
  91. package/dist/controls.es.js.map +1 -1
  92. package/dist/index.cjs.js +6 -4
  93. package/dist/index.cjs.js.map +1 -1
  94. package/dist/index.cjs2.js +2 -0
  95. package/dist/index.cjs2.js.map +1 -1
  96. package/dist/index.cjs5.js +2 -0
  97. package/dist/index.cjs5.js.map +1 -1
  98. package/dist/index.cjs6.js +663 -96
  99. package/dist/index.cjs6.js.map +1 -1
  100. package/dist/index.es.js +6 -4
  101. package/dist/index.es.js.map +1 -1
  102. package/dist/index.es2.js +2 -0
  103. package/dist/index.es2.js.map +1 -1
  104. package/dist/index.es5.js +2 -0
  105. package/dist/index.es5.js.map +1 -1
  106. package/dist/index.es6.js +657 -95
  107. package/dist/index.es6.js.map +1 -1
  108. package/dist/main.cjs.js +2 -0
  109. package/dist/main.cjs.js.map +1 -1
  110. package/dist/main.es.js +2 -0
  111. package/dist/main.es.js.map +1 -1
  112. package/dist/next.cjs.js +2 -0
  113. package/dist/next.cjs.js.map +1 -1
  114. package/dist/next.es.js +2 -0
  115. package/dist/next.es.js.map +1 -1
  116. package/dist/prop-controllers.cjs.js +2 -0
  117. package/dist/prop-controllers.cjs.js.map +1 -1
  118. package/dist/prop-controllers.es.js +2 -0
  119. package/dist/prop-controllers.es.js.map +1 -1
  120. package/dist/react.cjs.js +2 -0
  121. package/dist/react.cjs.js.map +1 -1
  122. package/dist/react.es.js +2 -0
  123. package/dist/react.es.js.map +1 -1
  124. package/dist/rich-text.cjs.js +894 -22
  125. package/dist/rich-text.cjs.js.map +1 -1
  126. package/dist/rich-text.es.js +888 -23
  127. package/dist/rich-text.es.js.map +1 -1
  128. package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
  129. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  130. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/ListPlugin.d.ts +13 -0
  131. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/ListPlugin.d.ts.map +1 -0
  132. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/constants.d.ts +3 -0
  133. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/constants.d.ts.map +1 -0
  134. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/index.d.ts +2 -0
  135. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/index.d.ts.map +1 -0
  136. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/dedent.d.ts +3 -0
  137. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/dedent.d.ts.map +1 -0
  138. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/indent.d.ts +4 -0
  139. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/indent.d.ts.map +1 -0
  140. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/index.d.ts +6 -0
  141. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/index.d.ts.map +1 -0
  142. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/toggleList.d.ts +8 -0
  143. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/toggleList.d.ts.map +1 -0
  144. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/unwrapList.d.ts +4 -0
  145. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/unwrapList.d.ts.map +1 -0
  146. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/editor.d.ts +7 -0
  147. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/editor.d.ts.map +1 -0
  148. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/element.d.ts +26 -0
  149. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/element.d.ts.map +1 -0
  150. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/filterForSubtreeRoots.d.ts +3 -0
  151. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/filterForSubtreeRoots.d.ts.map +1 -0
  152. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/getSelectedListItems.d.ts +5 -0
  153. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/getSelectedListItems.d.ts.map +1 -0
  154. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/location.d.ts +5 -0
  155. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/location.d.ts.map +1 -0
  156. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/wrapList.d.ts +8 -0
  157. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/wrapList.d.ts.map +1 -0
  158. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/dedent.test.d.ts +3 -0
  159. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/dedent.test.d.ts.map +1 -0
  160. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/indent.test.d.ts +3 -0
  161. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/indent.test.d.ts.map +1 -0
  162. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/normalization.test.d.ts +3 -0
  163. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/normalization.test.d.ts.map +1 -0
  164. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/slate-test-helper.d.ts +48 -0
  165. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/slate-test-helper.d.ts.map +1 -0
  166. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/toggleList.test.d.ts +3 -0
  167. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/toggleList.test.d.ts.map +1 -0
  168. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/types.d.ts +21 -0
  169. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/types.d.ts.map +1 -0
  170. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/unwrapList.test.d.ts +3 -0
  171. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/unwrapList.test.d.ts.map +1 -0
  172. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/filterForSubtreeRoots.test.d.ts +2 -0
  173. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/filterForSubtreeRoots.test.d.ts.map +1 -0
  174. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/getSelectedListItems.test.d.ts +3 -0
  175. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/getSelectedListItems.test.d.ts.map +1 -0
  176. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/wrapList.test.d.ts +3 -0
  177. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/wrapList.test.d.ts.map +1 -0
  178. package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts +13 -0
  179. package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +1 -0
  180. package/dist/types/src/components/builtin/Text/EditableText/index.d.ts +4 -0
  181. package/dist/types/src/components/builtin/Text/EditableText/index.d.ts.map +1 -0
  182. package/dist/types/src/components/builtin/Text/EditableText/useSyncWithBuilder.d.ts +8 -0
  183. package/dist/types/src/components/builtin/Text/EditableText/useSyncWithBuilder.d.ts.map +1 -0
  184. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts +16 -0
  185. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
  186. package/dist/types/src/components/builtin/Text/Text.d.ts +1 -1
  187. package/dist/types/src/components/builtin/Text/Text.d.ts.map +1 -1
  188. package/dist/types/src/components/builtin/Text/components/Element/block.d.ts +8 -0
  189. package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +1 -0
  190. package/dist/types/src/components/builtin/Text/components/Element/element.d.ts +4 -0
  191. package/dist/types/src/components/builtin/Text/components/Element/element.d.ts.map +1 -0
  192. package/dist/types/src/components/builtin/Text/components/Element/index.d.ts +2 -0
  193. package/dist/types/src/components/builtin/Text/components/Element/index.d.ts.map +1 -0
  194. package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts +8 -0
  195. package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts.map +1 -0
  196. package/dist/types/src/components/builtin/Text/components/Leaf/index.d.ts +3 -0
  197. package/dist/types/src/components/builtin/Text/components/Leaf/index.d.ts.map +1 -0
  198. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts +4 -0
  199. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +1 -0
  200. package/dist/types/src/components/builtin/Text/components/Leaf/typography.d.ts +27 -0
  201. package/dist/types/src/components/builtin/Text/components/Leaf/typography.d.ts.map +1 -0
  202. package/dist/types/src/components/builtin/Text/components/index.d.ts +3 -0
  203. package/dist/types/src/components/builtin/Text/components/index.d.ts.map +1 -0
  204. package/dist/types/src/components/utils/types.d.ts +1 -1
  205. package/dist/types/src/components/utils/types.d.ts.map +1 -1
  206. package/dist/types/src/controls/rich-text/compare.d.ts +5 -0
  207. package/dist/types/src/controls/rich-text/compare.d.ts.map +1 -0
  208. package/dist/types/src/controls/rich-text/compare.test.d.ts +2 -0
  209. package/dist/types/src/controls/rich-text/compare.test.d.ts.map +1 -0
  210. package/dist/types/src/controls/rich-text/dto-types.d.ts +131 -0
  211. package/dist/types/src/controls/rich-text/dto-types.d.ts.map +1 -0
  212. package/dist/types/src/controls/rich-text/fixtures/blockquote.d.ts +3 -0
  213. package/dist/types/src/controls/rich-text/fixtures/blockquote.d.ts.map +1 -0
  214. package/dist/types/src/controls/rich-text/fixtures/index.d.ts +4 -0
  215. package/dist/types/src/controls/rich-text/fixtures/index.d.ts.map +1 -0
  216. package/dist/types/src/controls/rich-text/fixtures/list.d.ts +3 -0
  217. package/dist/types/src/controls/rich-text/fixtures/list.d.ts.map +1 -0
  218. package/dist/types/src/controls/rich-text/fixtures/typography.d.ts +3 -0
  219. package/dist/types/src/controls/rich-text/fixtures/typography.d.ts.map +1 -0
  220. package/dist/types/src/controls/rich-text/index.d.ts +6 -0
  221. package/dist/types/src/controls/rich-text/index.d.ts.map +1 -0
  222. package/dist/types/src/controls/{rich-text.d.ts → rich-text/rich-text.d.ts} +8 -10
  223. package/dist/types/src/controls/rich-text/rich-text.d.ts.map +1 -0
  224. package/dist/types/src/controls/rich-text/translation.d.ts +8 -0
  225. package/dist/types/src/controls/rich-text/translation.d.ts.map +1 -0
  226. package/dist/types/src/controls/rich-text/translation.test.d.ts +2 -0
  227. package/dist/types/src/controls/rich-text/translation.test.d.ts.map +1 -0
  228. package/dist/types/src/controls/rich-text/types.d.ts +134 -0
  229. package/dist/types/src/controls/rich-text/types.d.ts.map +1 -0
  230. package/dist/types/src/prop-controllers/descriptors.d.ts +2 -3
  231. package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
  232. package/dist/types/src/prop-controllers/instances.d.ts +4 -7
  233. package/dist/types/src/prop-controllers/instances.d.ts.map +1 -1
  234. package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
  235. package/dist/types/src/runtimes/react/element-imperative-handle.d.ts.map +1 -1
  236. package/dist/typography.cjs.js +146 -0
  237. package/dist/typography.cjs.js.map +1 -0
  238. package/dist/typography.es.js +143 -0
  239. package/dist/typography.es.js.map +1 -0
  240. package/package.json +7 -10
  241. package/dist/EditableText.cjs.js +0 -380
  242. package/dist/EditableText.cjs.js.map +0 -1
  243. package/dist/EditableText.es.js +0 -373
  244. package/dist/EditableText.es.js.map +0 -1
  245. package/dist/types/src/components/builtin/Text/EditableText.d.ts +0 -16
  246. package/dist/types/src/components/builtin/Text/EditableText.d.ts.map +0 -1
  247. package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Block/index.d.ts +0 -10
  248. package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Block/index.d.ts.map +0 -1
  249. package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Mark/hooks/useTypographyMark.d.ts +0 -25
  250. package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Mark/hooks/useTypographyMark.d.ts.map +0 -1
  251. package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Mark/index.d.ts +0 -10
  252. package/dist/types/src/components/builtin/Text/components/RichTextEditor/components/Mark/index.d.ts.map +0 -1
  253. package/dist/types/src/components/builtin/Text/components/RichTextEditor/index.d.ts +0 -5
  254. package/dist/types/src/components/builtin/Text/components/RichTextEditor/index.d.ts.map +0 -1
  255. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesBlocks.d.ts +0 -3
  256. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesBlocks.d.ts.map +0 -1
  257. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesMarks.d.ts +0 -3
  258. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/DeviceOverridesMarks.d.ts.map +0 -1
  259. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/Inlines.d.ts +0 -3
  260. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/Inlines.d.ts.map +0 -1
  261. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/Link.d.ts +0 -3
  262. package/dist/types/src/components/builtin/Text/components/RichTextEditor/plugins/Link.d.ts.map +0 -1
  263. package/dist/types/src/controls/rich-text.d.ts.map +0 -1
@@ -30,112 +30,679 @@ var __objRest = (source, exclude) => {
30
30
  }
31
31
  return target;
32
32
  };
33
- var next = require("./index.cjs.js");
34
- var constants = require("./constants.cjs.js");
33
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
34
+ var React = require("react");
35
+ var slate = require("slate");
36
+ var slateReact = require("slate-react");
35
37
  var css = require("@emotion/css");
38
+ var boxModels = require("./box-models.cjs.js");
39
+ var richText = require("./rich-text.cjs.js");
40
+ var typography = require("./typography.cjs.js");
36
41
  var jsxRuntime = require("react/jsx-runtime");
37
- var React = require("react");
38
- const getDeviceId = ({ deviceId }) => deviceId;
39
- const withColor = (swatches) => (_a) => {
42
+ require("use-sync-external-store/shim");
43
+ var next = require("./index.cjs.js");
44
+ require("@emotion/serialize");
45
+ require("@emotion/utils");
46
+ var index = require("./index.cjs3.js");
47
+ var compare = require("./compare.cjs.js");
48
+ var isHotkey = require("is-hotkey");
49
+ require("css-box-model");
50
+ require("./actions.cjs.js");
51
+ require("./constants.cjs.js");
52
+ require("redux");
53
+ require("redux-thunk");
54
+ require("use-sync-external-store/shim/with-selector");
55
+ require("next/dynamic");
56
+ require("./text-input.cjs.js");
57
+ require("./combobox.cjs.js");
58
+ require("./types.cjs.js");
59
+ require("color");
60
+ require("scroll-into-view-if-needed");
61
+ require("react-dom");
62
+ require("html-react-parser");
63
+ require("next/head");
64
+ require("@emotion/server/create-instance");
65
+ require("next/document");
66
+ require("cookie");
67
+ require("cors");
68
+ require("http-proxy");
69
+ require("set-cookie-parser");
70
+ require("uuid/v4");
71
+ require("corporate-ipsum");
72
+ require("next/link");
73
+ function _interopDefaultLegacy(e) {
74
+ return e && typeof e === "object" && "default" in e ? e : { "default": e };
75
+ }
76
+ var isHotkey__default = /* @__PURE__ */ _interopDefaultLegacy(isHotkey);
77
+ function Leaf(_a) {
40
78
  var _b = _a, {
41
- value: _c
42
- } = _b, _d = _c, { color } = _d, restOfValue = __objRest(_d, ["color"]), rest = __objRest(_b, [
43
- "value"
79
+ leaf
80
+ } = _b, props = __objRest(_b, [
81
+ "leaf"
44
82
  ]);
45
- return __spreadProps(__spreadValues({}, rest), {
46
- value: __spreadValues(__spreadValues({}, restOfValue), color ? {
47
- color: {
48
- swatch: swatches.find((s) => s && s.id === color.swatchId),
49
- alpha: color.alpha
50
- }
51
- } : {})
52
- });
53
- };
54
- const overrideTypographyStyle = (source, override) => {
55
- const devices = [...new Set(source.map(getDeviceId).concat(override.map(getDeviceId)))];
56
- return devices.map((deviceId) => ({
57
- deviceId,
58
- value: __spreadValues(__spreadValues({}, (next.findDeviceOverride(source, deviceId) || { value: {} }).value), (next.findDeviceOverride(override, deviceId, (v) => v) || { value: {} }).value)
59
- }));
60
- };
61
- function useTypographyMark(value) {
62
- var _a, _b, _c;
63
- const typography = next.useTypography((_a = value == null ? void 0 : value.id) != null ? _a : null);
64
- const swatchIds = [
65
- ...constants.getTypographyStyleSwatchIds(value == null ? void 0 : value.style),
66
- ...constants.getTypographyStyleSwatchIds(typography == null ? void 0 : typography.style)
67
- ];
68
- const swatches = next.useSwatches(swatchIds);
69
- return overrideTypographyStyle((_b = typography == null ? void 0 : typography.style.map(withColor(swatches.filter(constants.isNonNullable)))) != null ? _b : [], (_c = value == null ? void 0 : value.style.map(withColor(swatches.filter(constants.isNonNullable)))) != null ? _c : []);
70
- }
71
- function Mark(_a) {
72
- var _b = _a, {
73
- value,
83
+ switch (leaf.type) {
84
+ case richText.TextType.Typography:
85
+ return /* @__PURE__ */ jsxRuntime.jsx(typography.TypographyLeaf, __spreadValues({
86
+ leaf
87
+ }, props));
88
+ default:
89
+ return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
90
+ children: props.children
91
+ }));
92
+ }
93
+ }
94
+ function BlockElement({
95
+ element,
96
+ attributes,
97
+ children
98
+ }) {
99
+ const blockStyles = [next.useStyle({
100
+ margin: 0
101
+ }), next.useStyle(next.responsiveStyle([element.textAlign], ([textAlign = "left"]) => ({
102
+ textAlign
103
+ })))];
104
+ switch (element.type) {
105
+ case richText.BlockType.Paragraph:
106
+ return /* @__PURE__ */ jsxRuntime.jsx("p", __spreadProps(__spreadValues({}, attributes), {
107
+ className: css.cx(...blockStyles),
108
+ children
109
+ }));
110
+ case richText.BlockType.Heading1:
111
+ return /* @__PURE__ */ jsxRuntime.jsx("h1", __spreadProps(__spreadValues({}, attributes), {
112
+ className: css.cx(...blockStyles),
113
+ children
114
+ }));
115
+ case richText.BlockType.Heading2:
116
+ return /* @__PURE__ */ jsxRuntime.jsx("h2", __spreadProps(__spreadValues({}, attributes), {
117
+ className: css.cx(...blockStyles),
118
+ children
119
+ }));
120
+ case richText.BlockType.Heading3:
121
+ return /* @__PURE__ */ jsxRuntime.jsx("h3", __spreadProps(__spreadValues({}, attributes), {
122
+ className: css.cx(...blockStyles),
123
+ children
124
+ }));
125
+ case richText.BlockType.Heading4:
126
+ return /* @__PURE__ */ jsxRuntime.jsx("h4", __spreadProps(__spreadValues({}, attributes), {
127
+ className: css.cx(...blockStyles),
128
+ children
129
+ }));
130
+ case richText.BlockType.Heading5:
131
+ return /* @__PURE__ */ jsxRuntime.jsx("h5", __spreadProps(__spreadValues({}, attributes), {
132
+ className: css.cx(...blockStyles),
133
+ children
134
+ }));
135
+ case richText.BlockType.Heading6:
136
+ return /* @__PURE__ */ jsxRuntime.jsx("h6", __spreadProps(__spreadValues({}, attributes), {
137
+ className: css.cx(...blockStyles),
138
+ children
139
+ }));
140
+ case richText.BlockType.BlockQuote:
141
+ return /* @__PURE__ */ jsxRuntime.jsx("blockquote", __spreadProps(__spreadValues({}, attributes), {
142
+ className: css.cx(...blockStyles, next.useStyle({
143
+ padding: "0.5em 10px",
144
+ fontSize: "1.25em",
145
+ fontWeight: "300",
146
+ borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
147
+ })),
148
+ children
149
+ }));
150
+ case richText.BlockType.OrderedList:
151
+ return /* @__PURE__ */ jsxRuntime.jsx("ol", __spreadProps(__spreadValues({}, attributes), {
152
+ className: css.cx(...blockStyles),
153
+ style: {
154
+ listStylePosition: "inside"
155
+ },
156
+ children
157
+ }));
158
+ case richText.BlockType.UnorderedList:
159
+ return /* @__PURE__ */ jsxRuntime.jsx("ul", __spreadProps(__spreadValues({}, attributes), {
160
+ className: css.cx(...blockStyles),
161
+ style: {
162
+ listStylePosition: "inside"
163
+ },
164
+ children
165
+ }));
166
+ case richText.BlockType.ListItem:
167
+ return /* @__PURE__ */ jsxRuntime.jsx("li", __spreadProps(__spreadValues({}, attributes), {
168
+ className: css.cx(...blockStyles),
169
+ children
170
+ }));
171
+ case richText.BlockType.ListItemChild:
172
+ return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({}, attributes), {
173
+ className: css.cx(...blockStyles),
174
+ children
175
+ }));
176
+ }
177
+ }
178
+ function StyledLink(_c) {
179
+ var _d = _c, {
74
180
  className
75
- } = _b, restOfProps = __objRest(_b, [
76
- "value",
181
+ } = _d, restOfProps = __objRest(_d, [
77
182
  "className"
78
183
  ]);
79
- const typographyStyle = useTypographyMark(value);
80
- const typographyClassName = next.useStyle(next.responsiveStyle([typographyStyle], ([{
81
- color,
82
- fontFamily,
83
- fontSize,
84
- fontWeight,
85
- lineHeight,
86
- letterSpacing,
87
- uppercase,
88
- underline,
89
- strikethrough,
90
- italic
91
- } = {}]) => __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, color == null ? {} : {
92
- color: next.colorToString(color)
93
- }), fontFamily == null ? {} : {
94
- fontFamily: `"${fontFamily}"`
95
- }), fontSize == null || fontSize.value == null || fontSize.unit == null ? {} : {
96
- fontSize: `${fontSize.value}${fontSize.unit}`
97
- }), fontWeight == null ? {} : {
98
- fontWeight
99
- }), lineHeight == null ? {} : {
100
- lineHeight
101
- }), letterSpacing == null ? {} : {
102
- letterSpacing: `${letterSpacing / 10}em`
103
- }), uppercase == null ? {} : {
104
- textTransform: uppercase === true ? "uppercase" : "initial"
105
- }), underline == null && strikethrough == null ? {} : {
106
- textDecoration: [Boolean(underline) && "underline", Boolean(strikethrough) && "line-through"].filter(Boolean).join(" ")
107
- }), italic == null ? {} : {
108
- fontStyle: italic === true ? "italic" : "initial"
109
- }), next.shallowMergeFallbacks));
110
- return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({}, restOfProps), {
111
- className: css.cx(typographyClassName, className)
184
+ return /* @__PURE__ */ jsxRuntime.jsx(index.Link, __spreadProps(__spreadValues({}, restOfProps), {
185
+ className: css.cx(next.useStyle({
186
+ textDecoration: "none"
187
+ }), className)
112
188
  }));
113
189
  }
114
- var DeviceOverrideBlock = React.forwardRef(function Block(_c, ref) {
115
- var _d = _c, {
116
- textAlign,
117
- className,
118
- as
119
- } = _d, restOfProps = __objRest(_d, [
120
- "textAlign",
121
- "className",
122
- "as"
190
+ function InlineElement({
191
+ element,
192
+ attributes,
193
+ children
194
+ }) {
195
+ switch (element.type) {
196
+ case richText.InlineType.Code:
197
+ return /* @__PURE__ */ jsxRuntime.jsx("code", __spreadProps(__spreadValues({}, attributes), {
198
+ children
199
+ }));
200
+ case richText.InlineType.SuperScript:
201
+ return /* @__PURE__ */ jsxRuntime.jsx("sup", __spreadProps(__spreadValues({}, attributes), {
202
+ children
203
+ }));
204
+ case richText.InlineType.SubScript:
205
+ return /* @__PURE__ */ jsxRuntime.jsx("sub", __spreadProps(__spreadValues({}, attributes), {
206
+ children
207
+ }));
208
+ case richText.InlineType.Link:
209
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledLink, __spreadProps(__spreadValues({}, attributes), {
210
+ link: element.link,
211
+ children
212
+ }));
213
+ }
214
+ }
215
+ function Element(_e) {
216
+ var _f = _e, {
217
+ element
218
+ } = _f, props = __objRest(_f, [
219
+ "element"
123
220
  ]);
124
- const Component = as != null ? as : "div";
125
- return /* @__PURE__ */ jsxRuntime.jsx(Component, __spreadProps(__spreadValues({}, restOfProps), {
126
- ref,
127
- className: css.cx(next.useStyle({
128
- margin: 0
129
- }), next.useStyle(next.responsiveStyle([textAlign], ([textAlign2 = "left"]) => ({
130
- textAlign: textAlign2
131
- }))), next.useStyle(as === "blockquote" ? {
132
- padding: "0.5em 10px",
133
- fontSize: "1.25em",
134
- fontWeight: "300",
135
- borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
136
- } : {}), className)
221
+ switch (element.type) {
222
+ case richText.InlineType.Code:
223
+ case richText.InlineType.SuperScript:
224
+ case richText.InlineType.SubScript:
225
+ case richText.InlineType.Link:
226
+ return /* @__PURE__ */ jsxRuntime.jsx(InlineElement, __spreadValues({
227
+ element
228
+ }, props));
229
+ case richText.BlockType.Paragraph:
230
+ case richText.BlockType.Heading1:
231
+ case richText.BlockType.Heading2:
232
+ case richText.BlockType.Heading3:
233
+ case richText.BlockType.BlockQuote:
234
+ case richText.BlockType.OrderedList:
235
+ case richText.BlockType.UnorderedList:
236
+ case richText.BlockType.ListItem:
237
+ case richText.BlockType.ListItemChild:
238
+ return /* @__PURE__ */ jsxRuntime.jsx(BlockElement, __spreadValues({
239
+ element
240
+ }, props));
241
+ default:
242
+ return /* @__PURE__ */ jsxRuntime.jsx("span", __spreadProps(__spreadValues({}, props.attributes), {
243
+ children: props.children
244
+ }));
245
+ }
246
+ }
247
+ const COMMIT_DEBOUNCE_DELAY = 500;
248
+ function useSyncWithBuilder(editor, text) {
249
+ const [shouldCommit, setShouldCommit] = React.useState(true);
250
+ React.useEffect(() => {
251
+ if (shouldCommit && text) {
252
+ const nextValue = richText.richTextDTOtoDAO(text);
253
+ const nextSelection = richText.richTextDTOtoSelection(text);
254
+ if (!compare.compareRichTextDAO(editor.children, nextValue) || !compare.compareRichTextSelection(editor.selection, nextSelection)) {
255
+ editor.children = nextValue;
256
+ editor.selection = nextSelection;
257
+ editor.onChange();
258
+ }
259
+ }
260
+ }, [editor, shouldCommit, text]);
261
+ React.useEffect(() => {
262
+ if (shouldCommit)
263
+ return;
264
+ const timeoutId = window.setTimeout(() => {
265
+ setShouldCommit(true);
266
+ }, COMMIT_DEBOUNCE_DELAY);
267
+ return () => {
268
+ window.clearTimeout(timeoutId);
269
+ };
270
+ }, [shouldCommit]);
271
+ return React.useCallback(() => setShouldCommit(false), []);
272
+ }
273
+ const ElementUtils = {
274
+ isConvertibleToListTextNode(node) {
275
+ return !this.isList(node) && !this.isListItem(node) && !this.isListItemChild(node) && !this.isText(node) && !this.isTypography(node);
276
+ },
277
+ isText(node) {
278
+ return slate.Element.isElementType(node, richText.TextType.Text) || slate.Text.isText(node);
279
+ },
280
+ isTypography(node) {
281
+ return slate.Element.isElementType(node, richText.TextType.Typography);
282
+ },
283
+ isParagraph(node) {
284
+ return slate.Element.isElementType(node, richText.BlockType.Paragraph);
285
+ },
286
+ isList(node) {
287
+ return slate.Element.isElementType(node, richText.BlockType.OrderedList) || slate.Element.isElementType(node, richText.BlockType.UnorderedList);
288
+ },
289
+ isListItem(node) {
290
+ return slate.Element.isElementType(node, richText.BlockType.ListItem);
291
+ },
292
+ isListItemChild(node) {
293
+ return slate.Element.isElementType(node, richText.BlockType.ListItemChild);
294
+ },
295
+ createText() {
296
+ return { text: "", type: richText.TextType.Text };
297
+ },
298
+ createParagraph() {
299
+ return {
300
+ children: [this.createText()],
301
+ type: richText.BlockType.Paragraph
302
+ };
303
+ },
304
+ createList(type = richText.BlockType.UnorderedList) {
305
+ return { children: [this.createText()], type };
306
+ },
307
+ createListItem() {
308
+ return {
309
+ children: [this.createListItemChild()],
310
+ type: richText.BlockType.ListItem
311
+ };
312
+ },
313
+ createListItemChild() {
314
+ return {
315
+ children: [this.createText()],
316
+ type: richText.BlockType.ListItemChild
317
+ };
318
+ }
319
+ };
320
+ function wrapList(editor, options = { type: richText.BlockType.UnorderedList }) {
321
+ if (!editor.selection)
322
+ return;
323
+ const nonListEntries = Array.from(slate.Editor.nodes(editor, {
324
+ at: editor.selection,
325
+ match: (node) => {
326
+ return slate.Element.isElement(node) && ElementUtils.isConvertibleToListTextNode(node);
327
+ }
137
328
  }));
329
+ const refs = nonListEntries.map(([_, path]) => slate.Editor.pathRef(editor, path));
330
+ refs.forEach((ref) => {
331
+ const path = ref.current;
332
+ if (path) {
333
+ slate.Editor.withoutNormalizing(editor, () => {
334
+ slate.Transforms.setNodes(editor, { type: richText.BlockType.ListItemChild }, {
335
+ at: path
336
+ });
337
+ slate.Transforms.wrapNodes(editor, ElementUtils.createListItem(), {
338
+ at: path
339
+ });
340
+ slate.Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {
341
+ at: path
342
+ });
343
+ });
344
+ }
345
+ ref.unref();
346
+ });
347
+ }
348
+ const LIST_ITEM_CHILD_POSITION = 0;
349
+ const LIST_ITEM_LIST_POSITION = 1;
350
+ const EditorUtils = {
351
+ getFirstAncestorList(editor, path) {
352
+ const parentList = slate.Editor.above(editor, {
353
+ at: path,
354
+ match: (node) => ElementUtils.isList(node)
355
+ });
356
+ return parentList != null ? parentList : null;
357
+ },
358
+ getFirstAncestorListItem(editor, path) {
359
+ const parentListItem = slate.Editor.above(editor, {
360
+ at: path,
361
+ match: (node) => ElementUtils.isListItem(node)
362
+ });
363
+ return parentListItem != null ? parentListItem : null;
364
+ }
365
+ };
366
+ function filterForSubtreeRoots(entries) {
367
+ return entries.filter(([, nodePath]) => !slate.Path.ancestors(nodePath).some((ancestor) => {
368
+ return entries.some(([, path]) => slate.Path.equals(path, ancestor));
369
+ }));
370
+ }
371
+ const LocationUtils = {
372
+ getStartPath(location) {
373
+ if (slate.Range.isRange(location))
374
+ return slate.Range.start(location).path;
375
+ if (slate.Point.isPoint(location))
376
+ return location.path;
377
+ return location;
378
+ }
379
+ };
380
+ function getSelectedListItems(editor) {
381
+ var _a, _b;
382
+ if (!editor.selection)
383
+ return [];
384
+ const start = LocationUtils.getStartPath(editor.selection);
385
+ const listItems = slate.Editor.nodes(editor, {
386
+ at: editor.selection,
387
+ match: (node) => ElementUtils.isListItem(node)
388
+ });
389
+ const firstAncestorPath = (_b = (_a = EditorUtils.getFirstAncestorListItem(editor, start)) == null ? void 0 : _a[1]) != null ? _b : [];
390
+ return Array.from(listItems).filter((node) => slate.Path.isDescendant(start, node[1]) ? slate.Path.equals(node[1], firstAncestorPath) : !slate.Path.isAfter(start, node[1]));
391
+ }
392
+ function unwrapPath(editor, listItemPath) {
393
+ const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
394
+ const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
395
+ if (!parentList || listItemContainingParentList)
396
+ return;
397
+ slate.Editor.withoutNormalizing(editor, () => {
398
+ const listItemTextPath = [...listItemPath, LIST_ITEM_CHILD_POSITION];
399
+ const listItemNestedListPath = [...listItemPath, LIST_ITEM_LIST_POSITION];
400
+ if (slate.Node.has(editor, listItemNestedListPath)) {
401
+ slate.Transforms.setNodes(editor, { type: parentList[0].type }, { at: listItemNestedListPath });
402
+ slate.Transforms.liftNodes(editor, { at: listItemNestedListPath });
403
+ slate.Transforms.liftNodes(editor, { at: slate.Path.next(listItemPath) });
404
+ }
405
+ if (slate.Node.has(editor, listItemTextPath)) {
406
+ slate.Transforms.setNodes(editor, { type: richText.BlockType.Paragraph }, {
407
+ at: listItemTextPath
408
+ });
409
+ slate.Transforms.liftNodes(editor, { at: listItemTextPath });
410
+ slate.Transforms.liftNodes(editor, { at: listItemPath });
411
+ }
412
+ });
413
+ }
414
+ function unwrapList(editor) {
415
+ if (!editor.selection)
416
+ return;
417
+ const listItems = getSelectedListItems(editor);
418
+ const subRoots = filterForSubtreeRoots(listItems);
419
+ const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
420
+ refs.forEach((ref) => {
421
+ if (ref.current) {
422
+ unwrapPath(editor, ref.current);
423
+ }
424
+ ref.unref();
425
+ });
426
+ }
427
+ function toggleList(editor, options = { type: richText.BlockType.UnorderedList }) {
428
+ if (!editor.selection)
429
+ return;
430
+ const start = LocationUtils.getStartPath(editor.selection);
431
+ const ancestorPath = slate.Path.ancestors(start).at(1);
432
+ if (!ancestorPath || !slate.Node.has(editor, ancestorPath))
433
+ return;
434
+ const ancestor = slate.Node.get(editor, ancestorPath);
435
+ if (!ElementUtils.isList(ancestor)) {
436
+ return wrapList(editor, { type: options.type });
437
+ }
438
+ if (ancestor.type === options.type) {
439
+ unwrapList(editor);
440
+ } else {
441
+ slate.Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath });
442
+ }
443
+ }
444
+ function indentPath(editor, path) {
445
+ const parent = slate.Node.parent(editor, path);
446
+ if (!path || !slate.Path.hasPrevious(path) || !ElementUtils.isList(parent))
447
+ return;
448
+ const previosPath = slate.Path.previous(path);
449
+ const previousChildListPath = [...previosPath, LIST_ITEM_LIST_POSITION];
450
+ const previousHasChildList = slate.Node.has(editor, previousChildListPath);
451
+ slate.Editor.withoutNormalizing(editor, () => {
452
+ if (!previousHasChildList) {
453
+ slate.Transforms.insertNodes(editor, ElementUtils.createList(parent.type), {
454
+ at: previousChildListPath
455
+ });
456
+ }
457
+ const previousChildList = slate.Node.get(editor, previousChildListPath);
458
+ if (ElementUtils.isList(previousChildList)) {
459
+ const index2 = previousHasChildList ? previousChildList.children.length : 0;
460
+ slate.Transforms.moveNodes(editor, {
461
+ at: path,
462
+ to: [...previousChildListPath, index2]
463
+ });
464
+ }
465
+ });
466
+ }
467
+ function indent(editor) {
468
+ if (!editor.selection)
469
+ return;
470
+ const listItems = getSelectedListItems(editor);
471
+ const subRoots = filterForSubtreeRoots(listItems);
472
+ const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
473
+ refs.forEach((ref) => {
474
+ if (ref.current) {
475
+ indentPath(editor, ref.current);
476
+ }
477
+ ref.unref();
478
+ });
479
+ }
480
+ function dedentPath(editor, listItemPath) {
481
+ const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
482
+ const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
483
+ if (!parentList || !listItemContainingParentList)
484
+ return;
485
+ const [parentListNode, parentListPath] = parentList;
486
+ const [_, listItemContainingParentListPath] = listItemContainingParentList;
487
+ const listItemPosition = listItemPath[listItemPath.length - 1];
488
+ const previousSiblings = parentListNode.children.slice(0, listItemPosition);
489
+ const nextSiblings = parentListNode.children.slice(listItemPosition + 1);
490
+ slate.Editor.withoutNormalizing(editor, () => {
491
+ nextSiblings.forEach(() => {
492
+ const nextSiblingPath = [...parentListPath, listItemPosition + 1];
493
+ indentPath(editor, nextSiblingPath);
494
+ });
495
+ slate.Transforms.moveNodes(editor, {
496
+ at: listItemPath,
497
+ to: slate.Path.next(listItemContainingParentListPath)
498
+ });
499
+ if (previousSiblings.length === 0) {
500
+ slate.Transforms.removeNodes(editor, { at: parentListPath });
501
+ }
502
+ });
503
+ }
504
+ function dedent(editor) {
505
+ if (!editor.selection)
506
+ return;
507
+ const listItems = getSelectedListItems(editor);
508
+ const subRoots = filterForSubtreeRoots(listItems);
509
+ const refs = subRoots.map(([_, path]) => slate.Editor.pathRef(editor, path));
510
+ refs.forEach((ref) => {
511
+ if (ref.current) {
512
+ dedentPath(editor, ref.current);
513
+ }
514
+ ref.unref();
515
+ });
516
+ }
517
+ const List = {
518
+ unwrapList,
519
+ wrapList,
520
+ indent,
521
+ dedent,
522
+ toggleList
523
+ };
524
+ function onKeyDown(e, editor) {
525
+ if (!editor.selection || Array.from(slate.Editor.nodes(editor, { match: (node) => ElementUtils.isListItem(node) })).length === 0)
526
+ return;
527
+ if (isHotkey__default["default"]("shift+tab", e)) {
528
+ e.preventDefault();
529
+ List.dedent(editor);
530
+ }
531
+ if (isHotkey__default["default"]("tab", e)) {
532
+ e.preventDefault();
533
+ List.indent(editor);
534
+ }
535
+ if (isHotkey__default["default"]("backspace", e)) {
536
+ if (!editor.selection)
537
+ return;
538
+ if (slate.Range.isExpanded(editor.selection))
539
+ return;
540
+ const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path);
541
+ if (editor.selection.anchor.offset === 0 && listItem) {
542
+ e.preventDefault();
543
+ const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1]);
544
+ const list = EditorUtils.getFirstAncestorList(editor, listItem[1]);
545
+ if (parentListItem) {
546
+ List.dedent(editor);
547
+ } else if (list) {
548
+ List.unwrapList(editor);
549
+ }
550
+ return;
551
+ }
552
+ }
553
+ if (isHotkey__default["default"]("enter", e)) {
554
+ e.preventDefault();
555
+ if (!editor.selection)
556
+ return;
557
+ if (slate.Range.isExpanded(editor.selection)) {
558
+ slate.Transforms.delete(editor);
559
+ return;
560
+ }
561
+ const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path);
562
+ if (editor.selection.anchor.offset === 0 && listItem && slate.Editor.string(editor, listItem[1]) === "") {
563
+ const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1]);
564
+ if (parentListItem) {
565
+ List.dedent(editor);
566
+ } else {
567
+ List.unwrapList(editor);
568
+ }
569
+ return;
570
+ }
571
+ slate.Transforms.splitNodes(editor, {
572
+ at: editor.selection,
573
+ always: true,
574
+ match: (node) => ElementUtils.isListItem(node)
575
+ });
576
+ }
577
+ if (isHotkey__default["default"]("shift+enter", e)) {
578
+ e.preventDefault();
579
+ editor.insertText("\n");
580
+ }
581
+ }
582
+ function withList(editor) {
583
+ editor.normalizeNode = (entry) => {
584
+ const [normalizationNode, normalizationPath] = entry;
585
+ if (ElementUtils.isListItem(normalizationNode)) {
586
+ const pathToListItemText = [...normalizationPath, LIST_ITEM_CHILD_POSITION];
587
+ if (slate.Node.has(editor, pathToListItemText)) {
588
+ const nodeInListItemTextPosition = slate.Node.get(editor, pathToListItemText);
589
+ if (ElementUtils.isParagraph(nodeInListItemTextPosition)) {
590
+ slate.Transforms.setNodes(editor, { type: richText.BlockType.ListItemChild }, {
591
+ at: pathToListItemText
592
+ });
593
+ return;
594
+ }
595
+ } else {
596
+ slate.Transforms.insertNodes(editor, ElementUtils.createListItem(), {
597
+ at: pathToListItemText
598
+ });
599
+ return;
600
+ }
601
+ }
602
+ if (ElementUtils.isList(normalizationNode)) {
603
+ Array.from(slate.Node.children(editor, normalizationPath)).forEach(([node, path]) => {
604
+ if (ElementUtils.isText(node)) {
605
+ slate.Transforms.removeNodes(editor, { at: path });
606
+ return;
607
+ }
608
+ });
609
+ }
610
+ if (!ElementUtils.isText(normalizationNode) && !ElementUtils.isTypography(normalizationNode)) {
611
+ const mergeableChildren = Array.from(slate.Node.children(editor, normalizationPath)).map((child, index2, children) => {
612
+ const potentialNodeToBeMerged = children.at(index2 + 1);
613
+ if (!potentialNodeToBeMerged || !ElementUtils.isList(potentialNodeToBeMerged[0]) || potentialNodeToBeMerged[0].type !== child[0].type) {
614
+ return null;
615
+ }
616
+ return [
617
+ slate.Editor.pathRef(editor, child[1]),
618
+ slate.Editor.pathRef(editor, potentialNodeToBeMerged[1])
619
+ ];
620
+ }).filter((mergeableNodes) => Boolean(mergeableNodes));
621
+ if (mergeableChildren.length !== 0) {
622
+ mergeableChildren.reverse().forEach(([nodePathRef, nodeToBeMergedPathRef]) => {
623
+ const nodePath = nodePathRef.current;
624
+ const nodeToBeMergedPath = nodeToBeMergedPathRef.current;
625
+ if (nodePath == null || nodeToBeMergedPath == null)
626
+ return;
627
+ const nodeChildren = Array.from(slate.Node.children(editor, nodePath));
628
+ const childrenToBeMerged = Array.from(slate.Node.children(editor, nodeToBeMergedPath));
629
+ slate.Editor.withoutNormalizing(editor, () => {
630
+ childrenToBeMerged.forEach(([_, childPath], index2) => {
631
+ slate.Transforms.moveNodes(editor, {
632
+ at: childPath,
633
+ to: [...nodePath, nodeChildren.length + index2]
634
+ });
635
+ });
636
+ slate.Transforms.removeNodes(editor, { at: nodeToBeMergedPath });
637
+ });
638
+ nodePathRef.unref();
639
+ nodeToBeMergedPathRef.unref();
640
+ });
641
+ return;
642
+ }
643
+ }
644
+ };
645
+ return editor;
646
+ }
647
+ const defaultText = [{
648
+ type: richText.BlockType.Paragraph,
649
+ children: [{
650
+ type: richText.TextType.Text,
651
+ text: ""
652
+ }]
653
+ }];
654
+ const EditableText = React.forwardRef(function EditableText2({
655
+ id,
656
+ text,
657
+ width,
658
+ margin
659
+ }, ref) {
660
+ const [editor] = React.useState(() => withList(slateReact.withReact(slate.createEditor())));
661
+ const delaySync = useSyncWithBuilder(editor, text);
662
+ const editMode = next.useBuilderEditMode();
663
+ const [propControllers, setPropControllers] = React.useState(null);
664
+ const controller = propControllers == null ? void 0 : propControllers.text;
665
+ React.useImperativeHandle(ref, () => ({
666
+ getDomNode() {
667
+ return slateReact.ReactEditor.toDOMNode(editor, editor);
668
+ },
669
+ getBoxModel() {
670
+ return boxModels.getBox(slateReact.ReactEditor.toDOMNode(editor, editor));
671
+ },
672
+ setPropControllers
673
+ }), [editor, setPropControllers]);
674
+ const initialValue = React.useMemo(() => text ? richText.richTextDTOtoDAO(text) : defaultText, [text]);
675
+ React.useEffect(() => {
676
+ controller == null ? void 0 : controller.setSlateEditor(editor);
677
+ }, [controller, editor]);
678
+ const handleFocus = React.useCallback(() => {
679
+ controller == null ? void 0 : controller.focus();
680
+ }, [controller]);
681
+ const handleKeyDown = React.useCallback((e) => {
682
+ if (isHotkey__default["default"]("mod+shift+z", e))
683
+ return controller == null ? void 0 : controller.redo();
684
+ if (isHotkey__default["default"]("mod+z", e))
685
+ return controller == null ? void 0 : controller.undo();
686
+ if (isHotkey__default["default"]("escape")(e))
687
+ return controller == null ? void 0 : controller.blur();
688
+ onKeyDown(e, editor);
689
+ }, [controller, editor]);
690
+ return /* @__PURE__ */ jsxRuntime.jsx(slateReact.Slate, {
691
+ editor,
692
+ value: initialValue,
693
+ onChange: delaySync,
694
+ children: /* @__PURE__ */ jsxRuntime.jsx(slateReact.Editable, {
695
+ id,
696
+ renderLeaf: Leaf,
697
+ renderElement: Element,
698
+ onKeyDown: handleKeyDown,
699
+ onFocus: handleFocus,
700
+ className: css.cx(width, margin),
701
+ readOnly: editMode === richText.BuilderEditMode.INTERACT
702
+ })
703
+ });
138
704
  });
139
- exports.DeviceOverrideBlock = DeviceOverrideBlock;
140
- exports.Mark = Mark;
705
+ var EditableText$1 = EditableText;
706
+ exports.EditableText = EditableText;
707
+ exports["default"] = EditableText$1;
141
708
  //# sourceMappingURL=index.cjs6.js.map