@makeswift/runtime 0.10.3 → 0.10.4

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 (146) hide show
  1. package/dist/Box.cjs.js +1 -3
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +2 -4
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +4 -4
  6. package/dist/Button.es.js +5 -5
  7. package/dist/Carousel.cjs.js +3 -3
  8. package/dist/Carousel.es.js +4 -4
  9. package/dist/Countdown.cjs.js +1 -3
  10. package/dist/Countdown.cjs.js.map +1 -1
  11. package/dist/Countdown.es.js +2 -4
  12. package/dist/Countdown.es.js.map +1 -1
  13. package/dist/Divider.cjs.js +1 -3
  14. package/dist/Divider.cjs.js.map +1 -1
  15. package/dist/Divider.es.js +2 -4
  16. package/dist/Divider.es.js.map +1 -1
  17. package/dist/Embed.cjs.js +1 -0
  18. package/dist/Embed.cjs.js.map +1 -1
  19. package/dist/Embed.es.js +2 -1
  20. package/dist/Embed.es.js.map +1 -1
  21. package/dist/Form.cjs.js +13 -13
  22. package/dist/Form.cjs.js.map +1 -1
  23. package/dist/Form.es.js +5 -5
  24. package/dist/Image.cjs.js +13 -13
  25. package/dist/Image.cjs.js.map +1 -1
  26. package/dist/Image.es.js +13 -13
  27. package/dist/LiveProvider.cjs.js +1 -3
  28. package/dist/LiveProvider.cjs.js.map +1 -1
  29. package/dist/LiveProvider.es.js +3 -5
  30. package/dist/LiveProvider.es.js.map +1 -1
  31. package/dist/Navigation.cjs.js +12 -12
  32. package/dist/Navigation.cjs.js.map +1 -1
  33. package/dist/Navigation.es.js +12 -12
  34. package/dist/PreviewProvider.cjs.js +1 -3
  35. package/dist/PreviewProvider.cjs.js.map +1 -1
  36. package/dist/PreviewProvider.es.js +3 -5
  37. package/dist/PreviewProvider.es.js.map +1 -1
  38. package/dist/ReadOnlyText.cjs.js +7 -6
  39. package/dist/ReadOnlyText.cjs.js.map +1 -1
  40. package/dist/ReadOnlyText.es.js +4 -3
  41. package/dist/ReadOnlyText.es.js.map +1 -1
  42. package/dist/ReadOnlyTextV2.cjs.js +7 -60
  43. package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
  44. package/dist/ReadOnlyTextV2.es.js +9 -62
  45. package/dist/ReadOnlyTextV2.es.js.map +1 -1
  46. package/dist/Root.cjs.js +1 -3
  47. package/dist/Root.cjs.js.map +1 -1
  48. package/dist/Root.es.js +2 -4
  49. package/dist/Root.es.js.map +1 -1
  50. package/dist/SocialLinks.cjs.js +6 -6
  51. package/dist/SocialLinks.cjs.js.map +1 -1
  52. package/dist/SocialLinks.es.js +7 -7
  53. package/dist/Video.cjs.js +1 -0
  54. package/dist/Video.cjs.js.map +1 -1
  55. package/dist/Video.es.js +2 -1
  56. package/dist/Video.es.js.map +1 -1
  57. package/dist/builder.cjs.js +1 -0
  58. package/dist/builder.cjs.js.map +1 -1
  59. package/dist/builder.es.js +1 -0
  60. package/dist/builder.es.js.map +1 -1
  61. package/dist/components.cjs.js +3 -3
  62. package/dist/components.es.js +3 -3
  63. package/dist/control-serialization.es.js +1 -1
  64. package/dist/controls.cjs.js +1 -0
  65. package/dist/controls.cjs.js.map +1 -1
  66. package/dist/controls.es.js +2 -1
  67. package/dist/controls.es.js.map +1 -1
  68. package/dist/index.cjs.js +120 -256
  69. package/dist/index.cjs.js.map +1 -1
  70. package/dist/index.cjs3.js +107 -21
  71. package/dist/index.cjs3.js.map +1 -1
  72. package/dist/index.cjs4.js +57 -16
  73. package/dist/index.cjs4.js.map +1 -1
  74. package/dist/index.cjs5.js +42 -81
  75. package/dist/index.cjs5.js.map +1 -1
  76. package/dist/index.cjs6.js +82 -17
  77. package/dist/index.cjs6.js.map +1 -1
  78. package/dist/index.cjs7.js +18 -377
  79. package/dist/index.cjs7.js.map +1 -1
  80. package/dist/index.cjs8.js +258 -181
  81. package/dist/index.cjs8.js.map +1 -1
  82. package/dist/index.cjs9.js +343 -0
  83. package/dist/index.cjs9.js.map +1 -0
  84. package/dist/index.es.js +125 -260
  85. package/dist/index.es.js.map +1 -1
  86. package/dist/index.es2.js +1 -1
  87. package/dist/index.es3.js +103 -22
  88. package/dist/index.es3.js.map +1 -1
  89. package/dist/index.es4.js +57 -16
  90. package/dist/index.es4.js.map +1 -1
  91. package/dist/index.es5.js +42 -80
  92. package/dist/index.es5.js.map +1 -1
  93. package/dist/index.es6.js +81 -17
  94. package/dist/index.es6.js.map +1 -1
  95. package/dist/index.es7.js +18 -371
  96. package/dist/index.es7.js.map +1 -1
  97. package/dist/index.es8.js +259 -182
  98. package/dist/index.es8.js.map +1 -1
  99. package/dist/index.es9.js +336 -0
  100. package/dist/index.es9.js.map +1 -0
  101. package/dist/main.cjs.js +1 -0
  102. package/dist/main.cjs.js.map +1 -1
  103. package/dist/main.es.js +1 -0
  104. package/dist/main.es.js.map +1 -1
  105. package/dist/next.cjs.js +1 -3
  106. package/dist/next.cjs.js.map +1 -1
  107. package/dist/next.es.js +2 -4
  108. package/dist/next.es.js.map +1 -1
  109. package/dist/prop-controllers.cjs.js +1 -0
  110. package/dist/prop-controllers.cjs.js.map +1 -1
  111. package/dist/prop-controllers.es.js +1 -0
  112. package/dist/prop-controllers.es.js.map +1 -1
  113. package/dist/react-page.cjs.js +26 -6
  114. package/dist/react-page.cjs.js.map +1 -1
  115. package/dist/react-page.es.js +26 -7
  116. package/dist/react-page.es.js.map +1 -1
  117. package/dist/react.cjs.js +1 -3
  118. package/dist/react.cjs.js.map +1 -1
  119. package/dist/react.es.js +1 -3
  120. package/dist/react.es.js.map +1 -1
  121. package/dist/slate.cjs.js +9 -6
  122. package/dist/slate.cjs.js.map +1 -1
  123. package/dist/slate.es.js +9 -7
  124. package/dist/slate.es.js.map +1 -1
  125. package/dist/toText.cjs.js +67 -0
  126. package/dist/toText.cjs.js.map +1 -0
  127. package/dist/toText.es.js +66 -0
  128. package/dist/toText.es.js.map +1 -0
  129. package/dist/types/src/components/builtin/Text/register.d.ts.map +1 -1
  130. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +2 -4
  131. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  132. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
  133. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -1
  134. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts +10 -0
  135. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts.map +1 -0
  136. package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
  137. package/dist/types/src/slate/BuilderPlugin/index.d.ts +2 -1
  138. package/dist/types/src/slate/BuilderPlugin/index.d.ts.map +1 -1
  139. package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
  140. package/dist/types/src/slate/index.d.ts +1 -0
  141. package/dist/types/src/slate/index.d.ts.map +1 -1
  142. package/dist/types/src/slate/utils/index.d.ts +2 -0
  143. package/dist/types/src/slate/utils/index.d.ts.map +1 -0
  144. package/dist/types/src/slate/utils/toText.d.ts +4 -0
  145. package/dist/types/src/slate/utils/toText.d.ts.map +1 -0
  146. package/package.json +1 -1
