@makeswift/runtime 0.6.1 → 0.6.3

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 (105) hide show
  1. package/dist/Box.cjs.js +1 -1
  2. package/dist/Box.es.js +1 -1
  3. package/dist/Button.cjs.js +1 -1
  4. package/dist/Button.es.js +1 -1
  5. package/dist/Carousel.cjs.js +1 -1
  6. package/dist/Carousel.es.js +1 -1
  7. package/dist/Countdown.cjs.js +1 -1
  8. package/dist/Countdown.es.js +1 -1
  9. package/dist/Divider.cjs.js +1 -1
  10. package/dist/Divider.es.js +1 -1
  11. package/dist/EditableText.cjs.js +11 -2
  12. package/dist/EditableText.cjs.js.map +1 -1
  13. package/dist/EditableText.es.js +13 -4
  14. package/dist/EditableText.es.js.map +1 -1
  15. package/dist/Embed.cjs.js +1 -1
  16. package/dist/Embed.es.js +1 -1
  17. package/dist/Form.cjs.js +1 -1
  18. package/dist/Form.es.js +1 -1
  19. package/dist/Image.cjs.js +3 -6
  20. package/dist/Image.cjs.js.map +1 -1
  21. package/dist/Image.es.js +4 -7
  22. package/dist/Image.es.js.map +1 -1
  23. package/dist/LiveProvider.cjs.js +1 -1
  24. package/dist/LiveProvider.es.js +1 -1
  25. package/dist/Navigation.cjs.js +1 -1
  26. package/dist/Navigation.es.js +1 -1
  27. package/dist/PreviewProvider.cjs.js +2 -2
  28. package/dist/PreviewProvider.cjs.js.map +1 -1
  29. package/dist/PreviewProvider.es.js +2 -2
  30. package/dist/ReadOnlyText.cjs.js +6 -3
  31. package/dist/ReadOnlyText.cjs.js.map +1 -1
  32. package/dist/ReadOnlyText.es.js +6 -3
  33. package/dist/ReadOnlyText.es.js.map +1 -1
  34. package/dist/Root.cjs.js +1 -1
  35. package/dist/Root.es.js +1 -1
  36. package/dist/SocialLinks.cjs.js +1 -1
  37. package/dist/SocialLinks.es.js +1 -1
  38. package/dist/Text.cjs.js +1 -1
  39. package/dist/Text.es.js +1 -1
  40. package/dist/Video.cjs.js +1 -1
  41. package/dist/Video.es.js +1 -1
  42. package/dist/builder.cjs.js +1 -1
  43. package/dist/builder.es.js +1 -1
  44. package/dist/components.cjs.js +1 -1
  45. package/dist/components.es.js +1 -1
  46. package/dist/constants.cjs.js +20 -20
  47. package/dist/constants.cjs.js.map +1 -1
  48. package/dist/constants.es.js +2 -2
  49. package/dist/control-serialization.cjs.js +37 -37
  50. package/dist/control-serialization.cjs.js.map +1 -1
  51. package/dist/control-serialization.es.js +1 -1
  52. package/dist/control.cjs.js +22 -22
  53. package/dist/control.cjs.js.map +1 -1
  54. package/dist/control.es.js +1 -1
  55. package/dist/controls.cjs.js +21 -17
  56. package/dist/controls.cjs.js.map +1 -1
  57. package/dist/controls.es.js +1 -1
  58. package/dist/index.cjs.js +237 -208
  59. package/dist/index.cjs.js.map +1 -1
  60. package/dist/index.cjs2.js +1 -1
  61. package/dist/index.cjs5.js +36 -139
  62. package/dist/index.cjs5.js.map +1 -1
  63. package/dist/index.cjs6.js +141 -0
  64. package/dist/index.cjs6.js.map +1 -0
  65. package/dist/index.es.js +52 -26
  66. package/dist/index.es.js.map +1 -1
  67. package/dist/index.es2.js +1 -1
  68. package/dist/index.es5.js +34 -138
  69. package/dist/index.es5.js.map +1 -1
  70. package/dist/index.es6.js +139 -0
  71. package/dist/index.es6.js.map +1 -0
  72. package/dist/main.cjs.js +1 -1
  73. package/dist/main.es.js +1 -1
  74. package/dist/next.cjs.js +1 -1
  75. package/dist/next.es.js +2 -2
  76. package/dist/prop-controllers.cjs.js +4 -4
  77. package/dist/prop-controllers.es.js +1 -1
  78. package/dist/react.cjs.js +1 -1
  79. package/dist/react.es.js +1 -1
  80. package/dist/{slot.cjs.js → rich-text.cjs.js} +84 -8
  81. package/dist/rich-text.cjs.js.map +1 -0
  82. package/dist/{slot.es.js → rich-text.es.js} +80 -8
  83. package/dist/rich-text.es.js.map +1 -0
  84. package/dist/types/src/components/builtin/Box/register.d.ts.map +1 -1
  85. package/dist/types/src/components/builtin/Image/Image.d.ts.map +1 -1
  86. package/dist/types/src/components/builtin/Text/EditableText.d.ts.map +1 -1
  87. package/dist/types/src/controls/index.d.ts +1 -0
  88. package/dist/types/src/controls/index.d.ts.map +1 -1
  89. package/dist/types/src/controls/rich-text.d.ts +66 -0
  90. package/dist/types/src/controls/rich-text.d.ts.map +1 -0
  91. package/dist/types/src/controls/style.d.ts +16 -4
  92. package/dist/types/src/controls/style.d.ts.map +1 -1
  93. package/dist/types/src/prop-controllers/descriptors.d.ts +4 -2
  94. package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
  95. package/dist/types/src/prop-controllers/instances.d.ts +13 -3
  96. package/dist/types/src/prop-controllers/instances.d.ts.map +1 -1
  97. package/dist/types/src/runtimes/react/controls/rich-text.d.ts +8 -0
  98. package/dist/types/src/runtimes/react/controls/rich-text.d.ts.map +1 -0
  99. package/dist/types/src/runtimes/react/controls/slot.d.ts.map +1 -1
  100. package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
  101. package/dist/types/src/runtimes/react/poll-box-model.d.ts +6 -0
  102. package/dist/types/src/runtimes/react/poll-box-model.d.ts.map +1 -0
  103. package/package.json +1 -1
  104. package/dist/slot.cjs.js.map +0 -1
  105. package/dist/slot.es.js.map +0 -1
