@makeswift/runtime 0.9.12 → 0.10.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 (235) hide show
  1. package/dist/Box.cjs.js +3 -0
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +4 -1
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +3 -2
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +4 -3
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +3 -2
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +4 -3
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +3 -0
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +4 -1
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +3 -0
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +4 -1
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/Embed.cjs.js +1 -0
  22. package/dist/Embed.cjs.js.map +1 -1
  23. package/dist/Embed.es.js +2 -1
  24. package/dist/Embed.es.js.map +1 -1
  25. package/dist/Form.cjs.js +13 -12
  26. package/dist/Form.cjs.js.map +1 -1
  27. package/dist/Form.es.js +5 -4
  28. package/dist/Form.es.js.map +1 -1
  29. package/dist/Image.cjs.js +11 -10
  30. package/dist/Image.cjs.js.map +1 -1
  31. package/dist/Image.es.js +11 -10
  32. package/dist/Image.es.js.map +1 -1
  33. package/dist/LiveProvider.cjs.js +3 -0
  34. package/dist/LiveProvider.cjs.js.map +1 -1
  35. package/dist/LiveProvider.es.js +5 -2
  36. package/dist/LiveProvider.es.js.map +1 -1
  37. package/dist/Navigation.cjs.js +11 -10
  38. package/dist/Navigation.cjs.js.map +1 -1
  39. package/dist/Navigation.es.js +11 -10
  40. package/dist/Navigation.es.js.map +1 -1
  41. package/dist/PreviewProvider.cjs.js +6 -3
  42. package/dist/PreviewProvider.cjs.js.map +1 -1
  43. package/dist/PreviewProvider.es.js +5 -2
  44. package/dist/PreviewProvider.es.js.map +1 -1
  45. package/dist/ReadOnlyText.cjs.js +19 -26
  46. package/dist/ReadOnlyText.cjs.js.map +1 -1
  47. package/dist/ReadOnlyText.es.js +15 -22
  48. package/dist/ReadOnlyText.es.js.map +1 -1
  49. package/dist/ReadOnlyTextV2.cjs.js +29 -26
  50. package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
  51. package/dist/ReadOnlyTextV2.es.js +28 -25
  52. package/dist/ReadOnlyTextV2.es.js.map +1 -1
  53. package/dist/Root.cjs.js +3 -0
  54. package/dist/Root.cjs.js.map +1 -1
  55. package/dist/Root.es.js +4 -1
  56. package/dist/Root.es.js.map +1 -1
  57. package/dist/SocialLinks.cjs.js +6 -5
  58. package/dist/SocialLinks.cjs.js.map +1 -1
  59. package/dist/SocialLinks.es.js +7 -6
  60. package/dist/SocialLinks.es.js.map +1 -1
  61. package/dist/Text.cjs.js +12 -71
  62. package/dist/Text.cjs.js.map +1 -1
  63. package/dist/Text.es.js +13 -64
  64. package/dist/Text.es.js.map +1 -1
  65. package/dist/Video.cjs.js +1 -0
  66. package/dist/Video.cjs.js.map +1 -1
  67. package/dist/Video.es.js +2 -1
  68. package/dist/Video.es.js.map +1 -1
  69. package/dist/builder.cjs.js +2 -0
  70. package/dist/builder.cjs.js.map +1 -1
  71. package/dist/builder.es.js +2 -0
  72. package/dist/builder.es.js.map +1 -1
  73. package/dist/components.cjs.js +3 -2
  74. package/dist/components.cjs.js.map +1 -1
  75. package/dist/components.es.js +3 -2
  76. package/dist/components.es.js.map +1 -1
  77. package/dist/control-serialization.es.js +1 -1
  78. package/dist/controls.cjs.js +8 -8
  79. package/dist/controls.es.js +4 -2
  80. package/dist/controls.es.js.map +1 -1
  81. package/dist/index.cjs.js +276 -213
  82. package/dist/index.cjs.js.map +1 -1
  83. package/dist/index.cjs3.js +21 -107
  84. package/dist/index.cjs3.js.map +1 -1
  85. package/dist/index.cjs4.js +16 -57
  86. package/dist/index.cjs4.js.map +1 -1
  87. package/dist/index.cjs5.js +53 -242
  88. package/dist/index.cjs5.js.map +1 -1
  89. package/dist/index.cjs6.js +0 -41
  90. package/dist/index.cjs6.js.map +1 -1
  91. package/dist/index.cjs7.js +376 -14
  92. package/dist/index.cjs7.js.map +1 -1
  93. package/dist/index.cjs8.js +275 -11
  94. package/dist/index.cjs8.js.map +1 -1
  95. package/dist/index.es.js +270 -206
  96. package/dist/index.es.js.map +1 -1
  97. package/dist/index.es2.js +2 -2
  98. package/dist/index.es3.js +22 -103
  99. package/dist/index.es3.js.map +1 -1
  100. package/dist/index.es4.js +16 -57
  101. package/dist/index.es4.js.map +1 -1
  102. package/dist/index.es5.js +53 -240
  103. package/dist/index.es5.js.map +1 -1
  104. package/dist/index.es6.js +1 -36
  105. package/dist/index.es6.js.map +1 -1
  106. package/dist/index.es7.js +372 -16
  107. package/dist/index.es7.js.map +1 -1
  108. package/dist/index.es8.js +270 -10
  109. package/dist/index.es8.js.map +1 -1
  110. package/dist/main.cjs.js +2 -0
  111. package/dist/main.cjs.js.map +1 -1
  112. package/dist/main.es.js +2 -0
  113. package/dist/main.es.js.map +1 -1
  114. package/dist/next.cjs.js +3 -0
  115. package/dist/next.cjs.js.map +1 -1
  116. package/dist/next.es.js +4 -1
  117. package/dist/next.es.js.map +1 -1
  118. package/dist/prop-controllers.cjs.js +2 -0
  119. package/dist/prop-controllers.cjs.js.map +1 -1
  120. package/dist/prop-controllers.es.js +2 -0
  121. package/dist/prop-controllers.es.js.map +1 -1
  122. package/dist/react-page.cjs.js +1450 -65
  123. package/dist/react-page.cjs.js.map +1 -1
  124. package/dist/react-page.es.js +1427 -66
  125. package/dist/react-page.es.js.map +1 -1
  126. package/dist/react.cjs.js +3 -0
  127. package/dist/react.cjs.js.map +1 -1
  128. package/dist/react.es.js +3 -0
  129. package/dist/react.es.js.map +1 -1
  130. package/dist/slate.cjs.js +33 -391
  131. package/dist/slate.cjs.js.map +1 -1
  132. package/dist/slate.es.js +15 -376
  133. package/dist/slate.es.js.map +1 -1
  134. package/dist/text-input.cjs.js +0 -22
  135. package/dist/text-input.cjs.js.map +1 -1
  136. package/dist/text-input.es.js +1 -18
  137. package/dist/text-input.es.js.map +1 -1
  138. package/dist/types/src/components/builtin/Text/Text.d.ts +3 -4
  139. package/dist/types/src/components/builtin/Text/Text.d.ts.map +1 -1
  140. package/dist/types/src/components/builtin/Text/register.d.ts.map +1 -1
  141. package/dist/types/src/controls/rich-text/fixtures/v2-data-types.d.ts.map +1 -1
  142. package/dist/types/src/controls/rich-text/rich-text.d.ts +0 -1
  143. package/dist/types/src/controls/rich-text/rich-text.d.ts.map +1 -1
  144. package/dist/types/src/controls/rich-text/translation.d.ts.map +1 -1
  145. package/dist/types/src/controls/rich-text-v2/plugin.d.ts +29 -0
  146. package/dist/types/src/controls/rich-text-v2/plugin.d.ts.map +1 -0
  147. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +17 -31
  148. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  149. package/dist/types/src/next/client.d.ts.map +1 -1
  150. package/dist/types/src/prop-controllers/descriptors.d.ts +1 -1
  151. package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
  152. package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
  153. package/dist/types/src/runtimes/react/controls/control.d.ts +1 -1
  154. package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
  155. package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/EditableText/editable-text.d.ts +4 -3
  156. package/dist/types/src/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts.map +1 -0
  157. package/dist/types/src/runtimes/react/controls/rich-text/EditableText/index.d.ts.map +1 -0
  158. package/dist/types/src/runtimes/react/controls/rich-text/EditableText/useSyncDOMSelection.d.ts.map +1 -0
  159. package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/EditableText/useSyncWithBuilder.d.ts +1 -1
  160. package/dist/types/src/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.d.ts.map +1 -0
  161. package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/ReadOnlyText.d.ts +2 -2
  162. package/dist/types/src/runtimes/react/controls/rich-text/ReadOnlyText.d.ts.map +1 -0
  163. package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Element/block.d.ts +1 -1
  164. package/dist/types/src/runtimes/react/controls/rich-text/components/Element/block.d.ts.map +1 -0
  165. package/dist/types/src/runtimes/react/controls/rich-text/components/Element/element.d.ts.map +1 -0
  166. package/dist/types/src/runtimes/react/controls/rich-text/components/Element/index.d.ts.map +1 -0
  167. package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Element/inline.d.ts +1 -1
  168. package/dist/types/src/runtimes/react/controls/rich-text/components/Element/inline.d.ts.map +1 -0
  169. package/dist/types/src/runtimes/react/controls/rich-text/components/Leaf/index.d.ts.map +1 -0
  170. package/dist/types/src/runtimes/react/controls/rich-text/components/Leaf/leaf.d.ts.map +1 -0
  171. package/dist/types/src/runtimes/react/controls/rich-text/components/index.d.ts.map +1 -0
  172. package/dist/types/src/runtimes/react/controls/rich-text/index.d.ts +2 -0
  173. package/dist/types/src/runtimes/react/controls/rich-text/index.d.ts.map +1 -0
  174. package/dist/types/src/runtimes/react/controls/{rich-text.d.ts → rich-text/rich-text.d.ts} +1 -1
  175. package/dist/types/src/runtimes/react/controls/rich-text/rich-text.d.ts.map +1 -0
  176. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
  177. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts +2 -1
  178. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -1
  179. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts +2 -1
  180. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts.map +1 -1
  181. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.d.ts.map +1 -1
  182. package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts +2 -1
  183. package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
  184. package/dist/types/src/slate/BlockPlugin/index.d.ts +3 -3
  185. package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
  186. package/dist/types/src/slate/InlineModePlugin/index.d.ts +6 -4
  187. package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
  188. package/dist/types/src/slate/InlinePlugin/index.d.ts +3 -3
  189. package/dist/types/src/slate/InlinePlugin/index.d.ts.map +1 -1
  190. package/dist/types/src/slate/InlinePlugin/types.d.ts +1 -1
  191. package/dist/types/src/slate/InlinePlugin/types.d.ts.map +1 -1
  192. package/dist/types/src/slate/LinkPlugin/index.d.ts +3 -3
  193. package/dist/types/src/slate/LinkPlugin/index.d.ts.map +1 -1
  194. package/dist/types/src/slate/LinkPlugin/linkPluginWithoutRenderElement.d.ts +16 -0
  195. package/dist/types/src/slate/LinkPlugin/linkPluginWithoutRenderElement.d.ts.map +1 -0
  196. package/dist/types/src/slate/TextAlignPlugin/index.d.ts +3 -3
  197. package/dist/types/src/slate/TypographyPlugin/index.d.ts +3 -3
  198. package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -1
  199. package/dist/types/src/slate/types.d.ts +1 -10
  200. package/dist/types/src/slate/types.d.ts.map +1 -1
  201. package/dist/types/src/slate/utils/element.d.ts.map +1 -1
  202. package/dist/types/src/state/modules/locales.d.ts.map +1 -1
  203. package/package.json +1 -1
  204. package/dist/index.cjs10.js +0 -390
  205. package/dist/index.cjs10.js.map +0 -1
  206. package/dist/index.cjs9.js +0 -295
  207. package/dist/index.cjs9.js.map +0 -1
  208. package/dist/index.es10.js +0 -383
  209. package/dist/index.es10.js.map +0 -1
  210. package/dist/index.es9.js +0 -288
  211. package/dist/index.es9.js.map +0 -1
  212. package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +0 -1
  213. package/dist/types/src/components/builtin/Text/EditableText/index.d.ts.map +0 -1
  214. package/dist/types/src/components/builtin/Text/EditableText/useSyncDOMSelection.d.ts.map +0 -1
  215. package/dist/types/src/components/builtin/Text/EditableText/useSyncWithBuilder.d.ts.map +0 -1
  216. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +0 -1
  217. package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +0 -1
  218. package/dist/types/src/components/builtin/Text/components/Element/element.d.ts.map +0 -1
  219. package/dist/types/src/components/builtin/Text/components/Element/index.d.ts.map +0 -1
  220. package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts.map +0 -1
  221. package/dist/types/src/components/builtin/Text/components/Leaf/index.d.ts.map +0 -1
  222. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +0 -1
  223. package/dist/types/src/components/builtin/Text/components/index.d.ts.map +0 -1
  224. package/dist/types/src/runtimes/react/controls/rich-text.d.ts.map +0 -1
  225. package/dist/types.cjs2.js +0 -765
  226. package/dist/types.cjs2.js.map +0 -1
  227. package/dist/types.es2.js +0 -748
  228. package/dist/types.es2.js.map +0 -1
  229. /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/EditableText/index.d.ts +0 -0
  230. /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/EditableText/useSyncDOMSelection.d.ts +0 -0
  231. /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Element/element.d.ts +0 -0
  232. /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Element/index.d.ts +0 -0
  233. /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Leaf/index.d.ts +0 -0
  234. /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Leaf/leaf.d.ts +0 -0
  235. /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/index.d.ts +0 -0