package/dist/index.es2.js CHANGED
@@ -30,7 +30,7 @@ var __objRest = (source, exclude) => {
30
30
  return target;
31
31
  };
32
32
  import { useMemo, useState, useEffect, useCallback, useRef, forwardRef, createElement, Children } from "react";
33
- import { aD as getBackgroundsFileIds, aE as getBackgroundsSwatchIds, _ as useStyle } from "./react-page.es.js";
33
+ import { aC as getBackgroundsFileIds, aD as getBackgroundsSwatchIds, Z as useStyle } from "./react-page.es.js";
34
34
  import "use-sync-external-store/shim";
35
35
  import { B as isNonNullable, F as useFiles, G as useSwatches, v as useResponsiveGridItem, c as DEFAULT_BOX_ANIMATE_TYPE, f as DEFAULT_ITEM_ANIMATE_TYPE, e as DEFAULT_BOX_ANIMATE_DURATION, d as DEFAULT_BOX_ANIMATE_DELAY, i as DEFAULT_ITEM_STAGGER_DURATION, n as useResponsiveStyle, q as colorToString } from "./index.es.js";
36
36
  import "./actions.es.js";
package/dist/index.es3.js CHANGED
@@ -29,31 +29,112 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { cx } from "@emotion/css";
33
- import { _ as useStyle } from "./react-page.es.js";
34
- import { n as useResponsiveStyle } from "./index.es.js";
32
+ import { forwardRef } from "react";
33
+ import scrollIntoView from "scroll-into-view-if-needed";
34
+ import NextLink from "next/link";
35
+ import { H as usePagePathnameSlice, I as useElementId } from "./index.es.js";
35
36
  import { jsx } from "react/jsx-runtime";
