@makeswift/runtime 0.23.0 → 0.23.1-canary.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.
@@ -37,7 +37,7 @@ async function handler(...args) {
37
37
  const supportsDraftMode = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => true).with(apiRoutePattern, () => false).exhaustive();
38
38
  const supportsWebhook = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => true).with(apiRoutePattern, () => false).exhaustive();
39
39
  const body = {
40
- version: "0.23.0",
40
+ version: "0.23.1-canary.0",
41
41
  previewMode: supportsPreviewMode,
42
42
  draftMode: supportsDraftMode,
43
43
  interactionMode: true,
@@ -38,7 +38,7 @@ var import_css = require("@emotion/css");
38
38
  var import_react = require("react");
39
39
  var import_controls = require("@makeswift/controls");
40
40
  var import_responsive_style = require("../../../../components/utils/responsive-style");
41
- var import_slate2 = require("../../../../slate");
41
+ var import_types = require("../../../../slate/types");
42
42
  var import_use_style = require("../../use-style");
43
43
  var import_typography = __toESM(require("../typography"));
44
44
  var import_Link = require("../../../../components/shared/Link");
@@ -90,13 +90,13 @@ function TextElement({ descendant }) {
90
90
  function InlineElement({ descendant }) {
91
91
  const linkClassName = (0, import_use_style.useStyle)({ textDecoration: "none" });
92
92
  switch (descendant.type) {
93
- case import_slate2.InlineType.Code:
93
+ case import_types.InlineType.Code:
94
94
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
95
- case import_slate2.InlineType.SuperScript:
95
+ case import_types.InlineType.SuperScript:
96
96
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("sup", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
97
- case import_slate2.InlineType.SubScript:
97
+ case import_types.InlineType.SubScript:
98
98
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("sub", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
99
- case import_slate2.InlineType.Link:
99
+ case import_types.InlineType.Link:
100
100
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Link.Link, { className: linkClassName, link: descendant.link ?? void 0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
101
101
  }
102
102
  }
@@ -112,30 +112,30 @@ function BlockElement({ descendant }) {
112
112
  borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
113
113
  });
114
114
  switch (descendant.type) {
115
- case import_slate2.BlockType.Default:
116
- case import_slate2.BlockType.Paragraph:
115
+ case import_types.BlockType.Default:
116
+ case import_types.BlockType.Paragraph:
117
117
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: (0, import_css.cx)(...blockStyles), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
118
- case import_slate2.BlockType.Heading1:
118
+ case import_types.BlockType.Heading1:
119
119
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: (0, import_css.cx)(...blockStyles), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
120
- case import_slate2.BlockType.Heading2:
120
+ case import_types.BlockType.Heading2:
121
121
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: (0, import_css.cx)(...blockStyles), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
122
- case import_slate2.BlockType.Heading3:
122
+ case import_types.BlockType.Heading3:
123
123
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: (0, import_css.cx)(...blockStyles), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
124
- case import_slate2.BlockType.Heading4:
124
+ case import_types.BlockType.Heading4:
125
125
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { className: (0, import_css.cx)(...blockStyles), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
126
- case import_slate2.BlockType.Heading5:
126
+ case import_types.BlockType.Heading5:
127
127
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h5", { className: (0, import_css.cx)(...blockStyles), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
128
- case import_slate2.BlockType.Heading6:
128
+ case import_types.BlockType.Heading6:
129
129
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h6", { className: (0, import_css.cx)(...blockStyles), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
130
- case import_slate2.BlockType.BlockQuote:
130
+ case import_types.BlockType.BlockQuote:
131
131
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("blockquote", { className: (0, import_css.cx)(...blockStyles, quoteStyle), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
132
- case import_slate2.BlockType.OrderedList:
132
+ case import_types.BlockType.OrderedList:
133
133
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ol", { className: (0, import_css.cx)(...blockStyles), style: { listStylePosition: "inside" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
134
- case import_slate2.BlockType.UnorderedList:
134
+ case import_types.BlockType.UnorderedList:
135
135
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: (0, import_css.cx)(...blockStyles), style: { listStylePosition: "inside" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
136
- case import_slate2.BlockType.ListItem:
136
+ case import_types.BlockType.ListItem:
137
137
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { className: (0, import_css.cx)(...blockStyles), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
138
- case import_slate2.BlockType.ListItemChild:
138
+ case import_types.BlockType.ListItemChild:
139
139
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (0, import_css.cx)(...blockStyles), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Descendants, { descendants: descendant.children }) });
140
140
  default:
141
141
  return null;
@@ -147,24 +147,24 @@ function Descendants({ descendants }) {
147
147
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextElement, { descendant }, index);
148
148
  }
149
149
  switch (descendant.type) {
150
- case import_slate2.InlineType.Link:
151
- case import_slate2.InlineType.Code:
152
- case import_slate2.InlineType.SubScript:
153
- case import_slate2.InlineType.SuperScript:
150
+ case import_types.InlineType.Link:
151
+ case import_types.InlineType.Code:
152
+ case import_types.InlineType.SubScript:
153
+ case import_types.InlineType.SuperScript:
154
154
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InlineElement, { descendant }, index);
155
- case import_slate2.BlockType.Heading1:
156
- case import_slate2.BlockType.Heading2:
157
- case import_slate2.BlockType.Heading3:
158
- case import_slate2.BlockType.Heading4:
159
- case import_slate2.BlockType.Heading5:
160
- case import_slate2.BlockType.Heading6:
161
- case import_slate2.BlockType.BlockQuote:
162
- case import_slate2.BlockType.Paragraph:
163
- case import_slate2.BlockType.Default:
164
- case import_slate2.BlockType.OrderedList:
165
- case import_slate2.BlockType.UnorderedList:
166
- case import_slate2.BlockType.ListItem:
167
- case import_slate2.BlockType.ListItemChild:
155
+ case import_types.BlockType.Heading1:
156
+ case import_types.BlockType.Heading2:
157
+ case import_types.BlockType.Heading3:
158
+ case import_types.BlockType.Heading4:
159
+ case import_types.BlockType.Heading5:
160
+ case import_types.BlockType.Heading6:
161
+ case import_types.BlockType.BlockQuote:
162
+ case import_types.BlockType.Paragraph:
163
+ case import_types.BlockType.Default:
164
+ case import_types.BlockType.OrderedList:
165
+ case import_types.BlockType.UnorderedList:
166
+ case import_types.BlockType.ListItem:
167
+ case import_types.BlockType.ListItemChild:
168
168
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BlockElement, { descendant }, index);
169
169
  default:
170
170
  return null;
@@ -175,19 +175,19 @@ function isBlock(descendant) {
175
175
  if ("text" in descendant)
176
176
  return false;
177
177
  switch (descendant.type) {
178
- case import_slate2.BlockType.Heading1:
179
- case import_slate2.BlockType.Heading2:
180
- case import_slate2.BlockType.Heading3:
181
- case import_slate2.BlockType.Heading4:
182
- case import_slate2.BlockType.Heading5:
183
- case import_slate2.BlockType.Heading6:
184
- case import_slate2.BlockType.BlockQuote:
185
- case import_slate2.BlockType.Paragraph:
186
- case import_slate2.BlockType.Default:
187
- case import_slate2.BlockType.OrderedList:
188
- case import_slate2.BlockType.UnorderedList:
189
- case import_slate2.BlockType.ListItem:
190
- case import_slate2.BlockType.ListItemChild:
178
+ case import_types.BlockType.Heading1:
179
+ case import_types.BlockType.Heading2:
180
+ case import_types.BlockType.Heading3:
181
+ case import_types.BlockType.Heading4:
182
+ case import_types.BlockType.Heading5:
183
+ case import_types.BlockType.Heading6:
184
+ case import_types.BlockType.BlockQuote:
185
+ case import_types.BlockType.Paragraph:
186
+ case import_types.BlockType.Default:
187
+ case import_types.BlockType.OrderedList:
188
+ case import_types.BlockType.UnorderedList:
189
+ case import_types.BlockType.ListItem:
190
+ case import_types.BlockType.ListItemChild:
191
191
  return true;
192
192
  default:
193
193
  return false;
@@ -198,24 +198,24 @@ function getTextByDescendant(descendant) {
198
198
  return descendant.text ?? "";
199
199
  }
200
200
  switch (descendant.type) {
201
- case import_slate2.InlineType.Link:
202
- case import_slate2.InlineType.Code:
203
- case import_slate2.InlineType.SubScript:
204
- case import_slate2.InlineType.SuperScript:
201
+ case import_types.InlineType.Link:
202
+ case import_types.InlineType.Code:
203
+ case import_types.InlineType.SubScript:
204
+ case import_types.InlineType.SuperScript:
205
205
  return descendant.children.map((descendant2) => getTextByDescendant(descendant2)).join("") ?? "";
206
- case import_slate2.BlockType.Heading1:
207
- case import_slate2.BlockType.Heading2:
208
- case import_slate2.BlockType.Heading3:
209
- case import_slate2.BlockType.Heading4:
210
- case import_slate2.BlockType.Heading5:
211
- case import_slate2.BlockType.Heading6:
212
- case import_slate2.BlockType.BlockQuote:
213
- case import_slate2.BlockType.Paragraph:
214
- case import_slate2.BlockType.Default:
215
- case import_slate2.BlockType.OrderedList:
216
- case import_slate2.BlockType.UnorderedList:
217
- case import_slate2.BlockType.ListItem:
218
- case import_slate2.BlockType.ListItemChild:
206
+ case import_types.BlockType.Heading1:
207
+ case import_types.BlockType.Heading2:
208
+ case import_types.BlockType.Heading3:
209
+ case import_types.BlockType.Heading4:
210
+ case import_types.BlockType.Heading5:
211
+ case import_types.BlockType.Heading6:
212
+ case import_types.BlockType.BlockQuote:
213
+ case import_types.BlockType.Paragraph:
214
+ case import_types.BlockType.Default:
215
+ case import_types.BlockType.OrderedList:
216
+ case import_types.BlockType.UnorderedList:
217
+ case import_types.BlockType.ListItem:
218
+ case import_types.BlockType.ListItemChild:
219
219
  return descendant.children.map((descendant2) => getTextByDescendant(descendant2)).join(descendant.children.every(isBlock) ? "\n" : "") ?? "";
220
220
  default:
221
221
  return "";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\n\nimport { Slate, RichTextValue, richTextDTOtoDAO } from '@makeswift/controls'\n\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { InlineType, BlockType } from '../../../../slate'\nimport { useStyle } from '../../use-style'\nimport useEnhancedTypography, { useTypographyClassName } from '../typography'\nimport { Link } from '../../../../components/shared/Link'\n\ntype Props = {\n id?: string\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div\n ref={ref}\n id={id}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n className={cx(width, margin)}\n >\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Slate.Inline\n}\n\nfunction InlineElement({ descendant }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link ?? undefined}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Slate.Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n const quoteStyle = useStyle({\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 switch (descendant.type) {\n case BlockType.Default:\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n default:\n return null\n }\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (Slate.isText(descendant)) {\n return <TextElement key={index} descendant={descendant} />\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return <InlineElement key={index} descendant={descendant} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Slate.Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText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B;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,yBAAW;AAAA,IAChB,KAAK,yBAAW;AAAA,IAChB,KAAK,yBAAW;AAAA,IAChB,KAAK,yBAAW;AACd,aAAO,WAAW,SAAS,IAAI,CAAAC,gBAAc,oBAAoBA,WAAU,CAAC,EAAE,KAAK,EAAE,KAAK;AAAA,IAC5F,KAAK,wBAAU;AAAA,IACf,KAAK,wBAAU;AAAA,IACf,KAAK,wBAAU;AAAA,IACf,KAAK,wBAAU;AAAA,IACf,KAAK,wBAAU;AAAA,IACf,KAAK,wBAAU;AAAA,IACf,KAAK,wBAAU;AAAA,IACf,KAAK,wBAAU;AAAA,IACf,KAAK,wBAAU;AAAA,IACf,KAAK,wBAAU;AAAA,IACf,KAAK,wBAAU;AAAA,IACf,KAAK,wBAAU;AAAA,IACf,KAAK,wBAAU;AACb,aACE,WAAW,SACR,IAAI,CAAAA,gBAAc,oBAAoBA,WAAU,CAAC,EACjD,KAAK,WAAW,SAAS,MAAM,OAAO,IAAI,OAAO,EAAE,KAAK;AAAA,IAE/D;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,QAAQ,YAAkC;AACjD,SAAO,WAAW,IAAI,mBAAmB,EAAE,KAAK,IAAI;AACtD;","names":["import_slate","ReadOnlyText","useEnhancedTypography","descendant"]}
1
+ {"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\n\nimport { Slate, RichTextValue, richTextDTOtoDAO } from '@makeswift/controls'\n\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { InlineType, BlockType } from '../../../../slate/types'\nimport { useStyle } from '../../use-style'\nimport useEnhancedTypography, { useTypographyClassName } from '../typography'\nimport { Link } from '../../../../components/shared/Link'\n\ntype Props = {\n id?: string\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div\n ref={ref}\n id={id}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n className={cx(width, margin)}\n >\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Slate.Inline\n}\n\nfunction InlineElement({ descendant }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link ?? undefined}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Slate.Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n const quoteStyle = useStyle({\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 switch (descendant.type) {\n case BlockType.Default:\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n default:\n return null\n }\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (Slate.isText(descendant)) {\n return <TextElement key={index} descendant={descendant} />\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return <InlineElement key={index} descendant={descendant} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Slate.Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CoC;AA1CpC,iBAAmB;AACnB,mBAAyC;AAGzC,sBAAuD;AAEvD,8BAAmC;AACnC,mBAAsC;AACtC,uBAAyB;AACzB,wBAA8D;AAC9D,kBAAqB;AASrB,MAAM,mBAAe,yBAAW,SAASA,cACvC,EAAE,IAAI,MAAM,OAAO,OAAO,GAC1B,KACA;AACA,QAAM,cAAc,QAAQ,OAAO,CAAC,QAAI,kCAAiB,IAAI;AAC7D,QAAM,sBAAsB,QAAQ,WAAW;AAE/C,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAML,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,UAAU;AAAA,MACZ;AAAA,MACA,eAAW,eAAG,OAAO,MAAM;AAAA,MAE1B,kCAAwB,KAAK,4CAAC,eAAY,IAAK,4CAAC,eAAY,aAA0B;AAAA;AAAA,EACzF;AAEJ,CAAC;AAED,IAAO,uBAAQ;AAEf,SAAS,YAAY,EAAE,OAAO,qBAAqB,GAAsB;AACvE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,2BAAS;AAAA,QAClB,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,eAAe;AAAA,MACjB,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AAEJ;AAMO,SAAS,YAAY,EAAE,WAAW,GAAc;AACrD,QAAM,yBAAqB,kBAAAC,SAAsB,WAAW,UAAU;AACtE,QAAM,0BAAs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E,aAAO;AAAA,EACX;AACF;AAEA,SAAS,oBAAoB,YAAgC;AAC3D,MAAI,UAAU,YAAY;AACxB,WAAO,WAAW,QAAQ;AAAA,EAC5B;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,wBAAW;AAAA,IAChB,KAAK,wBAAW;AAAA,IAChB,KAAK,wBAAW;AAAA,IAChB,KAAK,wBAAW;AACd,aAAO,WAAW,SAAS,IAAI,CAAAC,gBAAc,oBAAoBA,WAAU,CAAC,EAAE,KAAK,EAAE,KAAK;AAAA,IAC5F,KAAK,uBAAU;AAAA,IACf,KAAK,uBAAU;AAAA,IACf,KAAK,uBAAU;AAAA,IACf,KAAK,uBAAU;AAAA,IACf,KAAK,uBAAU;AAAA,IACf,KAAK,uBAAU;AAAA,IACf,KAAK,uBAAU;AAAA,IACf,KAAK,uBAAU;AAAA,IACf,KAAK,uBAAU;AAAA,IACf,KAAK,uBAAU;AAAA,IACf,KAAK,uBAAU;AAAA,IACf,KAAK,uBAAU;AAAA,IACf,KAAK,uBAAU;AACb,aACE,WAAW,SACR,IAAI,CAAAA,gBAAc,oBAAoBA,WAAU,CAAC,EACjD,KAAK,WAAW,SAAS,MAAM,OAAO,IAAI,OAAO,EAAE,KAAK;AAAA,IAE/D;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,QAAQ,YAAkC;AACjD,SAAO,WAAW,IAAI,mBAAmB,EAAE,KAAK,IAAI;AACtD;","names":["ReadOnlyText","useEnhancedTypography","descendant"]}
@@ -26,10 +26,10 @@ var import_jsx_runtime = require("react/jsx-runtime");
26
26
  var import_react = require("react");
27
27
  var import_rich_text_v2 = require("../../../../controls/rich-text-v2");
28
28
  var import_use_style = require("../../use-style");
29
- var import_slate2 = require("../../../../slate");
29
+ var import_utils = require("../../../../slate/utils");
30
30
  var import_control = require("../control");
31
31
  const ReadOnlyTextV2 = (0, import_react.forwardRef)(function ReadOnlyText({ text, definition }, ref) {
32
- const descendantsAsString = (0, import_slate2.toText)(
32
+ const descendantsAsString = (0, import_utils.toText)(
33
33
  text?.descendants ?? [],
34
34
  definition?.config.mode ?? import_rich_text_v2.RichText.Mode.Block
35
35
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } from 'react'\n\nimport { RichTextV2Definition, RichText } from '../../../../controls/rich-text-v2'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Element, Text } from 'slate'\nimport { toText } from '../../../../slate'\nimport { ControlValue } from '../control'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\nimport { RichTextV2Plugin } from '../../../../controls/rich-text-v2/plugin'\nimport { RichTextDataV2 } from '../../../../controls/rich-text-v2'\n\ntype Props = {\n text: RichTextDataV2 | undefined\n definition: RichTextV2Definition | undefined\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = toText(\n text?.descendants ?? [],\n definition?.config.mode ?? RichText.Mode.Block,\n )\n\n return (\n <div\n ref={ref}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n >\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants\n plugins={definition?.config.plugins ?? []}\n descendants={text?.descendants ?? []}\n />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps) {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf={descendant} />\n }\n\n return <ElementComponent key={index} descendant={descendant} plugins={plugins} />\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AGG;AACD,SACE,2EACG,sBAAY,IAAI,CAAC,YAAY,UAAU;AACtC,QAAI,OAAO,UAAU,GAAG;AACtB,aAAO,4CAAC,iBAA0B,SAAkB,MAAM,cAA/B,KAA2C;AAAA,IACxE;AAEA,WAAO,4CAAC,oBAA6B,YAAwB,WAA/B,KAAiD;AAAA,EACjF,CAAC,GACH;AAEJ;","names":["import_slate","props","renderLeaf","renderElement"]}
1
+ {"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Element, Text } from 'slate'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\n\nimport { RichTextV2Definition, RichText } from '../../../../controls/rich-text-v2'\nimport { useStyle } from '../../use-style'\nimport { toText } from '../../../../slate/utils'\nimport { RichTextV2Plugin } from '../../../../controls/rich-text-v2/plugin'\nimport { RichTextDataV2 } from '../../../../controls/rich-text-v2'\n\nimport { ControlValue } from '../control'\n\ntype Props = {\n text: RichTextDataV2 | undefined\n definition: RichTextV2Definition | undefined\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = toText(\n text?.descendants ?? [],\n definition?.config.mode ?? RichText.Mode.Block,\n )\n\n return (\n <div\n ref={ref}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n >\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants\n plugins={definition?.config.plugins ?? []}\n descendants={text?.descendants ?? []}\n />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps) {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf={descendant} />\n }\n\n return <ElementComponent key={index} descendant={descendant} plugins={plugins} />\n })}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCQ;AAzCR,mBAAyC;AAIzC,0BAA+C;AAC/C,uBAAyB;AACzB,mBAAuB;AAIvB,qBAA6B;AAO7B,MAAM,qBAAiB,yBAAW,SAAS,aACzC,EAAE,MAAM,WAAW,GACnB,KACA;AACA,QAAM,0BAAsB;AAAA,IAC1B,MAAM,eAAe,CAAC;AAAA,IACtB,YAAY,OAAO,QAAQ,6BAAS,KAAK;AAAA,EAC3C;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAML,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,UAAU;AAAA,MACZ;AAAA,MAEC,kCAAwB,KACvB,4CAAC,eAAY,IAEb;AAAA,QAAC;AAAA;AAAA,UACC,SAAS,YAAY,OAAO,WAAW,CAAC;AAAA,UACxC,aAAa,MAAM,eAAe,CAAC;AAAA;AAAA,MACrC;AAAA;AAAA,EAEJ;AAEJ,CAAC;AAED,IAAO,yBAAQ;AAEf,SAAS,YAAY,EAAE,OAAO,qBAAqB,GAAsB;AACvE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,2BAAS;AAAA,QAClB,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,eAAe;AAAA,MACjB,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AAEJ;AAOO,SAAS,cAAc,EAAE,SAAS,GAAG,MAAM,GAAc;AAC9D,WAAS,kBAAkB,EAAE,KAAK,GAAoB;AACpD,WAAO,4CAAC,UAAK,WAA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F;AAGA,SAAS,OAAO,MAAgC;AAC9C,MAAI,OAAO,SAAS,YAAY,UAAU;AAAM,WAAO;AAEvD,SAAO;AACT;AAEA,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AACF,GAGG;AACD,SACE,2EACG,sBAAY,IAAI,CAAC,YAAY,UAAU;AACtC,QAAI,OAAO,UAAU,GAAG;AACtB,aAAO,4CAAC,iBAA0B,SAAkB,MAAM,cAA/B,KAA2C;AAAA,IACxE;AAEA,WAAO,4CAAC,oBAA6B,YAAwB,WAA/B,KAAiD;AAAA,EACjF,CAAC,GACH;AAEJ;","names":["props","renderLeaf","renderElement"]}
@@ -14,7 +14,7 @@ async function handler(...args) {
14
14
  const supportsDraftMode = match(args).with(routeHandlerPattern, () => true).with(apiRoutePattern, () => false).exhaustive();
15
15
  const supportsWebhook = match(args).with(routeHandlerPattern, () => true).with(apiRoutePattern, () => false).exhaustive();
16
16
  const body = {
17
- version: "0.23.0",
17
+ version: "0.23.1-canary.0",
18
18
  previewMode: supportsPreviewMode,
19
19
  draftMode: supportsDraftMode,
20
20
  interactionMode: true,
@@ -3,7 +3,7 @@ import { cx } from "@emotion/css";
3
3
  import { forwardRef } from "react";
4
4
  import { Slate, richTextDTOtoDAO } from "@makeswift/controls";
5
5
  import { useResponsiveStyle } from "../../../../components/utils/responsive-style";
6
- import { InlineType, BlockType } from "../../../../slate";
6
+ import { InlineType, BlockType } from "../../../../slate/types";
7
7
  import { useStyle } from "../../use-style";
8
8
  import useEnhancedTypography, { useTypographyClassName } from "../typography";
9
9
  import { Link } from "../../../../components/shared/Link";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\n\nimport { Slate, RichTextValue, richTextDTOtoDAO } from '@makeswift/controls'\n\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { InlineType, BlockType } from '../../../../slate'\nimport { useStyle } from '../../use-style'\nimport useEnhancedTypography, { useTypographyClassName } from '../typography'\nimport { Link } from '../../../../components/shared/Link'\n\ntype Props = {\n id?: string\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div\n ref={ref}\n id={id}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n className={cx(width, margin)}\n >\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Slate.Inline\n}\n\nfunction InlineElement({ descendant }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link ?? undefined}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Slate.Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n const quoteStyle = useStyle({\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 switch (descendant.type) {\n case BlockType.Default:\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n default:\n return null\n }\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (Slate.isText(descendant)) {\n return <TextElement key={index} descendant={descendant} />\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return <InlineElement key={index} descendant={descendant} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Slate.Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"mappings":"AA0CoC,SA8KhC,UA9KgC;AA1CpC,SAAS,UAAU;AACnB,SAAuB,kBAAkB;AAGzC,SAAS,OAAsB,wBAAwB;AAEvD,SAAS,0BAA0B;AACnC,SAAS,YAAY,iBAAiB;AACtC,SAAS,gBAAgB;AACzB,OAAO,yBAAyB,8BAA8B;AAC9D,SAAS,YAAY;AASrB,MAAM,eAAe,WAAW,SAASA,cACvC,EAAE,IAAI,MAAM,OAAO,OAAO,GAC1B,KACA;AACA,QAAM,cAAc,QAAQ,OAAO,CAAC,IAAI,iBAAiB,IAAI;AAC7D,QAAM,sBAAsB,QAAQ,WAAW;AAE/C,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAML,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,UAAU;AAAA,MACZ;AAAA,MACA,WAAW,GAAG,OAAO,MAAM;AAAA,MAE1B,kCAAwB,KAAK,oBAAC,eAAY,IAAK,oBAAC,eAAY,aAA0B;AAAA;AAAA,EACzF;AAEJ,CAAC;AAED,IAAO,uBAAQ;AAEf,SAAS,YAAY,EAAE,OAAO,qBAAqB,GAAsB;AACvE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,SAAS;AAAA,QAClB,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,SA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KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AACb,aAAO;AAAA,IAET;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,oBAAoB,YAAgC;AAC3D,MAAI,UAAU,YAAY;AACxB,WAAO,WAAW,QAAQ;AAAA,EAC5B;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,WAAW;AAAA,IAChB,KAAK,WAAW;AAAA,IAChB,KAAK,WAAW;AAAA,IAChB,KAAK,WAAW;AACd,aAAO,WAAW,SAAS,IAAI,CAAAC,gBAAc,oBAAoBA,WAAU,CAAC,EAAE,KAAK,EAAE,KAAK;AAAA,IAC5F,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AACb,aACE,WAAW,SACR,IAAI,CAAAA,gBAAc,oBAAoBA,WAAU,CAAC,EACjD,KAAK,WAAW,SAAS,MAAM,OAAO,IAAI,OAAO,EAAE,KAAK;AAAA,IAE/D;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,QAAQ,YAAkC;AACjD,SAAO,WAAW,IAAI,mBAAmB,EAAE,KAAK,IAAI;AACtD;","names":["ReadOnlyText","descendant"]}
1
+ {"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\n\nimport { Slate, RichTextValue, richTextDTOtoDAO } from '@makeswift/controls'\n\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { InlineType, BlockType } from '../../../../slate/types'\nimport { useStyle } from '../../use-style'\nimport useEnhancedTypography, { useTypographyClassName } from '../typography'\nimport { Link } from '../../../../components/shared/Link'\n\ntype Props = {\n id?: string\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div\n ref={ref}\n id={id}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n className={cx(width, margin)}\n >\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Slate.Inline\n}\n\nfunction InlineElement({ descendant }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link ?? undefined}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Slate.Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n const quoteStyle = useStyle({\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 switch (descendant.type) {\n case BlockType.Default:\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n default:\n return null\n }\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (Slate.isText(descendant)) {\n return <TextElement key={index} descendant={descendant} />\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return <InlineElement key={index} descendant={descendant} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Slate.Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"mappings":"AA0CoC,SA8KhC,UA9KgC;AA1CpC,SAAS,UAAU;AACnB,SAAuB,kBAAkB;AAGzC,SAAS,OAAsB,wBAAwB;AAEvD,SAAS,0BAA0B;AACnC,SAAS,YAAY,iBAAiB;AACtC,SAAS,gBAAgB;AACzB,OAAO,yBAAyB,8BAA8B;AAC9D,SAAS,YAAY;AASrB,MAAM,eAAe,WAAW,SAASA,cACvC,EAAE,IAAI,MAAM,OAAO,OAAO,GAC1B,KACA;AACA,QAAM,cAAc,QAAQ,OAAO,CAAC,IAAI,iBAAiB,IAAI;AAC7D,QAAM,sBAAsB,QAAQ,WAAW;AAE/C,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAML,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,UAAU;AAAA,MACZ;AAAA,MACA,WAAW,GAAG,OAAO,MAAM;AAAA,MAE1B,kCAAwB,KAAK,oBAAC,eAAY,IAAK,oBAAC,eAAY,aAA0B;AAAA;AAAA,EACzF;AAEJ,CAAC;AAED,IAAO,uBAAQ;AAEf,SAAS,YAAY,EAAE,OAAO,qBAAqB,GAAsB;AACvE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,SAAS;AAAA,QAClB,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAU;AAAA,QACV,YAAY;AAAA,Q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A,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AACb,aAAO;AAAA,IAET;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,oBAAoB,YAAgC;AAC3D,MAAI,UAAU,YAAY;AACxB,WAAO,WAAW,QAAQ;AAAA,EAC5B;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,WAAW;AAAA,IAChB,KAAK,WAAW;AAAA,IAChB,KAAK,WAAW;AAAA,IAChB,KAAK,WAAW;AACd,aAAO,WAAW,SAAS,IAAI,CAAAC,gBAAc,oBAAoBA,WAAU,CAAC,EAAE,KAAK,EAAE,KAAK;AAAA,IAC5F,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AAAA,IACf,KAAK,UAAU;AACb,aACE,WAAW,SACR,IAAI,CAAAA,gBAAc,oBAAoBA,WAAU,CAAC,EACjD,KAAK,WAAW,SAAS,MAAM,OAAO,IAAI,OAAO,EAAE,KAAK;AAAA,IAE/D;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,QAAQ,YAAkC;AACjD,SAAO,WAAW,IAAI,mBAAmB,EAAE,KAAK,IAAI;AACtD;","names":["ReadOnlyText","descendant"]}
@@ -2,7 +2,7 @@ import { Fragment, jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import { RichText } from "../../../../controls/rich-text-v2";
4
4
  import { useStyle } from "../../use-style";
5
- import { toText } from "../../../../slate";
5
+ import { toText } from "../../../../slate/utils";
6
6
  import { ControlValue } from "../control";
7
7
  const ReadOnlyTextV2 = forwardRef(function ReadOnlyText({ text, definition }, ref) {
8
8
  const descendantsAsString = toText(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } from 'react'\n\nimport { RichTextV2Definition, RichText } from '../../../../controls/rich-text-v2'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Element, Text } from 'slate'\nimport { toText } from '../../../../slate'\nimport { ControlValue } from '../control'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\nimport { RichTextV2Plugin } from '../../../../controls/rich-text-v2/plugin'\nimport { RichTextDataV2 } from '../../../../controls/rich-text-v2'\n\ntype Props = {\n text: RichTextDataV2 | undefined\n definition: RichTextV2Definition | undefined\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = toText(\n text?.descendants ?? [],\n definition?.config.mode ?? RichText.Mode.Block,\n )\n\n return (\n <div\n ref={ref}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n >\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants\n plugins={definition?.config.plugins ?? []}\n descendants={text?.descendants ?? []}\n />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps) {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf={descendant} />\n }\n\n return <ElementComponent key={index} descendant={descendant} plugins={plugins} />\n })}\n </>\n )\n}\n"],"mappings":"AAwCQ,SAyGJ,UAzG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AAU,GAAG;AACtB,aAAO,oBAAC,iBAA0B,SAAkB,MAAM,cAA/B,KAA2C;AAAA,IACxE;AAEA,WAAO,oBAAC,oBAA6B,YAAwB,WAA/B,KAAiD;AAAA,EACjF,CAAC,GACH;AAEJ;","names":["props","renderLeaf","renderElement"]}
1
+ {"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Element, Text } from 'slate'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\n\nimport { RichTextV2Definition, RichText } from '../../../../controls/rich-text-v2'\nimport { useStyle } from '../../use-style'\nimport { toText } from '../../../../slate/utils'\nimport { RichTextV2Plugin } from '../../../../controls/rich-text-v2/plugin'\nimport { RichTextDataV2 } from '../../../../controls/rich-text-v2'\n\nimport { ControlValue } from '../control'\n\ntype Props = {\n text: RichTextDataV2 | undefined\n definition: RichTextV2Definition | undefined\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = toText(\n text?.descendants ?? [],\n definition?.config.mode ?? RichText.Mode.Block,\n )\n\n return (\n <div\n ref={ref}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n >\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants\n plugins={definition?.config.plugins ?? []}\n descendants={text?.descendants ?? []}\n />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps) {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf={descendant} />\n }\n\n return <ElementComponent key={index} descendant={descendant} plugins={plugins} />\n })}\n </>\n )\n}\n"],"mappings":"AAyCQ,SAyGJ,UAzGI;AAzCR,SAAuB,kBAAkB;AAIzC,SAA+B,gBAAgB;AAC/C,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAIvB,SAAS,oBAAoB;AAO7B,MAAM,iBAAiB,WAAW,SAAS,aACzC,EAAE,MAAM,WAAW,GACnB,KACA;AACA,QAAM,sBAAsB;AAAA,IAC1B,MAAM,eAAe,CAAC;AAAA,IACtB,YAAY,OAAO,QAAQ,SAAS,KAAK;AAAA,EAC3C;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAML,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,UAAU;AAAA,MACZ;AAAA,MAEC,kCAAwB,KACvB,oBAAC,eAAY,IAEb;AAAA,QAAC;AAAA;AAAA,UACC,SAAS,YAAY,OAAO,WAAW,CAAC;AAAA,UACxC,aAAa,MAAM,eAAe,CAAC;AAAA;AAAA,MACrC;AAAA;AAAA,EAEJ;AAEJ,CAAC;AAED,IAAO,yBAAQ;AAEf,SAAS,YAAY,EAAE,OAAO,qBAAqB,GAAsB;AACvE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,SAAS;AAAA,QAClB,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,eAAe;AAAA,MACjB,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AAEJ;AAOO,SAAS,cAAc,EAAE,SAAS,GAAG,MAAM,GAAc;AAC9D,WAAS,kBAAkB,EAAE,KAAK,GAAoB;AACpD,WAAO,oBAAC,UAAK,WAAW,KAAK,WAAY,eAAK,SAAS,KAAK,WAAW,KAAK,MAAK;AAAA,EACnF;AAEA,QAAM,aAAa,QAAQ;AAA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ACT;AAEA,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AACF,GAGG;AACD,SACE,gCACG,sBAAY,IAAI,CAAC,YAAY,UAAU;AACtC,QAAI,OAAO,UAAU,GAAG;AACtB,aAAO,oBAAC,iBAA0B,SAAkB,MAAM,cAA/B,KAA2C;AAAA,IACxE;AAEA,WAAO,oBAAC,oBAA6B,YAAwB,WAA/B,KAAiD;AAAA,EACjF,CAAC,GACH;AAEJ;","names":["props","renderLeaf","renderElement"]}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { RichTextV2Definition } from '../../../../controls/rich-text-v2';
3
2
  import { Text } from 'slate';
3
+ import { RichTextV2Definition } from '../../../../controls/rich-text-v2';
4
4
  import { RichTextV2Plugin } from '../../../../controls/rich-text-v2/plugin';
5
5
  import { RichTextDataV2 } from '../../../../controls/rich-text-v2';
6
6
  type Props = {
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyTextV2.d.ts","sourceRoot":"","sources":["../../../../../../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAY,MAAM,mCAAmC,CAAA;AAElF,OAAO,EAAuB,IAAI,EAAE,MAAM,OAAO,CAAA;AAIjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAA;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAElE,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,cAAc,GAAG,SAAS,CAAA;IAChC,UAAU,EAAE,oBAAoB,GAAG,SAAS,CAAA;CAC7C,CAAA;AAED,QAAA,MAAM,cAAc,kGAiClB,CAAA;AAEF,eAAe,cAAc,CAAA;AAmB7B,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,IAAI,CAAA;IACV,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAC5B,CAAA;AAED,wBAAgB,aAAa,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,2CAuB7D"}
1
+ {"version":3,"file":"ReadOnlyTextV2.d.ts","sourceRoot":"","sources":["../../../../../../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"names":[],"mappings":";AACA,OAAO,EAAuB,IAAI,EAAE,MAAM,OAAO,CAAA;AAGjD,OAAO,EAAE,oBAAoB,EAAY,MAAM,mCAAmC,CAAA;AAGlF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAA;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAIlE,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,cAAc,GAAG,SAAS,CAAA;IAChC,UAAU,EAAE,oBAAoB,GAAG,SAAS,CAAA;CAC7C,CAAA;AAED,QAAA,MAAM,cAAc,kGAiClB,CAAA;AAEF,eAAe,cAAc,CAAA;AAmB7B,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,IAAI,CAAA;IACV,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAC5B,CAAA;AAED,wBAAgB,aAAa,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,2CAuB7D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makeswift/runtime",
3
- "version": "0.23.0",
3
+ "version": "0.23.1-canary.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist",