@makeswift/runtime 0.7.13 → 0.7.14

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 (136) hide show
  1. package/dist/ReadOnlyText.cjs.js +15 -26
  2. package/dist/ReadOnlyText.cjs.js.map +1 -1
  3. package/dist/ReadOnlyText.es.js +15 -25
  4. package/dist/ReadOnlyText.es.js.map +1 -1
  5. package/dist/controls.cjs.js +1 -4
  6. package/dist/controls.cjs.js.map +1 -1
  7. package/dist/controls.es.js +1 -2
  8. package/dist/controls.es.js.map +1 -1
  9. package/dist/index.cjs.js +2 -1
  10. package/dist/index.cjs.js.map +1 -1
  11. package/dist/index.cjs6.js +143 -132
  12. package/dist/index.cjs6.js.map +1 -1
  13. package/dist/index.es.js +2 -2
  14. package/dist/index.es6.js +144 -133
  15. package/dist/index.es6.js.map +1 -1
  16. package/dist/introspection.cjs.js +0 -1
  17. package/dist/introspection.cjs.js.map +1 -1
  18. package/dist/introspection.es.js +1 -1
  19. package/dist/{typography.cjs.js → leaf.cjs.js} +49 -12
  20. package/dist/leaf.cjs.js.map +1 -0
  21. package/dist/{typography.es.js → leaf.es.js} +49 -12
  22. package/dist/leaf.es.js.map +1 -0
  23. package/dist/next.es.js +1 -1
  24. package/dist/rich-text.cjs.js +29 -43
  25. package/dist/rich-text.cjs.js.map +1 -1
  26. package/dist/rich-text.es.js +30 -44
  27. package/dist/rich-text.es.js.map +1 -1
  28. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  29. package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +1 -1
  30. package/dist/types/src/components/builtin/Text/EditableText/useSyncWithBuilder.d.ts.map +1 -1
  31. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts +2 -5
  32. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
  33. package/dist/types/src/components/builtin/Text/components/Leaf/index.d.ts +0 -1
  34. package/dist/types/src/components/builtin/Text/components/Leaf/index.d.ts.map +1 -1
  35. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts +21 -0
  36. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +1 -1
  37. package/dist/types/src/controls/rich-text/index.d.ts +0 -1
  38. package/dist/types/src/controls/rich-text/index.d.ts.map +1 -1
  39. package/dist/types/src/controls/rich-text/translation.d.ts.map +1 -1
  40. package/dist/types/src/controls/rich-text/types.d.ts +47 -27
  41. package/dist/types/src/controls/rich-text/types.d.ts.map +1 -1
  42. package/dist/types/src/slate/BlockPlugin/clearBlockKeyForDevice.d.ts +5 -0
  43. package/dist/types/src/slate/BlockPlugin/clearBlockKeyForDevice.d.ts.map +1 -0
  44. package/dist/types/src/slate/BlockPlugin/index.d.ts +9 -0
  45. package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -0
  46. package/dist/types/src/slate/BlockPlugin/setBlockKeyForDevice.d.ts +5 -0
  47. package/dist/types/src/slate/BlockPlugin/setBlockKeyForDevice.d.ts.map +1 -0
  48. package/dist/types/src/slate/BlockPlugin/types.d.ts +4 -0
  49. package/dist/types/src/slate/BlockPlugin/types.d.ts.map +1 -0
  50. package/dist/types/src/slate/ListPlugin/constants.d.ts.map +1 -0
  51. package/dist/types/src/slate/ListPlugin/dedent.d.ts.map +1 -0
  52. package/dist/types/src/slate/ListPlugin/indent.d.ts.map +1 -0
  53. package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/ListPlugin.d.ts → slate/ListPlugin/index.d.ts} +6 -2
  54. package/dist/types/src/slate/ListPlugin/index.d.ts.map +1 -0
  55. package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/toggleList.d.ts +1 -1
  56. package/dist/types/src/slate/ListPlugin/toggleList.d.ts.map +1 -0
  57. package/dist/types/src/slate/ListPlugin/unwrapList.d.ts.map +1 -0
  58. package/dist/types/src/slate/ListPlugin/utils/filterForSubtreeRoots.d.ts.map +1 -0
  59. package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts.map +1 -0
  60. package/dist/types/src/slate/ListPlugin/utils/location.d.ts.map +1 -0
  61. package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/wrapList.d.ts +1 -1
  62. package/dist/types/src/slate/ListPlugin/wrapList.d.ts.map +1 -0
  63. package/dist/types/src/slate/TypographyPlugin/clearActiveTypographyStyle.d.ts +3 -0
  64. package/dist/types/src/slate/TypographyPlugin/clearActiveTypographyStyle.d.ts.map +1 -0
  65. package/dist/types/src/slate/TypographyPlugin/clearDeviceActiveTypography.d.ts +3 -0
  66. package/dist/types/src/slate/TypographyPlugin/clearDeviceActiveTypography.d.ts.map +1 -0
  67. package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts +4 -0
  68. package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts.map +1 -0
  69. package/dist/types/src/slate/TypographyPlugin/index.d.ts +15 -0
  70. package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -0
  71. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyId.d.ts +3 -0
  72. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyId.d.ts.map +1 -0
  73. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyStyle.d.ts +3 -0
  74. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyStyle.d.ts.map +1 -0
  75. package/dist/types/src/slate/index.d.ts +4 -0
  76. package/dist/types/src/slate/index.d.ts.map +1 -0
  77. package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate}/utils/editor.d.ts +1 -1
  78. package/dist/types/src/slate/utils/editor.d.ts.map +1 -0
  79. package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate}/utils/element.d.ts +3 -5
  80. package/dist/types/src/slate/utils/element.d.ts.map +1 -0
  81. package/package.json +8 -1
  82. package/dist/compare.cjs.js +0 -126
  83. package/dist/compare.cjs.js.map +0 -1
  84. package/dist/compare.es.js +0 -124
  85. package/dist/compare.es.js.map +0 -1
  86. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/ListPlugin.d.ts.map +0 -1
  87. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/constants.d.ts.map +0 -1
  88. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/index.d.ts +0 -2
  89. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/index.d.ts.map +0 -1
  90. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/dedent.d.ts.map +0 -1
  91. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/indent.d.ts.map +0 -1
  92. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/index.d.ts +0 -6
  93. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/index.d.ts.map +0 -1
  94. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/toggleList.d.ts.map +0 -1
  95. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/unwrapList.d.ts.map +0 -1
  96. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/editor.d.ts.map +0 -1
  97. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/element.d.ts.map +0 -1
  98. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/filterForSubtreeRoots.d.ts.map +0 -1
  99. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/getSelectedListItems.d.ts.map +0 -1
  100. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/utils/location.d.ts.map +0 -1
  101. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/lib/wrapList.d.ts.map +0 -1
  102. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/dedent.test.d.ts +0 -3
  103. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/dedent.test.d.ts.map +0 -1
  104. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/indent.test.d.ts +0 -3
  105. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/indent.test.d.ts.map +0 -1
  106. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/normalization.test.d.ts +0 -3
  107. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/normalization.test.d.ts.map +0 -1
  108. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/slate-test-helper.d.ts +0 -48
  109. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/slate-test-helper.d.ts.map +0 -1
  110. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/toggleList.test.d.ts +0 -3
  111. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/toggleList.test.d.ts.map +0 -1
  112. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/types.d.ts +0 -21
  113. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/types.d.ts.map +0 -1
  114. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/unwrapList.test.d.ts +0 -3
  115. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/unwrapList.test.d.ts.map +0 -1
  116. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/filterForSubtreeRoots.test.d.ts +0 -2
  117. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/filterForSubtreeRoots.test.d.ts.map +0 -1
  118. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/getSelectedListItems.test.d.ts +0 -3
  119. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/utils/getSelectedListItems.test.d.ts.map +0 -1
  120. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/wrapList.test.d.ts +0 -3
  121. package/dist/types/src/components/builtin/Text/EditableText/ListPlugin/test/wrapList.test.d.ts.map +0 -1
  122. package/dist/types/src/components/builtin/Text/components/Leaf/typography.d.ts +0 -27
  123. package/dist/types/src/components/builtin/Text/components/Leaf/typography.d.ts.map +0 -1
  124. package/dist/types/src/controls/rich-text/compare.d.ts +0 -5
  125. package/dist/types/src/controls/rich-text/compare.d.ts.map +0 -1
  126. package/dist/types/src/controls/rich-text/compare.test.d.ts +0 -2
  127. package/dist/types/src/controls/rich-text/compare.test.d.ts.map +0 -1
  128. package/dist/typography.cjs.js.map +0 -1
  129. package/dist/typography.es.js.map +0 -1
  130. /package/dist/types/src/{components/builtin/Text/EditableText → slate}/ListPlugin/constants.d.ts +0 -0
  131. /package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/dedent.d.ts +0 -0
  132. /package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/indent.d.ts +0 -0
  133. /package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/unwrapList.d.ts +0 -0
  134. /package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/utils/filterForSubtreeRoots.d.ts +0 -0
  135. /package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/utils/getSelectedListItems.d.ts +0 -0
  136. /package/dist/types/src/{components/builtin/Text/EditableText/ListPlugin/lib → slate/ListPlugin}/utils/location.d.ts +0 -0
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  var css = require("@emotion/css");
4
4
  var React = require("react");