36
- function GutterContainer(_a) {
37
+ const Link = forwardRef(function Link2(_a, ref) {
37
38
  var _b = _a, {
38
- className,
39
- gutter,
40
- first,
41
- last
39
+ link,
40
+ onClick = () => {
41
+ }
42
42
  } = _b, restOfProps = __objRest(_b, [
43
- "className",
44
- "gutter",
45
- "first",
46
- "last"
43
+ "link",
44
+ "onClick"
47
45
  ]);
48
- return /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, restOfProps), {
49
- className: cx(useStyle(useResponsiveStyle([gutter], ([gutter2 = {
50
- value: 0,
51
- unit: "px"
52
- }]) => ({
53
- paddingLeft: first ? "0px" : `${gutter2.value / 2}${gutter2.unit}`,
54
- paddingRight: last ? "0px" : `${gutter2.value / 2}${gutter2.unit}`
55
- }))), className)
46
+ var _a2;
47
+ const pageId = link && link.type === "OPEN_PAGE" ? link.payload.pageId : null;
48
+ const page = usePagePathnameSlice(pageId != null ? pageId : null);
49
+ const elementKey = (link == null ? void 0 : link.type) === "SCROLL_TO_ELEMENT" ? (_a2 = link.payload.elementIdConfig) == null ? void 0 : _a2.elementKey : null;
50
+ const elementId = useElementId(elementKey);
51
+ let useNextLink;
52
+ let href;
53
+ let target;
54
+ let block;
55
+ if (link) {
56
+ switch (link.type) {
57
+ case "OPEN_PAGE": {
58
+ if (page) {
59
+ useNextLink = true;
60
+ href = `/${page.pathname}`;
61
+ }
62
+ target = link.payload.openInNewTab ? "_blank" : "_self";
63
+ break;
64
+ }
65
+ case "OPEN_URL": {
66
+ useNextLink = true;
67
+ href = link.payload.url;
68
+ target = link.payload.openInNewTab ? "_blank" : "_self";
69
+ break;
70
+ }
71
+ case "SEND_EMAIL": {
72
+ useNextLink = false;
73
+ const {
74
+ to,
75
+ subject = "",
76
+ body = ""
77
+ } = link.payload;
78
+ if (to != null)
79
+ href = `mailto:${to}?subject=${subject}&body=${body}`;
80
+ break;
81
+ }
82
+ case "CALL_PHONE": {
83
+ useNextLink = false;
84
+ href = `tel:${link.payload.phoneNumber}`;
85
+ break;
86
+ }
87
+ case "SCROLL_TO_ELEMENT": {
88
+ useNextLink = false;
89
+ href = `#${elementId != null ? elementId : ""}`;
90
+ block = link.payload.block;
91
+ break;
92
+ }
93
+ default:
94
+ throw new RangeError(`Invalid link type "${link.type}."`);
95
+ }
96
+ }
97
+ function handleClick(event) {
98
+ onClick(event);
99
+ if (event.defaultPrevented)
100
+ return;
101
+ if (event.currentTarget.isContentEditable)
102
+ return event.preventDefault();
103
+ if (link && link.type === "SCROLL_TO_ELEMENT") {
104
+ let hash;
105
+ try {
106
+ if (href != null)
107
+ hash = new URL(`http://www.example.com/${href}`).hash;
108
+ } catch (error) {
109
+ console.error(`Link received invalid href: ${href}`, error);
110
+ }
111
+ if (href != null && hash != null && href === hash) {
112
+ event.preventDefault();
113
+ const view = event.view;
114
+ scrollIntoView(view.document.querySelector(hash), {
115
+ behavior: "smooth",
116
+ block
117
+ });
118
+ if (view.location.hash !== hash)
119
+ view.history.pushState({}, "", hash);
120
+ }
121
+ }
122
+ }
123
+ if (useNextLink && href != null) {
124
+ return /* @__PURE__ */ jsx(NextLink, __spreadProps(__spreadValues({}, restOfProps), {
125
+ ref,
126
+ target,
127
+ onClick: handleClick,
128
+ href,
129
+ legacyBehavior: false
130
+ }));
131
+ }
132
+ return /* @__PURE__ */ jsx("a", __spreadProps(__spreadValues({}, restOfProps), {
133
+ ref,
134
+ href,
135
+ target,
136
+ onClick: handleClick
56
137
  }));
57
- }
58
- export { GutterContainer as G };
138
+ });
139
+ export { Link as L };
59
140
  //# sourceMappingURL=index.es3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es3.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,qEAEQC;IACJ,WAAWC,GACTC,SACEC,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.es3.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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeaA,MAAAA,OAAOC,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,qBAAqBJ,0BAAU,IAAX;AACjC,QAAMK,aACJR,8BAAMI,UAAS,sBAAsBJ,YAAKK,QAAQI,oBAAbT,oBAA8BQ,aAAa;AAC5EE,QAAAA,YAAYC,aAAaH,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,uBAAeD,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,+BAAC,UAAD,iCACMX,cADN;AAAA,MAEE;AAAA,MACA;AAAA,MACA,SAASsB;AAAAA,MACT;AAAA,MAEA,gBAAgB;AAAA,IAAA,EARpB;AAAA,EAWD;AAGD,mEAActB;IAAa;AAAA,IAAU;AAAA,IAAY;AAAA,IAAgB,SAASsB;AAAAA,EAAAA,EAA1E;AACD,CA7H6B;;"}