package/dist/index.es2.js CHANGED
@@ -32,7 +32,7 @@ var __objRest = (source, exclude) => {
32
32
  import { useMemo, useState, useEffect, useCallback, useRef, forwardRef, createElement, Children } from "react";
33
33
  import { J as useFiles, K as useSwatches, o as useStyle, w as responsiveGridItem, m as useMediaQuery, 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, r as responsiveStyle, s as colorToString } from "./index.es.js";
34
34
  import "use-sync-external-store/shim";
35
- import "./slot.es.js";
35
+ import "./rich-text.es.js";
36
36
  import { cx } from "@emotion/css";
37
37
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
38
38
  import { l as isNonNullable, y as getBackgroundsFileIds, z as getBackgroundsSwatchIds } from "./constants.es.js";
package/dist/index.es5.js CHANGED
@@ -1,139 +1,35 @@
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 { U as useTypography, K as useSwatches, G as findDeviceOverride, o as useStyle, r as responsiveStyle, V as shallowMergeFallbacks, s as colorToString } from "./index.es.js";
33
- import { R as getTypographyStyleSwatchIds, l as isNonNullable } from "./constants.es.js";
34
- import { cx } from "@emotion/css";
35
- import { jsx } from "react/jsx-runtime";
36
- import { forwardRef } from "react";
37
- const getDeviceId = ({ deviceId }) => deviceId;
38
- const withColor = (swatches) => (_a) => {
39
- var _b = _a, {
40
- value: _c
41
- } = _b, _d = _c, { color } = _d, restOfValue = __objRest(_d, ["color"]), rest = __objRest(_b, [
42
- "value"
43
- ]);
44
- return __spreadProps(__spreadValues({}, rest), {
45
- value: __spreadValues(__spreadValues({}, restOfValue), color ? {
46
- color: {
47
- swatch: swatches.find((s) => s && s.id === color.swatchId),
48
- alpha: color.alpha
49
- }
50
- } : {})
51
- });
52
- };
53
- const overrideTypographyStyle = (source, override) => {
54
- const devices = [...new Set(source.map(getDeviceId).concat(override.map(getDeviceId)))];
55
- return devices.map((deviceId) => ({
56
- deviceId,
57
- value: __spreadValues(__spreadValues({}, (findDeviceOverride(source, deviceId) || { value: {} }).value), (findDeviceOverride(override, deviceId, (v) => v) || { value: {} }).value)
58
- }));
59
- };
60
- function useTypographyMark(value) {
61
- var _a, _b, _c;
62
- const typography = useTypography((_a = value == null ? void 0 : value.id) != null ? _a : null);
63
- const swatchIds = [
64
- ...getTypographyStyleSwatchIds(value == null ? void 0 : value.style),
65
- ...getTypographyStyleSwatchIds(typography == null ? void 0 : typography.style)
66
- ];
67
- const swatches = useSwatches(swatchIds);
68
- return overrideTypographyStyle((_b = typography == null ? void 0 : typography.style.map(withColor(swatches.filter(isNonNullable)))) != null ? _b : [], (_c = value == null ? void 0 : value.style.map(withColor(swatches.filter(isNonNullable)))) != null ? _c : []);
69
- }
70
- function Mark(_a) {
71
- var _b = _a, {
72
- value,
73
- className
74
- } = _b, restOfProps = __objRest(_b, [
75
- "value",
76
- "className"
77
- ]);
78
- const typographyStyle = useTypographyMark(value);
79
- const typographyClassName = useStyle(responsiveStyle([typographyStyle], ([{
80
- color,
81
- fontFamily,
82
- fontSize,
83
- fontWeight,
84
- lineHeight,
85
- letterSpacing,
86
- uppercase,
87
- underline,
88
- strikethrough,
89
- italic
90
- } = {}]) => __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, color == null ? {} : {
91
- color: colorToString(color)
92
- }), fontFamily == null ? {} : {
93
- fontFamily
94
- }), fontSize == null || fontSize.value == null || fontSize.unit == null ? {} : {
95
- fontSize: `${fontSize.value}${fontSize.unit}`
96
- }), fontWeight == null ? {} : {
97
- fontWeight
98
- }), lineHeight == null ? {} : {
99
- lineHeight
100
- }), letterSpacing == null ? {} : {
101
- letterSpacing: `${letterSpacing / 10}em`
102
- }), uppercase == null ? {} : {
103
- textTransform: uppercase === true ? "uppercase" : "initial"
104
- }), underline == null && strikethrough == null ? {} : {
105
- textDecoration: [Boolean(underline) && "underline", Boolean(strikethrough) && "line-through"].filter(Boolean).join(" ")
106
- }), italic == null ? {} : {
107
- fontStyle: italic === true ? "italic" : "initial"
108
- }), shallowMergeFallbacks));
109
- return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, restOfProps), {
110
- className: cx(typographyClassName, className)
111
- }));
112
- }
113
- var DeviceOverrideBlock = forwardRef(function Block(_c, ref) {
114
- var _d = _c, {
115
- textAlign,
116
- className,
117
- as
118
- } = _d, restOfProps = __objRest(_d, [
119
- "textAlign",
120
- "className",
121
- "as"
122
- ]);
123
- const Component = as != null ? as : "div";
124
- return /* @__PURE__ */ jsx(Component, __spreadProps(__spreadValues({}, restOfProps), {
125
- ref,
126
- className: cx(useStyle({
127
- margin: 0
128
- }), useStyle(responsiveStyle([textAlign], ([textAlign2 = "left"]) => ({
129
- textAlign: textAlign2
130
- }))), useStyle(as === "blockquote" ? {
131
- padding: "0.5em 10px",
132
- fontSize: "1.25em",
133
- fontWeight: "300",
134
- borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
135
- } : {}), className)
136
- }));
137
- });
138
- export { DeviceOverrideBlock as D, Mark as M };
1
+ export { default } from "./Text.es.js";
2
+ import "next/dynamic";
3
+ import "react";
4
+ import "./index.es.js";
5
+ import "use-sync-external-store/shim/with-selector";
6
+ import "./constants.es.js";
7
+ import "redux";
8
+ import "redux-thunk";
9
+ import "./actions.es.js";
10
+ import "./rich-text.es.js";
11
+ import "./control.es.js";
12
+ import "@emotion/css";
13
+ import "@emotion/serialize";
14
+ import "@emotion/utils";
15
+ import "react/jsx-runtime";
16
+ import "./text-input.es.js";
17
+ import "./combobox.es.js";
18
+ import "use-sync-external-store/shim";
19
+ import "./types.es.js";
20
+ import "color";
21
+ import "scroll-into-view-if-needed";
22
+ import "./box-models.es.js";
23
+ import "css-box-model";
24
+ import "react-dom";
25
+ import "html-react-parser";
26
+ import "next/head";
27
+ import "@emotion/server/create-instance";
28
+ import "next/document";
29
+ import "cookie";
30
+ import "cors";
31
+ import "http-proxy";
32
+ import "set-cookie-parser";
33
+ import "uuid/v4";
34
+ import "corporate-ipsum";
139
35
  //# sourceMappingURL=index.es5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es5.js","sources":["../src/components/builtin/Text/components/RichTextEditor/components/Mark/hooks/useTypographyMark.ts","../src/components/builtin/Text/components/RichTextEditor/components/Mark/index.tsx","../src/components/builtin/Text/components/RichTextEditor/components/Block/index.tsx"],"sourcesContent":["import { Length as LengthValue } from '../../../../../../../../prop-controllers'\nimport { ColorValue as Color } from '../../../../../../../utils/types'\nimport { findDeviceOverride } from '../../../../../../../utils/devices'\nimport type { DeviceOverride } from '../../../../../../../../prop-controllers'\nimport {\n useSwatches,\n useTypography,\n} from '../../../../../../../../runtimes/react/hooks/makeswift-api'\nimport { Swatch, Typography } from '../../../../../../../../api'\nimport { getTypographyStyleSwatchIds } from '../../../../../../../../prop-controllers/introspection'\nimport { isNonNullable } from '../../../../../../../utils/isNonNullable'\n\nexport type TypographyMarkDataValue = {\n fontWeight?: number\n fontSize?: LengthValue\n fontFamily?: string\n color?: Color\n textAlign?: string\n lineHeight?: number\n letterSpacing?: number\n uppercase?: boolean\n italic?: boolean\n underline?: boolean\n strikethrough?: boolean\n}\n\nexport type TypographyMarkValue = {\n id: string | null | undefined\n style: Typography['style']\n}\n\nexport type TypographyMarkData = Array<DeviceOverride<TypographyMarkDataValue>>\n\nconst getDeviceId = ({ deviceId }: DeviceOverride<unknown>) => deviceId\n\nconst withColor =\n (swatches: Swatch[]) =>\n ({\n value: { color, ...restOfValue },\n ...rest\n }: Typography['style'][number]): DeviceOverride<TypographyMarkDataValue> =>\n ({\n ...rest,\n value: {\n ...restOfValue,\n ...(color\n ? {\n color: {\n swatch: swatches.find(s => s && s.id === color.swatchId),\n alpha: color.alpha,\n },\n }\n : {}),\n } as TypographyMarkDataValue,\n } as DeviceOverride<TypographyMarkDataValue>)\n\nexport const overrideTypographyStyle = <A>(\n source: Array<DeviceOverride<A>>,\n override: Array<DeviceOverride<A>>,\n): Array<DeviceOverride<A>> => {\n const devices = [...new Set(source.map(getDeviceId).concat(override.map(getDeviceId)))]\n\n return devices.map(deviceId => ({\n deviceId,\n value: {\n ...(findDeviceOverride(source, deviceId) || { value: {} }).value,\n ...(findDeviceOverride(override, deviceId, v => v) || { value: {} }).value,\n },\n })) as DeviceOverride<A>[]\n}\n\nexport default function useTypographyMark(\n value: TypographyMarkValue | null | undefined,\n): TypographyMarkData | null | undefined {\n const typography = useTypography(value?.id ?? null)\n const swatchIds = [\n ...getTypographyStyleSwatchIds(value?.style),\n ...getTypographyStyleSwatchIds(typography?.style),\n ]\n const swatches = useSwatches(swatchIds)\n\n return overrideTypographyStyle(\n typography?.style.map(withColor(swatches.filter(isNonNullable))) ?? [],\n value?.style.map(withColor(swatches.filter(isNonNullable))) ?? [],\n )\n}\n","import { ComponentPropsWithoutRef } from 'react'\n\nimport useTypographyMark, {\n TypographyMarkValue,\n overrideTypographyStyle,\n TypographyMarkDataValue,\n} from './hooks/useTypographyMark'\nimport { colorToString } from '../../../../../../utils/colorToString'\nimport { shallowMergeFallbacks } from '../../../../../../utils/devices'\nimport { cx } from '@emotion/css'\nimport { useStyle } from '../../../../../../../runtimes/react/use-style'\nimport { responsiveStyle } from '../../../../../../utils/responsive-style'\nimport { ResponsiveValue } from '../../../../../../../prop-controllers/descriptors'\n\nexport type { TypographyMarkValue }\nexport { overrideTypographyStyle }\n\ntype BaseProps = { value: TypographyMarkValue }\n\ntype Props = BaseProps & Omit<ComponentPropsWithoutRef<'span'>, keyof BaseProps>\n\nexport default function Mark({ value, className, ...restOfProps }: Props): JSX.Element {\n const typographyStyle = useTypographyMark(value)\n const typographyClassName = useStyle(\n responsiveStyle<\n TypographyMarkDataValue,\n [ResponsiveValue<TypographyMarkDataValue> | null | undefined]\n >(\n [typographyStyle],\n ([\n {\n color,\n fontFamily,\n fontSize,\n fontWeight,\n lineHeight,\n letterSpacing,\n uppercase,\n underline,\n strikethrough,\n italic,\n } = {} as TypographyMarkDataValue,\n ]) => ({\n ...(color == null ? {} : { color: colorToString(color) }),\n ...(fontFamily == null ? {} : { fontFamily }),\n ...(fontSize == null || fontSize.value == null || fontSize.unit == null\n ? {}\n : { fontSize: `${fontSize.value}${fontSize.unit}` }),\n ...(fontWeight == null ? {} : { fontWeight }),\n ...(lineHeight == null ? {} : { lineHeight }),\n ...(letterSpacing == null ? {} : { letterSpacing: `${letterSpacing / 10}em` }),\n ...(uppercase == null\n ? {}\n : { textTransform: uppercase === true ? 'uppercase' : 'initial' }),\n ...(underline == null && strikethrough == null\n ? {}\n : {\n textDecoration: [\n Boolean(underline) && 'underline',\n Boolean(strikethrough) && 'line-through',\n ]\n .filter(Boolean)\n .join(' '),\n }),\n ...(italic == null ? {} : { fontStyle: italic === true ? 'italic' : 'initial' }),\n }),\n shallowMergeFallbacks,\n ),\n )\n\n return <span {...restOfProps} className={cx(typographyClassName, className)} />\n}\n","import { cx } from '@emotion/css'\nimport { forwardRef, ComponentPropsWithoutRef, ForwardedRef, ElementRef, ElementType } from 'react'\n\nimport type { ResponsiveValue } from '../../../../../../../prop-controllers'\nimport { useStyle } from '../../../../../../../runtimes/react/use-style'\nimport { responsiveStyle } from '../../../../../../utils/responsive-style'\n\ntype BaseProps<T extends ElementType> = {\n as?: T\n textAlign?: ResponsiveValue<'left' | 'center' | 'right' | 'justify'>\n}\n\ntype Props<T extends ElementType> = BaseProps<T> &\n Omit<ComponentPropsWithoutRef<T>, keyof BaseProps<T>>\n\nexport default forwardRef(function Block<T extends ElementType>(\n { textAlign, className, as, ...restOfProps }: Props<T>,\n ref: ForwardedRef<ElementRef<T>>,\n) {\n const Component = as ?? 'div'\n\n return (\n // @ts-ignore: `ref` types don't match.\n <Component\n {...restOfProps}\n ref={ref}\n className={cx(\n useStyle({ margin: 0 }),\n useStyle(responsiveStyle([textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n useStyle(\n as === 'blockquote'\n ? {\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n }\n : {},\n ),\n className,\n )}\n />\n )\n})\n"],"names":["value","className","restOfProps","typographyStyle","useTypographyMark","typographyClassName","useStyle","responsiveStyle","color","fontFamily","fontSize","fontWeight","lineHeight","letterSpacing","uppercase","underline","strikethrough","italic","colorToString","unit","textTransform","textDecoration","Boolean","filter","join","fontStyle","shallowMergeFallbacks","cx","forwardRef","ref","textAlign","as","Component","margin","padding","borderLeft"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,cAAc,CAAC,EAAE,eAAwC;AAE/D,MAAM,YACJ,CAAC,aACD,CAAC,OAIE;AAJF,eACQ;AAAA,IAAP,OAAO;AAAA,MADR,IACQ,SAAE,YAAF,IAAY,wBAAZ,IAAY,CAAV,WACN,iBAFJ,IAEI;AAAA,IADH;AAAA;AAGC,0CACI,OADJ;AAAA,IAEC,OAAO,kCACF,cACC,QACA;AAAA,MACE,OAAO;AAAA,QACL,QAAQ,SAAS,KAAK,CAAA,MAAK,KAAK,EAAE,OAAO,MAAM,QAAQ;AAAA,QACvD,OAAO,MAAM;AAAA,MACf;AAAA,IAAA,IAEF,CAAC;AAAA,EAET;AAAA;AAES,MAAA,0BAA0B,CACrC,QACA,aAC6B;AAC7B,QAAM,UAAU,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,WAAW,EAAE,OAAO,SA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E,GAURlC,SAbW;AAAA,EAAA,EAHf;AAoBH,CA5BwB;;"}
