@makeswift/runtime 0.9.12 → 0.10.1
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.
- package/dist/Box.cjs.js +3 -0
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +4 -1
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +3 -2
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Button.es.js +4 -3
- package/dist/Button.es.js.map +1 -1
- package/dist/Carousel.cjs.js +3 -2
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +4 -3
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +3 -0
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +4 -1
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +3 -0
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +4 -1
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +1 -0
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +2 -1
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +13 -12
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +5 -4
- package/dist/Form.es.js.map +1 -1
- package/dist/Image.cjs.js +11 -10
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +11 -10
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +3 -0
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +5 -2
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +11 -10
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +11 -10
- package/dist/Navigation.es.js.map +1 -1
- package/dist/PreviewProvider.cjs.js +10 -6
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +9 -5
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +19 -26
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +15 -22
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +29 -26
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +28 -25
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +3 -0
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +4 -1
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +6 -5
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +7 -6
- package/dist/SocialLinks.es.js.map +1 -1
- package/dist/Text.cjs.js +12 -71
- package/dist/Text.cjs.js.map +1 -1
- package/dist/Text.es.js +13 -64
- package/dist/Text.es.js.map +1 -1
- package/dist/Video.cjs.js +1 -0
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +2 -1
- package/dist/Video.es.js.map +1 -1
- package/dist/actions.cjs.js +2 -2
- package/dist/actions.cjs.js.map +1 -1
- package/dist/actions.es.js +2 -2
- package/dist/actions.es.js.map +1 -1
- package/dist/builder.cjs.js +2 -0
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +2 -0
- package/dist/builder.es.js.map +1 -1
- package/dist/components.cjs.js +3 -2
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +3 -2
- package/dist/components.es.js.map +1 -1
- package/dist/control-serialization.es.js +1 -1
- package/dist/controls.cjs.js +8 -8
- package/dist/controls.es.js +4 -2
- package/dist/controls.es.js.map +1 -1
- package/dist/index.cjs.js +280 -216
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs3.js +21 -107
- package/dist/index.cjs3.js.map +1 -1
- package/dist/index.cjs4.js +16 -57
- package/dist/index.cjs4.js.map +1 -1
- package/dist/index.cjs5.js +53 -242
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +0 -41
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs7.js +376 -14
- package/dist/index.cjs7.js.map +1 -1
- package/dist/index.cjs8.js +275 -11
- package/dist/index.cjs8.js.map +1 -1
- package/dist/index.es.js +274 -209
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +2 -2
- package/dist/index.es3.js +22 -103
- package/dist/index.es3.js.map +1 -1
- package/dist/index.es4.js +16 -57
- package/dist/index.es4.js.map +1 -1
- package/dist/index.es5.js +53 -240
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +1 -36
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es7.js +372 -16
- package/dist/index.es7.js.map +1 -1
- package/dist/index.es8.js +270 -10
- package/dist/index.es8.js.map +1 -1
- package/dist/main.cjs.js +2 -0
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +2 -0
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +3 -0
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +4 -1
- package/dist/next.es.js.map +1 -1
- package/dist/prop-controllers.cjs.js +2 -0
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +2 -0
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react-page.cjs.js +1450 -65
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +1427 -66
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +3 -0
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +3 -0
- package/dist/react.es.js.map +1 -1
- package/dist/slate.cjs.js +33 -391
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +15 -376
- package/dist/slate.es.js.map +1 -1
- package/dist/text-input.cjs.js +0 -22
- package/dist/text-input.cjs.js.map +1 -1
- package/dist/text-input.es.js +1 -18
- package/dist/text-input.es.js.map +1 -1
- package/dist/types/src/components/builtin/Text/Text.d.ts +3 -4
- package/dist/types/src/components/builtin/Text/Text.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/register.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/fixtures/v2-data-types.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/rich-text.d.ts +0 -1
- package/dist/types/src/controls/rich-text/rich-text.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text/translation.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/plugin.d.ts +29 -0
- package/dist/types/src/controls/rich-text-v2/plugin.d.ts.map +1 -0
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +17 -31
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/index.d.ts.map +1 -1
- package/dist/types/src/next/client.d.ts.map +1 -1
- package/dist/types/src/next/index.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/descriptors.d.ts +1 -1
- package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/control.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
- package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/EditableText/editable-text.d.ts +4 -3
- package/dist/types/src/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/EditableText/index.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/EditableText/useSyncDOMSelection.d.ts.map +1 -0
- package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/EditableText/useSyncWithBuilder.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.d.ts.map +1 -0
- package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/ReadOnlyText.d.ts +2 -2
- package/dist/types/src/runtimes/react/controls/rich-text/ReadOnlyText.d.ts.map +1 -0
- package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Element/block.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text/components/Element/block.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/components/Element/element.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/components/Element/index.d.ts.map +1 -0
- package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Element/inline.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text/components/Element/inline.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/components/Leaf/index.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/components/Leaf/leaf.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/components/index.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text/index.d.ts +2 -0
- package/dist/types/src/runtimes/react/controls/rich-text/index.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/{rich-text.d.ts → rich-text/rich-text.d.ts} +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text/rich-text.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts +2 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts +2 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts +2 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/index.d.ts +3 -3
- package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/InlineModePlugin/index.d.ts +6 -4
- package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/InlinePlugin/index.d.ts +3 -3
- package/dist/types/src/slate/InlinePlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/InlinePlugin/types.d.ts +1 -1
- package/dist/types/src/slate/InlinePlugin/types.d.ts.map +1 -1
- package/dist/types/src/slate/LinkPlugin/index.d.ts +3 -3
- package/dist/types/src/slate/LinkPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/LinkPlugin/linkPluginWithoutRenderElement.d.ts +16 -0
- package/dist/types/src/slate/LinkPlugin/linkPluginWithoutRenderElement.d.ts.map +1 -0
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts +3 -3
- package/dist/types/src/slate/TypographyPlugin/index.d.ts +3 -3
- package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/types.d.ts +1 -10
- package/dist/types/src/slate/types.d.ts.map +1 -1
- package/dist/types/src/slate/utils/element.d.ts.map +1 -1
- package/dist/types/src/state/actions.d.ts +2 -1
- package/dist/types/src/state/actions.d.ts.map +1 -1
- package/dist/types/src/state/modules/locales.d.ts.map +1 -1
- package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index.cjs10.js +0 -390
- package/dist/index.cjs10.js.map +0 -1
- package/dist/index.cjs9.js +0 -295
- package/dist/index.cjs9.js.map +0 -1
- package/dist/index.es10.js +0 -383
- package/dist/index.es10.js.map +0 -1
- package/dist/index.es9.js +0 -288
- package/dist/index.es9.js.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/index.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/useSyncDOMSelection.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/EditableText/useSyncWithBuilder.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/Element/element.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/Element/index.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/Element/inline.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/Leaf/index.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +0 -1
- package/dist/types/src/components/builtin/Text/components/index.d.ts.map +0 -1
- package/dist/types/src/runtimes/react/controls/rich-text.d.ts.map +0 -1
- package/dist/types.cjs2.js +0 -765
- package/dist/types.cjs2.js.map +0 -1
- package/dist/types.es2.js +0 -748
- package/dist/types.es2.js.map +0 -1
- /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/EditableText/index.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/EditableText/useSyncDOMSelection.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Element/element.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Element/index.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Leaf/index.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/Leaf/leaf.d.ts +0 -0
- /package/dist/types/src/{components/builtin/Text → runtimes/react/controls/rich-text}/components/index.d.ts +0 -0
|
@@ -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, 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 { Inline, InlineType, Block, BlockType } from '../../../slate'\nimport { richTextDTOtoDAO } from '../../../controls'\nimport useEnhancedTypography, {\n useTypographyClassName,\n} from '../../../runtimes/react/controls/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 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 ?? undefined}>\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 const quoteStyle = useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n })\n\n switch (descendant.type) {\n case BlockType.Text:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n case BlockType.Default:\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n default:\n return null\n }\n}\n\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.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.Text:\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.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.Text:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.Text:\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","undefined","blockStyles","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","Default","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBMA,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,GAA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aAAAA,iBAAWW,SACRgC,IAAI3C,CAAc8C,gBAAAA,oBAAoB9C,WAAD,CADxC,EAEG+C,KAAK/C,WAAWW,SAASqC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAAjD,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAW2C,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;"}
|
|
1
|
+
{"version":3,"file":"ReadOnlyText.es.js","sources":["../src/runtimes/react/controls/rich-text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { richTextDTOtoDAO } from '../../../../controls'\nimport type { ElementIDValue, RichTextValue } from '../../../../prop-controllers/descriptors'\nimport { Inline, InlineType, Block, BlockType } from '../../../../slate'\nimport { useStyle } from '../../use-style'\nimport useEnhancedTypography, { useTypographyClassName } from '../typography'\nimport { Link } from '../../../../components/shared/Link'\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\n ref={ref}\n id={id}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n className={cx(width, margin)}\n >\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Inline\n}\n\nfunction InlineElement({ descendant }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link ?? undefined}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n const quoteStyle = useStyle({\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n })\n\n switch (descendant.type) {\n case BlockType.Default:\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} />\n </span>\n )\n default:\n return null\n }\n}\n\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.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","descendantsAsString","getText","position","whiteSpace","wordWrap","cx","_jsx","useStyle","display","maxWidth","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","undefined","blockStyles","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Default","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBMA,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,IACE;AAAA,IACA;AAAA,IACA,OAAO;AAAA,MAMLI,UAAU;AAAA,MACVC,YAAY;AAAA,MACZC,UAAU;AAAA,IAXd;AAAA,IAaE,WAAWC,GAAGV,OAAOC,MAAR;AAAA,IAEZI,UAAAA,wBAAwB,KAAKM,oBAAC,aAAD,EAAA,IAAkBA,oBAAC,aAAD;AAAA,MAAa;AAAA,IAAA,CAAb;AAAA,EAAA,CAhBpD;AAmBD,CA1B8B;AA8B/B,qBAAqB;AAAA,EAAEZ,OAAO;AAAA,GAA2C;AAErE,6BAAA,QAAA;AAAA,IACE,WAAWa,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTb,OAAO;AAAA,MACPc,UAAU;AAAA,MACVN,YAAY;AAAA,MACZO,SAAS;AAAA,MACTC,eAAe;AAAA,IAAA,CANE;AAAA,IASlBjB,UAAAA;AAAAA,EAAAA,CAXL;AAcD;AAM2B,qBAAA;AAAA,EAAEkB;AAAAA,GAAyB;AAC/CC,QAAAA,qBAAqBC,sBAAsBF,WAAWG,UAAZ;AAC1CC,QAAAA,sBAAsBC,uBAAuBJ,kBAAD;AAGhD,6BAAA,QAAA;AAAA,IAAM,WAAWG;AAAAA,IACdJ,UAAAA,WAAWlB,S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S+B,IAAI1C,CAAc6C,gBAAAA,oBAAoB7C,WAAD,CAAzD,EAAuE8C,KAAK,EAA5E,MAAA9C,YAAmF;AAAA,SACvFyB,UAAUG;AAAAA,SACVH,UAAUI;AAAAA,SACVJ,UAAUK;AAAAA,SACVL,UAAUM;AAAAA,SACVN,UAAUO;AAAAA,SACVP,UAAUQ;AAAAA,SACVR,UAAUS;AAAAA,SACVT,UAAUE;AAAAA,SACVF,UAAUC;AAAAA,SACVD,UAAUU;AAAAA,SACVV,UAAUY;AAAAA,SACVZ,UAAUa;AAAAA,SACVb,UAAUc;AAEXvC,aAAAA,iBAAWW,SACR+B,IAAI1C,CAAc6C,gBAAAA,oBAAoB7C,WAAD,CADxC,EAEG8C,KAAK9C,WAAWW,SAASoC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAAhD,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAW0C,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;"}
|
|
@@ -17,33 +17,31 @@ var __objRest = (source, exclude) => {
|
|
|
17
17
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
18
18
|
var React = require("react");
|
|
19
19
|
var reactPage = require("./react-page.cjs.js");
|
|
20
|
-
require("slate");
|
|
21
|
-
require("./state/breakpoints.cjs.js");
|
|
22
20
|
require("./actions.cjs.js");
|
|
23
|
-
require("
|
|
24
|
-
require("is-hotkey");
|
|
21
|
+
require("slate");
|
|
25
22
|
require("slate-react");
|
|
26
|
-
var
|
|
27
|
-
require("./index.cjs3.js");
|
|
28
|
-
require("@emotion/css");
|
|
23
|
+
var index = require("./index.cjs5.js");
|
|
29
24
|
require("uuid");
|
|
30
25
|
var next = require("./index.cjs.js");
|
|
26
|
+
var jsxRuntime = require("react/jsx-runtime");
|
|
31
27
|
require("redux");
|
|
32
28
|
require("redux-thunk");
|
|
29
|
+
require("./state/breakpoints.cjs.js");
|
|
30
|
+
require("zod");
|
|
31
|
+
require("@emotion/css");
|
|
33
32
|
require("@emotion/serialize");
|
|
34
33
|
require("@emotion/utils");
|
|
35
|
-
require("
|
|
36
|
-
require("./text-input.cjs.js");
|
|
37
|
-
require("scroll-into-view-if-needed");
|
|
38
|
-
require("next/link");
|
|
34
|
+
require("is-hotkey");
|
|
39
35
|
require("use-sync-external-store/shim/with-selector");
|
|
40
36
|
require("next/dynamic");
|
|
37
|
+
require("./text-input.cjs.js");
|
|
41
38
|
require("./combobox.cjs.js");
|
|
42
39
|
require("use-sync-external-store/shim");
|
|
43
40
|
require("./types.cjs.js");
|
|
44
41
|
require("./box-models.cjs.js");
|
|
45
42
|
require("css-box-model");
|
|
46
43
|
require("color");
|
|
44
|
+
require("scroll-into-view-if-needed");
|
|
47
45
|
require("react-dom");
|
|
48
46
|
require("html-react-parser");
|
|
49
47
|
require("next/head");
|
|
@@ -56,18 +54,24 @@ require("http-proxy");
|
|
|
56
54
|
require("set-cookie-parser");
|
|
57
55
|
require("./constants.cjs.js");
|
|
58
56
|
require("corporate-ipsum");
|
|
57
|
+
require("next/link");
|
|
59
58
|
const ReadOnlyTextV2 = React.forwardRef(function ReadOnlyText({
|
|
60
59
|
text: {
|
|
61
60
|
descendants
|
|
62
61
|
},
|
|
63
62
|
definition
|
|
64
63
|
}, ref) {
|
|
65
|
-
var _a;
|
|
66
|
-
const descendantsAsString = getText(descendants);
|
|
64
|
+
var _a, _b;
|
|
65
|
+
const descendantsAsString = getText(descendants, (_a = definition == null ? void 0 : definition.config.mode) != null ? _a : reactPage.RichTextV2Mode.Block);
|
|
67
66
|
return /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
68
67
|
ref,
|
|
68
|
+
style: {
|
|
69
|
+
position: "relative",
|
|
70
|
+
whiteSpace: "pre-wrap",
|
|
71
|
+
wordWrap: "break-word"
|
|
72
|
+
},
|
|
69
73
|
children: descendantsAsString === "" ? /* @__PURE__ */ jsxRuntime.jsx(Placeholder, {}) : /* @__PURE__ */ jsxRuntime.jsx(Descendants, {
|
|
70
|
-
plugins: (
|
|
74
|
+
plugins: ((_b = definition == null ? void 0 : definition.config) == null ? void 0 : _b.mode) === reactPage.RichTextV2Mode.Inline ? [reactPage.InlineModePlugin()] : [reactPage.BlockPlugin(), reactPage.TypographyPlugin(), reactPage.TextAlignPlugin(), reactPage.InlinePlugin(), index.LinkPlugin()],
|
|
71
75
|
descendants
|
|
72
76
|
})
|
|
73
77
|
});
|
|
@@ -166,17 +170,17 @@ function Descendants({
|
|
|
166
170
|
plugins
|
|
167
171
|
}) {
|
|
168
172
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
169
|
-
children: descendants.map((descendant,
|
|
173
|
+
children: descendants.map((descendant, index2) => {
|
|
170
174
|
if (isText(descendant)) {
|
|
171
175
|
return /* @__PURE__ */ jsxRuntime.jsx(LeafComponent, {
|
|
172
176
|
plugins,
|
|
173
177
|
leaf: descendant
|
|
174
|
-
},
|
|
178
|
+
}, index2);
|
|
175
179
|
}
|
|
176
180
|
return /* @__PURE__ */ jsxRuntime.jsx(ElementComponent, {
|
|
177
181
|
descendant,
|
|
178
182
|
plugins
|
|
179
|
-
},
|
|
183
|
+
}, index2);
|
|
180
184
|
})
|
|
181
185
|
});
|
|
182
186
|
}
|
|
@@ -193,7 +197,6 @@ function isBlock(descendant) {
|
|
|
193
197
|
case reactPage.BlockType.BlockQuote:
|
|
194
198
|
case reactPage.BlockType.Paragraph:
|
|
195
199
|
case reactPage.BlockType.Default:
|
|
196
|
-
case reactPage.BlockType.Text:
|
|
197
200
|
case reactPage.BlockType.OrderedList:
|
|
198
201
|
case reactPage.BlockType.UnorderedList:
|
|
199
202
|
case reactPage.BlockType.ListItem:
|
|
@@ -203,17 +206,19 @@ function isBlock(descendant) {
|
|
|
203
206
|
return false;
|
|
204
207
|
}
|
|
205
208
|
}
|
|
206
|
-
function getTextByDescendant(descendant) {
|
|
207
|
-
var _a, _b, _c;
|
|
209
|
+
function getTextByDescendant(descendant, mode) {
|
|
210
|
+
var _a, _b, _c, _d, _e;
|
|
208
211
|
if (isText(descendant)) {
|
|
209
212
|
return (_a = descendant.text) != null ? _a : "";
|
|
210
213
|
}
|
|
211
214
|
switch (descendant.type) {
|
|
215
|
+
case reactPage.BlockType.Default:
|
|
216
|
+
return mode === reactPage.RichTextV2Mode.Inline ? (_b = descendant.children.map((descendant2) => getTextByDescendant(descendant2, mode)).join("")) != null ? _b : "" : (_c = descendant.children.map((descendant2) => getTextByDescendant(descendant2, mode)).join(descendant.children.every(isBlock) ? "\n" : "")) != null ? _c : "";
|
|
212
217
|
case reactPage.InlineType.Link:
|
|
213
218
|
case reactPage.InlineType.Code:
|
|
214
219
|
case reactPage.InlineType.SubScript:
|
|
215
220
|
case reactPage.InlineType.SuperScript:
|
|
216
|
-
return (
|
|
221
|
+
return (_d = descendant.children.map((descendant2) => getTextByDescendant(descendant2, mode)).join("")) != null ? _d : "";
|
|
217
222
|
case reactPage.BlockType.Heading1:
|
|
218
223
|
case reactPage.BlockType.Heading2:
|
|
219
224
|
case reactPage.BlockType.Heading3:
|
|
@@ -222,19 +227,17 @@ function getTextByDescendant(descendant) {
|
|
|
222
227
|
case reactPage.BlockType.Heading6:
|
|
223
228
|
case reactPage.BlockType.BlockQuote:
|
|
224
229
|
case reactPage.BlockType.Paragraph:
|
|
225
|
-
case reactPage.BlockType.Default:
|
|
226
|
-
case reactPage.BlockType.Text:
|
|
227
230
|
case reactPage.BlockType.OrderedList:
|
|
228
231
|
case reactPage.BlockType.UnorderedList:
|
|
229
232
|
case reactPage.BlockType.ListItem:
|
|
230
233
|
case reactPage.BlockType.ListItemChild:
|
|
231
|
-
return (
|
|
234
|
+
return (_e = descendant.children.map((descendant2) => getTextByDescendant(descendant2, mode)).join(descendant.children.every(isBlock) ? "\n" : "")) != null ? _e : "";
|
|
232
235
|
default:
|
|
233
236
|
return "";
|
|
234
237
|
}
|
|
235
238
|
}
|
|
236
|
-
function getText(descendant) {
|
|
237
|
-
return descendant.map(getTextByDescendant).join("\n");
|
|
239
|
+
function getText(descendant, mode) {
|
|
240
|
+
return descendant.map((node) => getTextByDescendant(node, mode)).join("\n");
|
|
238
241
|
}
|
|
239
242
|
exports.LeafComponent = LeafComponent;
|
|
240
243
|
exports["default"] = ReadOnlyTextV2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadOnlyTextV2.cjs.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } from 'react'\nimport {\n RichTextV2ControlData,\n RichTextV2ControlDefinition,\n RichTextV2Plugin,\n} from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Element, Text } from 'slate'\nimport { InlineType, Block, BlockType } from '../../../../slate'\nimport { ControlValue } from '../control'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\n\ntype Props = {\n text: RichTextV2ControlData\n definition: RichTextV2ControlDefinition | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: { descendants }, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants)\n\n return (\n <div ref={ref}>\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants plugins={definition?.config.plugins ?? []} descendants={descendants} />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps) {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf={descendant} />\n }\n\n return <ElementComponent key={index} descendant={descendant} plugins={plugins} />\n })}\n </>\n )\n}\n\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.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.Text:\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 (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.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.Text:\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","definition","ref","descendantsAsString","getText","_jsx","config","plugins","useStyle","display","width","maxWidth","whiteSpace","opacity","verticalAlign","props","leaf","className","renderLeaf","reduce","renderFn","plugin","control","getLeafValue","undefined","ControlValue","value","initialRenderLeaf","attributes","children","element","renderElement","getElementValue","initialRenderElement","descendant","node","_Fragment","map","index","isText","type","BlockType","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","Paragraph","Default","Text","OrderedList","UnorderedList","ListItem","ListItemChild","InlineType","Link","Code","SubScript","SuperScript","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBMA,MAAAA,iBAAiBC,MAAAA,WAAW,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,CAAzD,EAAuE4B,KAAK,EAA5E,MAAA5B,YAAmF;AAAA,SACvFO,UAAAA,UAAUC;AAAAA,SACVD,UAAAA,UAAUE;AAAAA,SACVF,UAAAA,UAAUG;AAAAA,SACVH,UAAAA,UAAUI;AAAAA,SACVJ,UAAAA,UAAUK;AAAAA,SACVL,UAAAA,UAAUM;AAAAA,SACVN,UAAAA,UAAUO;AAAAA,SACVP,UAAAA,UAAUQ;AAAAA,SACVR,UAAAA,UAAUS;AAAAA,SACVT,UAAAA,UAAUU;AAAAA,SACVV,UAAAA,UAAUW;AAAAA,SACVX,UAAAA,UAAUY;AAAAA,SACVZ,UAAAA,UAAUa;AAAAA,SACVb,UAAUc,UAAAA;AAEXrB,aAAAA,iBAAWL,SACRQ,IAAIH,CAAc2B,gBAAAA,oBAAoB3B,WAAD,CADxC,EAEG4B,KAAK5B,WAAWL,SAASkC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAA9B,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAWG,IAAIwB,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;;"}
|
|
1
|
+
{"version":3,"file":"ReadOnlyTextV2.cjs.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } from 'react'\nimport {\n RichTextV2ControlData,\n RichTextV2ControlDefinition,\n RichTextV2Mode,\n} from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Element, Text } from 'slate'\nimport {\n InlineType,\n Block,\n BlockType,\n BlockPlugin,\n InlineModePlugin,\n InlinePlugin,\n LinkPlugin,\n TextAlignPlugin,\n TypographyPlugin,\n} from '../../../../slate'\nimport { ControlValue } from '../control'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\nimport { RichTextV2Plugin } from '../../../../controls/rich-text-v2/plugin'\n\ntype Props = {\n text: RichTextV2ControlData\n definition: RichTextV2ControlDefinition | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: { descendants }, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants, definition?.config.mode ?? RichTextV2Mode.Block)\n\n return (\n <div\n ref={ref}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n >\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants\n plugins={\n /**\n * TODO: we are manually referencing our default plugins for each mode here because\n * Referencing the real LinkPlugin causes a circular dependency.\n * When circular dependencies calm down we should update the plugin definition to use real plugins,\n * and just use the plugins that are defined by our config.\n */\n // definition?.config?.plugins ,\n definition?.config?.mode === RichTextV2Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]\n }\n descendants={descendants}\n />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps) {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf={descendant} />\n }\n\n return <ElementComponent key={index} descendant={descendant} plugins={plugins} />\n })}\n </>\n )\n}\n\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.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant, mode: RichTextV2Mode): string {\n if (isText(descendant)) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case BlockType.Default:\n return mode === RichTextV2Mode.Inline\n ? descendant.children.map(descendant => getTextByDescendant(descendant, mode)).join('') ??\n ''\n : descendant.children\n .map(descendant => getTextByDescendant(descendant, mode))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return (\n descendant.children.map(descendant => getTextByDescendant(descendant, mode)).join('') ?? ''\n )\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant, mode))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[], mode: RichTextV2Mode): string {\n return descendant.map(node => getTextByDescendant(node, mode)).join('\\n')\n}\n"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","definition","ref","descendantsAsString","getText","config","mode","RichTextV2Mode","Block","position","whiteSpace","wordWrap","_jsx","Inline","InlineModePlugin","BlockPlugin","TypographyPlugin","TextAlignPlugin","InlinePlugin","LinkPlugin","useStyle","display","width","maxWidth","opacity","verticalAlign","plugins","props","leaf","className","renderLeaf","reduce","renderFn","plugin","control","getLeafValue","undefined","ControlValue","value","initialRenderLeaf","attributes","children","element","renderElement","getElementValue","initialRenderElement","descendant","node","_Fragment","map","index","isText","type","BlockType","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","Paragraph","Default","OrderedList","UnorderedList","ListItem","ListItemChild","getTextByDesc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EAEG8D,KAAKtB,WAAWL,SAAS4B,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAAxB,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAA0BxC,MAA8B;AAChEwC,SAAAA,WAAWG,IAAIF,CAAQoB,SAAAA,oBAAoBpB,MAAMzC,IAAP,CAA1C,EAAwD8D,KAAK,IAA7D;AACR;;;"}
|
|
@@ -14,34 +14,32 @@ var __objRest = (source, exclude) => {
|
|
|
14
14
|
return target;
|
|
15
15
|
};
|
|
16
16
|
import { forwardRef } from "react";
|
|
17
|
-
import {
|
|
18
|
-
import "slate";
|
|
19
|
-
import "./state/breakpoints.es.js";
|
|
17
|
+
import { bq as RichTextV2Mode, bI as InlineModePlugin, bG as BlockPlugin, bB as TypographyPlugin, bK as TextAlignPlugin, bP as InlinePlugin, _ as useStyle, Y as BlockType, bM as InlineType } from "./react-page.es.js";
|
|
20
18
|
import "./actions.es.js";
|
|
21
|
-
import "
|
|
22
|
-
import "is-hotkey";
|
|
19
|
+
import "slate";
|
|
23
20
|
import "slate-react";
|
|
24
|
-
import {
|
|
25
|
-
import "./index.es3.js";
|
|
26
|
-
import "@emotion/css";
|
|
21
|
+
import { L as LinkPlugin } from "./index.es5.js";
|
|
27
22
|
import "uuid";
|
|
28
|
-
import {
|
|
23
|
+
import { Q as ControlValue } from "./index.es.js";
|
|
24
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
29
25
|
import "redux";
|
|
30
26
|
import "redux-thunk";
|
|
27
|
+
import "./state/breakpoints.es.js";
|
|
28
|
+
import "zod";
|
|
29
|
+
import "@emotion/css";
|
|
31
30
|
import "@emotion/serialize";
|
|
32
31
|
import "@emotion/utils";
|
|
33
|
-
import "
|
|
34
|
-
import "./text-input.es.js";
|
|
35
|
-
import "scroll-into-view-if-needed";
|
|
36
|
-
import "next/link";
|
|
32
|
+
import "is-hotkey";
|
|
37
33
|
import "use-sync-external-store/shim/with-selector";
|
|
38
34
|
import "next/dynamic";
|
|
35
|
+
import "./text-input.es.js";
|
|
39
36
|
import "./combobox.es.js";
|
|
40
37
|
import "use-sync-external-store/shim";
|
|
41
38
|
import "./types.es.js";
|
|
42
39
|
import "./box-models.es.js";
|
|
43
40
|
import "css-box-model";
|
|
44
41
|
import "color";
|
|
42
|
+
import "scroll-into-view-if-needed";
|
|
45
43
|
import "react-dom";
|
|
46
44
|
import "html-react-parser";
|
|
47
45
|
import "next/head";
|
|
@@ -54,18 +52,24 @@ import "http-proxy";
|
|
|
54
52
|
import "set-cookie-parser";
|
|
55
53
|
import "./constants.es.js";
|
|
56
54
|
import "corporate-ipsum";
|
|
55
|
+
import "next/link";
|
|
57
56
|
const ReadOnlyTextV2 = forwardRef(function ReadOnlyText({
|
|
58
57
|
text: {
|
|
59
58
|
descendants
|
|
60
59
|
},
|
|
61
60
|
definition
|
|
62
61
|
}, ref) {
|
|
63
|
-
var _a;
|
|
64
|
-
const descendantsAsString = getText(descendants);
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const descendantsAsString = getText(descendants, (_a = definition == null ? void 0 : definition.config.mode) != null ? _a : RichTextV2Mode.Block);
|
|
65
64
|
return /* @__PURE__ */ jsx("div", {
|
|
66
65
|
ref,
|
|
66
|
+
style: {
|
|
67
|
+
position: "relative",
|
|
68
|
+
whiteSpace: "pre-wrap",
|
|
69
|
+
wordWrap: "break-word"
|
|
70
|
+
},
|
|
67
71
|
children: descendantsAsString === "" ? /* @__PURE__ */ jsx(Placeholder, {}) : /* @__PURE__ */ jsx(Descendants, {
|
|
68
|
-
plugins: (
|
|
72
|
+
plugins: ((_b = definition == null ? void 0 : definition.config) == null ? void 0 : _b.mode) === RichTextV2Mode.Inline ? [InlineModePlugin()] : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()],
|
|
69
73
|
descendants
|
|
70
74
|
})
|
|
71
75
|
});
|
|
@@ -191,7 +195,6 @@ function isBlock(descendant) {
|
|
|
191
195
|
case BlockType.BlockQuote:
|
|
192
196
|
case BlockType.Paragraph:
|
|
193
197
|
case BlockType.Default:
|
|
194
|
-
case BlockType.Text:
|
|
195
198
|
case BlockType.OrderedList:
|
|
196
199
|
case BlockType.UnorderedList:
|
|
197
200
|
case BlockType.ListItem:
|
|
@@ -201,17 +204,19 @@ function isBlock(descendant) {
|
|
|
201
204
|
return false;
|
|
202
205
|
}
|
|
203
206
|
}
|
|
204
|
-
function getTextByDescendant(descendant) {
|
|
205
|
-
var _a, _b, _c;
|
|
207
|
+
function getTextByDescendant(descendant, mode) {
|
|
208
|
+
var _a, _b, _c, _d, _e;
|
|
206
209
|
if (isText(descendant)) {
|
|
207
210
|
return (_a = descendant.text) != null ? _a : "";
|
|
208
211
|
}
|
|
209
212
|
switch (descendant.type) {
|
|
213
|
+
case BlockType.Default:
|
|
214
|
+
return mode === RichTextV2Mode.Inline ? (_b = descendant.children.map((descendant2) => getTextByDescendant(descendant2, mode)).join("")) != null ? _b : "" : (_c = descendant.children.map((descendant2) => getTextByDescendant(descendant2, mode)).join(descendant.children.every(isBlock) ? "\n" : "")) != null ? _c : "";
|
|
210
215
|
case InlineType.Link:
|
|
211
216
|
case InlineType.Code:
|
|
212
217
|
case InlineType.SubScript:
|
|
213
218
|
case InlineType.SuperScript:
|
|
214
|
-
return (
|
|
219
|
+
return (_d = descendant.children.map((descendant2) => getTextByDescendant(descendant2, mode)).join("")) != null ? _d : "";
|
|
215
220
|
case BlockType.Heading1:
|
|
216
221
|
case BlockType.Heading2:
|
|
217
222
|
case BlockType.Heading3:
|
|
@@ -220,19 +225,17 @@ function getTextByDescendant(descendant) {
|
|
|
220
225
|
case BlockType.Heading6:
|
|
221
226
|
case BlockType.BlockQuote:
|
|
222
227
|
case BlockType.Paragraph:
|
|
223
|
-
case BlockType.Default:
|
|
224
|
-
case BlockType.Text:
|
|
225
228
|
case BlockType.OrderedList:
|
|
226
229
|
case BlockType.UnorderedList:
|
|
227
230
|
case BlockType.ListItem:
|
|
228
231
|
case BlockType.ListItemChild:
|
|
229
|
-
return (
|
|
232
|
+
return (_e = descendant.children.map((descendant2) => getTextByDescendant(descendant2, mode)).join(descendant.children.every(isBlock) ? "\n" : "")) != null ? _e : "";
|
|
230
233
|
default:
|
|
231
234
|
return "";
|
|
232
235
|
}
|
|
233
236
|
}
|
|
234
|
-
function getText(descendant) {
|
|
235
|
-
return descendant.map(getTextByDescendant).join("\n");
|
|
237
|
+
function getText(descendant, mode) {
|
|
238
|
+
return descendant.map((node) => getTextByDescendant(node, mode)).join("\n");
|
|
236
239
|
}
|
|
237
240
|
export { LeafComponent, ReadOnlyTextV2 as default };
|
|
238
241
|
//# sourceMappingURL=ReadOnlyTextV2.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadOnlyTextV2.es.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } from 'react'\nimport {\n RichTextV2ControlData,\n RichTextV2ControlDefinition,\n RichTextV2Plugin,\n} from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Element, Text } from 'slate'\nimport { InlineType, Block, BlockType } from '../../../../slate'\nimport { ControlValue } from '../control'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\n\ntype Props = {\n text: RichTextV2ControlData\n definition: RichTextV2ControlDefinition | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: { descendants }, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants)\n\n return (\n <div ref={ref}>\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants plugins={definition?.config.plugins ?? []} descendants={descendants} />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps) {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf={descendant} />\n }\n\n return <ElementComponent key={index} descendant={descendant} plugins={plugins} />\n })}\n </>\n )\n}\n\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.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.Text:\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 (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.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.Text:\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","definition","ref","descendantsAsString","getText","_jsx","config","plugins","useStyle","display","width","maxWidth","whiteSpace","opacity","verticalAlign","props","leaf","className","renderLeaf","reduce","renderFn","plugin","control","getLeafValue","undefined","value","initialRenderLeaf","attributes","children","element","renderElement","getElementValue","initialRenderElement","descendant","node","_Fragment","map","index","isText","type","BlockType","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","Paragraph","Default","Text","OrderedList","UnorderedList","ListItem","ListItemChild","InlineType","Link","Code","SubScript","SuperScript","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBMA,MAAAA,iBAAiBC,WAAW,sBAChC;AAAA,EAAEC,MAAM;AAAA,IAAEC;AAAAA;AAAAA,EAAeC;AAAAA,GACzBC,KACA;;AACMC,QAAAA,sBAAsBC,QAAQJ,WAAD;AAGjC,6BAAA,OAAA;AAAA,IAAK;AAAA,IACFG,UAAAA,wBAAwB,KACvBE,oBAAC,aAAD,EAAA,IAEAA,oBAAC,aAAD;AAAA,MAAa,SAASJ,+CAAYK,OAAOC,YAAnBN,YAA8B,CAApD;AAAA,MAAwD;AAAA,IAAA,CAAxD;AAAA,EAAA,CALN;AASD,CAfgC;AAmBjC,qBAAqB;AAAA,EAAEF,OAAO;AAAA,GAA2C;AAErE,6BAAA,QAAA;AAAA,IACE,WAAWS,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTC,OAAO;AAAA,MACPC,UAAU;AAAA,MACVC,YAAY;AAAA,MACZC,SAAS;AAAA,MACTC,eAAe;AAAA,IAAA,CANE;AAAA,IASlBf,UAAAA;AAAAA,EAAAA,CAXL;AAcD;AAO6B,uBAAA,IAAkC;AAAlC,eAAEQ;AAAAA;AAAAA,MAAF,IAAcQ,kBAAd,IAAcA;AAAAA,IAAZR;AAAAA;AACH,6BAAA;AAAA,IAAES;AAAAA,KAAyB;AAC7C,+BAAA,QAAA;AAAA,MAAM,WAAWA,KAAKC;AAAAA,MAAYD,UAAAA,KAAKjB,SAAS,KAAK,WAAWiB,KAAKjB;AAAAA,IAAAA,CAA5E;AAAA,EACD;AAED,QAAMmB,aAAaX,QAAQY,OACzB,CAACC,UAAUC,WAAW,CAACN,WAA2B;AAC1C,UAAA;AAAA,MAAEO;AAAAA,MAASJ,YAAAA;AAAAA,QA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ASQ,IAAIH,CAAc2B,gBAAAA,oBAAoB3B,WAAD,CAAzD,EAAuE4B,KAAK,EAA5E,MAAA5B,YAAmF;AAAA,SACvFO,UAAUC;AAAAA,SACVD,UAAUE;AAAAA,SACVF,UAAUG;AAAAA,SACVH,UAAUI;AAAAA,SACVJ,UAAUK;AAAAA,SACVL,UAAUM;AAAAA,SACVN,UAAUO;AAAAA,SACVP,UAAUQ;AAAAA,SACVR,UAAUS;AAAAA,SACVT,UAAUU;AAAAA,SACVV,UAAUW;AAAAA,SACVX,UAAUY;AAAAA,SACVZ,UAAUa;AAAAA,SACVb,UAAUc;AAEXrB,aAAAA,iBAAWL,SACRQ,IAAIH,CAAc2B,gBAAAA,oBAAoB3B,WAAD,CADxC,EAEG4B,KAAK5B,WAAWL,SAASkC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAA9B,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAWG,IAAIwB,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;"}
|
|
1
|
+
{"version":3,"file":"ReadOnlyTextV2.es.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } from 'react'\nimport {\n RichTextV2ControlData,\n RichTextV2ControlDefinition,\n RichTextV2Mode,\n} from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Element, Text } from 'slate'\nimport {\n InlineType,\n Block,\n BlockType,\n BlockPlugin,\n InlineModePlugin,\n InlinePlugin,\n LinkPlugin,\n TextAlignPlugin,\n TypographyPlugin,\n} from '../../../../slate'\nimport { ControlValue } from '../control'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\nimport { RichTextV2Plugin } from '../../../../controls/rich-text-v2/plugin'\n\ntype Props = {\n text: RichTextV2ControlData\n definition: RichTextV2ControlDefinition | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: { descendants }, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants, definition?.config.mode ?? RichTextV2Mode.Block)\n\n return (\n <div\n ref={ref}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n >\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants\n plugins={\n /**\n * TODO: we are manually referencing our default plugins for each mode here because\n * Referencing the real LinkPlugin causes a circular dependency.\n * When circular dependencies calm down we should update the plugin definition to use real plugins,\n * and just use the plugins that are defined by our config.\n */\n // definition?.config?.plugins ,\n definition?.config?.mode === RichTextV2Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]\n }\n descendants={descendants}\n />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps) {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf={descendant} />\n }\n\n return <ElementComponent key={index} descendant={descendant} plugins={plugins} />\n })}\n </>\n )\n}\n\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.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.Default:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant, mode: RichTextV2Mode): string {\n if (isText(descendant)) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case BlockType.Default:\n return mode === RichTextV2Mode.Inline\n ? descendant.children.map(descendant => getTextByDescendant(descendant, mode)).join('') ??\n ''\n : descendant.children\n .map(descendant => getTextByDescendant(descendant, mode))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return (\n descendant.children.map(descendant => getTextByDescendant(descendant, mode)).join('') ?? ''\n )\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.Heading4:\n case BlockType.Heading5:\n case BlockType.Heading6:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant, mode))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[], mode: RichTextV2Mode): string {\n return descendant.map(node => getTextByDescendant(node, mode)).join('\\n')\n}\n"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","definition","ref","descendantsAsString","getText","config","mode","RichTextV2Mode","Block","position","whiteSpace","wordWrap","_jsx","Inline","InlineModePlugin","BlockPlugin","TypographyPlugin","TextAlignPlugin","InlinePlugin","LinkPlugin","useStyle","display","width","maxWidth","opacity","verticalAlign","plugins","props","leaf","className","renderLeaf","reduce","renderFn","plugin","control","getLeafValue","undefined","value","initialRenderLeaf","attributes","children","element","renderElement","getElementValue","initialRenderElement","descendant","node","_Fragment","map","index","isText","type","BlockType","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","Paragraph","Default","OrderedList","UnorderedList","ListItem","ListItemChild","getTextByDescendant","join","every","isBlock","InlineType","Link","Code","SubScript","SuperScript"],"mappings":";;;;;;;;;;;;;;;;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require("slate");
|
|
19
|
+
require("is-hotkey");
|
|
19
20
|
require("use-sync-external-store/shim/with-selector");
|
|
20
21
|
require("next/dynamic");
|
|
21
22
|
require("./text-input.cjs.js");
|
|
@@ -39,6 +40,8 @@ require("set-cookie-parser");
|
|
|
39
40
|
require("./constants.cjs.js");
|
|
40
41
|
require("uuid");
|
|
41
42
|
require("corporate-ipsum");
|
|
43
|
+
require("slate-react");
|
|
44
|
+
require("next/link");
|
|
42
45
|
require("./useMediaQuery.cjs.js");
|
|
43
46
|
require("next/image");
|
|
44
47
|
require("./useIsomorphicLayoutEffect.cjs.js");
|
package/dist/Root.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Root.cjs.js","sources":["../src/components/builtin/Root/components/Placeholder/index.tsx","../src/runtimes/react/use-global-style.ts","../src/components/builtin/Root/Root.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\n\nexport default forwardRef<HTMLDivElement>(function Placeholder(_props, ref) {\n return (\n <div\n ref={ref}\n className={useStyle({\n width: '100%',\n background: 'rgba(161, 168, 194, 0.18)',\n height: 80,\n padding: 8,\n })}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"100%\"\n height=\"100%\"\n style={{ overflow: 'visible' }}\n >\n <rect\n x={0}\n y={0}\n width=\"100%\"\n height=\"100%\"\n strokeWidth={2}\n strokeDasharray=\"4 2\"\n fill=\"none\"\n stroke=\"rgba(161, 168, 194, 0.40)\"\n rx=\"4\"\n ry=\"4\"\n />\n </svg>\n </div>\n )\n})\n","import * as React from 'react'\nimport { useRef } from 'react'\nimport { cache, injectGlobal } from '@emotion/css'\nimport { CSSInterpolation, serializeStyles } from '@emotion/serialize'\nimport { StyleSheet } from '@emotion/sheet'\nimport { insertStyles } from '@emotion/utils'\n\nconst isServer = typeof window === 'undefined'\nconst useInsertionEffectSpecifier = 'useInsertionEffect'\nconst useInsertionEffect = React[useInsertionEffectSpecifier] ?? React.useLayoutEffect\n\nexport function useGlobalStyle(...args: CSSInterpolation[]): void {\n if (isServer) return injectGlobal(args)\n\n const serialized = serializeStyles(args, cache.registered)\n const sheetRef = useRef<[StyleSheet, boolean]>()\n\n // Hydration\n useInsertionEffect(() => {\n const key = `${cache.key}-global`\n\n const cacheSheet = cache.sheet as StyleSheet\n const sheet = new (cacheSheet.constructor as typeof StyleSheet)({\n key,\n nonce: cacheSheet.nonce,\n container: cacheSheet.container,\n speedy: cacheSheet.isSpeedy,\n })\n\n const node = document.querySelector<HTMLStyleElement>(\n `style[data-emotion=\"${key} ${serialized.name}\"]`,\n )\n\n if (cache.sheet.tags.length > 0) {\n sheet.before = cache.sheet.tags[0]\n }\n\n let rehydrating = false\n\n if (node != null) {\n rehydrating = true\n node.setAttribute('data-emotion', key)\n sheet.hydrate([node])\n }\n\n sheetRef.current = [sheet, rehydrating]\n\n return () => {\n sheet.flush()\n }\n })\n\n // Insertion\n useInsertionEffect(() => {\n const [sheet, rehydrating] = sheetRef.current ?? []\n\n if (sheet == null || rehydrating == null) return\n\n if (rehydrating) {\n sheetRef.current = [sheet, false]\n\n return\n }\n\n if (serialized.next != null) {\n insertStyles(cache, serialized.next, true)\n }\n\n if (sheet.tags.length > 0) {\n const element = sheet.tags[sheet.tags.length - 1].nextElementSibling\n\n sheet.before = element\n\n sheet.flush()\n }\n\n cache.insert('', serialized, sheet, false)\n })\n}\n","import { normalize } from 'polished'\nimport { forwardRef, Ref } from 'react'\n\nimport Placeholder from './components/Placeholder'\nimport type {\n GridValue,\n BackgroundsValue,\n GapXValue,\n GapYValue,\n} from '../../../prop-controllers/descriptors'\nimport { Element } from '../../../runtimes/react'\nimport BackgroundsContainer from '../../shared/BackgroundsContainer'\nimport { useGlobalStyle } from '../../../runtimes/react/use-global-style'\nimport { GridItem } from '../../shared/grid-item'\nimport { useStyle } from '../../../runtimes/react/use-style'\n\ntype Props = {\n children?: GridValue\n backgrounds?: BackgroundsValue\n rowGap?: GapYValue\n columnGap?: GapXValue\n}\n\nconst Root = forwardRef(function Page(\n { children, backgrounds, rowGap, columnGap }: Props,\n ref: Ref<HTMLDivElement>,\n) {\n useGlobalStyle({\n html: {\n boxSizing: 'border-box',\n },\n '*, *::before, *::after': {\n boxSizing: 'inherit',\n },\n })\n\n useGlobalStyle(normalize())\n\n return (\n <BackgroundsContainer ref={ref} style={{ background: 'white' }} backgrounds={backgrounds}>\n <div className={useStyle({ display: 'flex', flexWrap: 'wrap', width: '100%' })}>\n {children && children.elements.length > 0 ? (\n children.elements.map((child, index) => (\n <GridItem\n key={child.key}\n grid={children.columns}\n index={index}\n columnGap={columnGap}\n rowGap={rowGap}\n >\n <Element element={child} />\n </GridItem>\n ))\n ) : (\n <Placeholder />\n )}\n </div>\n </BackgroundsContainer>\n )\n})\n\nexport default Root\n"],"names":["forwardRef","_props","ref","useStyle","width","background","height","padding","overflow","React","injectGlobal","serializeStyles","cache","useRef","insertStyles","Root","children","backgrounds","rowGap","columnGap","html","boxSizing","useGlobalStyle","normalize","BackgroundsContainer","display","flexWrap","elements","length","map","child","index","GridItem","columns","Element","key","_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Root.cjs.js","sources":["../src/components/builtin/Root/components/Placeholder/index.tsx","../src/runtimes/react/use-global-style.ts","../src/components/builtin/Root/Root.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\n\nexport default forwardRef<HTMLDivElement>(function Placeholder(_props, ref) {\n return (\n <div\n ref={ref}\n className={useStyle({\n width: '100%',\n background: 'rgba(161, 168, 194, 0.18)',\n height: 80,\n padding: 8,\n })}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"100%\"\n height=\"100%\"\n style={{ overflow: 'visible' }}\n >\n <rect\n x={0}\n y={0}\n width=\"100%\"\n height=\"100%\"\n strokeWidth={2}\n strokeDasharray=\"4 2\"\n fill=\"none\"\n stroke=\"rgba(161, 168, 194, 0.40)\"\n rx=\"4\"\n ry=\"4\"\n />\n </svg>\n </div>\n )\n})\n","import * as React from 'react'\nimport { useRef } from 'react'\nimport { cache, injectGlobal } from '@emotion/css'\nimport { CSSInterpolation, serializeStyles } from '@emotion/serialize'\nimport { StyleSheet } from '@emotion/sheet'\nimport { insertStyles } from '@emotion/utils'\n\nconst isServer = typeof window === 'undefined'\nconst useInsertionEffectSpecifier = 'useInsertionEffect'\nconst useInsertionEffect = React[useInsertionEffectSpecifier] ?? React.useLayoutEffect\n\nexport function useGlobalStyle(...args: CSSInterpolation[]): void {\n if (isServer) return injectGlobal(args)\n\n const serialized = serializeStyles(args, cache.registered)\n const sheetRef = useRef<[StyleSheet, boolean]>()\n\n // Hydration\n useInsertionEffect(() => {\n const key = `${cache.key}-global`\n\n const cacheSheet = cache.sheet as StyleSheet\n const sheet = new (cacheSheet.constructor as typeof StyleSheet)({\n key,\n nonce: cacheSheet.nonce,\n container: cacheSheet.container,\n speedy: cacheSheet.isSpeedy,\n })\n\n const node = document.querySelector<HTMLStyleElement>(\n `style[data-emotion=\"${key} ${serialized.name}\"]`,\n )\n\n if (cache.sheet.tags.length > 0) {\n sheet.before = cache.sheet.tags[0]\n }\n\n let rehydrating = false\n\n if (node != null) {\n rehydrating = true\n node.setAttribute('data-emotion', key)\n sheet.hydrate([node])\n }\n\n sheetRef.current = [sheet, rehydrating]\n\n return () => {\n sheet.flush()\n }\n })\n\n // Insertion\n useInsertionEffect(() => {\n const [sheet, rehydrating] = sheetRef.current ?? []\n\n if (sheet == null || rehydrating == null) return\n\n if (rehydrating) {\n sheetRef.current = [sheet, false]\n\n return\n }\n\n if (serialized.next != null) {\n insertStyles(cache, serialized.next, true)\n }\n\n if (sheet.tags.length > 0) {\n const element = sheet.tags[sheet.tags.length - 1].nextElementSibling\n\n sheet.before = element\n\n sheet.flush()\n }\n\n cache.insert('', serialized, sheet, false)\n })\n}\n","import { normalize } from 'polished'\nimport { forwardRef, Ref } from 'react'\n\nimport Placeholder from './components/Placeholder'\nimport type {\n GridValue,\n BackgroundsValue,\n GapXValue,\n GapYValue,\n} from '../../../prop-controllers/descriptors'\nimport { Element } from '../../../runtimes/react'\nimport BackgroundsContainer from '../../shared/BackgroundsContainer'\nimport { useGlobalStyle } from '../../../runtimes/react/use-global-style'\nimport { GridItem } from '../../shared/grid-item'\nimport { useStyle } from '../../../runtimes/react/use-style'\n\ntype Props = {\n children?: GridValue\n backgrounds?: BackgroundsValue\n rowGap?: GapYValue\n columnGap?: GapXValue\n}\n\nconst Root = forwardRef(function Page(\n { children, backgrounds, rowGap, columnGap }: Props,\n ref: Ref<HTMLDivElement>,\n) {\n useGlobalStyle({\n html: {\n boxSizing: 'border-box',\n },\n '*, *::before, *::after': {\n boxSizing: 'inherit',\n },\n })\n\n useGlobalStyle(normalize())\n\n return (\n <BackgroundsContainer ref={ref} style={{ background: 'white' }} backgrounds={backgrounds}>\n <div className={useStyle({ display: 'flex', flexWrap: 'wrap', width: '100%' })}>\n {children && children.elements.length > 0 ? (\n children.elements.map((child, index) => (\n <GridItem\n key={child.key}\n grid={children.columns}\n index={index}\n columnGap={columnGap}\n rowGap={rowGap}\n >\n <Element element={child} />\n </GridItem>\n ))\n ) : (\n <Placeholder />\n )}\n </div>\n </BackgroundsContainer>\n )\n})\n\nexport default Root\n"],"names":["forwardRef","_props","ref","useStyle","width","background","height","padding","overflow","React","injectGlobal","serializeStyles","cache","useRef","insertStyles","Root","children","backgrounds","rowGap","columnGap","html","boxSizing","useGlobalStyle","normalize","BackgroundsContainer","display","flexWrap","elements","length","map","child","index","GridItem","columns","Element","key","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAeA,cAAAA,MAAAA,WAA2B,sBAAqBC,QAAQC,KAAK;AAExE,wCAAA,OAAA;AAAA,IACE;AAAA,IACA,WAAWC,UAAAA,SAAS;AAAA,MAClBC,OAAO;AAAA,MACPC,Y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QAEE,MAAMhB,SAASiB;AAAAA,QAAAA,OACfF;AAAAA,QACA;AAAA,QACA;AAAA,QALF,yCAOGG,cAAD;AAAA,UAAS,SAASJ;AAAAA,QAAAA,CAAlB;AAAA,MAAA,GANKA,MAAMK,GADb,CADF,IAYCC,2BAAAA,IAAA,aAAD,CAAA,CAAA;AAAA,IAAA,CAdJ;AAAA,EAAA,CAFJ;AAqBD,CApCsB;;"}
|
package/dist/Root.es.js
CHANGED
|
@@ -2,7 +2,7 @@ var _a;
|
|
|
2
2
|
import { normalize } from "polished";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { forwardRef, useRef } from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { _ as useStyle } from "./react-page.es.js";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import { E as Element } from "./index.es.js";
|
|
8
8
|
import { B as BackgroundsContainer, G as GridItem } from "./index.es2.js";
|
|
@@ -15,6 +15,7 @@ import "./actions.es.js";
|
|
|
15
15
|
import "zod";
|
|
16
16
|
import "./state/breakpoints.es.js";
|
|
17
17
|
import "slate";
|
|
18
|
+
import "is-hotkey";
|
|
18
19
|
import "use-sync-external-store/shim/with-selector";
|
|
19
20
|
import "next/dynamic";
|
|
20
21
|
import "./text-input.es.js";
|
|
@@ -38,6 +39,8 @@ import "set-cookie-parser";
|
|
|
38
39
|
import "./constants.es.js";
|
|
39
40
|
import "uuid";
|
|
40
41
|
import "corporate-ipsum";
|
|
42
|
+
import "slate-react";
|
|
43
|
+
import "next/link";
|
|
41
44
|
import "./useMediaQuery.es.js";
|
|
42
45
|
import "next/image";
|
|
43
46
|
import "./useIsomorphicLayoutEffect.es.js";
|
package/dist/Root.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Root.es.js","sources":["../src/components/builtin/Root/components/Placeholder/index.tsx","../src/runtimes/react/use-global-style.ts","../src/components/builtin/Root/Root.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\n\nexport default forwardRef<HTMLDivElement>(function Placeholder(_props, ref) {\n return (\n <div\n ref={ref}\n className={useStyle({\n width: '100%',\n background: 'rgba(161, 168, 194, 0.18)',\n height: 80,\n padding: 8,\n })}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"100%\"\n height=\"100%\"\n style={{ overflow: 'visible' }}\n >\n <rect\n x={0}\n y={0}\n width=\"100%\"\n height=\"100%\"\n strokeWidth={2}\n strokeDasharray=\"4 2\"\n fill=\"none\"\n stroke=\"rgba(161, 168, 194, 0.40)\"\n rx=\"4\"\n ry=\"4\"\n />\n </svg>\n </div>\n )\n})\n","import * as React from 'react'\nimport { useRef } from 'react'\nimport { cache, injectGlobal } from '@emotion/css'\nimport { CSSInterpolation, serializeStyles } from '@emotion/serialize'\nimport { StyleSheet } from '@emotion/sheet'\nimport { insertStyles } from '@emotion/utils'\n\nconst isServer = typeof window === 'undefined'\nconst useInsertionEffectSpecifier = 'useInsertionEffect'\nconst useInsertionEffect = React[useInsertionEffectSpecifier] ?? React.useLayoutEffect\n\nexport function useGlobalStyle(...args: CSSInterpolation[]): void {\n if (isServer) return injectGlobal(args)\n\n const serialized = serializeStyles(args, cache.registered)\n const sheetRef = useRef<[StyleSheet, boolean]>()\n\n // Hydration\n useInsertionEffect(() => {\n const key = `${cache.key}-global`\n\n const cacheSheet = cache.sheet as StyleSheet\n const sheet = new (cacheSheet.constructor as typeof StyleSheet)({\n key,\n nonce: cacheSheet.nonce,\n container: cacheSheet.container,\n speedy: cacheSheet.isSpeedy,\n })\n\n const node = document.querySelector<HTMLStyleElement>(\n `style[data-emotion=\"${key} ${serialized.name}\"]`,\n )\n\n if (cache.sheet.tags.length > 0) {\n sheet.before = cache.sheet.tags[0]\n }\n\n let rehydrating = false\n\n if (node != null) {\n rehydrating = true\n node.setAttribute('data-emotion', key)\n sheet.hydrate([node])\n }\n\n sheetRef.current = [sheet, rehydrating]\n\n return () => {\n sheet.flush()\n }\n })\n\n // Insertion\n useInsertionEffect(() => {\n const [sheet, rehydrating] = sheetRef.current ?? []\n\n if (sheet == null || rehydrating == null) return\n\n if (rehydrating) {\n sheetRef.current = [sheet, false]\n\n return\n }\n\n if (serialized.next != null) {\n insertStyles(cache, serialized.next, true)\n }\n\n if (sheet.tags.length > 0) {\n const element = sheet.tags[sheet.tags.length - 1].nextElementSibling\n\n sheet.before = element\n\n sheet.flush()\n }\n\n cache.insert('', serialized, sheet, false)\n })\n}\n","import { normalize } from 'polished'\nimport { forwardRef, Ref } from 'react'\n\nimport Placeholder from './components/Placeholder'\nimport type {\n GridValue,\n BackgroundsValue,\n GapXValue,\n GapYValue,\n} from '../../../prop-controllers/descriptors'\nimport { Element } from '../../../runtimes/react'\nimport BackgroundsContainer from '../../shared/BackgroundsContainer'\nimport { useGlobalStyle } from '../../../runtimes/react/use-global-style'\nimport { GridItem } from '../../shared/grid-item'\nimport { useStyle } from '../../../runtimes/react/use-style'\n\ntype Props = {\n children?: GridValue\n backgrounds?: BackgroundsValue\n rowGap?: GapYValue\n columnGap?: GapXValue\n}\n\nconst Root = forwardRef(function Page(\n { children, backgrounds, rowGap, columnGap }: Props,\n ref: Ref<HTMLDivElement>,\n) {\n useGlobalStyle({\n html: {\n boxSizing: 'border-box',\n },\n '*, *::before, *::after': {\n boxSizing: 'inherit',\n },\n })\n\n useGlobalStyle(normalize())\n\n return (\n <BackgroundsContainer ref={ref} style={{ background: 'white' }} backgrounds={backgrounds}>\n <div className={useStyle({ display: 'flex', flexWrap: 'wrap', width: '100%' })}>\n {children && children.elements.length > 0 ? (\n children.elements.map((child, index) => (\n <GridItem\n key={child.key}\n grid={children.columns}\n index={index}\n columnGap={columnGap}\n rowGap={rowGap}\n >\n <Element element={child} />\n </GridItem>\n ))\n ) : (\n <Placeholder />\n )}\n </div>\n </BackgroundsContainer>\n )\n})\n\nexport default Root\n"],"names":["forwardRef","_props","ref","useStyle","width","background","height","padding","overflow","Root","children","backgrounds","rowGap","columnGap","html","boxSizing","useGlobalStyle","normalize","display","flexWrap","elements","length","map","child","index","columns","key","_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Root.es.js","sources":["../src/components/builtin/Root/components/Placeholder/index.tsx","../src/runtimes/react/use-global-style.ts","../src/components/builtin/Root/Root.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\n\nexport default forwardRef<HTMLDivElement>(function Placeholder(_props, ref) {\n return (\n <div\n ref={ref}\n className={useStyle({\n width: '100%',\n background: 'rgba(161, 168, 194, 0.18)',\n height: 80,\n padding: 8,\n })}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"100%\"\n height=\"100%\"\n style={{ overflow: 'visible' }}\n >\n <rect\n x={0}\n y={0}\n width=\"100%\"\n height=\"100%\"\n strokeWidth={2}\n strokeDasharray=\"4 2\"\n fill=\"none\"\n stroke=\"rgba(161, 168, 194, 0.40)\"\n rx=\"4\"\n ry=\"4\"\n />\n </svg>\n </div>\n )\n})\n","import * as React from 'react'\nimport { useRef } from 'react'\nimport { cache, injectGlobal } from '@emotion/css'\nimport { CSSInterpolation, serializeStyles } from '@emotion/serialize'\nimport { StyleSheet } from '@emotion/sheet'\nimport { insertStyles } from '@emotion/utils'\n\nconst isServer = typeof window === 'undefined'\nconst useInsertionEffectSpecifier = 'useInsertionEffect'\nconst useInsertionEffect = React[useInsertionEffectSpecifier] ?? React.useLayoutEffect\n\nexport function useGlobalStyle(...args: CSSInterpolation[]): void {\n if (isServer) return injectGlobal(args)\n\n const serialized = serializeStyles(args, cache.registered)\n const sheetRef = useRef<[StyleSheet, boolean]>()\n\n // Hydration\n useInsertionEffect(() => {\n const key = `${cache.key}-global`\n\n const cacheSheet = cache.sheet as StyleSheet\n const sheet = new (cacheSheet.constructor as typeof StyleSheet)({\n key,\n nonce: cacheSheet.nonce,\n container: cacheSheet.container,\n speedy: cacheSheet.isSpeedy,\n })\n\n const node = document.querySelector<HTMLStyleElement>(\n `style[data-emotion=\"${key} ${serialized.name}\"]`,\n )\n\n if (cache.sheet.tags.length > 0) {\n sheet.before = cache.sheet.tags[0]\n }\n\n let rehydrating = false\n\n if (node != null) {\n rehydrating = true\n node.setAttribute('data-emotion', key)\n sheet.hydrate([node])\n }\n\n sheetRef.current = [sheet, rehydrating]\n\n return () => {\n sheet.flush()\n }\n })\n\n // Insertion\n useInsertionEffect(() => {\n const [sheet, rehydrating] = sheetRef.current ?? []\n\n if (sheet == null || rehydrating == null) return\n\n if (rehydrating) {\n sheetRef.current = [sheet, false]\n\n return\n }\n\n if (serialized.next != null) {\n insertStyles(cache, serialized.next, true)\n }\n\n if (sheet.tags.length > 0) {\n const element = sheet.tags[sheet.tags.length - 1].nextElementSibling\n\n sheet.before = element\n\n sheet.flush()\n }\n\n cache.insert('', serialized, sheet, false)\n })\n}\n","import { normalize } from 'polished'\nimport { forwardRef, Ref } from 'react'\n\nimport Placeholder from './components/Placeholder'\nimport type {\n GridValue,\n BackgroundsValue,\n GapXValue,\n GapYValue,\n} from '../../../prop-controllers/descriptors'\nimport { Element } from '../../../runtimes/react'\nimport BackgroundsContainer from '../../shared/BackgroundsContainer'\nimport { useGlobalStyle } from '../../../runtimes/react/use-global-style'\nimport { GridItem } from '../../shared/grid-item'\nimport { useStyle } from '../../../runtimes/react/use-style'\n\ntype Props = {\n children?: GridValue\n backgrounds?: BackgroundsValue\n rowGap?: GapYValue\n columnGap?: GapXValue\n}\n\nconst Root = forwardRef(function Page(\n { children, backgrounds, rowGap, columnGap }: Props,\n ref: Ref<HTMLDivElement>,\n) {\n useGlobalStyle({\n html: {\n boxSizing: 'border-box',\n },\n '*, *::before, *::after': {\n boxSizing: 'inherit',\n },\n })\n\n useGlobalStyle(normalize())\n\n return (\n <BackgroundsContainer ref={ref} style={{ background: 'white' }} backgrounds={backgrounds}>\n <div className={useStyle({ display: 'flex', flexWrap: 'wrap', width: '100%' })}>\n {children && children.elements.length > 0 ? (\n children.elements.map((child, index) => (\n <GridItem\n key={child.key}\n grid={children.columns}\n index={index}\n columnGap={columnGap}\n rowGap={rowGap}\n >\n <Element element={child} />\n </GridItem>\n ))\n ) : (\n <Placeholder />\n )}\n </div>\n </BackgroundsContainer>\n )\n})\n\nexport default Root\n"],"names":["forwardRef","_props","ref","useStyle","width","background","height","padding","overflow","Root","children","backgrounds","rowGap","columnGap","html","boxSizing","useGlobalStyle","normalize","display","flexWrap","elements","length","map","child","index","columns","key","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAeA,cAAAA,WAA2B,sBAAqBC,QAAQC,KAAK;AAExE,6BAAA,OAAA;AAAA,IACE;AAAA,IACA,WAAWC,SAAS;AAAA,MAClBC,OAAO;AAAA,MACPC,YAAY;AAAA,MACZC,QAAQ;AAAA,MACRC,SAAS;AAAA,IAAA,CAJQ;AAAA,IAOnB,8BAAA,OAAA;AAAA,MACE,OAAM;AAAA,MACN,OAAM;AAAA,MACN,QAAO;AAAA,MACP,OAAO;AAAA,QAAEC,UAAU;AAAA,MAJrB;AAAA,MAME,8BAAA,QAAA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,QACH,OAAM;AAAA,QACN,QAAO;AAAA,QACP,aAAa;AAAA,QACb,iBAAgB;AAAA,QAChB,MAAK;AAAA,QACL,QAAO;AAAA,QACP,IAAG;AAAA,QACH,IAAG;AAAA,MAAA,CAVL;AAAA,IAAA,CANF;AAAA,EAAA,CAVJ;AA+BD,CAhCwB;ACIzB,MAAM,WAAW,OAAO,WAAW;AACnC,MAAM,8BAA8B;AACpC,MAAM,qBAAqB,YAAM,iCAAN,YAAsC,MAAM;AAEhE,2BAA2B,MAAgC;AAC5D,MAAA;AAAU,WAAO,aAAa,IAAI;AAEtC,QAAM,aAAa,gBAAgB,MAAM,MAAM,UAAU;AACzD,QAAM,WAAW;AAGjB,qBAAmB,MAAM;AACjB,UAAA,MAAM,GAAG,MAAM;A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