@@ -30,117 +30,31 @@ var __objRest = (source, exclude) => {
30
30
  }
31
31
  return target;
32
32
  };
33
- var React = require("react");
34
- var scrollIntoView = require("scroll-into-view-if-needed");
35
- var NextLink = require("next/link");
33
+ var css = require("@emotion/css");
34
+ var reactPage = require("./react-page.cjs.js");
36
35
  var next = require("./index.cjs.js");
37
36
  var jsxRuntime = require("react/jsx-runtime");
38
- function _interopDefaultLegacy(e) {
39
- return e && typeof e === "object" && "default" in e ? e : { "default": e };
40
- }
41
- var scrollIntoView__default = /* @__PURE__ */ _interopDefaultLegacy(scrollIntoView);
42
- var NextLink__default = /* @__PURE__ */ _interopDefaultLegacy(NextLink);
43
- const Link = React.forwardRef(function Link2(_a, ref) {
37
+ function GutterContainer(_a) {
44
38
  var _b = _a, {
45
- link,
46
- onClick = () => {
47
- }
39
+ className,
40
+ gutter,
41
+ first,
42
+ last
48
43
  } = _b, restOfProps = __objRest(_b, [
49
- "link",
50
- "onClick"
44
+ "className",
45
+ "gutter",
46
+ "first",
47
+ "last"
51
48
  ]);
52
- var _a2;
53
- const pageId = link && link.type === "OPEN_PAGE" ? link.payload.pageId : null;
54
- const page = next.usePagePathnameSlice(pageId != null ? pageId : null);
55
- const elementKey = (link == null ? void 0 : link.type) === "SCROLL_TO_ELEMENT" ? (_a2 = link.payload.elementIdConfig) == null ? void 0 : _a2.elementKey : null;
56
- const elementId = next.useElementId(elementKey);
57
- let useNextLink;
58
- let href;
59
- let target;
60
- let block;
61
- if (link) {
62
- switch (link.type) {
63
- case "OPEN_PAGE": {
64
- if (page) {
65
- useNextLink = true;
66
- href = `/${page.pathname}`;
67
- }
68
- target = link.payload.openInNewTab ? "_blank" : "_self";
69
- break;
70
- }
71
- case "OPEN_URL": {
72
- useNextLink = true;
73
- href = link.payload.url;
74
- target = link.payload.openInNewTab ? "_blank" : "_self";
75
- break;
76
- }
77
- case "SEND_EMAIL": {
78
- useNextLink = false;
79
- const {
80
- to,
81
- subject = "",
82
- body = ""
83
- } = link.payload;
84
- if (to != null)
85
- href = `mailto:${to}?subject=${subject}&body=${body}`;
86
- break;
87
- }
88
- case "CALL_PHONE": {
89
- useNextLink = false;
90
- href = `tel:${link.payload.phoneNumber}`;
91
- break;
92
- }
93
- case "SCROLL_TO_ELEMENT": {
94
- useNextLink = false;
95
- href = `#${elementId != null ? elementId : ""}`;
96
- block = link.payload.block;
97
- break;
98
- }
99
- default:
100
- throw new RangeError(`Invalid link type "${link.type}."`);
101
- }
102
- }
103
- function handleClick(event) {
104
- onClick(event);
105
- if (event.defaultPrevented)
106
- return;
107
- if (event.currentTarget.isContentEditable)
108
- return event.preventDefault();
109
- if (link && link.type === "SCROLL_TO_ELEMENT") {
110
- let hash;
111
- try {
112
- if (href != null)
113
- hash = new URL(`http://www.example.com/${href}`).hash;
114
- } catch (error) {
115
- console.error(`Link received invalid href: ${href}`, error);
116
- }
117
- if (href != null && hash != null && href === hash) {
118
- event.preventDefault();
119
- const view = event.view;
120
- scrollIntoView__default["default"](view.document.querySelector(hash), {
121
- behavior: "smooth",
122
- block
123
- });
124
- if (view.location.hash !== hash)
125
- view.history.pushState({}, "", hash);
126
- }
127
- }
128
- }
129
- if (useNextLink && href != null) {
130
- return /* @__PURE__ */ jsxRuntime.jsx(NextLink__default["default"], __spreadProps(__spreadValues({}, restOfProps), {
131
- ref,
132
- target,
133
- onClick: handleClick,
134
- href,
135
- legacyBehavior: false
136
- }));
137
- }
138
- return /* @__PURE__ */ jsxRuntime.jsx("a", __spreadProps(__spreadValues({}, restOfProps), {
139
- ref,
140
- href,
141
- target,
142
- onClick: handleClick
49
+ return /* @__PURE__ */ jsxRuntime.jsx("div", __spreadProps(__spreadValues({}, restOfProps), {
50
+ className: css.cx(reactPage.useStyle(next.useResponsiveStyle([gutter], ([gutter2 = {
51
+ value: 0,
52
+ unit: "px"
53
+ }]) => ({
54
+ paddingLeft: first ? "0px" : `${gutter2.value / 2}${gutter2.unit}`,
55
+ paddingRight: last ? "0px" : `${gutter2.value / 2}${gutter2.unit}`
56
+ }))), className)
143
57
  }));
144
- });
145
- exports.Link = Link;
58
+ }
59
+ exports.GutterContainer = GutterContainer;
146
60
  //# sourceMappingURL=index.cjs3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs3.js","sources":["../src/components/shared/Link/index.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, forwardRef, MouseEvent } from 'react'\nimport scrollIntoView from 'scroll-into-view-if-needed'\nimport NextLink from 'next/link'\n\nimport { LinkValue as LinkPropControllerValue } from '../../../prop-controllers/descriptors'\nimport { useElementId } from '../../../runtimes/react'\nimport { usePagePathnameSlice } from '../../../runtimes/react/hooks/makeswift-api'\n\ntype BaseProps = {\n link?: LinkPropControllerValue\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => unknown\n}\n\ntype Props = BaseProps & Omit<ComponentPropsWithoutRef<'a'>, keyof BaseProps>\n\nexport const Link = forwardRef<HTMLAnchorElement, Props>(function Link(\n { link, onClick = () => {}, ...restOfProps }: Props,\n ref,\n) {\n const pageId = link && link.type === 'OPEN_PAGE' ? link.payload.pageId : null\n const page = usePagePathnameSlice(pageId ?? null)\n const elementKey =\n link?.type === 'SCROLL_TO_ELEMENT' ? link.payload.elementIdConfig?.elementKey : null\n const elementId = useElementId(elementKey)\n\n // We don't want to use `next/link` with relative paths because Next.js will attempt to normalize\n // it and mess up the path.\n let useNextLink: boolean | undefined\n let href: string | undefined\n let target: '_blank' | '_self' | undefined\n let block: 'start' | 'center' | 'end' | undefined\n\n if (link) {\n switch (link.type) {\n case 'OPEN_PAGE': {\n if (page) {\n useNextLink = true\n\n href = `/${page.pathname}`\n }\n\n target = link.payload.openInNewTab ? '_blank' : '_self'\n\n break\n }\n\n case 'OPEN_URL': {\n useNextLink = true\n\n href = link.payload.url\n\n target = link.payload.openInNewTab ? '_blank' : '_self'\n\n break\n }\n\n case 'SEND_EMAIL': {\n useNextLink = false\n\n const { to, subject = '', body = '' } = link.payload\n\n if (to != null) href = `mailto:${to}?subject=${subject}&body=${body}`\n\n break\n }\n\n case 'CALL_PHONE': {\n useNextLink = false\n\n href = `tel:${link.payload.phoneNumber}`\n\n break\n }\n\n case 'SCROLL_TO_ELEMENT': {\n useNextLink = false\n\n href = `#${elementId ?? ''}`\n\n block = link.payload.block\n\n break\n }\n\n default:\n throw new RangeError(`Invalid link type \"${(link as any).type}.\"`)\n }\n }\n\n function handleClick(event: MouseEvent<HTMLAnchorElement>) {\n onClick(event)\n\n if (event.defaultPrevented) return\n\n /**\n * When we introduced `next/link` instead of just `a` element slate no longer prevented link from navigating within\n * content mode. This is a hack to compensate for what would be expected as slate's default behavior.\n * On upgrade of slate this can be reevaluated.\n */\n if (event.currentTarget.isContentEditable) return event.preventDefault()\n\n if (link && link.type === 'SCROLL_TO_ELEMENT') {\n let hash: string | undefined\n\n try {\n if (href != null) hash = new URL(`http://www.example.com/${href}`).hash\n } catch (error) {\n console.error(`Link received invalid href: ${href}`, error)\n }\n\n if (href != null && hash != null && href === hash) {\n event.preventDefault()\n const view = event.view as unknown as Window\n\n scrollIntoView(view.document.querySelector(hash)!, {\n behavior: 'smooth',\n block,\n })\n\n if (view.location.hash !== hash) view.history.pushState({}, '', hash)\n }\n }\n }\n\n if (useNextLink && href != null) {\n return (\n <NextLink\n {...restOfProps}\n ref={ref}\n target={target}\n onClick={handleClick}\n href={href}\n // Next.js v12 has legacyBehavior set to true by default\n legacyBehavior={false}\n />\n )\n }\n\n // eslint-disable-next-line\n return <a {...restOfProps} ref={ref} href={href} target={target} onClick={handleClick} />\n})\n"],"names":["Link","forwardRef","ref","link","onClick","restOfProps","pageId","type","payload","page","usePagePathnameSlice","elementKey","elementIdConfig","elementId","useElementId","useNextLink","href","target","block","pathname","openInNewTab","url","to","subject","body","phoneNumber","RangeError","handleClick","event","defaultPrevented","currentTarget","isContentEditable","preventDefault","hash","URL","error","view","scrollIntoView","document","querySelector","behavior","location","history","pushState","NextLink"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeaA,MAAAA,OAAOC,MAAAA,WAAqC,eACvD,IACAC,KACA;AAFA,eAAEC;AAAAA;AAAAA,IAAMC,UAAU,MAAM;AAAA,IAAE;AAAA,MAA1B,IAA+BC,wBAA/B,IAA+BA;AAAAA,IAA7BF;AAAAA,IAAMC;AAAAA;;AAGR,QAAME,SAASH,QAAQA,KAAKI,SAAS,cAAcJ,KAAKK,QAAQF,SAAS;AACnEG,QAAAA,OAAOC,KAAAA,qBAAqBJ,0BAAU,IAAX;AACjC,QAAMK,aACJR,8BAAMI,UAAS,sBAAsBJ,YAAKK,QAAQI,oBAAbT,oBAA8BQ,aAAa;AAC5EE,QAAAA,YAAYC,kBAAaH,UAAD;AAI1BI,MAAAA;AACAC,MAAAA;AACAC,MAAAA;AACAC,MAAAA;AAEJ,MAAIf,MAAM;AACAA,YAAAA,KAAKI;AAAAA,WACN,aAAa;AAChB,YAAIE,MAAM;AACM,wBAAA;AAEdO,iBAAQ,IAAGP,KAAKU;AAAAA,QACjB;AAEQhB,iBAAAA,KAAKK,QAAQY,eAAe,WAAW;AAEhD;AAAA,MACD;AAAA,WAEI,YAAY;AACD,sBAAA;AAEdJ,eAAOb,KAAKK,QAAQa;AAEXlB,iBAAAA,KAAKK,QAAQY,eAAe,WAAW;AAEhD;AAAA,MACD;AAAA,WAEI,cAAc;AACH,sBAAA;AAER,cAAA;AAAA,UAAEE;AAAAA,UAAIC,UAAU;AAAA,UAAIC,OAAO;AAAA,YAAOrB,KAAKK;AAE7C,YAAIc,MAAM;AAAc,iBAAA,UAASA,cAAcC,gBAAgBC;AAE/D;AAAA,MACD;AAAA,WAEI,cAAc;AACH,sBAAA;AAEN,eAAA,OAAMrB,KAAKK,QAAQiB;AAE3B;AAAA,MACD;AAAA,WAEI,qBAAqB;AACV,sBAAA;AAEdT,eAAQ,IAAGH,gCAAa;AAExBK,gBAAQf,KAAKK,QAAQU;AAErB;AAAA,MACD;AAAA;AAGO,cAAA,IAAIQ,WAAY,sBAAsBvB,KAAaI,QAAnD;AAAA;AAAA,EAEX;AAEQoB,uBAAYC,OAAsC;AACzDxB,YAAQwB,KAAD;AAEHA,QAAAA,MAAMC;AAAkB;AAOxBD,QAAAA,MAAME,cAAcC;AAAmB,aAAOH,MAAMI;AAEpD7B,QAAAA,QAAQA,KAAKI,SAAS,qBAAqB;AACzC0B,UAAAA;AAEA,UAAA;AACF,YAAIjB,QAAQ;AAAMiB,iBAAO,IAAIC,IAAK,0BAAyBlB,MAAlC,EAA0CiB;AAAAA,eAC5DE;AACCA,gBAAAA,MAAO,+BAA8BnB,QAAQmB,KAArD;AAAA,MACD;AAEGnB,UAAAA,QAAQ,QAAQiB,QAAQ,QAAQjB,SAASiB,MAAM;AACjDL,cAAMI,eAAN;AACMI,cAAAA,OAAOR,MAAMQ;AAEnBC,gCAAAA,WAAeD,KAAKE,SAASC,cAAcN,IAA5B,GAAoC;AAAA,UACjDO,UAAU;AAAA,UACVtB;AAAAA,QAAAA,CAFY;AAKVkB,YAAAA,KAAKK,SAASR,SAASA;AAAMG,eAAKM,QAAQC,UAAU,IAAI,IAAIV,IAA/B;AAAA,MAClC;AAAA,IACF;AAAA,EACF;AAEGlB,MAAAA,eAAeC,QAAQ,MAAM;AAE7B,0CAAC4B,kBAAAA,YAAD,iCACMvC,cADN;AAAA,MAEE;AAAA,MACA;AAAA,MACA,SAASsB;AAAAA,MACT;AAAA,MAEA,gBAAgB;AAAA,IAAA,EARpB;AAAA,EAWD;AAGD,8EAActB;IAAa;AAAA,IAAU;AAAA,IAAY;AAAA,IAAgB,SAASsB;AAAAA,EAAAA,EAA1E;AACD,CA7H6B;;"}
1
+ {"version":3,"file":"index.cjs3.js","sources":["../src/components/shared/GutterContainer/index.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef } from 'react'\nimport { ResponsiveValue, Length } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\n\ntype BaseProps = {\n className?: string\n gutter?: ResponsiveValue<Length>\n first: boolean\n last: boolean\n}\n\ntype Props = BaseProps & Omit<ComponentPropsWithoutRef<'div'>, keyof BaseProps>\n\nexport default function GutterContainer({ className, gutter, first, last, ...restOfProps }: Props) {\n return (\n <div\n {...restOfProps}\n className={cx(\n useStyle(\n useResponsiveStyle([gutter] as const, ([gutter = { value: 0, unit: 'px' }]) => ({\n paddingLeft: first ? '0px' : `${gutter.value / 2}${gutter.unit}`,\n paddingRight: last ? '0px' : `${gutter.value / 2}${gutter.unit}`,\n })),\n ),\n className,\n )}\n />\n )\n}\n"],"names":["className","gutter","first","last","restOfProps","cx","useStyle","useResponsiveStyle","value","unit","paddingLeft","paddingRight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAewC,yBAAA,IAA2D;AAA3D,eAAEA;AAAAA;AAAAA,IAAWC;AAAAA,IAAQC;AAAAA,IAAOC;AAAAA,MAA5B,IAAqCC,wBAArC,IAAqCA;AAAAA,IAAnCJ;AAAAA,IAAWC;AAAAA,IAAQC;AAAAA,IAAOC;AAAAA;AAClE,gFAEQC;IACJ,WAAWC,OACTC,mBACEC,KAAAA,mBAAmB,CAACN,MAAD,GAAmB,CAAC,CAACA,UAAS;AAAA,MAAEO,OAAO;AAAA,MAAGC,MAAM;AAAA,IAAA,OAAa;AAAA,MAC9EC,aAAaR,QAAQ,QAAS,GAAED,QAAOO,QAAQ,IAAIP,QAAOQ;AAAAA,MAC1DE,cAAcR,OAAO,QAAS,GAAEF,QAAOO,QAAQ,IAAIP,QAAOQ;AAAAA,IAAAA,EAF1C,CADZ,GAMRT,SAPW;AAAA,EAAA,EAHjB;AAcD;;"}
@@ -1,60 +1,19 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __spreadValues = (a, b) => {
10
- for (var prop in b || (b = {}))
11
- if (__hasOwnProp.call(b, prop))
12
- __defNormalProp(a, prop, b[prop]);
13
- if (__getOwnPropSymbols)
14
- for (var prop of __getOwnPropSymbols(b)) {
15
- if (__propIsEnum.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- }
18
- return a;
19
- };
20
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
- var __objRest = (source, exclude) => {
22
- var target = {};
23
- for (var prop in source)
24
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
- target[prop] = source[prop];
26
- if (source != null && __getOwnPropSymbols)
27
- for (var prop of __getOwnPropSymbols(source)) {
28
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
- target[prop] = source[prop];
30
- }
31
- return target;
32
- };
33
- var css = require("@emotion/css");
34
- var reactPage = require("./react-page.cjs.js");
35
- var next = require("./index.cjs.js");
36
- var jsxRuntime = require("react/jsx-runtime");
37
- function GutterContainer(_a) {
38
- var _b = _a, {
39
- className,
40
- gutter,
41
- first,
42
- last
43
- } = _b, restOfProps = __objRest(_b, [
44
- "className",
45
- "gutter",
46
- "first",
47
- "last"
48
- ]);
49
- return /* @__PURE__ */ jsxRuntime.jsx("div", __spreadProps(__spreadValues({}, restOfProps), {
50
- className: css.cx(reactPage.useStyle(next.useResponsiveStyle([gutter], ([gutter2 = {
51
- value: 0,
52
- unit: "px"
53
- }]) => ({
54
- paddingLeft: first ? "0px" : `${gutter2.value / 2}${gutter2.unit}`,
55
- paddingRight: last ? "0px" : `${gutter2.value / 2}${gutter2.unit}`
56
- }))), className)
57
- }));
2
+ var slate = require("slate");
3
+ var slateReact = require("slate-react");
4
+ function withBuilder(editor) {
5
+ editor.deselectAndBlur = function() {
6
+ slateReact.ReactEditor.deselect(editor);
7
+ slateReact.ReactEditor.blur(editor);
8
+ };
9
+ editor.focusAndSelectAll = function() {
10
+ slateReact.ReactEditor.focus(editor);
11
+ slate.Transforms.select(editor, {
12
+ anchor: slate.Editor.start(editor, []),
13
+ focus: slate.Editor.end(editor, [])
14
+ });
15
+ };
16
+ return editor;
58
17
  }
59
- exports.GutterContainer = GutterContainer;
18
+ exports.withBuilder = withBuilder;
60
19
  //# sourceMappingURL=index.cjs4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs4.js","sources":["../src/components/shared/GutterContainer/index.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ComponentPropsWithoutRef } from 'react'\nimport { ResponsiveValue, Length } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\n\ntype BaseProps = {\n className?: string\n gutter?: ResponsiveValue<Length>\n first: boolean\n last: boolean\n}\n\ntype Props = BaseProps & Omit<ComponentPropsWithoutRef<'div'>, keyof BaseProps>\n\nexport default function GutterContainer({ className, gutter, first, last, ...restOfProps }: Props) {\n return (\n <div\n {...restOfProps}\n className={cx(\n useStyle(\n useResponsiveStyle([gutter] as const, ([gutter = { value: 0, unit: 'px' }]) => ({\n paddingLeft: first ? '0px' : `${gutter.value / 2}${gutter.unit}`,\n paddingRight: last ? '0px' : `${gutter.value / 2}${gutter.unit}`,\n })),\n ),\n className,\n )}\n />\n )\n}\n"],"names":["className","gutter","first","last","restOfProps","cx","useStyle","useResponsiveStyle","value","unit","paddingLeft","paddingRight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAewC,yBAAA,IAA2D;AAA3D,eAAEA;AAAAA;AAAAA,IAAWC;AAAAA,IAAQC;AAAAA,IAAOC;AAAAA,MAA5B,IAAqCC,wBAArC,IAAqCA;AAAAA,IAAnCJ;AAAAA,IAAWC;AAAAA,IAAQC;AAAAA,IAAOC;AAAAA;AAClE,gFAEQC;IACJ,WAAWC,OACTC,mBACEC,KAAAA,mBAAmB,CAACN,MAAD,GAAmB,CAAC,CAACA,UAAS;AAAA,MAAEO,OAAO;AAAA,MAAGC,MAAM;AAAA,IAAA,OAAa;AAAA,MAC9EC,aAAaR,QAAQ,QAAS,GAAED,QAAOO,QAAQ,IAAIP,QAAOQ;AAAAA,MAC1DE,cAAcR,OAAO,QAAS,GAAEF,QAAOO,QAAQ,IAAIP,QAAOQ;AAAAA,IAAAA,EAF1C,CADZ,GAMRT,SAPW;AAAA,EAAA,EAHjB;AAcD;;"}
1
+ {"version":3,"file":"index.cjs4.js","sources":["../src/slate/BuilderPlugin/index.ts"],"sourcesContent":["import { BaseEditor, Editor, Transforms } from 'slate'\nimport { ReactEditor } from 'slate-react'\n\nexport interface BuilderEditor extends BaseEditor {\n focusAndSelectAll: () => void\n deselectAndBlur: () => void\n}\n\nexport function withBuilder(editor: Editor) {\n editor.deselectAndBlur = function () {\n ReactEditor.deselect(editor)\n ReactEditor.blur(editor)\n }\n\n editor.focusAndSelectAll = function () {\n ReactEditor.focus(editor)\n Transforms.select(editor, {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n })\n }\n\n return editor\n}\n"],"names":["ReactEditor","Transforms","Editor"],"mappings":";;;AAQO,qBAAqB,QAAgB;AAC1C,SAAO,kBAAkB,WAAY;AACnCA,2BAAY,SAAS,MAAM;AAC3BA,2BAAY,KAAK,MAAM;AAAA,EAAA;AAGzB,SAAO,oBAAoB,WAAY;AACrCA,2BAAY,MAAM,MAAM;AACxBC,UAAA,WAAW,OAAO,QAAQ;AAAA,MACxB,QAAQC,MAAA,OAAO,MAAM,QAAQ,CAAA,CAAE;AAAA,MAC/B,OAAOA,MAAA,OAAO,IAAI,QAAQ,CAAA,CAAE;AAAA,IAAA,CAC7B;AAAA,EAAA;AAGI,SAAA;AACT;;"}
@@ -18,259 +18,70 @@ var __spreadValues = (a, b) => {
18
18
  return a;
19
19
  };
20
20
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
- var slate = require("slate");
22
- var state_breakpoints = require("./state/breakpoints.cjs.js");
23
21
  var reactPage = require("./react-page.cjs.js");
24
- require("./actions.cjs.js");
25
- var types = require("./types.cjs2.js");
26
- function clearActiveTypographyStyle(editor, options) {
27
- slate.Editor.withoutNormalizing(editor, () => {
28
- var _a;
29
- const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
30
- if (!at)
31
- return;
32
- const atRef = slate.Editor.rangeRef(editor, at);
33
- if (atRef.current) {
34
- slate.Transforms.setNodes(editor, {
35
- slice: true
36
- }, {
37
- at: atRef.current,
38
- match: (node) => slate.Text.isText(node),
39
- split: slate.Range.isExpanded(atRef.current)
40
- });
41
- }
42
- if (atRef.current) {
43
- const textNodes = Array.from(slate.Editor.nodes(editor, {
44
- at: atRef.current,
45
- match: (node) => slate.Text.isText(node) && node.slice === true
46
- }));
47
- for (const [node, path] of textNodes) {
48
- if (slate.Text.isText(node)) {
49
- const typography = __spreadProps(__spreadValues({}, node.typography), {
50
- style: []
51
- });
52
- slate.Transforms.setNodes(editor, {
53
- typography
54
- }, { at: path });
55
- }
56
- }
57
- }
58
- atRef.unref();
59
- });
60
- }
61
- function clearDeviceActiveTypography(editor, currentDeviceId, options) {
62
- slate.Editor.withoutNormalizing(editor, () => {
63
- var _a, _b, _c;
64
- const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
65
- if (!at)
66
- return;
67
- const atRef = slate.Editor.rangeRef(editor, at);
68
- if (atRef.current) {
69
- slate.Transforms.setNodes(editor, {
70
- slice: true
71
- }, {
72
- at: atRef.current,
73
- match: (node) => slate.Text.isText(node),
74
- split: slate.Range.isExpanded(atRef.current)
75
- });
76
- }
77
- if (atRef.current) {
78
- const textNodes = Array.from(slate.Editor.nodes(editor, {
79
- at: atRef.current,
80
- match: (node) => slate.Text.isText(node) && node.slice === true
81
- }));
82
- for (const [node, path] of textNodes) {
83
- if (slate.Text.isText(node)) {
84
- const typography = __spreadProps(__spreadValues({}, node.typography), {
85
- style: (_c = (_b = node == null ? void 0 : node.typography) == null ? void 0 : _b.style.filter(({ deviceId }) => deviceId !== currentDeviceId)) != null ? _c : []
86
- });
87
- slate.Transforms.setNodes(editor, {
88
- typography
89
- }, { at: path });
90
- }
91
- }
92
- }
93
- atRef.unref();
94
- });
95
- }
96
- function detachActiveTypography(editor, value, options) {
97
- slate.Editor.withoutNormalizing(editor, () => {
98
- var _a;
99
- const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
100
- if (!at)
101
- return;
102
- const atRef = slate.Editor.rangeRef(editor, at);
103
- if (atRef.current) {
104
- slate.Transforms.setNodes(editor, {
105
- slice: true
106
- }, {
107
- at: atRef.current,
108
- match: (node) => slate.Text.isText(node),
109
- split: slate.Range.isExpanded(atRef.current)
110
- });
111
- }
112
- if (atRef.current) {
113
- const textNodes = Array.from(slate.Editor.nodes(editor, {
114
- at: atRef.current,
115
- match: (node) => slate.Text.isText(node) && node.slice === true
116
- }));
117
- for (const [node, path] of textNodes) {
118
- if (slate.Text.isText(node)) {
119
- slate.Transforms.setNodes(editor, {
120
- typography: {
121
- style: value
122
- }
123
- }, { at: path });
124
- }
125
- }
126
- }
127
- atRef.unref();
128
- });
129
- }
130
- function setActiveTypographyId(editor, id, options) {
22
+ var next = require("./index.cjs.js");
23
+ var css = require("@emotion/css");
24
+ var jsxRuntime = require("react/jsx-runtime");
25
+ const withLink = (editor) => {
26
+ const {
27
+ isInline
28
+ } = editor;
29
+ editor.isInline = (entry) => {
30
+ return reactPage.ElementUtils.isInline(entry) && isInline(entry);
31
+ };
32
+ return editor;
33
+ };
34
+ function InlinePluginComponent({
35
+ element,
36
+ attributes,
37
+ children,
38
+ renderElement
39
+ }) {
131
40
  var _a;
132
- const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
133
- if (!at)
134
- return;
135
- slate.Transforms.setNodes(editor, {
136
- typography: {
137
- id,
138
- style: []
139
- }
140
- }, {
141
- at,
142
- match: (node) => slate.Text.isText(node),
143
- split: slate.Range.isExpanded(at)
41
+ const linkStyle = reactPage.useStyle({
42
+ textDecoration: "none"
144
43
  });
145
- }
146
- function setActiveTypographyStyle(editor, breakpoints, deviceId, prop, value, options) {
147
- slate.Editor.withoutNormalizing(editor, () => {
148
- var _a, _b, _c;
149
- const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
150
- if (!at)
151
- return;
152
- const atRef = slate.Editor.rangeRef(editor, at);
153
- if (atRef.current) {
154
- slate.Transforms.setNodes(editor, {
155
- slice: true
156
- }, {
157
- at: atRef.current,
158
- match: (node) => slate.Text.isText(node),
159
- split: slate.Range.isExpanded(atRef.current)
160
- });
161
- }
162
- if (atRef.current) {
163
- const textNodes = Array.from(slate.Editor.nodes(editor, {
164
- at: atRef.current,
165
- match: (node) => slate.Text.isText(node) && node.slice === true
44
+ switch (element.type) {
45
+ case reactPage.InlineType.Link:
46
+ return /* @__PURE__ */ jsxRuntime.jsx(next.Link, __spreadProps(__spreadValues({}, attributes), {
47
+ link: (_a = element.link) != null ? _a : void 0,
48
+ className: css.cx(linkStyle, element.className),
49
+ children: renderElement({
50
+ element,
51
+ attributes,
52
+ children
53
+ })
166
54
  }));
167
- for (const [node, path] of textNodes) {
168
- if (slate.Text.isText(node)) {
169
- const deviceOverrides = (_c = (_b = node == null ? void 0 : node.typography) == null ? void 0 : _b.style) != null ? _c : [];
170
- const deviceStyle = state_breakpoints.findBreakpointOverride(breakpoints, deviceOverrides, deviceId, (v) => v) || {
171
- value: {}
172
- };
173
- const nextDeviceStyle = {
174
- deviceId,
175
- value: __spreadProps(__spreadValues({}, deviceStyle.value), { [prop]: value })
176
- };
177
- const nextTypography = __spreadProps(__spreadValues({}, node.typography), {
178
- style: [...deviceOverrides.filter((v) => v.deviceId !== deviceId), nextDeviceStyle]
179
- });
180
- slate.Transforms.setNodes(editor, {
181
- typography: nextTypography
182
- }, { at: path });
183
- }
184
- }
185
- }
186
- atRef.unref();
187
- });
188
- }
189
- function getValue(editor) {
190
- const matchingValues = Array.from(slate.Editor.nodes(editor, {
191
- at: types.getSelection(editor),
192
- match: slate.Text.isText
193
- })).map(([node]) => node["typography"]);
194
- return matchingValues;
195
- }
196
- const TypographyActions = {
197
- setActiveTypographyId,
198
- setActiveTypographyStyle,
199
- clearActiveTypographyStyle,
200
- clearDeviceActiveTypography,
201
- detachActiveTypography
202
- };
203
- const TYPOGRAPHY_KEY = "typography";
204
- function withTypography(editor) {
205
- const { normalizeNode } = editor;
206
- editor.normalizeNode = (entry) => {
207
- var _a, _b;
208
- const [normalizationNode, normalizationPath] = entry;
209
- if (slate.Text.isText(normalizationNode) && ((_a = normalizationNode == null ? void 0 : normalizationNode.typography) == null ? void 0 : _a.id) == null && ((_b = normalizationNode == null ? void 0 : normalizationNode.typography) == null ? void 0 : _b.style.length) === 0) {
210
- slate.Transforms.unsetNodes(editor, TYPOGRAPHY_KEY, { at: normalizationPath });
211
- return;
212
- }
213
- if (slate.Text.isText(normalizationNode) && (normalizationNode == null ? void 0 : normalizationNode.slice) != null) {
214
- slate.Transforms.unsetNodes(editor, "slice", { at: normalizationPath });
215
- return;
216
- }
217
- normalizeNode(entry);
218
- };
219
- return editor;
55
+ default:
56
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
57
+ children: renderElement({
58
+ element,
59
+ attributes,
60
+ children
61
+ })
62
+ });
63
+ }
220
64
  }
221
- function TypographyPlugin() {
65
+ function LinkPlugin() {
222
66
  return reactPage.createRichTextV2Plugin({
223
- withPlugin: withTypography,
224
67
  control: {
225
- definition: reactPage.unstable_Typography(),
226
- onChange: (editor, value) => {
227
- slate.Editor.withoutNormalizing(editor, () => {
228
- const at = types.getSelection(editor);
229
- if (!at)
230
- return;
231
- const atRef = slate.Editor.rangeRef(editor, at);
232
- if (atRef.current) {
233
- slate.Transforms.setNodes(editor, {
234
- slice: true
235
- }, {
236
- at: atRef.current,
237
- match: slate.Text.isText,
238
- split: true
239
- });
240
- }
241
- if (atRef.current) {
242
- const nodesToUpdate = Array.from(slate.Editor.nodes(editor, {
243
- at: atRef.current,
244
- match: (node) => slate.Text.isText(node) && node.slice === true
245
- }));
246
- if (nodesToUpdate.length !== (value == null ? void 0 : value.length))
247
- return console.error(`TypographyControl.onChange received the wrong number of arguments.
248
- Called with ${value == null ? void 0 : value.length} values mapping to ${nodesToUpdate.length} nodes.`);
249
- for (const [index, [, path]] of nodesToUpdate.entries()) {
250
- slate.Transforms.setNodes(editor, {
251
- typography: value == null ? void 0 : value.at(index)
252
- }, { at: path, match: slate.Text.isText });
253
- }
254
- }
255
- atRef.unref();
256
- });
257
- },
258
- getValue: (editor) => getValue(editor),
259
- getLeafValue: (text) => {
260
- return slate.Text.isText(text) ? text.typography : void 0;
68
+ definition: reactPage.Link$1({
69
+ label: "On Click"
70
+ }),
71
+ onChange: reactPage.onChange,
72
+ getValue: reactPage.getValue,
73
+ getElementValue: (element) => {
74
+ return reactPage.ElementUtils.isInline(element) && reactPage.isLinkElement(element) ? element.link : void 0;
261
75
  }
262
76
  },
263
- renderLeaf: (renderLeaf, className) => (props) => {
264
- return renderLeaf(__spreadProps(__spreadValues({}, props), {
265
- leaf: __spreadProps(__spreadValues({}, props.leaf), {
266
- className: `${props.leaf.className} ${className}`
267
- })
77
+ withPlugin: withLink,
78
+ renderElement: (renderElement) => (props) => {
79
+ return /* @__PURE__ */ jsxRuntime.jsx(InlinePluginComponent, __spreadProps(__spreadValues({}, props), {
80
+ renderElement
268
81
  }));
269
82
  }
270
83
  });
271
84
  }
272
- exports.TYPOGRAPHY_KEY = TYPOGRAPHY_KEY;
273
- exports.TypographyActions = TypographyActions;
274
- exports.TypographyPlugin = TypographyPlugin;
275
- exports.withTypography = withTypography;
85
+ exports.LinkPlugin = LinkPlugin;
86
+ exports.withLink = withLink;
276
87
  //# sourceMappingURL=index.cjs5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs5.js","sources":["../src/slate/TypographyPlugin/clearActiveTypographyStyle.ts","../src/slate/TypographyPlugin/clearDeviceActiveTypography.ts","../src/slate/TypographyPlugin/detachActiveTypography.ts","../src/slate/TypographyPlugin/setActiveTypographyId.ts","../src/slate/TypographyPlugin/setActiveTypographyStyle.ts","../src/slate/TypographyPlugin/getValue.tsx","../src/slate/TypographyPlugin/index.ts"],"sourcesContent":["import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype ClearActiveTypographyStyleOptions = {\n at?: Range\n}\n\nexport function clearActiveTypographyStyle(\n editor: Editor,\n options?: ClearActiveTypographyStyleOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const typography: RichTextTypography = {\n ...node.typography,\n style: [],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype ClearDeviceActiveTypographyOptions = {\n at?: Range\n}\n\nexport function clearDeviceActiveTypography(\n editor: Editor,\n currentDeviceId: string,\n options?: ClearDeviceActiveTypographyOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const typography: RichTextTypography = {\n ...node.typography,\n style:\n node?.typography?.style.filter(({ deviceId }) => deviceId !== currentDeviceId) ?? [],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { RichTextTypography } from '../types'\n\ntype SetActiveTypographyIdOptions = {\n at?: Range\n}\n\nexport function detachActiveTypography(\n editor: Editor,\n value: RichTextTypography['style'],\n options?: SetActiveTypographyIdOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n Transforms.setNodes(\n editor,\n {\n typography: {\n style: value,\n },\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\n\ntype SetActiveTypographyIdOptions = {\n at?: Range\n}\n\nexport function setActiveTypographyId(\n editor: Editor,\n id?: string,\n options?: SetActiveTypographyIdOptions,\n) {\n const at = options?.at ?? editor.selection\n if (!at) return\n Transforms.setNodes(\n editor,\n {\n typography: {\n id,\n style: [],\n },\n },\n {\n at,\n match: node => Text.isText(node),\n split: Range.isExpanded(at),\n },\n )\n}\n","import { Editor, Transforms, Text, Range } from 'slate'\nimport { Breakpoints, findBreakpointOverride, BreakpointId } from '../../state/modules/breakpoints'\nimport { RichTextTypography } from '../types'\n\ntype SetActiveTypographyStyleOptions = {\n at?: Range\n}\n\nexport function setActiveTypographyStyle(\n editor: Editor,\n breakpoints: Breakpoints,\n deviceId: string,\n prop: string,\n value?: unknown,\n options?: SetActiveTypographyStyleOptions,\n) {\n Editor.withoutNormalizing(editor, () => {\n const at = options?.at ?? editor.selection\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n\n if (atRef.current) {\n Transforms.setNodes(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: node => Text.isText(node),\n split: Range.isExpanded(atRef.current),\n },\n )\n }\n\n if (atRef.current) {\n const textNodes = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n )\n\n for (const [node, path] of textNodes) {\n if (Text.isText(node)) {\n const deviceOverrides = node?.typography?.style ?? []\n const deviceStyle = findBreakpointOverride(\n breakpoints,\n deviceOverrides,\n deviceId as BreakpointId,\n v => v,\n ) || {\n value: {},\n }\n const nextDeviceStyle = {\n deviceId,\n value: { ...deviceStyle.value, [prop]: value },\n }\n\n const nextTypography: RichTextTypography = {\n ...node.typography,\n style: [...deviceOverrides.filter(v => v.deviceId !== deviceId), nextDeviceStyle],\n }\n\n Transforms.setNodes(\n editor,\n {\n typography: nextTypography,\n },\n { at: path },\n )\n }\n }\n }\n\n atRef.unref()\n })\n}\n","import { Editor, Text } from 'slate'\nimport { RichTextTypography } from '../types'\nimport { getSelection } from '../selectors'\n\nexport function getValue(editor: Editor) {\n const matchingValues = Array.from(\n Editor.nodes(editor, {\n at: getSelection(editor),\n match: Text.isText,\n }),\n ).map(([node]) => node['typography']) as (RichTextTypography | undefined)[]\n\n return matchingValues\n}\n","import { Descendant, Editor, NodeEntry, Text, Transforms } from 'slate'\nimport { clearActiveTypographyStyle } from './clearActiveTypographyStyle'\nimport { clearDeviceActiveTypography } from './clearDeviceActiveTypography'\nimport { detachActiveTypography } from './detachActiveTypography'\nimport { setActiveTypographyId } from './setActiveTypographyId'\nimport { setActiveTypographyStyle } from './setActiveTypographyStyle'\nimport { createRichTextV2Plugin, unstable_Typography } from '../../controls'\nimport { getValue } from './getValue'\nimport { getSelection } from '../selectors'\n\nexport const TypographyActions = {\n setActiveTypographyId,\n setActiveTypographyStyle,\n clearActiveTypographyStyle,\n clearDeviceActiveTypography,\n detachActiveTypography,\n}\n\nexport const TYPOGRAPHY_KEY = 'typography'\n\nexport function withTypography(editor: Editor) {\n const { normalizeNode } = editor\n editor.normalizeNode = entry => {\n const [normalizationNode, normalizationPath] = entry\n if (\n Text.isText(normalizationNode) &&\n normalizationNode?.typography?.id == null &&\n normalizationNode?.typography?.style.length === 0\n ) {\n Transforms.unsetNodes(editor, TYPOGRAPHY_KEY, { at: normalizationPath })\n return\n }\n\n if (Text.isText(normalizationNode) && normalizationNode?.slice != null) {\n Transforms.unsetNodes(editor, 'slice', { at: normalizationPath })\n return\n }\n\n normalizeNode(entry)\n }\n\n return editor\n}\n\nexport function TypographyPlugin() {\n return createRichTextV2Plugin({\n withPlugin: withTypography,\n control: {\n definition: unstable_Typography(),\n onChange: (editor, value) => {\n Editor.withoutNormalizing(editor, () => {\n const at = getSelection(editor)\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n if (atRef.current) {\n Transforms.setNodes<Descendant>(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: Text.isText,\n split: true,\n },\n )\n }\n\n if (atRef.current) {\n const nodesToUpdate = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n ) as NodeEntry<Text>[]\n\n if (nodesToUpdate.length !== value?.length)\n return console.error(\n `TypographyControl.onChange received the wrong number of arguments.\nCalled with ${value?.length} values mapping to ${nodesToUpdate.length} nodes.`,\n )\n\n for (const [index, [, path]] of nodesToUpdate.entries()) {\n Transforms.setNodes(\n editor,\n {\n typography: value?.at(index),\n },\n { at: path, match: Text.isText },\n )\n }\n }\n\n atRef.unref()\n })\n },\n getValue: editor => getValue(editor),\n getLeafValue: (text: Text) => {\n return Text.isText(text) ? text.typography : undefined\n },\n },\n renderLeaf: (renderLeaf, className) => props => {\n return renderLeaf({\n ...props,\n leaf: {\n ...props.leaf,\n className: `${props.leaf.className} ${className}`,\n },\n })\n },\n })\n}\n"],"names":["Editor","Transforms","Text","Range","findBreakpointOverride","editor","matchingValues","Array","from","nodes","at","getSelection","match","isText","map","node","createRichTextV2Plugin","unstable_Typography"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAOO,oCACL,QACA,SACA;AACOA,eAAA,mBAAmB,QAAQ,MAAM;;AAChC,UAAA,KAAK,yCAAS,OAAT,YAAe,OAAO;AACjC,QAAI,CAAC;AAAI;AACT,UAAM,QAAQA,MAAA,OAAO,SAAS,QAAQ,EAAE;AAExC,QAAI,MAAM,SAAS;AACjBC,YAAA,WAAW,SACT,QACA;AAAA,QACE,OAAO;AAAA,MAAA,GAET;AAAA,QACE,IAAI,MAAM;AAAA,QACV,OAAO,CAAA,SAAQC,WAAK,OAAO,IAAI;AAAA,QAC/B,OAAOC,MAAA,MAAM,WAAW,MAAM,OAAO;AAAA,MAAA,CAEzC;AAAA,IACF;AAEA,QAAI,MAAM,SAAS;AACjB,YAAM,YAAY,MAAM,KACtBH,MAAAA,OAAO,MAAM,QAAQ;AAAA,QACnB,IAAI,MAAM;AAAA,QACV,OAAO,CAAQ,SAAAE,WAAK,OAAO,IAAI,KAAK,KAAK,UAAU;AAAA,MACpD,CAAA,CACH;AAEW,iBAAA,CAAC,MAAM,SAAS,WAAW;AAChC,YAAAA,MAAA,KAAK,OAAO,IAAI,GAAG;AACrB,gBAAM,aAAiC,iCAClC,KAAK,aAD6B;AAA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GAET;AAAA,cACE,IAAI,MAAM;AAAA,cACV,OAAOC,MAAK,KAAA;AAAA,cACZ,OAAO;AAAA,YAAA,CAEX;AAAA,UACF;AAEA,cAAI,MAAM,SAAS;AACjB,kBAAM,gBAAgB,MAAM,KAC1BF,MAAAA,OAAO,MAAM,QAAQ;AAAA,cACnB,IAAI,MAAM;AAAA,cACV,OAAO,CAAQ,SAAAE,WAAK,OAAO,IAAI,KAAK,KAAK,UAAU;AAAA,YACpD,CAAA,CACH;AAEI,gBAAA,cAAc,WAAW,gCAAO;AAClC,qBAAO,QAAQ,MACb;AAAA,cACF,+BAAO,4BAA4B,cAAc,eACjD;AAEF,uBAAW,CAAC,OAAO,CAAG,EAAA,UAAU,cAAc,WAAW;AACvDD,oBAAA,WAAW,SACT,QACA;AAAA,gBACE,YAAY,+BAAO,GAAG;AAAA,cAAK,GAE7B,EAAE,IAAI,MAAM,OAAOC,MAAA,KAAK,QAC1B;AAAA,YACF;AAAA,UACF;AAEA,gBAAM,MAAM;AAAA,QAAA,CACb;AAAA,MACH;AAAA,MACA,UAAU,CAAU,WAAA,SAAS,MAAM;AAAA,MACnC,cAAc,CAAC,SAAe;AAC5B,eAAOA,MAAAA,KAAK,OAAO,IAAI,IAAI,KAAK,aAAa;AAAA,MAC/C;AAAA,IACF;AAAA,IACA,YAAY,CAAC,YAAY,cAAc,CAAS,UAAA;AAC9C,aAAO,WAAW,iCACb,QADa;AAAA,QAEhB,MAAM,iCACD,MAAM,OADL;AAAA,UAEJ,WAAW,GAAG,MAAM,KAAK,aAAa;AAAA,QACxC;AAAA,MAAA,EACD;AAAA,IACH;AAAA,EAAA,CACD;AACH;;;;;"}
1
+ {"version":3,"file":"index.cjs5.js","sources":["../src/slate/LinkPlugin/index.tsx"],"sourcesContent":["import { Editor, Element } from 'slate'\nimport { RenderElement, createRichTextV2Plugin } from '../../controls/rich-text-v2/plugin'\nimport { Link } from '../../controls/link'\nimport { ElementUtils } from '../utils/element'\nimport { InlineType } from '../types'\nimport { RenderElementProps } from 'slate-react'\nimport { useStyle } from '../../runtimes/react/use-style'\nimport { Link as LinkComponent } from '../../components/shared/Link'\nimport { cx } from '@emotion/css'\nimport { isLinkElement } from './types'\nimport { onChange } from './onChange'\nimport { getValue } from './getValue'\n\nexport const withLink = (editor: Editor) => {\n const { isInline } = editor\n\n editor.isInline = entry => {\n return ElementUtils.isInline(entry) && isInline(entry)\n }\n\n return editor\n}\n\nfunction InlinePluginComponent({\n element,\n attributes,\n children,\n renderElement,\n}: RenderElementProps & { renderElement: RenderElement }) {\n const linkStyle = useStyle({ textDecoration: 'none' })\n switch (element.type) {\n case InlineType.Link:\n return (\n <LinkComponent\n {...attributes}\n link={element.link ?? undefined}\n className={cx(linkStyle, element.className)}\n >\n {renderElement({\n element,\n attributes,\n children,\n })}\n </LinkComponent>\n )\n\n default:\n return (\n <>\n {renderElement({\n element,\n attributes,\n children,\n })}\n </>\n )\n }\n}\n\nexport function LinkPlugin() {\n return createRichTextV2Plugin({\n control: {\n definition: Link({\n label: 'On Click',\n }),\n onChange,\n getValue,\n getElementValue: (element: Element) => {\n return ElementUtils.isInline(element) && isLinkElement(element) ? element.link : undefined\n },\n },\n withPlugin: withLink,\n renderElement: renderElement => props => {\n return <InlinePluginComponent {...props} renderElement={renderElement} />\n },\n })\n}\n"],"names":["withLink","editor","isInline","entry","ElementUtils","element","attributes","children","renderElement","linkStyle","useStyle","textDecoration","type","InlineType","Link","LinkComponent","link","undefined","cx","className","_Fragment","createRichTextV2Plugin","control","definition","label","onChange","getValue","getElementValue","isLinkElement","withPlugin","props"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAaaA,MAAAA,WAAW,CAACC,WAAmB;AACpC,QAAA;AAAA,IAAEC;AAAAA,MAAaD;AAErBA,SAAOC,WAAWC,CAAS,UAAA;AAClBC,WAAAA,UAAAA,aAAaF,SAASC,KAAtB,KAAgCD,SAASC,KAAD;AAAA,EAAA;AAG1CF,SAAAA;AACR;AAED,+BAA+B;AAAA,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