@makeswift/runtime 0.8.9 → 0.8.10

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 (249) hide show
  1. package/dist/Box.cjs.js +2 -4
  2. package/dist/Box.cjs.js.map +1 -1
  3. package/dist/Box.es.js +2 -4
  4. package/dist/Box.es.js.map +1 -1
  5. package/dist/Button.cjs.js +1 -4
  6. package/dist/Button.cjs.js.map +1 -1
  7. package/dist/Button.es.js +1 -4
  8. package/dist/Button.es.js.map +1 -1
  9. package/dist/Carousel.cjs.js +1 -4
  10. package/dist/Carousel.cjs.js.map +1 -1
  11. package/dist/Carousel.es.js +1 -4
  12. package/dist/Carousel.es.js.map +1 -1
  13. package/dist/Countdown.cjs.js +1 -4
  14. package/dist/Countdown.cjs.js.map +1 -1
  15. package/dist/Countdown.es.js +1 -4
  16. package/dist/Countdown.es.js.map +1 -1
  17. package/dist/Divider.cjs.js +1 -4
  18. package/dist/Divider.cjs.js.map +1 -1
  19. package/dist/Divider.es.js +1 -4
  20. package/dist/Divider.es.js.map +1 -1
  21. package/dist/Embed.cjs.js +3 -5
  22. package/dist/Embed.cjs.js.map +1 -1
  23. package/dist/Embed.es.js +3 -5
  24. package/dist/Embed.es.js.map +1 -1
  25. package/dist/Form.cjs.js +1 -4
  26. package/dist/Form.cjs.js.map +1 -1
  27. package/dist/Form.es.js +2 -5
  28. package/dist/Form.es.js.map +1 -1
  29. package/dist/Image.cjs.js +1 -4
  30. package/dist/Image.cjs.js.map +1 -1
  31. package/dist/Image.es.js +2 -5
  32. package/dist/Image.es.js.map +1 -1
  33. package/dist/LiveProvider.cjs.js +1 -4
  34. package/dist/LiveProvider.cjs.js.map +1 -1
  35. package/dist/LiveProvider.es.js +2 -5
  36. package/dist/LiveProvider.es.js.map +1 -1
  37. package/dist/Navigation.cjs.js +3 -5
  38. package/dist/Navigation.cjs.js.map +1 -1
  39. package/dist/Navigation.es.js +3 -5
  40. package/dist/Navigation.es.js.map +1 -1
  41. package/dist/PreviewProvider.cjs.js +1 -4
  42. package/dist/PreviewProvider.cjs.js.map +1 -1
  43. package/dist/PreviewProvider.es.js +3 -6
  44. package/dist/PreviewProvider.es.js.map +1 -1
  45. package/dist/ReadOnlyText.cjs.js +62 -60
  46. package/dist/ReadOnlyText.cjs.js.map +1 -1
  47. package/dist/ReadOnlyText.es.js +9 -7
  48. package/dist/ReadOnlyText.es.js.map +1 -1
  49. package/dist/ReadOnlyTextV2.cjs.js +318 -0
  50. package/dist/ReadOnlyTextV2.cjs.js.map +1 -0
  51. package/dist/ReadOnlyTextV2.es.js +314 -0
  52. package/dist/ReadOnlyTextV2.es.js.map +1 -0
  53. package/dist/Root.cjs.js +2 -4
  54. package/dist/Root.cjs.js.map +1 -1
  55. package/dist/Root.es.js +2 -4
  56. package/dist/Root.es.js.map +1 -1
  57. package/dist/SocialLinks.cjs.js +1 -4
  58. package/dist/SocialLinks.cjs.js.map +1 -1
  59. package/dist/SocialLinks.es.js +1 -4
  60. package/dist/SocialLinks.es.js.map +1 -1
  61. package/dist/Text.cjs.js +2 -5
  62. package/dist/Text.cjs.js.map +1 -1
  63. package/dist/Text.es.js +3 -6
  64. package/dist/Text.es.js.map +1 -1
  65. package/dist/Video.cjs.js +1 -4
  66. package/dist/Video.cjs.js.map +1 -1
  67. package/dist/Video.es.js +1 -4
  68. package/dist/Video.es.js.map +1 -1
  69. package/dist/actions.cjs.js.map +1 -1
  70. package/dist/actions.es.js.map +1 -1
  71. package/dist/builder.cjs.js +1 -2
  72. package/dist/builder.cjs.js.map +1 -1
  73. package/dist/builder.es.js +1 -2
  74. package/dist/builder.es.js.map +1 -1
  75. package/dist/components.cjs.js +2 -4
  76. package/dist/components.cjs.js.map +1 -1
  77. package/dist/components.es.js +2 -4
  78. package/dist/components.es.js.map +1 -1
  79. package/dist/constants.cjs.js.map +1 -1
  80. package/dist/constants.es.js.map +1 -1
  81. package/dist/control-serialization.cjs.js +0 -2
  82. package/dist/control-serialization.cjs.js.map +1 -1
  83. package/dist/control-serialization.es.js +0 -2
  84. package/dist/control-serialization.es.js.map +1 -1
  85. package/dist/controls.cjs.js +2 -6
  86. package/dist/controls.cjs.js.map +1 -1
  87. package/dist/controls.es.js +2 -3
  88. package/dist/controls.es.js.map +1 -1
  89. package/dist/descriptors.cjs.js +53 -88
  90. package/dist/descriptors.cjs.js.map +1 -1
  91. package/dist/descriptors.es.js +32 -64
  92. package/dist/descriptors.es.js.map +1 -1
  93. package/dist/element.cjs.js +55 -0
  94. package/dist/element.cjs.js.map +1 -0
  95. package/dist/element.es.js +54 -0
  96. package/dist/element.es.js.map +1 -0
  97. package/dist/index.cjs.js +33 -116
  98. package/dist/index.cjs.js.map +1 -1
  99. package/dist/index.cjs2.js +3 -4
  100. package/dist/index.cjs2.js.map +1 -1
  101. package/dist/index.cjs5.js +48 -82
  102. package/dist/index.cjs5.js.map +1 -1
  103. package/dist/index.cjs6.js +41 -42
  104. package/dist/index.cjs6.js.map +1 -1
  105. package/dist/index.cjs7.js +14 -341
  106. package/dist/index.cjs7.js.map +1 -1
  107. package/dist/index.cjs8.js +209 -0
  108. package/dist/index.cjs8.js.map +1 -0
  109. package/dist/index.cjs9.js +370 -0
  110. package/dist/index.cjs9.js.map +1 -0
  111. package/dist/index.es.js +32 -117
  112. package/dist/index.es.js.map +1 -1
  113. package/dist/index.es2.js +2 -3
  114. package/dist/index.es2.js.map +1 -1
  115. package/dist/index.es3.js +1 -1
  116. package/dist/index.es5.js +19 -54
  117. package/dist/index.es5.js.map +1 -1
  118. package/dist/index.es6.js +36 -40
  119. package/dist/index.es6.js.map +1 -1
  120. package/dist/index.es7.js +13 -336
  121. package/dist/index.es7.js.map +1 -1
  122. package/dist/index.es8.js +202 -0
  123. package/dist/index.es8.js.map +1 -0
  124. package/dist/index.es9.js +363 -0
  125. package/dist/index.es9.js.map +1 -0
  126. package/dist/introspection.cjs.js +0 -2
  127. package/dist/introspection.cjs.js.map +1 -1
  128. package/dist/introspection.es.js +0 -2
  129. package/dist/introspection.es.js.map +1 -1
  130. package/dist/leaf.cjs.js.map +1 -1
  131. package/dist/leaf.es.js +1 -1
  132. package/dist/leaf.es.js.map +1 -1
  133. package/dist/main.cjs.js +1 -2
  134. package/dist/main.cjs.js.map +1 -1
  135. package/dist/main.es.js +1 -2
  136. package/dist/main.es.js.map +1 -1
  137. package/dist/next.cjs.js +1 -4
  138. package/dist/next.cjs.js.map +1 -1
  139. package/dist/next.es.js +2 -5
  140. package/dist/next.es.js.map +1 -1
  141. package/dist/prop-controllers.cjs.js +1 -2
  142. package/dist/prop-controllers.cjs.js.map +1 -1
  143. package/dist/prop-controllers.es.js +1 -2
  144. package/dist/prop-controllers.es.js.map +1 -1
  145. package/dist/react.cjs.js +1 -4
  146. package/dist/react.cjs.js.map +1 -1
  147. package/dist/react.es.js +1 -4
  148. package/dist/react.es.js.map +1 -1
  149. package/dist/slate.cjs.js +8 -3
  150. package/dist/slate.cjs.js.map +1 -1
  151. package/dist/slate.cjs2.js +46 -0
  152. package/dist/slate.cjs2.js.map +1 -0
  153. package/dist/slate.es.js +6 -4
  154. package/dist/slate.es.js.map +1 -1
  155. package/dist/slate.es2.js +44 -0
  156. package/dist/slate.es2.js.map +1 -0
  157. package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
  158. package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
  159. package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +1 -1
  160. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts +2 -1
  161. package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
  162. package/dist/types/src/components/builtin/Text/components/Element/block.d.ts +1 -1
  163. package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +1 -1
  164. package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts +1 -1
  165. package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts.map +1 -1
  166. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts +1 -1
  167. package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +1 -1
  168. package/dist/types/src/controls/list.d.ts +2 -1
  169. package/dist/types/src/controls/list.d.ts.map +1 -1
  170. package/dist/types/src/controls/rich-text/dto-types.d.ts +1 -1
  171. package/dist/types/src/controls/rich-text/dto-types.d.ts.map +1 -1
  172. package/dist/types/src/controls/rich-text/index.d.ts +0 -1
  173. package/dist/types/src/controls/rich-text/index.d.ts.map +1 -1
  174. package/dist/types/src/controls/rich-text/rich-text.d.ts +1 -1
  175. package/dist/types/src/controls/rich-text/rich-text.d.ts.map +1 -1
  176. package/dist/types/src/controls/rich-text/translation.d.ts +1 -1
  177. package/dist/types/src/controls/rich-text/translation.d.ts.map +1 -1
  178. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +25 -4
  179. package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  180. package/dist/types/src/controls/shape.d.ts +2 -1
  181. package/dist/types/src/controls/shape.d.ts.map +1 -1
  182. package/dist/types/src/controls/slot.d.ts +1 -1
  183. package/dist/types/src/controls/slot.d.ts.map +1 -1
  184. package/dist/types/src/controls/style.d.ts +2 -1
  185. package/dist/types/src/controls/style.d.ts.map +1 -1
  186. package/dist/types/src/prop-controllers/base.d.ts +7 -0
  187. package/dist/types/src/prop-controllers/base.d.ts.map +1 -0
  188. package/dist/types/src/prop-controllers/instances.d.ts +1 -5
  189. package/dist/types/src/prop-controllers/instances.d.ts.map +1 -1
  190. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts +13 -0
  191. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -0
  192. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/index.d.ts +4 -0
  193. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/index.d.ts.map +1 -0
  194. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.d.ts +9 -0
  195. package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.d.ts.map +1 -0
  196. package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts +21 -0
  197. package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -0
  198. package/dist/types/src/runtimes/react/controls/rich-text-v2/index.d.ts +2 -0
  199. package/dist/types/src/runtimes/react/controls/rich-text-v2/index.d.ts.map +1 -0
  200. package/dist/types/src/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts +8 -0
  201. package/dist/types/src/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -0
  202. package/dist/types/src/slate/BlockPlugin/index.d.ts +1 -1
  203. package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
  204. package/dist/types/src/slate/BlockPlugin/types.d.ts +1 -1
  205. package/dist/types/src/slate/BlockPlugin/types.d.ts.map +1 -1
  206. package/dist/types/src/slate/BlockPlugin/unwrapInline.d.ts +1 -1
  207. package/dist/types/src/slate/BlockPlugin/unwrapInline.d.ts.map +1 -1
  208. package/dist/types/src/slate/BlockPlugin/wrapInline.d.ts +1 -1
  209. package/dist/types/src/slate/BlockPlugin/wrapInline.d.ts.map +1 -1
  210. package/dist/types/src/slate/BuilderPlugin/index.d.ts +7 -0
  211. package/dist/types/src/slate/BuilderPlugin/index.d.ts.map +1 -0
  212. package/dist/types/src/slate/InlineModePlugin/index.d.ts +5 -0
  213. package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -0
  214. package/dist/types/src/slate/ListPlugin/index.d.ts +1 -1
  215. package/dist/types/src/slate/ListPlugin/index.d.ts.map +1 -1
  216. package/dist/types/src/slate/ListPlugin/toggleList.d.ts +1 -1
  217. package/dist/types/src/slate/ListPlugin/toggleList.d.ts.map +1 -1
  218. package/dist/types/src/slate/ListPlugin/wrapList.d.ts +1 -1
  219. package/dist/types/src/slate/ListPlugin/wrapList.d.ts.map +1 -1
  220. package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts +1 -1
  221. package/dist/types/src/slate/TypographyPlugin/detachActiveTypography.d.ts.map +1 -1
  222. package/dist/types/src/slate/TypographyPlugin/index.d.ts +1 -1
  223. package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -1
  224. package/dist/types/src/slate/TypographyPlugin/setActiveTypographyStyle.d.ts.map +1 -1
  225. package/dist/types/src/slate/index.d.ts +2 -0
  226. package/dist/types/src/slate/index.d.ts.map +1 -1
  227. package/dist/types/src/slate/selectors.d.ts +1 -1
  228. package/dist/types/src/slate/selectors.d.ts.map +1 -1
  229. package/dist/types/src/slate/utils/editor.d.ts +1 -1
  230. package/dist/types/src/slate/utils/editor.d.ts.map +1 -1
  231. package/dist/types/src/slate/utils/element.d.ts +1 -1
  232. package/dist/types/src/slate/utils/element.d.ts.map +1 -1
  233. package/dist/types/src/state/actions.d.ts +2 -1
  234. package/dist/types/src/state/actions.d.ts.map +1 -1
  235. package/dist/types/src/state/modules/prop-controller-handles.d.ts +2 -1
  236. package/dist/types/src/state/modules/prop-controller-handles.d.ts.map +1 -1
  237. package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
  238. package/dist/types/src/state/react-page.d.ts +1 -1
  239. package/dist/types/src/state/react-page.d.ts.map +1 -1
  240. package/dist/types/{src/controls/rich-text/types.d.ts → types/slate.d.ts} +20 -17
  241. package/dist/types/types/slate.d.ts.map +1 -0
  242. package/dist/useIsomorphicLayoutEffect.cjs.js +6 -0
  243. package/dist/useIsomorphicLayoutEffect.cjs.js.map +1 -0
  244. package/dist/useIsomorphicLayoutEffect.es.js +5 -0
  245. package/dist/useIsomorphicLayoutEffect.es.js.map +1 -0
  246. package/package.json +1 -1
  247. package/dist/types/src/controls/rich-text/types.d.ts.map +0 -1
  248. package/dist/types/src/runtimes/react/controls/rich-text-v2.d.ts +0 -15
  249. package/dist/types/src/runtimes/react/controls/rich-text-v2.d.ts.map +0 -1