1
+ {"version":3,"file":"index.es5.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,139 @@
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 { V as useTypography, K as useSwatches, G as findDeviceOverride, o as useStyle, r as responsiveStyle, W as shallowMergeFallbacks, s as colorToString } from "./index.es.js";
33
+ import { R as getTypographyStyleSwatchIds, l as isNonNullable } from "./constants.es.js";
34
+ import { cx } from "@emotion/css";
35
+ import { jsx } from "react/jsx-runtime";
36
+ import { forwardRef } from "react";
37
+ const getDeviceId = ({ deviceId }) => deviceId;
38
+ const withColor = (swatches) => (_a) => {
39
+ var _b = _a, {
40
+ value: _c
41
+ } = _b, _d = _c, { color } = _d, restOfValue = __objRest(_d, ["color"]), rest = __objRest(_b, [
42
+ "value"
43
+ ]);
44
+ return __spreadProps(__spreadValues({}, rest), {
45
+ value: __spreadValues(__spreadValues({}, restOfValue), color ? {
46
+ color: {
47
+ swatch: swatches.find((s) => s && s.id === color.swatchId),
48
+ alpha: color.alpha
49
+ }
50
+ } : {})
51
+ });
52
+ };
53
+ const overrideTypographyStyle = (source, override) => {
54
+ const devices = [...new Set(source.map(getDeviceId).concat(override.map(getDeviceId)))];
55
+ return devices.map((deviceId) => ({
56
+ deviceId,
57
+ value: __spreadValues(__spreadValues({}, (findDeviceOverride(source, deviceId) || { value: {} }).value), (findDeviceOverride(override, deviceId, (v) => v) || { value: {} }).value)
58
+ }));
59
+ };
60
+ function useTypographyMark(value) {
61
+ var _a, _b, _c;
62
+ const typography = useTypography((_a = value == null ? void 0 : value.id) != null ? _a : null);
63
+ const swatchIds = [
64
+ ...getTypographyStyleSwatchIds(value == null ? void 0 : value.style),
65
+ ...getTypographyStyleSwatchIds(typography == null ? void 0 : typography.style)
66
+ ];
67
+ const swatches = useSwatches(swatchIds);
68
+ return overrideTypographyStyle((_b = typography == null ? void 0 : typography.style.map(withColor(swatches.filter(isNonNullable)))) != null ? _b : [], (_c = value == null ? void 0 : value.style.map(withColor(swatches.filter(isNonNullable)))) != null ? _c : []);
69
+ }
70
+ function Mark(_a) {
71
+ var _b = _a, {
72
+ value,
73
+ className
74
+ } = _b, restOfProps = __objRest(_b, [
75
+ "value",
76
+ "className"
77
+ ]);
78
+ const typographyStyle = useTypographyMark(value);
79
+ const typographyClassName = useStyle(responsiveStyle([typographyStyle], ([{
80
+ color,
81
+ fontFamily,
82
+ fontSize,
83
+ fontWeight,
84
+ lineHeight,
85
+ letterSpacing,
86
+ uppercase,
87
+ underline,
88
+ strikethrough,
89
+ italic
90
+ } = {}]) => __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, color == null ? {} : {
91
+ color: colorToString(color)
92
+ }), fontFamily == null ? {} : {
93
+ fontFamily
94
+ }), fontSize == null || fontSize.value == null || fontSize.unit == null ? {} : {
95
+ fontSize: `${fontSize.value}${fontSize.unit}`
96
+ }), fontWeight == null ? {} : {
97
+ fontWeight
98
+ }), lineHeight == null ? {} : {
99
+ lineHeight
100
+ }), letterSpacing == null ? {} : {
101
+ letterSpacing: `${letterSpacing / 10}em`
102
+ }), uppercase == null ? {} : {
103
+ textTransform: uppercase === true ? "uppercase" : "initial"
104
+ }), underline == null && strikethrough == null ? {} : {
105
+ textDecoration: [Boolean(underline) && "underline", Boolean(strikethrough) && "line-through"].filter(Boolean).join(" ")
106
+ }), italic == null ? {} : {
107
+ fontStyle: italic === true ? "italic" : "initial"
108
+ }), shallowMergeFallbacks));
109
+ return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, restOfProps), {
110
+ className: cx(typographyClassName, className)
111
+ }));
112
+ }
113
+ var DeviceOverrideBlock = forwardRef(function Block(_c, ref) {
114
+ var _d = _c, {
115
+ textAlign,
116
+ className,
117
+ as
118
+ } = _d, restOfProps = __objRest(_d, [
119
+ "textAlign",
120
+ "className",
121
+ "as"
122
+ ]);
123
+ const Component = as != null ? as : "div";
124
+ return /* @__PURE__ */ jsx(Component, __spreadProps(__spreadValues({}, restOfProps), {
125
+ ref,
126
+ className: cx(useStyle({
127
+ margin: 0
128
+ }), useStyle(responsiveStyle([textAlign], ([textAlign2 = "left"]) => ({
129
+ textAlign: textAlign2
130
+ }))), useStyle(as === "blockquote" ? {
131
+ padding: "0.5em 10px",
132
+ fontSize: "1.25em",
133
+ fontWeight: "300",
134
+ borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
135
+ } : {}), className)
136
+ }));
137
+ });
138
+ export { DeviceOverrideBlock as D, Mark as M };
139
+ //# sourceMappingURL=index.es6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.es6.js","sources":["../src/components/builtin/Text/components/RichTextEditor/components/Mark/hooks/useTypographyMark.ts","../src/components/builtin/Text/components/RichTextEditor/components/Mark/index.tsx","../src/components/builtin/Text/components/RichTextEditor/components/Block/index.tsx"],"sourcesContent":["import { Length as LengthValue } from '../../../../../../../../prop-controllers'\nimport { ColorValue as Color } from '../../../../../../../utils/types'\nimport { findDeviceOverride } from '../../../../../../../utils/devices'\nimport type { DeviceOverride } from '../../../../../../../../prop-controllers'\nimport {\n useSwatches,\n useTypography,\n} from '../../../../../../../../runtimes/react/hooks/makeswift-api'\nimport { Swatch, Typography } from '../../../../../../../../api'\nimport { getTypographyStyleSwatchIds } from '../../../../../../../../prop-controllers/introspection'\nimport { isNonNullable } from '../../../../../../../utils/isNonNullable'\n\nexport type TypographyMarkDataValue = {\n fontWeight?: number\n fontSize?: LengthValue\n fontFamily?: string\n color?: Color\n textAlign?: string\n lineHeight?: number\n letterSpacing?: number\n uppercase?: boolean\n italic?: boolean\n underline?: boolean\n strikethrough?: boolean\n}\n\nexport type TypographyMarkValue = {\n id: string | null | undefined\n style: Typography['style']\n}\n\nexport type TypographyMarkData = Array<DeviceOverride<TypographyMarkDataValue>>\n\nconst getDeviceId = ({ deviceId }: DeviceOverride<unknown>) => deviceId\n\nconst withColor =\n (swatches: Swatch[]) =>\n ({\n value: { color, ...restOfValue },\n ...rest\n }: Typography['style'][number]): DeviceOverride<TypographyMarkDataValue> =>\n ({\n ...rest,\n value: {\n ...restOfValue,\n ...(color\n ? {\n color: {\n swatch: swatches.find(s => s && s.id === color.swatchId),\n alpha: color.alpha,\n },\n }\n : {}),\n } as TypographyMarkDataValue,\n } as DeviceOverride<TypographyMarkDataValue>)\n\nexport const overrideTypographyStyle = <A>(\n source: Array<DeviceOverride<A>>,\n override: Array<DeviceOverride<A>>,\n): Array<DeviceOverride<A>> => {\n const devices = [...new Set(source.map(getDeviceId).concat(override.map(getDeviceId)))]\n\n return devices.map(deviceId => ({\n deviceId,\n value: {\n ...(findDeviceOverride(source, deviceId) || { value: {} }).value,\n ...(findDeviceOverride(override, deviceId, v => v) || { value: {} }).value,\n },\n })) as DeviceOverride<A>[]\n}\n\nexport default function useTypographyMark(\n value: TypographyMarkValue | null | undefined,\n): TypographyMarkData | null | undefined {\n const typography = useTypography(value?.id ?? null)\n const swatchIds = [\n ...getTypographyStyleSwatchIds(value?.style),\n ...getTypographyStyleSwatchIds(typography?.style),\n ]\n const swatches = useSwatches(swatchIds)\n\n return overrideTypographyStyle(\n typography?.style.map(withColor(swatches.filter(isNonNullable))) ?? [],\n value?.style.map(withColor(swatches.filter(isNonNullable))) ?? [],\n )\n}\n","import { ComponentPropsWithoutRef } from 'react'\n\nimport useTypographyMark, {\n TypographyMarkValue,\n overrideTypographyStyle,\n TypographyMarkDataValue,\n} from './hooks/useTypographyMark'\nimport { colorToString } from '../../../../../../utils/colorToString'\nimport { shallowMergeFallbacks } from '../../../../../../utils/devices'\nimport { cx } from '@emotion/css'\nimport { useStyle } from '../../../../../../../runtimes/react/use-style'\nimport { responsiveStyle } from '../../../../../../utils/responsive-style'\nimport { ResponsiveValue } from '../../../../../../../prop-controllers/descriptors'\n\nexport type { TypographyMarkValue }\nexport { overrideTypographyStyle }\n\ntype BaseProps = { value: TypographyMarkValue }\n\ntype Props = BaseProps & Omit<ComponentPropsWithoutRef<'span'>, keyof BaseProps>\n\nexport default function Mark({ value, className, ...restOfProps }: Props): JSX.Element {\n const typographyStyle = useTypographyMark(value)\n const typographyClassName = useStyle(\n responsiveStyle<\n TypographyMarkDataValue,\n [ResponsiveValue<TypographyMarkDataValue> | null | undefined]\n >(\n [typographyStyle],\n ([\n {\n color,\n fontFamily,\n fontSize,\n fontWeight,\n lineHeight,\n letterSpacing,\n uppercase,\n underline,\n strikethrough,\n italic,\n } = {} as TypographyMarkDataValue,\n ]) => ({\n ...(color == null ? {} : { color: colorToString(color) }),\n ...(fontFamily == null ? {} : { fontFamily }),\n ...(fontSize == null || fontSize.value == null || fontSize.unit == null\n ? {}\n : { fontSize: `${fontSize.value}${fontSize.unit}` }),\n ...(fontWeight == null ? {} : { fontWeight }),\n ...(lineHeight == null ? {} : { lineHeight }),\n ...(letterSpacing == null ? {} : { letterSpacing: `${letterSpacing / 10}em` }),\n ...(uppercase == null\n ? {}\n : { textTransform: uppercase === true ? 'uppercase' : 'initial' }),\n ...(underline == null && strikethrough == null\n ? {}\n : {\n textDecoration: [\n Boolean(underline) && 'underline',\n Boolean(strikethrough) && 'line-through',\n ]\n .filter(Boolean)\n .join(' '),\n }),\n ...(italic == null ? {} : { fontStyle: italic === true ? 'italic' : 'initial' }),\n }),\n shallowMergeFallbacks,\n ),\n )\n\n return <span {...restOfProps} className={cx(typographyClassName, className)} />\n}\n","import { cx } from '@emotion/css'\nimport { forwardRef, ComponentPropsWithoutRef, ForwardedRef, ElementRef, ElementType } from 'react'\n\nimport type { ResponsiveValue } from '../../../../../../../prop-controllers'\nimport { useStyle } from '../../../../../../../runtimes/react/use-style'\nimport { responsiveStyle } from '../../../../../../utils/responsive-style'\n\ntype BaseProps<T extends ElementType> = {\n as?: T\n textAlign?: ResponsiveValue<'left' | 'center' | 'right' | 'justify'>\n}\n\ntype Props<T extends ElementType> = BaseProps<T> &\n Omit<ComponentPropsWithoutRef<T>, keyof BaseProps<T>>\n\nexport default forwardRef(function Block<T extends ElementType>(\n { textAlign, className, as, ...restOfProps }: Props<T>,\n ref: ForwardedRef<ElementRef<T>>,\n) {\n const Component = as ?? 'div'\n\n return (\n // @ts-ignore: `ref` types don't match.\n <Component\n {...restOfProps}\n ref={ref}\n className={cx(\n useStyle({ margin: 0 }),\n useStyle(responsiveStyle([textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n useStyle(\n as === 'blockquote'\n ? {\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n }\n : {},\n ),\n className,\n )}\n />\n )\n})\n"],"names":["value","className","restOfProps","typographyStyle","useTypographyMark","typographyClassName","useStyle","responsiveStyle","color","fontFamily","fontSize","fontWeight","lineHeight","letterSpacing","uppercase","underline","strikethrough","italic","colorToString","unit","textTransform","textDecoration","Boolean","filter","join","fontStyle","shallowMergeFallbacks","cx","forwardRef","ref","textAlign","as","Component","margin","padding","borderLeft"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,cAAc,CAAC,EAAE,eAAwC;AAE/D,MAAM,YACJ,CAAC,aACD,CAAC,OAIE;AAJF,eACQ;AAAA,IAAP,OAAO;AAAA,MADR,IACQ,SAAE,YAAF,IAAY,wBAAZ,IAAY,CAAV,WACN,iBAFJ,IAEI;AAAA,IADH;AAAA;AAGC,0CACI,OADJ;AAAA,IAEC,OAAO,kCACF,cACC,QACA;AAAA,MACE,OAAO;AAAA,QACL,QAAQ,SAAS,KAAK,CAAA,MAAK,KAAK,EAAE,OAAO,MAAM,QAAQ;AAAA,QACvD,OAAO,MAAM;AAAA,MACf;AAAA,IAAA,IAEF,CAAC;AAAA,EAET;AAAA;AAES,MAAA,0BAA0B,CACrC,QACA,aAC6B;AAC7B,QAAM,UAAU,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,WAAW,EAAE,OAAO,SAAS,IAAI,WAAW,CAAC,CAAC,CAAC;AAE/E,SAAA,QAAQ,IAAI,CAAa,aAAA;AAAA,IAC9B;AAAA,IACA,OAAO,kCACD,oBAAmB,QAAQ,QAAQ,KAAK,EAAE,OAAO,MAAM,QACvD,oBAAmB,UAAU,UAAU,CAAK,MAAA,CAAC,KAAK,EAAE,OAAO,CAAC,EAAA,GAAK;AAAA,EAEvE,EAAA;AACJ;AAEA,2BACE,OACuC;;AACvC,QAAM,aAAa,cAAc,qCAAO,OAAP,YAAa,IAAI;AAClD,QAAM,YAAY;AAAA,IAChB,GAAG,4BAA4B,+BAAO,KAAK;AAAA,IAC3C,G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tBO,QAAQN,aAAD,KAAmB,cAFZ,EAIbO,OAAOD,OAJM,EAKbE,KAAK,GALQ;AAAA,EADlB,IAQAP,UAAU,OAAO,KAAK;AAAA,IAAEQ,WAAWR,WAAW,OAAO,WAAW;AAAA,EAApE,IAEFS,qBA1Ca,CADmB;AA+CpC,sEAAiBxB;IAAa,WAAWyB,GAAGtB,qBAAqBJ,SAAtB;AAAA,EAAA,EAA3C;AACD;ACxDD,IAAA,sBAAe2B,WAAW,eACxB,IACAC,KACA;AAFA,eAAEC;AAAAA;AAAAA,IAAW7B;AAAAA,IAAW8B;AAAAA,MAAxB,IAA+B7B,wBAA/B,IAA+BA;AAAAA,IAA7B4B;AAAAA,IAAW7B;AAAAA,IAAW8B;AAAAA;AAGxB,QAAMC,YAAYD,kBAAM;AAExB,6BAEG,4CACK7B;IACJ;AAAA,IACA,WAAWyB,GACTrB,SAAS;AAAA,MAAE2B,QAAQ;AAAA,IAAA,CAAX,GACR3B,SAASC,gBAAgB,CAACuB,SAAD,GAAa,CAAC,CAACA,aAAY,YAAa;AAAA,MAAEA,WAAAA;AAAAA,IAA3C,EAAA,CAAhB,GACRxB,SACEyB,OAAO,eACH;AAAA,MACEG,SAAS;AAAA,MACTxB,UAAU;AAAA,MACVC,YAAY;AAAA,MACZwB,YAAY;AAAA,IAAA,IAEd,CAAA,CARE,GAURlC,SAbW;AAAA,EAAA,EAHf;AAoBH,CA5BwB;;"}
package/dist/main.cjs.js CHANGED
@@ -4,7 +4,7 @@ var actions = require("./actions.cjs.js");
4
4
  var constants = require("./constants.cjs.js");