package/dist/index.es4.js CHANGED
@@ -1,18 +1,59 @@
1
- import { Transforms, Editor } from "slate";
2
- import { ReactEditor } from "slate-react";
3
- function withBuilder(editor) {
4
- editor.deselectAndBlur = function() {
5
- ReactEditor.deselect(editor);
6
- ReactEditor.blur(editor);
7
- };
8
- editor.focusAndSelectAll = function() {
9
- ReactEditor.focus(editor);
10
- Transforms.select(editor, {
11
- anchor: Editor.start(editor, []),
12
- focus: Editor.end(editor, [])
13
- });
14
- };
15
- return editor;
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ import { cx } from "@emotion/css";
33
+ import { Z as useStyle } from "./react-page.es.js";
34
+ import { n as useResponsiveStyle } from "./index.es.js";
35
+ import { jsx } from "react/jsx-runtime";
36
+ function GutterContainer(_a) {
37
+ var _b = _a, {
38
+ className,
39
+ gutter,
40
+ first,
41
+ last
42
+ } = _b, restOfProps = __objRest(_b, [
43
+ "className",
44
+ "gutter",
45
+ "first",
46
+ "last"
47
+ ]);
48
+ return /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, restOfProps), {
49
+ className: cx(useStyle(useResponsiveStyle([gutter], ([gutter2 = {
50
+ value: 0,
51
+ unit: "px"
52
+ }]) => ({
53
+ paddingLeft: first ? "0px" : `${gutter2.value / 2}${gutter2.unit}`,
54
+ paddingRight: last ? "0px" : `${gutter2.value / 2}${gutter2.unit}`
55
+ }))), className)
56
+ }));
16
57
  }
17
- export { withBuilder as w };
58
+ export { GutterContainer as G };
18
59
  //# sourceMappingURL=index.es4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es4.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":[],"mappings":";;AAQO,qBAAqB,QAAgB;AAC1C,SAAO,kBAAkB,WAAY;AACnC,gBAAY,SAAS,MAAM;AAC3B,gBAAY,KAAK,MAAM;AAAA,EAAA;AAGzB,SAAO,oBAAoB,WAAY;AACrC,gBAAY,MAAM,MAAM;AACxB,eAAW,OAAO,QAAQ;AAAA,MACxB,QAAQ,OAAO,MAAM,QAAQ,CAAA,CAAE;AAAA,MAC/B,OAAO,OAAO,IAAI,QAAQ,CAAA,CAAE;AAAA,IAAA,CAC7B;AAAA,EAAA;AAGI,SAAA;AACT;;"}