5
+ var slate = require("slate");
5
6
  var richText = require("./rich-text.cjs.js");
6
- require("slate");
7
7
  require("slate-react");
8
8
  var next = require("./index.cjs.js");
9
9
  var index = require("./index.cjs3.js");
10
- var typography = require("./typography.cjs.js");
11
10
  var jsxRuntime = require("react/jsx-runtime");
11
+ var leaf = require("./leaf.cjs.js");
12
12
  require("./actions.cjs.js");
13
13
  require("use-sync-external-store/shim/with-selector");
14
14
  require("next/dynamic");
@@ -72,15 +72,8 @@ function Placeholder({
72
72
  function TextElement({
73
73
  descendant
74
74
  }) {
75
- return /* @__PURE__ */ jsxRuntime.jsx("span", {
76
- children: descendant.text
77
- });
78
- }
79
- function TypographyElement({
80
- descendant
81
- }) {
82
- const enhancedTypography = typography.useEnhancedTypography(descendant.typography);
83
- const typographyClassName = typography.useTypographyClassName(enhancedTypography);
75
+ const enhancedTypography = leaf.useEnhancedTypography(descendant.typography);
76
+ const typographyClassName = leaf.useTypographyClassName(enhancedTypography);
84
77
  return /* @__PURE__ */ jsxRuntime.jsx("span", {
85
78
  className: typographyClassName,
86
79
  children: descendant.text
@@ -231,23 +224,20 @@ function Descendants({
231
224
  descendants
232
225
  }) {
233
226
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
234
- children: descendants.map((d) => {
235
- switch (d.type) {
236
- case richText.TextType.Typography:
237
- return /* @__PURE__ */ jsxRuntime.jsx(TypographyElement, {
238
- descendant: d
239
- });
240
- case richText.TextType.Text:
241
- return /* @__PURE__ */ jsxRuntime.jsx(TextElement, {
242
- descendant: d
243
- });
227
+ children: descendants.map((descendant, index2) => {
228
+ if (slate.Text.isText(descendant)) {
229
+ return /* @__PURE__ */ jsxRuntime.jsx(TextElement, {
230
+ descendant
231
+ }, index2);
232
+ }
233
+ switch (descendant.type) {
244
234
  case richText.InlineType.Link:
245
235
  case richText.InlineType.Code:
246
236
  case richText.InlineType.SubScript:
247
237
  case richText.InlineType.SuperScript:
248
238
  return /* @__PURE__ */ jsxRuntime.jsx(InlineElement, {
249
- descendant: d
250
- });
239
+ descendant
240
+ }, index2);
251
241
  case richText.BlockType.Heading1:
252
242
  case richText.BlockType.Heading2:
253
243
  case richText.BlockType.Heading3:
@@ -258,8 +248,8 @@ function Descendants({
258
248
  case richText.BlockType.ListItem:
259
249
  case richText.BlockType.ListItemChild:
260
250
  return /* @__PURE__ */ jsxRuntime.jsx(BlockElement, {
261
- descendant: d
262
- });
251
+ descendant
252
+ }, index2);
263
253
  default:
264
254
  return null;
265
255
  }
@@ -268,6 +258,5 @@ function Descendants({
268
258
  }
269
259
  exports.BlockElement = BlockElement;
270
260
  exports.TextElement = TextElement;
271
- exports.TypographyElement = TypographyElement;
272
261
  exports["default"] = ReadOnlyText;
273
262
  //# sourceMappingURL=ReadOnlyText.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyText.cjs.js","sources":["../src/components/builtin/Text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant } from 'slate'\nimport {\n Block,\n BlockType,\n Inline,\n InlineType,\n richTextDTOtoDAO,\n Text,\n TextType,\n TypographyText,\n} from '../../../controls'\nimport type { ElementIDValue, RichTextValue } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport { responsiveStyle } from '../../utils/responsive-style'\nimport useEnhancedTypography, { useTypographyClassName } from './components/Leaf/typography'\n\ntype Props = {\n id?: ElementIDValue\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 return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {descendants === '' ? <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 return <span>{descendant.text}</span>\n}\n\nexport interface TypographyProps {\n descendant: TypographyText\n}\n\nexport function TypographyElement({ descendant }: TypographyProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return <span className={typographyClassName}>{descendant.text}</span>\n}\n\nexport interface InlineProps {\n descendant: 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}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(responsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n\n switch (descendant.type) {\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\n className={cx(\n ...blockStyles,\n 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 >\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 }\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map(d => {\n switch (d.type) {\n case TextType.Typography:\n return <TypographyElement descendant={d} />\n case TextType.Text:\n return <TextElement descendant={d} />\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return <InlineElement descendant={d} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement descendant={d} />\n default:\n return null\n }\n })}\n </>\n )\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","responsiveStyle","textAlign","BlockType","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","padding","fontSize","fontWeight","borderLeft","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","_Fragment","map","d","TextType","Typography","Text"],"mappings":";;;;;;;;;;;;;;;;;;;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AhC;AAAA,aACG9B,SAAAA,WAAWK;AAAAA,aACXL,SAAAA,WAAWC;AAAAA,aACXD,SAAAA,WAAWI;AAAAA,aACXJ,SAAWG,WAAAA;AACd,gDAAQ,eAAD;AAAA,YAAe,YAAY2B;AAAAA,UAAAA,CAAlC;AAAA,aACGpB,SAAAA,UAAUE;AAAAA,aACVF,SAAAA,UAAUG;AAAAA,aACVH,SAAAA,UAAUI;AAAAA,aACVJ,SAAAA,UAAUQ;AAAAA,aACVR,SAAAA,UAAUC;AAAAA,aACVD,SAAAA,UAAUa;AAAAA,aACVb,SAAAA,UAAUe;AAAAA,aACVf,SAAAA,UAAUgB;AAAAA,aACVhB,SAAUiB,UAAAA;AACb,gDAAQ,cAAD;AAAA,YAAc,YAAYG;AAAAA,UAAAA,CAAjC;AAAA;AAEO,iBAAA;AAAA;AAAA,IAAA,CAtBZ;AAAA,EAAA,CAFL;AA6BD;;;;;"}
1
+ {"version":3,"file":"ReadOnlyText.cjs.js","sources":["../src/components/builtin/Text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\nimport { Block, BlockType, Inline, InlineType, richTextDTOtoDAO } from '../../../controls'\nimport type { ElementIDValue, RichTextValue } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport { responsiveStyle } from '../../utils/responsive-style'\nimport { useTypographyClassName } from './components'\nimport useEnhancedTypography from './components/Leaf/leaf'\n\ntype Props = {\n id?: ElementIDValue\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 return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {descendants === '' ? <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 <span className={typographyClassName}>{descendant.text}</span>\n}\n\nexport interface InlineProps {\n descendant: 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}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(responsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n\n switch (descendant.type) {\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\n className={cx(\n ...blockStyles,\n 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 >\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 }\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (Text.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.BlockQuote:\n case BlockType.Paragraph:\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"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","responsiveStyle","textAlign","BlockType","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","padding","fontSize","fontWeight","borderLeft","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","_Fragment","map","index","Text","isText"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBMA,MAAAA,eAAeC,MAAAA,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACMC,QAAAA,cAAcJ,QAAQ,OAAO,KAAKK,SAAAA,iBAAiBL,IAAD;AAEtD,wCAAA,OAAA;AAAA,IAAK;AAAA,IAAU;AAAA,IAAQ,WAAWM,IAAAA,GAAGL,OAAOC,MAAR;AAAA,IACjCE,UAAAA,gBAAgB,KAAKG,2BAAA,IAAC,aAAD,EAAA,IAAkBA,2BAAA,IAAC,aAAD;AAAA,MAAa;AAAA,IAAA,CAAb;AAAA,EAAA,CAF5C;AAKD,CAV8B;AAc/B,qBAAqB;AAAA,EAAEP,OAAO;AAAA,GAA2C;AAErE,wCAAA,QAAA;AAAA,IACE,WAAWQ,KAAAA,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTR,OAAO;AAAA,MACPS,UAAU;AAAA,MACVC,YAAY;AAAA,MACZC,SAAS;AAAA,MACTC,eAAe;AAAA,IAAA,CANE;AAAA,IASlBb,UAAAA;AAAAA,EAAAA,CAXL;AAcD;AAM2B,qBAAA;AAAA,EAAEc;AAAAA,GAAyB;AAC/CC,QAAAA,qBAAqBC,KAAAA,sBAAsBF,WAAWG,UAAZ;AAC1CC,QAAAA,sBAAsBC,4BAAuBJ,kBAAD;AAE3C,wCAAA,QA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,UAAAA,YAAYgD,IAAI,CAACtC,YAAYuC,WAAU;AAClCC,UAAAA,MAAAA,KAAKC,OAAOzC,UAAZ,GAAyB;AAC3B,8CAAQ,aAAD;AAAA,UAAyB;AAAA,WAAPuC,MAAlB;AAAA,MACR;AAEOvC,cAAAA,WAAWQ;AAAAA,aACZC,SAAAA,WAAWK;AAAAA,aACXL,SAAAA,WAAWC;AAAAA,aACXD,SAAAA,WAAWI;AAAAA,aACXJ,SAAWG,WAAAA;AACd,gDAAQ,eAAD;AAAA,YAA2B;AAAA,aAAP2B,MAApB;AAAA,aACJpB,SAAAA,UAAUE;AAAAA,aACVF,SAAAA,UAAUG;AAAAA,aACVH,SAAAA,UAAUI;AAAAA,aACVJ,SAAAA,UAAUQ;AAAAA,aACVR,SAAAA,UAAUC;AAAAA,aACVD,SAAAA,UAAUa;AAAAA,aACVb,SAAAA,UAAUe;AAAAA,aACVf,SAAAA,UAAUgB;AAAAA,aACVhB,SAAUiB,UAAAA;AACb,gDAAQ,cAAD;AAAA,YAA0B;AAAA,aAAPG,MAAnB;AAAA;AAEA,iBAAA;AAAA;AAAA,IAAA,CAtBZ;AAAA,EAAA,CAFL;AA6BD;;;;"}
@@ -1,12 +1,12 @@
1
1
  import { cx } from "@emotion/css";
2
2
  import { forwardRef } from "react";
3
- import { ar as richTextDTOtoDAO, av as BlockType, aw as InlineType, au as TextType } from "./rich-text.es.js";
4
- import "slate";
3
+ import { Text } from "slate";
4
+ import { ar as richTextDTOtoDAO, au as BlockType, av as InlineType } from "./rich-text.es.js";
5
5
  import "slate-react";
6
6
  import { o as useStyle, r as responsiveStyle } from "./index.es.js";
7
7
  import { L as Link } from "./index.es3.js";
8
- import { u as useEnhancedTypography, a as useTypographyClassName } from "./typography.es.js";
9
8
  import { jsx, Fragment } from "react/jsx-runtime";
9
+ import { u as useEnhancedTypography, a as useTypographyClassName } from "./leaf.es.js";
10
10
  import "./actions.es.js";
11
11
  import "use-sync-external-store/shim/with-selector";
12
12
  import "next/dynamic";
@@ -69,13 +69,6 @@ function Placeholder({
69
69
  }
70
70
  function TextElement({
71
71
  descendant
72
- }) {
73
- return /* @__PURE__ */ jsx("span", {
74
- children: descendant.text
75
- });
76
- }
77
- function TypographyElement({
78
- descendant
79
72
  }) {
80
73
  const enhancedTypography = useEnhancedTypography(descendant.typography);
81
74
  const typographyClassName = useTypographyClassName(enhancedTypography);
@@ -229,23 +222,20 @@ function Descendants({
229
222
  descendants
230
223
  }) {
231
224
  return /* @__PURE__ */ jsx(Fragment, {
232
- children: descendants.map((d) => {
233
- switch (d.type) {
234
- case TextType.Typography:
235
- return /* @__PURE__ */ jsx(TypographyElement, {
236
- descendant: d
237
- });
238
- case TextType.Text:
239
- return /* @__PURE__ */ jsx(TextElement, {
240
- descendant: d
241
- });
225
+ children: descendants.map((descendant, index) => {
226
+ if (Text.isText(descendant)) {
227
+ return /* @__PURE__ */ jsx(TextElement, {
228
+ descendant
229
+ }, index);
230
+ }
231
+ switch (descendant.type) {
242
232
  case InlineType.Link:
243
233
  case InlineType.Code:
244
234
  case InlineType.SubScript:
245
235
  case InlineType.SuperScript:
246
236
  return /* @__PURE__ */ jsx(InlineElement, {
247
- descendant: d
248
- });
237
+ descendant
238
+ }, index);
249
239
  case BlockType.Heading1:
250
240
  case BlockType.Heading2:
251
241
  case BlockType.Heading3:
@@ -256,13 +246,13 @@ function Descendants({
256
246
  case BlockType.ListItem:
257
247
  case BlockType.ListItemChild:
258
248
  return /* @__PURE__ */ jsx(BlockElement, {
259
- descendant: d
260
- });
249
+ descendant
250
+ }, index);
261
251
  default:
262
252
  return null;
263
253
  }
264
254
  })
265
255
  });
266
256
  }
267
- export { BlockElement, TextElement, TypographyElement, ReadOnlyText as default };
257
+ export { BlockElement, TextElement, ReadOnlyText as default };
268
258
  //# sourceMappingURL=ReadOnlyText.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyText.es.js","sources":["../src/components/builtin/Text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant } from 'slate'\nimport {\n Block,\n BlockType,\n Inline,\n InlineType,\n richTextDTOtoDAO,\n Text,\n TextType,\n TypographyText,\n} from '../../../controls'\nimport type { ElementIDValue, RichTextValue } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport { responsiveStyle } from '../../utils/responsive-style'\nimport useEnhancedTypography, { useTypographyClassName } from './components/Leaf/typography'\n\ntype Props = {\n id?: ElementIDValue\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 return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {descendants === '' ? <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 return <span>{descendant.text}</span>\n}\n\nexport interface TypographyProps {\n descendant: TypographyText\n}\n\nexport function TypographyElement({ descendant }: TypographyProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return <span className={typographyClassName}>{descendant.text}</span>\n}\n\nexport interface InlineProps {\n descendant: 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}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(responsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n\n switch (descendant.type) {\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\n className={cx(\n ...blockStyles,\n 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 >\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 }\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map(d => {\n switch (d.type) {\n case TextType.Typography:\n return <TypographyElement descendant={d} />\n case TextType.Text:\n return <TextElement descendant={d} />\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return <InlineElement descendant={d} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement descendant={d} />\n default:\n return null\n }\n })}\n </>\n )\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","responsiveStyle","textAlign","BlockType","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","padding","fontSize","fontWeight","borderLeft","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","_Fragment","map","d","TextType","Typography","Text"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BMA,MAAAA,eAAeC,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACMC,QAAAA,cAAcJ,QAAQ,OAAO,KAAKK,iBAAiBL,IAAD;AAEtD,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.js","sources":["../src/components/builtin/Text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\nimport { Block, BlockType, Inline, InlineType, richTextDTOtoDAO } from '../../../controls'\nimport type { ElementIDValue, RichTextValue } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport { responsiveStyle } from '../../utils/responsive-style'\nimport { useTypographyClassName } from './components'\nimport useEnhancedTypography from './components/Leaf/leaf'\n\ntype Props = {\n id?: ElementIDValue\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 return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {descendants === '' ? <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 <span className={typographyClassName}>{descendant.text}</span>\n}\n\nexport interface InlineProps {\n descendant: 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}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(responsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n\n switch (descendant.type) {\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\n className={cx(\n ...blockStyles,\n 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 >\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 }\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (Text.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.BlockQuote:\n case BlockType.Paragraph:\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"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","responsiveStyle","textAlign","BlockType","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","padding","fontSize","fontWeight","borderLeft","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","_Fragment","map","index","Text","isText"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBMA,MAAAA,eAAeC,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACMC,QAAAA,cAAcJ,QAAQ,OAAO,KAAKK,iBAAiBL,IAAD;AAEtD,6BAAA,OAAA;AAAA,IAAK;AAAA,IAAU;AAAA,IAAQ,WAAWM,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BACG,aAAD;AAAA,UAAa,aAAahB,WAAWW;AAAAA,QAAAA,CAArC;AAAA,MAAA,CAFJ;AAAA,SAKGQ,UAAUiB;AAEX,iCAAA,QAAA;AAAA,QAAM,WAAW5C,GAAG,GAAGwB,WAAJ;AAAA,QAAnB,8BACG,aAAD;AAAA,UAAa,aAAahB,WAAWW;AAAAA,QAAAA,CAArC;AAAA,MAAA,CAFJ;AAAA;AAML;AAED,qBAAqB;AAAA,EAAErB;AAAAA,GAA8C;AAEjE,6BAAA+C,UAAA;AAAA,IACG/C,UAAAA,YAAYgD,IAAI,CAACtC,YAAYuC,UAAU;AAClCC,UAAAA,KAAKC,OAAOzC,UAAZ,GAAyB;AAC3B,mCAAQ,aAAD;AAAA,UAAyB;AAAA,WAAPuC,KAAlB;AAAA,MACR;AAEOvC,cAAAA,WAAWQ;AAAAA,aACZC,WAAWK;AAAAA,aACXL,WAAWC;AAAAA,aACXD,WAAWI;AAAAA,aACXJ,WAAWG;AACd,qCAAQ,eAAD;AAAA,YAA2B;AAAA,aAAP2B,KAApB;AAAA,aACJpB,UAAUE;AAAAA,aACVF,UAAUG;AAAAA,aACVH,UAAUI;AAAAA,aACVJ,UAAUQ;AAAAA,aACVR,UAAUC;AAAAA,aACVD,UAAUa;AAAAA,aACVb,UAAUe;AAAAA,aACVf,UAAUgB;AAAAA,aACVhB,UAAUiB;AACb,qCAAQ,cAAD;AAAA,YAA0B;AAAA,aAAPG,KAAnB;AAAA;AAEA,iBAAA;AAAA;AAAA,IAAA,CAtBZ;AAAA,EAAA,CAFL;AA6BD;;"}
@@ -3,7 +3,6 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
3
3
  var textInput = require("./text-input.cjs.js");
4
4
  var richText = require("./rich-text.cjs.js");
5
5
  var combobox = require("./combobox.cjs.js");
6
- var compare = require("./compare.cjs.js");
7
6
  require("./actions.cjs.js");
8
7
  require("slate");
9
8
  require("slate-react");
@@ -17,6 +16,7 @@ exports.TextArea = textInput.TextArea;
17
16
  exports.TextAreaControlType = textInput.TextAreaControlType;
18
17
  exports.TextInput = textInput.TextInput;
19
18
  exports.TextInputControlType = textInput.TextInputControlType;
19
+ exports.BlockTextAlignment = richText.BlockTextAlignment;
20
20
  exports.BlockType = richText.BlockType;
21
21
  exports.Color = richText.Color;
22
22
  exports.ColorControlType = richText.ColorControlType;
@@ -46,7 +46,6 @@ exports.SlotControlType = richText.SlotControlType;
46
46
  exports.Style = richText.Style;
47
47
  exports.StyleControlProperty = richText.StyleControlProperty;
48
48
  exports.StyleControlType = richText.StyleControlType;
49
- exports.TextType = richText.TextType;
50
49
  exports.copy = richText.copy;
51
50
  exports.copyColorData = richText.copyColorData;
52
51
  exports.copyImageData = richText.copyImageData;
@@ -61,6 +60,4 @@ exports.richTextDTOtoSelection = richText.richTextDTOtoSelection;
61
60
  exports.toSelectionDTO = richText.toSelectionDTO;
62
61
  exports.Combobox = combobox.Combobox;
63
62
  exports.ComboboxControlType = combobox.ComboboxControlType;
64
- exports.compareRichTextDAO = compare.compareRichTextDAO;
65
- exports.compareRichTextSelection = compare.compareRichTextSelection;
66
63
  //# sourceMappingURL=controls.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"controls.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"controls.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,7 +1,6 @@
1
1
  export { b as Checkbox, C as CheckboxControlType, c as Number, N as NumberControlType, d as Select, S as SelectControlType, e as TextArea, T as TextAreaControlType, f as TextInput, a as TextInputControlType } from "./text-input.es.js";
2
- export { av as BlockType, a2 as Color, C as ColorControlType, a4 as Image, I as ImageControlType, O as ImageControlValueFormat, aw as InlineType, a6 as Link, Q as LinkControlType, a8 as List, aa as ListControl, a9 as ListControlMessageType, L as ListControlType, am as ObjectType, an as RichText, ap as RichTextControl, ao as RichTextControlMessageType, a0 as RichTextControlType, ac as Shape, ae as ShapeControl, ad as ShapeControlMessageType, S as ShapeControlType, ag as Slot, ai as SlotControl, ah as SlotControlMessageType, b as SlotControlType, ak as Style, K as StyleControlProperty, a1 as StyleControlType, au as TextType, a as copy, a3 as copyColorData, a5 as copyImageData, a7 as copyLinkData, ab as copyListData, af as copyShapeData, aj as copySlotData, al as copyStyleData, at as richTextDAOToDTO, ar as richTextDTOtoDAO, aq as richTextDTOtoSelection, as as toSelectionDTO } from "./rich-text.es.js";
2
+ export { aw as BlockTextAlignment, au as BlockType, a2 as Color, C as ColorControlType, a4 as Image, I as ImageControlType, O as ImageControlValueFormat, av as InlineType, a6 as Link, Q as LinkControlType, a8 as List, aa as ListControl, a9 as ListControlMessageType, L as ListControlType, am as ObjectType, an as RichText, ap as RichTextControl, ao as RichTextControlMessageType, a0 as RichTextControlType, ac as Shape, ae as ShapeControl, ad as ShapeControlMessageType, S as ShapeControlType, ag as Slot, ai as SlotControl, ah as SlotControlMessageType, b as SlotControlType, ak as Style, K as StyleControlProperty, a1 as StyleControlType, a as copy, a3 as copyColorData, a5 as copyImageData, a7 as copyLinkData, ab as copyListData, af as copyShapeData, aj as copySlotData, al as copyStyleData, at as richTextDAOToDTO, ar as richTextDTOtoDAO, aq as richTextDTOtoSelection, as as toSelectionDTO } from "./rich-text.es.js";
3
3
  export { a as Combobox, C as ComboboxControlType } from "./combobox.es.js";
4
- export { c as compareRichTextDAO, a as compareRichTextSelection } from "./compare.es.js";
5
4
  import "./actions.es.js";
6
5
  import "slate";
7
6
  import "slate-react";
@@ -1 +1 @@
1
- {"version":3,"file":"controls.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
1
+ {"version":3,"file":"controls.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
package/dist/index.cjs.js CHANGED
@@ -1002,7 +1002,7 @@ function useCachedSite(siteId) {
1002
1002
  const site = shim.useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot);
1003
1003
  return site;
1004
1004
  }
1005
- const version = "0.7.13";
1005
+ const version = "0.7.14";
1006
1006
  class Makeswift {
1007
1007
  constructor(apiKey, { apiOrigin = "https://api.makeswift.com" } = {}) {
1008
1008
  __publicField(this, "apiKey");
@@ -4251,6 +4251,7 @@ exports.forwardNextDynamicRef = forwardNextDynamicRef;
4251
4251
  exports.getServerSideProps = getServerSideProps;
4252
4252
  exports.getStaticPaths = getStaticPaths;
4253
4253
  exports.getStaticProps = getStaticProps;
4254
+ exports.pollBoxModel = pollBoxModel;
4254
4255
  exports.responsiveGridItem = responsiveGridItem;
4255
4256
  exports.responsiveStyle = responsiveStyle;
4256
4257
  exports.responsiveTextStyle = responsiveTextStyle;