5
5
  require("redux");
6
6
  require("redux-thunk");
7
- require("./slot.cjs.js");
7
+ require("./rich-text.cjs.js");
8
8
  require("./control.cjs.js");
9
9
  exports.ActionTypes = actions.ActionTypes;
10
10
  exports.changeApiResource = actions.changeApiResource;
package/dist/main.es.js CHANGED
@@ -2,6 +2,6 @@ export { A as ActionTypes, d as changeApiResource, c as changeDocument, a as cha
2
2
  export { M as MakeswiftComponentType, c as createDocument } from "./constants.es.js";
3
3
  import "redux";
4
4
  import "redux-thunk";
5
- import "./slot.es.js";
5
+ import "./rich-text.es.js";
6
6
  import "./control.es.js";
7
7
  //# sourceMappingURL=main.es.js.map
package/dist/next.cjs.js CHANGED
@@ -9,7 +9,7 @@ require("./constants.cjs.js");
9
9
  require("redux");
10
10
  require("redux-thunk");
11
11
  require("./actions.cjs.js");
12
- require("./slot.cjs.js");
12
+ require("./rich-text.cjs.js");
13
13
  require("./control.cjs.js");
14
14
  require("@emotion/css");
15
15
  require("@emotion/serialize");
package/dist/next.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "react";
2
- export { a1 as Document, $ as Makeswift, a2 as MakeswiftApiHandler, W as MakeswiftClient, _ as Page, a0 as PreviewModeScript, H as forwardNextDynamicRef, Z as getServerSideProps, X as getStaticPaths, Y as getStaticProps } from "./index.es.js";
2
+ export { a2 as Document, a0 as Makeswift, a3 as MakeswiftApiHandler, X as MakeswiftClient, $ as Page, a1 as PreviewModeScript, H as forwardNextDynamicRef, _ as getServerSideProps, Y as getStaticPaths, Z as getStaticProps } from "./index.es.js";
3
3
  import "react/jsx-runtime";
4
4
  import "use-sync-external-store/shim/with-selector";
5
5
  import "next/dynamic";
@@ -7,7 +7,7 @@ import "./constants.es.js";
7
7
  import "redux";
8
8
  import "redux-thunk";
9
9
  import "./actions.es.js";
10
- import "./slot.es.js";
10
+ import "./rich-text.es.js";
11
11
  import "./control.es.js";
12
12
  import "@emotion/css";
13
13
  import "@emotion/serialize";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- var slot = require("./slot.cjs.js");
4
- exports.Props = slot.descriptors;
5
- exports.RichTextPropControllerMessageType = slot.RichTextPropControllerMessageType;
6
- exports.TableFormFieldsMessageType = slot.TableFormFieldsMessageType;
3
+ var richText = require("./rich-text.cjs.js");
4
+ exports.Props = richText.descriptors;
5
+ exports.RichTextPropControllerMessageType = richText.RichTextPropControllerMessageType;
6
+ exports.TableFormFieldsMessageType = richText.TableFormFieldsMessageType;
7
7
  //# sourceMappingURL=prop-controllers.cjs.js.map
@@ -1,2 +1,2 @@
1
- export { f as Props, R as RichTextPropControllerMessageType, g as TableFormFieldsMessageType } from "./slot.es.js";
1
+ export { f as Props, R as RichTextPropControllerMessageType, g as TableFormFieldsMessageType } from "./rich-text.es.js";
2
2
  //# sourceMappingURL=prop-controllers.es.js.map
package/dist/react.cjs.js CHANGED
@@ -8,7 +8,7 @@ require("next/dynamic");
8
8
  require("./constants.cjs.js");
9
9
  require("redux");
10
10
  require("redux-thunk");
11
- require("./slot.cjs.js");
11
+ require("./rich-text.cjs.js");
12
12
  require("./control.cjs.js");
13
13
  require("@emotion/css");
14
14
  require("@emotion/serialize");
package/dist/react.es.js CHANGED
@@ -6,7 +6,7 @@ import "next/dynamic";
6
6
  import "./constants.es.js";
7
7
  import "redux";
8
8
  import "redux-thunk";
9
- import "./slot.es.js";
9
+ import "./rich-text.es.js";
10
10
  import "./control.es.js";
11
11
  import "@emotion/css";
12
12
  import "@emotion/serialize";
@@ -230,7 +230,7 @@ function ResponsiveOpacity(options = {}) {
230
230
  function ResponsiveSelect(options) {
231
231
  return { type: Types.ResponsiveSelect, options };
232
232
  }
233
- function RichText(options = {}) {
233
+ function RichText$1(options = {}) {
234
234
  return { type: Types.RichText, options };
235
235
  }
236
236
  const ShadowsPropControllerFormat = {
@@ -307,7 +307,7 @@ var descriptors = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro
307
307
  ResponsiveNumber,
308
308
  ResponsiveOpacity,
309
309
  ResponsiveSelect,
310
- RichText,
310
+ RichText: RichText$1,
311
311
  ShadowsPropControllerFormat,
312
312
  Shadows,
313
313
  Shape,
@@ -348,7 +348,8 @@ const RichTextPropControllerMessageType = {
348
348
  FOCUS: "FOCUS",
349
349
  BLUR: "BLUR",
350
350
  UNDO: "UNDO",
351
- REDO: "REDO"
351
+ REDO: "REDO",
352
+ CHANGE_BOX_MODEL: "CHANGE_BOX_MODEL"
352
353
  };
353
354
  class PropController {
354
355
  constructor(send) {
@@ -373,12 +374,13 @@ class RichTextPropController extends PropController {
373
374
  case BuilderEditMode.BUILD:
374
375
  (_a = this.editor) == null ? void 0 : _a.deselect().blur();
375
376
  break;
376
- case BuilderEditMode.CONTENT:
377
- (_b = this.editor) == null ? void 0 : _b.focus().moveToRangeOfDocument();
378
- break;
379
377
  }
380
378
  break;
381
379
  }
380
+ case RichTextPropControllerMessageType.FOCUS: {
381
+ (_b = this.editor) == null ? void 0 : _b.focus().moveToRangeOfDocument();
382
+ break;
383
+ }
382
384
  }
383
385
  }
384
386
  setSlateEditor(editor) {
@@ -406,6 +408,9 @@ class RichTextPropController extends PropController {
406
408
  redo() {
407
409
  this.send({ type: RichTextPropControllerMessageType.REDO });
408
410
  }
411
+ changeBoxModel(boxModel) {
412
+ this.send({ type: RichTextPropControllerMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
413
+ }
409
414
  }
410
415
  const TableFormFieldsMessageType = {
411
416
  TABLE_FORM_LAYOUT_CHANGE: "TABLE_FORM_LAYOUT_CHANGE",
@@ -429,6 +434,8 @@ function createPropController(descriptor, send) {
429
434
  return new TableFormFieldsPropController(send);
430
435
  case SlotControlType:
431
436
  return new SlotControl(send);
437
+ case RichTextControlType:
438
+ return new RichTextControl(send);
432
439
  default:
433
440
  return new DefaultPropController(send);
434
441
  }
@@ -458,6 +465,71 @@ function copySlotData(value, context) {
458
465
  elements: value.elements.map((element) => context.copyElement(element))
459
466
  });
460
467
  }
468
+ const RichTextControlType = "makeswift::controls::rich-text";
469
+ function RichText() {
470
+ return { type: RichTextControlType };
471
+ }
472
+ const RichTextControlMessageType = {
473
+ CHANGE_BUILDER_EDIT_MODE: "CHANGE_BUILDER_EDIT_MODE",
474
+ INITIALIZE_EDITOR: "INITIALIZE_EDITOR",
475
+ CHANGE_EDITOR_VALUE: "CHANGE_EDITOR_VALUE",
476
+ FOCUS: "FOCUS",
477
+ BLUR: "BLUR",
478
+ UNDO: "UNDO",
479
+ REDO: "REDO",
480
+ CHANGE_BOX_MODEL: "CHANGE_BOX_MODEL"
481
+ };
482
+ class RichTextControl extends PropController {
483
+ constructor() {
484
+ super(...arguments);
485
+ __publicField(this, "editor", null);
486
+ }
487
+ recv(message) {
488
+ var _a, _b;
489
+ switch (message.type) {
490
+ case RichTextControlMessageType.CHANGE_BUILDER_EDIT_MODE: {
491
+ switch (message.editMode) {
492
+ case BuilderEditMode.BUILD:
493
+ (_a = this.editor) == null ? void 0 : _a.deselect().blur();
494
+ break;
495
+ }
496
+ break;
497
+ }
498
+ case RichTextControlMessageType.FOCUS: {
499
+ (_b = this.editor) == null ? void 0 : _b.focus().moveToRangeOfDocument();
500
+ break;
501
+ }
502
+ }
503
+ }
504
+ setSlateEditor(editor) {
505
+ this.editor = editor;
506
+ this.send({
507
+ type: RichTextControlMessageType.INITIALIZE_EDITOR,
508
+ value: editor.value.toJSON({ preserveSelection: false })
509
+ });
510
+ }
511
+ onChange(change) {
512
+ this.send({
513
+ type: RichTextControlMessageType.CHANGE_EDITOR_VALUE,
514
+ value: change.value.toJSON({ preserveSelection: true })
515
+ });
516
+ }
517
+ focus() {
518
+ this.send({ type: RichTextControlMessageType.FOCUS });
519
+ }
520
+ blur() {
521
+ this.send({ type: RichTextControlMessageType.BLUR });
522
+ }
523
+ undo() {
524
+ this.send({ type: RichTextControlMessageType.UNDO });
525
+ }
526
+ redo() {
527
+ this.send({ type: RichTextControlMessageType.REDO });
528
+ }
529
+ changeBoxModel(boxModel) {
530
+ this.send({ type: RichTextControlMessageType.CHANGE_BOX_MODEL, payload: { boxModel } });
531
+ }
532
+ }
461
533
  exports.Backgrounds = Backgrounds;
462
534
  exports.Border = Border;
463
535
  exports.BorderPropControllerFormat = BorderPropControllerFormat;
@@ -490,7 +562,11 @@ exports.ResponsiveLength = ResponsiveLength;
490
562
  exports.ResponsiveNumber = ResponsiveNumber;
491
563
  exports.ResponsiveOpacity = ResponsiveOpacity;
492
564
  exports.ResponsiveSelect = ResponsiveSelect;
493
- exports.RichText = RichText;
565
+ exports.RichText = RichText$1;
566
+ exports.RichText$1 = RichText;
567
+ exports.RichTextControl = RichTextControl;
568
+ exports.RichTextControlMessageType = RichTextControlMessageType;
569
+ exports.RichTextControlType = RichTextControlType;
494
570
  exports.RichTextPropControllerMessageType = RichTextPropControllerMessageType;
495
571
  exports.Shadows = Shadows;
496
572
  exports.ShadowsPropControllerFormat = ShadowsPropControllerFormat;
@@ -518,4 +594,4 @@ exports.copySlotData = copySlotData;
518
594
  exports.copyStyleData = copyStyleData;
519
595
  exports.createPropController = createPropController;
520
596
  exports.descriptors = descriptors;
521
- //# sourceMappingURL=slot.cjs.js.map
597
+ //# sourceMappingURL=rich-text.cjs.js.map