1
+ {"version":3,"file":"index.es4.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,qEAEQC;IACJ,WAAWC,GACTC,SACEC,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;;"}
package/dist/index.es5.js CHANGED
@@ -1,85 +1,47 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
1
+ import { Node, Transforms, Text, Editor } from "slate";
2
+ import { ReactEditor } from "slate-react";
3
+ import { bS as ElementUtils } from "./react-page.es.js";
4
+ function withBuilder(editor) {
5
+ editor.resetValue = function(value) {
6
+ var _a;
7
+ const firstRootBlock = Node.has(editor, [0]) && Node.get(editor, [0]);
8
+ const textAlignOfFirstBlock = firstRootBlock && ElementUtils.isRootBlock(firstRootBlock) ? firstRootBlock.textAlign : void 0;
9
+ const typographyOfFirstText = (_a = Array.from(Node.texts(editor)).at(0)) == null ? void 0 : _a[0].typography;
10
+ ReactEditor.deselect(editor);
11
+ ReactEditor.blur(editor);
12
+ editor.children = value;
13
+ editor.onChange();
14
+ if (typographyOfFirstText) {
15
+ Transforms.setNodes(editor, { typography: typographyOfFirstText }, {
16
+ match: Text.isText,
17
+ at: {
18
+ anchor: Editor.start(editor, []),
19
+ focus: Editor.end(editor, [])
20
+ }
21
+ });
16
22
  }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { bS as ElementUtils, bw as createRichTextV2Plugin, aN as Link, bT as onChange, bU as getValue, bV as isLinkElement, _ as useStyle, bO as InlineType } from "./react-page.es.js";
21
- import { L as Link$1 } from "./index.es.js";
22
- import { cx } from "@emotion/css";
23
- import { jsx, Fragment } from "react/jsx-runtime";
24
- const withLink = (editor) => {
25
- const {
26
- isInline
27
- } = editor;
28
- editor.isInline = (entry) => {
29
- return ElementUtils.isInline(entry) && isInline(entry);
30
- };
31
- return editor;
32
- };
33
- function InlinePluginComponent({
34
- element,
35
- attributes,
36
- children,
37
- renderElement
38
- }) {
39
- var _a;
40
- const linkStyle = useStyle({
41
- textDecoration: "none"
42
- });
43
- switch (element.type) {
44
- case InlineType.Link:
45
- return /* @__PURE__ */ jsx(Link$1, __spreadProps(__spreadValues({}, attributes), {
46
- link: (_a = element.link) != null ? _a : void 0,
47
- className: cx(linkStyle, element.className),
48
- children: renderElement({
49
- element,
50
- attributes,
51
- children
52
- })
53
- }));
54
- default:
55
- return /* @__PURE__ */ jsx(Fragment, {
56
- children: renderElement({
57
- element,
58
- attributes,
59
- children
60
- })
23
+ if (textAlignOfFirstBlock) {
24
+ Transforms.setNodes(editor, { textAlign: textAlignOfFirstBlock }, {
25
+ match: ElementUtils.isRootBlock,
26
+ at: {
27
+ anchor: Editor.start(editor, []),
28
+ focus: Editor.end(editor, [])
29
+ }
61
30
  });
62
- }
63
- }
64
- function LinkPlugin() {
65
- return createRichTextV2Plugin({
66
- control: {
67
- definition: Link({
68
- label: "On Click"
69
- }),
70
- onChange,
71
- getValue,
72
- getElementValue: (element) => {
73
- return ElementUtils.isInline(element) && isLinkElement(element) ? element.link : void 0;
74
- }
75
- },
76
- withPlugin: withLink,
77
- renderElement: (renderElement) => (props) => {
78
- return /* @__PURE__ */ jsx(InlinePluginComponent, __spreadProps(__spreadValues({}, props), {
79
- renderElement
80
- }));
81
31
  }
82
- });
32
+ };
33
+ editor.deselectAndBlur = function() {
34
+ ReactEditor.deselect(editor);
35
+ ReactEditor.blur(editor);
36
+ };
37
+ editor.focusAndSelectAll = function() {
38
+ ReactEditor.focus(editor);
39
+ Transforms.select(editor, {
40
+ anchor: Editor.start(editor, []),
41
+ focus: Editor.end(editor, [])
42
+ });
43
+ };
44
+ return editor;
83
45
  }
84
- export { LinkPlugin as L, withLink as w };
46
+ export { withBuilder as w };
85
47
  //# sourceMappingURL=index.es5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es5.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,aAAaF,SAASC,KAAtB,KAAgCD,SAASC,KAAD;AAAA,EAAA;AAG1CF,SAAAA;AACR;AAED,+BAA+B;AAAA,EAC7BI;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,GACwD;;AAClDC,QAAAA,YAAYC,SAAS;AAAA,IAAEC,gBAAgB;AAAA,EAAA,CAAnB;AAClBN,UAAAA,QAAQO;AAAAA,SACTC,WAAWC;AAEZ,iCAACC,QAAD,iCACMT,aADN;AAAA,QAEE,MAAMD,cAAQW,SAARX,YAAgBY;AAAAA,QACtB,WAAWC,GAAGT,WAAWJ,QAAQc,SAApB;AAAA,QAHf,UAKGX,cAAc;AAAA,UACbH;AAAAA,UACAC;AAAAA,UACAC;AAAAA,QAAAA,CAHY;AAAA,MAAA,EANlB;AAAA;AAgBE,iCAAAa,UAAA;AAAA,QAAA,UACGZ,cAAc;AAAA,UACbH;AAAAA,UACAC;AAAAA,UACAC;AAAAA,QAAAA,CAHY;AAAA,MAAA,CAFlB;AAAA;AAUL;AAE4B,sBAAA;AAC3B,SAAOc,uBAAuB;AAAA,IAC5BC,SAAS;AAAA,MACPC,YAAYT,KAAK;AAAA,QACfU,OAAO;AAAA,MAAA,CADO;AAAA,MAGhBC;AAAAA,MACAC;AAAAA,MACAC,iBAAiB,CAACtB,YAAqB;AAC9BD,eAAAA,aAAaF,SAASG,OAAtB,KAAkCuB,cAAcvB,OAAD,IAAYA,QAAQW,OAAOC;AAAAA,MAClF;AAAA,IATyB;AAAA,IAW5BY,YAAY7B;AAAAA,IACZQ,eAAeA,mBAAiBsB,CAAS,UAAA;AAChC,iCAAC,uBAAD,iCAA2BA,QAA3B;AAAA,QAAkC;AAAA,MAAA,EAAzC;AAAA,IACD;AAAA,EAAA,CAd0B;AAgB9B;;"}
1
+ {"version":3,"file":"index.es5.js","sources":["../src/slate/BuilderPlugin/index.ts"],"sourcesContent":["import { BaseEditor, Descendant, Editor, Transforms, Text, Node } from 'slate'\nimport { ReactEditor } from 'slate-react'\nimport { ElementUtils } from '../utils/element'\n\nexport interface BuilderEditor extends BaseEditor {\n focusAndSelectAll: () => void\n deselectAndBlur: () => void\n resetValue: (value: Descendant[]) => void\n}\n\nexport function withBuilder(editor: Editor) {\n editor.resetValue = function (value: Descendant[]) {\n const firstRootBlock = Node.has(editor, [0]) && Node.get(editor, [0])\n const textAlignOfFirstBlock =\n firstRootBlock && ElementUtils.isRootBlock(firstRootBlock)\n ? firstRootBlock.textAlign\n : undefined\n const typographyOfFirstText = Array.from(Node.texts(editor)).at(0)?.[0].typography\n\n ReactEditor.deselect(editor)\n ReactEditor.blur(editor)\n\n editor.children = value\n editor.onChange()\n\n if (typographyOfFirstText) {\n Transforms.setNodes(\n editor,\n { typography: typographyOfFirstText },\n {\n match: Text.isText,\n at: {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n },\n },\n )\n }\n if (textAlignOfFirstBlock) {\n Transforms.setNodes(\n editor,\n { textAlign: textAlignOfFirstBlock },\n {\n match: ElementUtils.isRootBlock,\n at: {\n anchor: Editor.start(editor, []),\n focus: Editor.end(editor, []),\n },\n },\n )\n }\n }\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":[],"mappings":";;;AAUO,qBAAqB,QAAgB;AACnC,SAAA,aAAa,SAAU,OAAqB;;AACjD,UAAM,iBAAiB,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC;AACpE,UAAM,wBACJ,kBAAkB,aAAa,YAAY,cAAc,IACrD,eAAe,YACf;AACA,UAAA,wBAAwB,YAAM,KAAK,KAAK,MAAM,MAAM,CAAC,EAAE,GAAG,CAAC,MAAnC,mBAAuC,GAAG;AAExE,gBAAY,SAAS,MAAM;AAC3B,gBAAY,KAAK,MAAM;AAEvB,WAAO,WAAW;AAClB,WAAO,SAAS;AAEhB,QAAI,uBAAuB;AACzB,iBAAW,SACT,QACA,EAAE,YAAY,yBACd;AAAA,QACE,OAAO,KAAK;AAAA,QACZ,IAAI;AAAA,UACF,QAAQ,OAAO,MAAM,QAAQ,CAAA,CAAE;AAAA,UAC/B,OAAO,OAAO,IAAI,QAAQ,CAAA,CAAE;AAAA,QAC9B;AAAA,MAAA,CAEJ;AAAA,IACF;AACA,QAAI,uBAAuB;AACzB,iBAAW,SACT,QACA,EAAE,WAAW,yBACb;AAAA,QACE,OAAO,aAAa;AAAA,QACpB,IAAI;AAAA,UACF,QAAQ,OAAO,MAAM,QAAQ,CAAA,CAAE;AAAA,UAC/B,OAAO,OAAO,IAAI,QAAQ,CAAA,CAAE;AAAA,QAC9B;AAAA,MAAA,CAEJ;AAAA,IACF;AAAA,EAAA;AAEF,SAAO,kBAAkB,WAAY;AACnC,gBAAY,SAAS,MAAM;AAC3B,gBAAY,KAAK,MAAM;AAAA,EAAA;AAGzB,SAAO,oBAAoB,WAAY;AACrC,gBAAY,MAAM,MAAM;AACxB,eAAW,OAAO,QAAQ;AAAA,MACxB,QAAQ,OAAO,MAAM,QAAQ,CAAA,CAAE;AAAA,MAC/B,OAAO,OAAO,IAAI,QAAQ,CAAA,CAAE;AAAA,IAAA,CAC7B;AAAA,EAAA;AAGI,SAAA;AACT;;"}
package/dist/index.es6.js CHANGED
@@ -1,21 +1,85 @@
1
- import { v4 } from "uuid";
2
- function withLocalChanges(editor) {
3
- editor.localChanges = /* @__PURE__ */ new Map();
4
- editor.recentLocalChanges = [];
5
- editor.currentKey = "";
6
- const _onChange = editor.onChange;
7
- editor.onChange = (options) => {
8
- _onChange(options);
9
- if (editor == null || (options == null ? void 0 : options.operation) == null)
10
- return;
11
- const key = v4();
12
- editor.localChanges.set(key, {
13
- selection: editor.selection,
14
- time: performance.now()
15
- });
16
- editor.currentKey = key;
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { bS as ElementUtils, bv as createRichTextV2Plugin, aM as Link, bT as onChange, bU as getValue, bV as isLinkElement, Z as useStyle, bO as InlineType } from "./react-page.es.js";
21
+ import { L as Link$1 } from "./index.es3.js";
22
+ import { cx } from "@emotion/css";
23
+ import { jsx, Fragment } from "react/jsx-runtime";
24
+ const withLink = (editor) => {
25
+ const {
26
+ isInline
27
+ } = editor;
28
+ editor.isInline = (entry) => {
29
+ return ElementUtils.isInline(entry) && isInline(entry);
17
30
  };
18
31
  return editor;
32
+ };
33
+ function InlinePluginComponent({
34
+ element,
35
+ attributes,
36
+ children,
37
+ renderElement
38
+ }) {
39
+ var _a;
40
+ const linkStyle = useStyle({
41
+ textDecoration: "none"
42
+ });
43
+ switch (element.type) {
44
+ case InlineType.Link:
45
+ return /* @__PURE__ */ jsx(Link$1, __spreadProps(__spreadValues({}, attributes), {
46
+ link: (_a = element.link) != null ? _a : void 0,
47
+ className: cx(linkStyle, element.className),
48
+ children: renderElement({
49
+ element,
50
+ attributes,
51
+ children
52
+ })
53
+ }));
54
+ default:
55
+ return /* @__PURE__ */ jsx(Fragment, {
56
+ children: renderElement({
57
+ element,
58
+ attributes,
59
+ children
60
+ })
61
+ });
62
+ }
19
63
  }
20
- export { withLocalChanges as w };
64
+ function LinkPlugin() {
65
+ return createRichTextV2Plugin({
66
+ control: {
67
+ definition: Link({
68
+ label: "On Click"
69
+ }),
70
+ onChange,
71
+ getValue,
72
+ getElementValue: (element) => {
73
+ return ElementUtils.isInline(element) && isLinkElement(element) ? element.link : void 0;
74
+ }
75
+ },
76
+ withPlugin: withLink,
77
+ renderElement: (renderElement) => (props) => {
78
+ return /* @__PURE__ */ jsx(InlinePluginComponent, __spreadProps(__spreadValues({}, props), {
79
+ renderElement
80
+ }));
81
+ }
82
+ });
83
+ }
84
+ export { LinkPlugin as L, withLink as w };
21
85
  //# sourceMappingURL=index.es6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es6.js","sources":["../src/slate/LocalChangesPlugin/index.tsx"],"sourcesContent":["import { BaseEditor, Editor, Selection } from 'slate'\nimport { v4 as uuid } from 'uuid'\n\nexport type LocalChange = { selection: Selection; time: number }\n\nexport interface LocalChangesEditor extends BaseEditor {\n localChanges: Map<string, LocalChange>\n recentKeys: Map<string, number>\n recentLocalChanges: { time: number; key: string }[]\n currentKey: string\n}\n\nexport function withLocalChanges(editor: Editor): Editor {\n editor.localChanges = new Map<string, LocalChange>()\n editor.recentLocalChanges = []\n editor.currentKey = ''\n\n const _onChange = editor.onChange\n editor.onChange = options => {\n _onChange(options)\n if (editor == null || options?.operation == null) return\n\n const key = uuid()\n editor.localChanges.set(key, { selection: editor.selection, time: performance.now() })\n editor.currentKey = key\n }\n\n return editor\n}\n"],"names":["editor","localChanges","Map","recentLocalChanges","currentKey","_onChange","onChange","options","operation","key","uuid","set","selection","time","performance","now"],"mappings":";AAYO,0BAA0BA,QAAwB;AAChDC,SAAAA,mCAAmBC;AAC1BF,SAAOG,qBAAqB;AAC5BH,SAAOI,aAAa;AAEpB,QAAMC,YAAYL,OAAOM;AACzBN,SAAOM,WAAWC,CAAW,YAAA;AAC3BF,cAAUE,OAAD;AACLP,QAAAA,UAAU,QAAQO,oCAASC,cAAa;AAAM;AAE5CC,UAAAA,MAAMC;AACLT,WAAAA,aAAaU,IAAIF,KAAK;AAAA,MAAEG,WAAWZ,OAAOY;AAAAA,MAAWC,MAAMC,YAAYC,IAAZ;AAAA,IAAA,CAAlE;AACAf,WAAOI,aAAaK;AAAAA,EAAAA;AAGfT,SAAAA;AACR;;"}
1
+ {"version":3,"file":"index.es6.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,aAAaF,SAASC,KAAtB,KAAgCD,SAASC,KAAD;AAAA,EAAA;AAG1CF,SAAAA;AACR;AAED,+BAA+B;AAAA,EAC7BI;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,GACwD;;AAClDC,QAAAA,YAAYC,SAAS;AAAA,IAAEC,gBAAgB;AAAA,EAAA,CAAnB;AAClBN,UAAAA,QAAQO;AAAAA,SACTC,WAAWC;AAEZ,iCAACC,QAAD,iCACMT,aADN;AAAA,QAEE,MAAMD,cAAQW,SAARX,YAAgBY;AAAAA,QACtB,WAAWC,GAAGT,WAAWJ,QAAQc,SAApB;AAAA,QAHf,UAKGX,cAAc;AAAA,UACbH;AAAAA,UACAC;AAAAA,UACAC;AAAAA,QAAAA,CAHY;AAAA,MAAA,EANlB;AAAA;AAgBE,iCAAAa,UAAA;AAAA,QAAA,UACGZ,cAAc;AAAA,UACbH;AAAAA,UACAC;AAAAA,UACAC;AAAAA,QAAAA,CAHY;AAAA,MAAA,CAFlB;AAAA;AAUL;AAE4B,sBAAA;AAC3B,SAAOc,uBAAuB;AAAA,IAC5BC,SAAS;AAAA,MACPC,YAAYT,KAAK;AAAA,QACfU,OAAO;AAAA,MAAA,CADO;AAAA,MAGhBC;AAAAA,MACAC;AAAAA,MACAC,iBAAiB,CAACtB,YAAqB;AAC9BD,eAAAA,aAAaF,SAASG,OAAtB,KAAkCuB,cAAcvB,OAAD,IAAYA,QAAQW,OAAOC;AAAAA,MAClF;AAAA,IATyB;AAAA,IAW5BY,YAAY7B;AAAAA,IACZQ,eAAeA,mBAAiBsB,CAAS,UAAA;AAChC,iCAAC,uBAAD,iCAA2BA,QAA3B;AAAA,QAAkC;AAAA,MAAA,EAAzC;AAAA,IACD;AAAA,EAAA,CAd0B;AAgB9B;;"}