@@ -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 {\n Block,\n BlockType,\n Inline,\n InlineType,\n richTextDTOtoDAO,\n Text,\n Element,\n} from '../../../controls'\nimport type { ElementIDValue, RichTextValue } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport { useResponsiveStyle } 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 const descendantsAsString = getText(descendants)\n\n return (\n <div ref={ref} id={id} className={cx(width, margin)}>\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: 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(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n\n switch (descendant.type) {\n case BlockType.Text:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\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: (Element | Text)[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if ('text' in 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.Text:\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\nfunction isBlock(descendant: Element | Text): descendant is 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.BlockQuote:\n case BlockType.Paragraph:\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\n/**\n * I am using `Element | Text` here to ensure that nothing from Slate\n * is imported so that the RichText maintains it's slim bundle size\n */\nfunction getTextByDescendant(descendant: Element | Text): 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.BlockQuote:\n case BlockType.Paragraph:\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: (Element | Text)[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","descendantsAsString","getText","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","useResponsiveStyle","textAlign","BlockType","Text","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","padding","fontSize","fontWeight","borderLeft","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","_Fragment","map","index","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBMA,MAAAA,eAAeC,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACMC,QAAAA,cAAcJ,QAAQ,OAAO,CAAA,IAAKK,iBAAiBL,IAAD;AAClDM,QAAAA,sBAAsBC,QAAQH,WAAD;AAGjC,6BAAA,OAAA;AAAA,IAAK;AAAA,IAAU;AAAA,IAAQ,WAAWI,GAAGP,OAAOC,MAAR;AAAA,IACjCI,UAAAA,wBAAwB,KAAKG,oBAAC,aAAD,EAAA,IAAkBA,oBAAC,aAAD;AAAA,MAAa;AA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AAA,SACVT,UAAUE;AAAAA,SACVF,UAAUc;AAAAA,SACVd,UAAUgB;AAAAA,SACVhB,UAAUiB;AAAAA,SACVjB,UAAUkB;AACN,aAAA;AAAA;AAGA,aAAA;AAAA;AAEZ;AAMD,6BAA6BrC,YAAoC;;AAC3D,MAAA,UAAUA,YAAY;AACxB,WAAOA,iBAAWhB,SAAXgB,YAAmB;AAAA,EAC3B;AAEOA,UAAAA,WAAWQ;AAAAA,SACZC,WAAWK;AAAAA,SACXL,WAAWC;AAAAA,SACXD,WAAWI;AAAAA,SACXJ,WAAWG;AACPZ,aAAAA,iBAAWW,SAAS4B,IAAIvC,CAAcyC,gBAAAA,oBAAoBzC,WAAD,CAAzD,EAAuE0C,KAAK,EAA5E,MAAA1C,YAAmF;AAAA,SACvFmB,UAAUG;AAAAA,SACVH,UAAUI;AAAAA,SACVJ,UAAUK;AAAAA,SACVL,UAAUS;AAAAA,SACVT,UAAUE;AAAAA,SACVF,UAAUc;AAAAA,SACVd,UAAUgB;AAAAA,SACVhB,UAAUiB;AAAAA,SACVjB,UAAUkB;AAEXrC,aAAAA,iBAAWW,SACR4B,IAAIvC,CAAcyC,gBAAAA,oBAAoBzC,WAAD,CADxC,EAEG0C,KAAK1C,WAAWW,SAASgC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAA5C,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAwC;AAChDA,SAAAA,WAAWuC,IAAIE,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;"}
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, Text } from 'slate'\n\nimport type { ElementIDValue, RichTextValue } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\nimport { useTypographyClassName } from './components'\nimport useEnhancedTypography from './components/Leaf/leaf'\nimport { Inline, InlineType, Block, BlockType } from '../../../../types/slate'\nimport { richTextDTOtoDAO } from '../../../controls'\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 const descendantsAsString = getText(descendants)\n\n return (\n <div ref={ref} id={id} className={cx(width, margin)}>\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: 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(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n\n switch (descendant.type) {\n case BlockType.Text:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\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\n// reimplemented from slate source for code splitting\nfunction isText(node: any): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (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.Text:\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\nfunction isBlock(descendant: Descendant): descendant is 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.BlockQuote:\n case BlockType.Paragraph:\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.BlockQuote:\n case BlockType.Paragraph:\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"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","descendantsAsString","getText","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","useResponsiveStyle","textAlign","BlockType","Text","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","padding","fontSize","fontWeight","borderLeft","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBMA,MAAAA,eAAeC,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACMC,QAAAA,cAAcJ,QAAQ,OAAO,CAAA,IAAKK,iBAAiBL,IAAD;AAClDM,QAAAA,sBAAsBC,QAAQH,WAAD;AAGjC,6BAAA,OAAA;AAAA,IAAK;AAAA,IAAU;AAAA,IAAQ,WAAWI,GAAGP,OAAOC,MAAR;AAAA,IACjCI,UAAAA,wBAAwB,KAAKG,oBAAC,aAAD,EAAA,IAAkBA,oBAAC,aAAD;AAAA,MAAa;AAAA,IAAA,CAAb;AAAA,EAAA,CAFpD;AAKD,CAZ8B;AAgB/B,qBAAqB;AAAA,EAAET,OAAO;AAAA,GAA2C;AAErE,6BAAA,QAAA;AAAA,IACE,WAAWU,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTV,OAAO;AAAA,MACPW,UAAU;AAAA,MACVC,YAAY;AAAA,MACZC,SAAS;AAAA,MACTC,eAAe;AAAA,IAAA,CANE;AAAA,IASlBf,UAAAA;AAA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,YAAY;AACxB,WAAOA,iBAAWhB,SAAXgB,YAAmB;AAAA,EAC3B;AAEOA,UAAAA,WAAWQ;AAAAA,SACZC,WAAWK;AAAAA,SACXL,WAAWC;AAAAA,SACXD,WAAWI;AAAAA,SACXJ,WAAWG;AACPZ,aAAAA,iBAAWW,SAAS6B,IAAIxC,CAAc2C,gBAAAA,oBAAoB3C,WAAD,CAAzD,EAAuE4C,KAAK,EAA5E,MAAA5C,YAAmF;AAAA,SACvFmB,UAAUG;AAAAA,SACVH,UAAUI;AAAAA,SACVJ,UAAUK;AAAAA,SACVL,UAAUS;AAAAA,SACVT,UAAUE;AAAAA,SACVF,UAAUc;AAAAA,SACVd,UAAUgB;AAAAA,SACVhB,UAAUiB;AAAAA,SACVjB,UAAUkB;AAEXrC,aAAAA,iBAAWW,SACR6B,IAAIxC,CAAc2C,gBAAAA,oBAAoB3C,WAAD,CADxC,EAEG4C,KAAK5C,WAAWW,SAASkC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAA9C,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAWwC,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;"}
@@ -0,0 +1,318 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ var css = require("@emotion/css");
4
+ var React = require("react");
5
+ var next = require("./index.cjs.js");
6
+ var slate = require("./slate.cjs2.js");
7
+ var jsxRuntime = require("react/jsx-runtime");
8
+ var index = require("./index.cjs3.js");
9
+ var leaf = require("./leaf.cjs.js");
10
+ require("use-sync-external-store/shim/with-selector");
11
+ require("next/dynamic");
12
+ require("./constants.cjs.js");
13
+ require("redux");
14
+ require("redux-thunk");
15
+ require("./actions.cjs.js");
16
+ require("./descriptors.cjs.js");
17
+ require("./state/breakpoints.cjs.js");
18
+ require("./introspection.cjs.js");
19
+ require("@emotion/serialize");
20
+ require("@emotion/utils");
21
+ require("./text-input.cjs.js");
22
+ require("./combobox.cjs.js");
23
+ require("use-sync-external-store/shim");
24
+ require("./types.cjs.js");
25
+ require("./box-models.cjs.js");
26
+ require("css-box-model");
27
+ require("color");
28
+ require("scroll-into-view-if-needed");
29
+ require("react-dom");
30
+ require("html-react-parser");
31
+ require("next/head");
32
+ require("@emotion/server/create-instance");
33
+ require("next/document");
34
+ require("cors");
35
+ require("path-to-regexp");
36
+ require("cookie");
37
+ require("http-proxy");
38
+ require("set-cookie-parser");
39
+ require("uuid");
40
+ require("corporate-ipsum");
41
+ require("next/link");
42
+ const ReadOnlyTextV2 = React.forwardRef(function ReadOnlyText({
43
+ text: descendants
44
+ }, ref) {
45
+ const descendantsAsString = getText(descendants);
46
+ return /* @__PURE__ */ jsxRuntime.jsx("div", {
47
+ ref,
48
+ children: descendantsAsString === "" ? /* @__PURE__ */ jsxRuntime.jsx(Placeholder, {}) : /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
49
+ descendants
50
+ })
51
+ });
52
+ });
53
+ function Placeholder({
54
+ text = "Write some text..."
55
+ }) {
56
+ return /* @__PURE__ */ jsxRuntime.jsx("span", {
57
+ className: next.useStyle({
58
+ display: "inline-block",
59
+ width: 0,
60
+ maxWidth: "100%",
61
+ whiteSpace: "nowrap",
62
+ opacity: 0.333,
63
+ verticalAlign: "text-top"
64
+ }),
65
+ children: text
66
+ });
67
+ }
68
+ function TextElement({
69
+ descendant
70
+ }) {
71
+ const enhancedTypography = leaf.useEnhancedTypography(descendant.typography);
72
+ const typographyClassName = leaf.useTypographyClassName(enhancedTypography);
73
+ return /* @__PURE__ */ jsxRuntime.jsx("span", {
74
+ className: typographyClassName,
75
+ children: descendant.text === "" ? "\uFEFF" : descendant.text
76
+ });
77
+ }
78
+ function InlineElement({
79
+ descendant
80
+ }) {
81
+ const linkClassName = next.useStyle({
82
+ textDecoration: "none"
83
+ });
84
+ switch (descendant.type) {
85
+ case slate.InlineType.Code:
86
+ return /* @__PURE__ */ jsxRuntime.jsx("code", {
87
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
88
+ descendants: descendant.children
89
+ })
90
+ });
91
+ case slate.InlineType.SuperScript:
92
+ return /* @__PURE__ */ jsxRuntime.jsx("sup", {
93
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
94
+ descendants: descendant.children
95
+ })
96
+ });
97
+ case slate.InlineType.SubScript:
98
+ return /* @__PURE__ */ jsxRuntime.jsx("sub", {
99
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
100
+ descendants: descendant.children
101
+ })
102
+ });
103
+ case slate.InlineType.Link:
104
+ return /* @__PURE__ */ jsxRuntime.jsx(index.Link, {
105
+ className: linkClassName,
106
+ link: descendant.link,
107
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
108
+ descendants: descendant.children
109
+ })
110
+ });
111
+ }
112
+ }
113
+ function BlockElement({
114
+ descendant
115
+ }) {
116
+ const blockStyles = [next.useStyle({
117
+ margin: 0
118
+ }), next.useStyle(next.useResponsiveStyle([descendant.textAlign], ([textAlign = "left"]) => ({
119
+ textAlign
120
+ })))];
121
+ switch (descendant.type) {
122
+ case slate.BlockType.Text:
123
+ return /* @__PURE__ */ jsxRuntime.jsx("span", {
124
+ className: css.cx(...blockStyles),
125
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
126
+ descendants: descendant.children
127
+ })
128
+ });
129
+ case slate.BlockType.Paragraph:
130
+ return /* @__PURE__ */ jsxRuntime.jsx("p", {
131
+ className: css.cx(...blockStyles),
132
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
133
+ descendants: descendant.children
134
+ })
135
+ });
136
+ case slate.BlockType.Heading1:
137
+ return /* @__PURE__ */ jsxRuntime.jsx("h1", {
138
+ className: css.cx(...blockStyles),
139
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
140
+ descendants: descendant.children
141
+ })
142
+ });
143
+ case slate.BlockType.Heading2:
144
+ return /* @__PURE__ */ jsxRuntime.jsx("h2", {
145
+ className: css.cx(...blockStyles),
146
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
147
+ descendants: descendant.children
148
+ })
149
+ });
150
+ case slate.BlockType.Heading3:
151
+ return /* @__PURE__ */ jsxRuntime.jsx("h3", {
152
+ className: css.cx(...blockStyles),
153
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
154
+ descendants: descendant.children
155
+ })
156
+ });
157
+ case slate.BlockType.Heading4:
158
+ return /* @__PURE__ */ jsxRuntime.jsx("h4", {
159
+ className: css.cx(...blockStyles),
160
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
161
+ descendants: descendant.children
162
+ })
163
+ });
164
+ case slate.BlockType.Heading5:
165
+ return /* @__PURE__ */ jsxRuntime.jsx("h5", {
166
+ className: css.cx(...blockStyles),
167
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
168
+ descendants: descendant.children
169
+ })
170
+ });
171
+ case slate.BlockType.Heading6:
172
+ return /* @__PURE__ */ jsxRuntime.jsx("h6", {
173
+ className: css.cx(...blockStyles),
174
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
175
+ descendants: descendant.children
176
+ })
177
+ });
178
+ case slate.BlockType.BlockQuote:
179
+ return /* @__PURE__ */ jsxRuntime.jsx("blockquote", {
180
+ className: css.cx(...blockStyles, next.useStyle({
181
+ padding: "0.5em 10px",
182
+ fontSize: "1.25em",
183
+ fontWeight: "300",
184
+ borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
185
+ })),
186
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
187
+ descendants: descendant.children
188
+ })
189
+ });
190
+ case slate.BlockType.OrderedList:
191
+ return /* @__PURE__ */ jsxRuntime.jsx("ol", {
192
+ className: css.cx(...blockStyles),
193
+ style: {
194
+ listStylePosition: "inside"
195
+ },
196
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
197
+ descendants: descendant.children
198
+ })
199
+ });
200
+ case slate.BlockType.UnorderedList:
201
+ return /* @__PURE__ */ jsxRuntime.jsx("ul", {
202
+ className: css.cx(...blockStyles),
203
+ style: {
204
+ listStylePosition: "inside"
205
+ },
206
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
207
+ descendants: descendant.children
208
+ })
209
+ });
210
+ case slate.BlockType.ListItem:
211
+ return /* @__PURE__ */ jsxRuntime.jsx("li", {
212
+ className: css.cx(...blockStyles),
213
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
214
+ descendants: descendant.children
215
+ })
216
+ });
217
+ case slate.BlockType.ListItemChild:
218
+ return /* @__PURE__ */ jsxRuntime.jsx("span", {
219
+ className: css.cx(...blockStyles),
220
+ children: /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
221
+ descendants: descendant.children
222
+ })
223
+ });
224
+ }
225
+ }
226
+ function isText(node) {
227
+ if (typeof node === "object" && "text" in node)
228
+ return true;
229
+ return false;
230
+ }
231
+ function Descendants({
232
+ descendants
233
+ }) {
234
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
235
+ children: descendants.map((descendant, index2) => {
236
+ if (isText(descendant)) {
237
+ return /* @__PURE__ */ jsxRuntime.jsx(TextElement, {
238
+ descendant
239
+ }, index2);
240
+ }
241
+ switch (descendant.type) {
242
+ case slate.InlineType.Link:
243
+ case slate.InlineType.Code:
244
+ case slate.InlineType.SubScript:
245
+ case slate.InlineType.SuperScript:
246
+ return /* @__PURE__ */ jsxRuntime.jsx(InlineElement, {
247
+ descendant
248
+ }, index2);
249
+ case slate.BlockType.Heading1:
250
+ case slate.BlockType.Heading2:
251
+ case slate.BlockType.Heading3:
252
+ case slate.BlockType.BlockQuote:
253
+ case slate.BlockType.Text:
254
+ case slate.BlockType.Paragraph:
255
+ case slate.BlockType.OrderedList:
256
+ case slate.BlockType.UnorderedList:
257
+ case slate.BlockType.ListItem:
258
+ case slate.BlockType.ListItemChild:
259
+ return /* @__PURE__ */ jsxRuntime.jsx(BlockElement, {
260
+ descendant
261
+ }, index2);
262
+ default:
263
+ return null;
264
+ }
265
+ })
266
+ });
267
+ }
268
+ function isBlock(descendant) {
269
+ if (isText(descendant))
270
+ return false;
271
+ switch (descendant.type) {
272
+ case slate.BlockType.Heading1:
273
+ case slate.BlockType.Heading2:
274
+ case slate.BlockType.Heading3:
275
+ case slate.BlockType.BlockQuote:
276
+ case slate.BlockType.Paragraph:
277
+ case slate.BlockType.OrderedList:
278
+ case slate.BlockType.UnorderedList:
279
+ case slate.BlockType.ListItem:
280
+ case slate.BlockType.ListItemChild:
281
+ case slate.BlockType.Text:
282
+ return true;
283
+ default:
284
+ return false;
285
+ }
286
+ }
287
+ function getTextByDescendant(descendant) {
288
+ var _a, _b, _c;
289
+ if (isText(descendant)) {
290
+ return (_a = descendant.text) != null ? _a : "";
291
+ }
292
+ switch (descendant.type) {
293
+ case slate.InlineType.Link:
294
+ case slate.InlineType.Code:
295
+ case slate.InlineType.SubScript:
296
+ case slate.InlineType.SuperScript:
297
+ return (_b = descendant.children.map((descendant2) => getTextByDescendant(descendant2)).join("")) != null ? _b : "";
298
+ case slate.BlockType.Heading1:
299
+ case slate.BlockType.Heading2:
300
+ case slate.BlockType.Heading3:
301
+ case slate.BlockType.BlockQuote:
302
+ case slate.BlockType.Paragraph:
303
+ case slate.BlockType.OrderedList:
304
+ case slate.BlockType.UnorderedList:
305
+ case slate.BlockType.ListItem:
306
+ case slate.BlockType.ListItemChild:
307
+ return (_c = descendant.children.map((descendant2) => getTextByDescendant(descendant2)).join(descendant.children.every(isBlock) ? "\n" : "")) != null ? _c : "";
308
+ default:
309
+ return "";
310
+ }
311
+ }
312
+ function getText(descendant) {
313
+ return descendant.map(getTextByDescendant).join("\n");
314
+ }
315
+ exports.BlockElement = BlockElement;
316
+ exports.TextElement = TextElement;
317
+ exports["default"] = ReadOnlyTextV2;
318
+ //# sourceMappingURL=ReadOnlyTextV2.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadOnlyTextV2.cjs.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { useTypographyClassName } from '../../../../components/builtin/Text/components'\nimport useEnhancedTypography from '../../../../components/builtin/Text/components/Leaf/leaf'\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { RichTextV2ControlData } from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Text } from 'slate'\nimport { Link } from '../../../../components/shared/Link'\nimport { Inline, InlineType, Block, BlockType } from '../../../../../types/slate'\n\ntype Props = {\n text: RichTextV2ControlData\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: descendants }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants)\n\n return (\n <div ref={ref}>\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\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\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: 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(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n\n switch (descendant.type) {\n case BlockType.Text:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\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\n// reimplemented from slate source for code splitting\nfunction isText(node: any): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({ descendants }: { descendants: Descendant[] }) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (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.Text:\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\nfunction isBlock(descendant: Descendant): descendant is Block {\n if (isText(descendant)) return false\n\n switch (descendant.type) {\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 case BlockType.Text:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if (isText(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.BlockQuote:\n case BlockType.Paragraph:\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"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","ref","descendantsAsString","getText","_jsx","useStyle","display","width","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","margin","useResponsiveStyle","textAlign","BlockType","Text","cx","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","padding","fontSize","fontWeight","borderLeft","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeMA,MAAAA,iBAAiBC,MAAAA,WAAW,sBAChC;AAAA,EAAEC,MAAMC;AAAAA,GACRC,KACA;AACMC,QAAAA,sBAAsBC,QAAQH,WAAD;AAGjC,wCAAA,OAAA;AAAA,IAAK;AAAA,IACFE,UAAAA,wBAAwB,KAAKE,2BAAA,IAAC,aAAD,EAAA,IAAkBA,2BAAA,IAAC,aAAD;AAAA,MAAa;AAAA,IAAA,CAAb;AAAA,EAAA,CAFpD;AAKD,CAXgC;AAejC,qBAAqB;AAAA,EAAEL,OAAO;AAAA,GAA2C;AAErE,wCAAA,QAAA;AAAA,IACE,WAAWM,KAAAA,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTC,OAAO;AAAA,MACPC,UAAU;AAAA,MACVC,YAAY;AAAA,M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