@makeswift/runtime 0.9.0 → 0.9.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 +15 -14
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +10 -9
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +12 -11
- package/dist/Button.cjs.js.map +1 -1
- package/dist/Button.es.js +10 -9
- package/dist/Button.es.js.map +1 -1
- package/dist/Carousel.cjs.js +26 -25
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +5 -4
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +15 -14
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +7 -6
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +12 -11
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +10 -9
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +4 -29
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +3 -28
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +51 -50
- package/dist/Form.cjs.js.map +1 -1
- package/dist/Form.es.js +7 -6
- package/dist/Form.es.js.map +1 -1
- package/dist/Image.cjs.js +8 -7
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +7 -6
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +4 -3
- package/dist/LiveProvider.cjs.js.map +1 -1
- package/dist/LiveProvider.es.js +6 -5
- package/dist/LiveProvider.es.js.map +1 -1
- package/dist/Navigation.cjs.js +26 -25
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +5 -4
- package/dist/Navigation.es.js.map +1 -1
- package/dist/PreviewProvider.cjs.js +6 -5
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +6 -5
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +14 -13
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +9 -8
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +11 -10
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +7 -6
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +7 -6
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +5 -4
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +14 -13
- package/dist/SocialLinks.cjs.js.map +1 -1
- package/dist/SocialLinks.es.js +10 -9
- package/dist/SocialLinks.es.js.map +1 -1
- package/dist/Text.cjs.js +4 -3
- package/dist/Text.cjs.js.map +1 -1
- package/dist/Text.es.js +5 -4
- package/dist/Text.es.js.map +1 -1
- package/dist/Video.cjs.js +4 -29
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +3 -28
- package/dist/Video.es.js.map +1 -1
- package/dist/builder.cjs.js +5 -0
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +5 -0
- package/dist/builder.es.js.map +1 -1
- package/dist/components.cjs.js +9 -8
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +9 -8
- package/dist/components.es.js.map +1 -1
- package/dist/control-serialization.cjs.js +88 -9
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +89 -10
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/controls.cjs.js +10 -0
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +6 -1
- package/dist/controls.es.js.map +1 -1
- package/dist/deepEqual.cjs.js +40 -0
- package/dist/deepEqual.cjs.js.map +1 -0
- package/dist/deepEqual.es.js +39 -0
- package/dist/deepEqual.es.js.map +1 -0
- package/dist/index.cjs.js +62 -91
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs10.js +8 -7
- package/dist/index.cjs10.js.map +1 -1
- package/dist/index.cjs2.js +13 -13
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs4.js +2 -1
- package/dist/index.cjs4.js.map +1 -1
- package/dist/index.cjs8.js +4 -3
- package/dist/index.cjs8.js.map +1 -1
- package/dist/index.cjs9.js +69 -105
- package/dist/index.cjs9.js.map +1 -1
- package/dist/index.es.js +47 -75
- package/dist/index.es.js.map +1 -1
- package/dist/index.es10.js +5 -4
- package/dist/index.es10.js.map +1 -1
- package/dist/index.es2.js +2 -2
- package/dist/index.es3.js +1 -1
- package/dist/index.es4.js +2 -1
- package/dist/index.es4.js.map +1 -1
- package/dist/index.es6.js +1 -1
- package/dist/index.es8.js +4 -3
- package/dist/index.es8.js.map +1 -1
- package/dist/index.es9.js +71 -107
- package/dist/index.es9.js.map +1 -1
- package/dist/leaf.cjs.js +1 -1
- package/dist/leaf.cjs.js.map +1 -1
- package/dist/leaf.es.js +2 -2
- package/dist/main.cjs.js +5 -0
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +5 -0
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +4 -3
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +5 -4
- package/dist/next.es.js.map +1 -1
- package/dist/prop-controllers.cjs.js +5 -0
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +5 -0
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react-page.cjs.js +376 -203
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +349 -204
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +4 -3
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +4 -3
- package/dist/react.es.js.map +1 -1
- package/dist/slate.cjs.js +88 -4
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +89 -5
- package/dist/slate.es.js.map +1 -1
- package/dist/types/src/builder/serialization/control-serialization.d.ts +3 -3
- package/dist/types/src/builder/serialization/control-serialization.d.ts.map +1 -1
- package/dist/types/src/builder/serialization/controls/rich-text-v2.d.ts +2 -2
- package/dist/types/src/builder/serialization/controls/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/builder/serialization/controls/style-v2.d.ts +5 -0
- package/dist/types/src/builder/serialization/controls/style-v2.d.ts.map +1 -0
- package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
- package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
- package/dist/types/src/components/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/types/src/components/hooks/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/dist/types/src/controls/control.d.ts +3 -2
- package/dist/types/src/controls/control.d.ts.map +1 -1
- package/dist/types/src/controls/index.d.ts +1 -0
- package/dist/types/src/controls/index.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +8 -3
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/controls/style-v2.d.ts +55 -0
- package/dist/types/src/controls/style-v2.d.ts.map +1 -0
- package/dist/types/src/prop-controllers/descriptors.d.ts +4 -3
- package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/instances.d.ts +2 -2
- package/dist/types/src/prop-controllers/instances.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/control.d.ts +3 -2
- package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts +2 -1
- 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/rich-text-v2.d.ts +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/style-v2.d.ts +4 -0
- package/dist/types/src/runtimes/react/controls/style-v2.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/index.d.ts +3 -0
- package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/InlineModePlugin/index.d.ts +1 -0
- package/dist/types/src/slate/InlineModePlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts +9 -0
- package/dist/types/src/slate/TextAlignPlugin/index.d.ts.map +1 -0
- package/dist/types/src/slate/index.d.ts +1 -0
- package/dist/types/src/slate/index.d.ts.map +1 -1
- package/dist/types/src/slate/types.d.ts +18 -0
- package/dist/types/src/slate/types.d.ts.map +1 -1
- package/dist/useMediaQuery.es.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadOnlyText.cjs.js","sources":["../src/components/builtin/Text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\n\nimport type { ElementIDValue, RichTextValue } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\nimport { useTypographyClassName } from './components'\nimport useEnhancedTypography from './components/Leaf/leaf'\nimport { Inline, InlineType, Block, BlockType } from '../../../slate'\nimport { richTextDTOtoDAO } from '../../../controls'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Inline\n}\n\nfunction InlineElement({ descendant }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n 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.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.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","descendantsAsString","getText","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBMA,MAAAA,eAAeC,MAAAA,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACMC,QAAAA,cAAcJ,QAAQ,OAAO,CAAA,IAAKK,UAAAA,iBAAiBL,IAAD;AAClDM,QAAAA,sBAAsBC,QAAQH,WAAD;AAGjC,wCAAA,OAAA;AAAA,IAAK;AAAA,IAAU;AAAA,IAAQ,WAAWI,IAAAA,GAAGP,OAAOC,MAAR;AAAA,IACjCI,UAAAA,wBAAwB,KAAKG,2BAAA,IAAC,aAAD,EAAA,IAAkBA,2BAAA,IAAC,aAAD;AAAA,MAAa;AAAA,IAAA,CAAb;AAAA,EAAA,CAFpD;AAKD,CAZ8B;AAgB/B,qBAAqB;AAAA,EAAET,OAAO;AAAA,GAA2C;AAErE,wCAAA,QAAA;AAAA,IACE,WAAWU,KAAAA,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTV,OAAO;AAAA,MACPW,UAAU;AAAA,MACVC,YAAY;AAAA,MACZC,SAAS;AAAA,MACTC,eAAe;AAAA,IAAA,CANE;AAAA,IASlBf,UAAAA;AAAAA,EAAAA,CAXL;AAcD;AAM2B,qBAAA;AAAA,EAAEgB;AAAAA,GAAyB;AAC/CC,QAAAA,qBAAqBC,KAAAA,sBAAsBF,WAAWG,UAAZ;AAC1CC,QAAAA,sBAAsBC,4BAAuBJ,kBAAD;AAGhD,wCAAA,QAAA;AAAA,IAAM,WAAWG;AAAAA,IACdJ,UAAAA,WAAWhB,SAAS,KAAK,WAAWgB,WAAWhB;AAAAA,EAAAA,CAFpD;AAKD;AAMD,uBAAuB;AAAA,EAAEgB;AAAAA,GAA2B;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AAA,UAAUa;AAAAA,SACVb,UAAUc,UAAAA;AACN,aAAA;AAAA;AAGA,aAAA;AAAA;AAEZ;AAED,6BAA6BtC,YAAgC;;AACvD,MAAA,UAAUA,YAAY;AACxB,WAAOA,iBAAWhB,SAAXgB,YAAmB;AAAA,EAC3B;AAEOA,UAAAA,WAAWQ;AAAAA,SACZC,UAAAA,WAAWK;AAAAA,SACXL,UAAAA,WAAWC;AAAAA,SACXD,UAAAA,WAAWI;AAAAA,SACXJ,UAAWG,WAAAA;AACPZ,aAAAA,iBAAWW,SAAS8B,IAAIzC,CAAc4C,gBAAAA,oBAAoB5C,WAAD,CAAzD,EAAuE6C,KAAK,EAA5E,MAAA7C,YAAmF;AAAA,SACvFwB,UAAAA,UAAUG;AAAAA,SACVH,UAAAA,UAAUI;AAAAA,SACVJ,UAAAA,UAAUK;AAAAA,SACVL,UAAAA,UAAUS;AAAAA,SACVT,UAAAA,UAAUE;AAAAA,SACVF,UAAAA,UAAUU;AAAAA,SACVV,UAAAA,UAAUY;AAAAA,SACVZ,UAAAA,UAAUa;AAAAA,SACVb,UAAUc,UAAAA;AAEXtC,aAAAA,iBAAWW,SACR8B,IAAIzC,CAAc4C,gBAAAA,oBAAoB5C,WAAD,CADxC,EAEG6C,KAAK7C,WAAWW,SAASmC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAA/C,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAWyC,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;;;"}
|
|
1
|
+
{"version":3,"file":"ReadOnlyText.cjs.js","sources":["../src/components/builtin/Text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\n\nimport type { ElementIDValue, RichTextValue } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\nimport { useTypographyClassName } from './components'\nimport useEnhancedTypography from './components/Leaf/leaf'\nimport { Inline, InlineType, Block, BlockType } from '../../../slate'\nimport { richTextDTOtoDAO } from '../../../controls'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Inline\n}\n\nfunction InlineElement({ descendant }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n 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.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.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","descendantsAsString","getText","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBMA,MAAAA,eAAeC,MAAAA,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACMC,QAAAA,cAAcJ,QAAQ,OAAO,CAAA,IAAKK,UAAAA,iBAAiBL,IAAD;AAClDM,QAAAA,sBAAsBC,QAAQH,WAAD;AAGjC,wCAAA,OAAA;AAAA,IAAK;AAAA,IAAU;AAAA,IAAQ,WAAWI,IAAAA,GAAGP,OAAOC,MAAR;AAAA,IACjCI,UAAAA,wBAAwB,KAAKG,2BAAA,IAAC,aAAD,EAAA,IAAkBA,2BAAA,IAAC,aAAD;AAAA,MAAa;AAAA,IAAA,CAAb;AAAA,EAAA,CAFpD;AAKD,CAZ8B;AAgB/B,qBAAqB;AAAA,EAAET,OAAO;AAAA,GAA2C;AAErE,wCAAA,QAAA;AAAA,IACE,WAAWU,UAAAA,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTV,OAAO;AAAA,MACPW,U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ASmC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAA/C,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAWyC,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;;;"}
|
package/dist/ReadOnlyText.es.js
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
import { cx } from "@emotion/css";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { b4 as richTextDTOtoDAO, Z as useStyle, bk as BlockType, bl as InlineType } from "./react-page.es.js";
|
|
4
4
|
import { L as Link } from "./index.es3.js";
|
|
5
|
+
import { n as useResponsiveStyle } from "./index.es.js";
|
|
5
6
|
import "slate";
|
|
6
7
|
import "./state/breakpoints.es.js";
|
|
7
|
-
import { a_ as richTextDTOtoDAO, bc as BlockType, bd as InlineType } from "./react-page.es.js";
|
|
8
8
|
import "is-hotkey";
|
|
9
9
|
import "slate-react";
|
|
10
10
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
11
11
|
import { u as useEnhancedTypography, a as useTypographyClassName } from "./leaf.es.js";
|
|
12
|
-
import "
|
|
13
|
-
import "
|
|
12
|
+
import "redux";
|
|
13
|
+
import "redux-thunk";
|
|
14
14
|
import "./actions.es.js";
|
|
15
15
|
import "@emotion/serialize";
|
|
16
16
|
import "@emotion/utils";
|
|
17
|
+
import "scroll-into-view-if-needed";
|
|
18
|
+
import "next/link";
|
|
19
|
+
import "use-sync-external-store/shim/with-selector";
|
|
20
|
+
import "next/dynamic";
|
|
17
21
|
import "./text-input.es.js";
|
|
18
22
|
import "./combobox.es.js";
|
|
19
23
|
import "use-sync-external-store/shim";
|
|
20
|
-
import "redux";
|
|
21
|
-
import "redux-thunk";
|
|
22
24
|
import "./types.es.js";
|
|
25
|
+
import "./deepEqual.es.js";
|
|
23
26
|
import "./box-models.es.js";
|
|
24
27
|
import "css-box-model";
|
|
25
28
|
import "color";
|
|
26
|
-
import "scroll-into-view-if-needed";
|
|
27
29
|
import "react-dom";
|
|
28
30
|
import "html-react-parser";
|
|
29
31
|
import "next/head";
|
|
@@ -38,7 +40,6 @@ import "set-cookie-parser";
|
|
|
38
40
|
import "./constants.es.js";
|
|
39
41
|
import "uuid";
|
|
40
42
|
import "corporate-ipsum";
|
|
41
|
-
import "next/link";
|
|
42
43
|
const ReadOnlyText = forwardRef(function ReadOnlyText2({
|
|
43
44
|
id,
|
|
44
45
|
text,
|
|
@@ -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 { useTypographyClassName } from './components'\nimport useEnhancedTypography from './components/Leaf/leaf'\nimport { Inline, InlineType, Block, BlockType } from '../../../slate'\nimport { richTextDTOtoDAO } from '../../../controls'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Inline\n}\n\nfunction InlineElement({ descendant }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n 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.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.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","descendantsAsString","getText","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBMA,MAAAA,eAAeC,WAAW,uBAC9B;AAAA,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,WAAWW,SAASmC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAA/C,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAWyC,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;"}
|
|
1
|
+
{"version":3,"file":"ReadOnlyText.es.js","sources":["../src/components/builtin/Text/ReadOnlyText.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Text } from 'slate'\n\nimport type { ElementIDValue, RichTextValue } from '../../../prop-controllers/descriptors'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { Link } from '../../shared/Link'\nimport { useResponsiveStyle } from '../../utils/responsive-style'\nimport { useTypographyClassName } from './components'\nimport useEnhancedTypography from './components/Leaf/leaf'\nimport { Inline, InlineType, Block, BlockType } from '../../../slate'\nimport { richTextDTOtoDAO } from '../../../controls'\n\ntype Props = {\n id?: ElementIDValue\n text?: RichTextValue\n width?: string\n margin?: string\n}\n\nconst ReadOnlyText = forwardRef(function ReadOnlyText(\n { id, text, width, margin }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendants = text == null ? [] : richTextDTOtoDAO(text)\n const descendantsAsString = getText(descendants)\n\n return (\n <div ref={ref} id={id} className={cx(width, margin)}>\n {descendantsAsString === '' ? <Placeholder /> : <Descendants descendants={descendants} />}\n </div>\n )\n})\n\nexport default ReadOnlyText\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\nexport interface TextProps {\n descendant: Text\n}\n\nexport function TextElement({ descendant }: TextProps) {\n const enhancedTypography = useEnhancedTypography(descendant.typography)\n const typographyClassName = useTypographyClassName(enhancedTypography)\n\n return (\n <span className={typographyClassName}>\n {descendant.text === '' ? '\\uFEFF' : descendant.text}\n </span>\n )\n}\n\nexport interface InlineProps {\n descendant: Inline\n}\n\nfunction InlineElement({ descendant }: InlineProps) {\n const linkClassName = useStyle({ textDecoration: 'none' })\n\n switch (descendant.type) {\n case InlineType.Code:\n return (\n <code>\n <Descendants descendants={descendant.children} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link}>\n <Descendants descendants={descendant.children} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n}\n\nexport function BlockElement({ descendant }: BlockProps) {\n const blockStyles = [\n useStyle({ margin: 0 }),\n useStyle(useResponsiveStyle([descendant.textAlign], ([textAlign = 'left']) => ({ textAlign }))),\n ]\n 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.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.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if ('text' in descendant) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if ('text' in descendant) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyText","forwardRef","id","text","width","margin","ref","descendants","richTextDTOtoDAO","descendantsAsString","getText","cx","_jsx","useStyle","display","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBMA,MAAAA,eAAeC,WAAW,uBAC9B;AAAA,EAAEC;AAAAA,EAAIC;AAAAA,EAAMC;AAAAA,EAAOC;AAAAA,GACnBC,KACA;AACMC,QAAAA,cAAcJ,QAAQ,OAAO,CAAA,IAAKK,iBAAiBL,IAAD;AAClDM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WyC,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;"}
|
|
@@ -2,26 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
var css = require("@emotion/css");
|
|
4
4
|
var React = require("react");
|
|
5
|
+
var reactPage = require("./react-page.cjs.js");
|
|
5
6
|
var next = require("./index.cjs.js");
|
|
6
7
|
require("slate");
|
|
7
8
|
require("./state/breakpoints.cjs.js");
|
|
8
|
-
var reactPage = require("./react-page.cjs.js");
|
|
9
9
|
require("is-hotkey");
|
|
10
10
|
require("slate-react");
|
|
11
11
|
var jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
var index = require("./index.cjs3.js");
|
|
13
13
|
var leaf = require("./leaf.cjs.js");
|
|
14
|
-
require("
|
|
15
|
-
require("
|
|
14
|
+
require("redux");
|
|
15
|
+
require("redux-thunk");
|
|
16
16
|
require("./actions.cjs.js");
|
|
17
17
|
require("@emotion/serialize");
|
|
18
18
|
require("@emotion/utils");
|
|
19
|
+
require("use-sync-external-store/shim/with-selector");
|
|
20
|
+
require("next/dynamic");
|
|
19
21
|
require("./text-input.cjs.js");
|
|
20
22
|
require("./combobox.cjs.js");
|
|
21
23
|
require("use-sync-external-store/shim");
|
|
22
|
-
require("redux");
|
|
23
|
-
require("redux-thunk");
|
|
24
24
|
require("./types.cjs.js");
|
|
25
|
+
require("./deepEqual.cjs.js");
|
|
25
26
|
require("./box-models.cjs.js");
|
|
26
27
|
require("css-box-model");
|
|
27
28
|
require("color");
|
|
@@ -60,7 +61,7 @@ function Placeholder({
|
|
|
60
61
|
text = "Write some text..."
|
|
61
62
|
}) {
|
|
62
63
|
return /* @__PURE__ */ jsxRuntime.jsx("span", {
|
|
63
|
-
className:
|
|
64
|
+
className: reactPage.useStyle({
|
|
64
65
|
display: "inline-block",
|
|
65
66
|
width: 0,
|
|
66
67
|
maxWidth: "100%",
|
|
@@ -85,7 +86,7 @@ function InlineElement({
|
|
|
85
86
|
descendant,
|
|
86
87
|
mode
|
|
87
88
|
}) {
|
|
88
|
-
const linkClassName =
|
|
89
|
+
const linkClassName = reactPage.useStyle({
|
|
89
90
|
textDecoration: "none"
|
|
90
91
|
});
|
|
91
92
|
switch (descendant.type) {
|
|
@@ -125,12 +126,12 @@ function BlockElement({
|
|
|
125
126
|
descendant,
|
|
126
127
|
mode
|
|
127
128
|
}) {
|
|
128
|
-
const blockStyles = [
|
|
129
|
+
const blockStyles = [reactPage.useStyle({
|
|
129
130
|
margin: 0
|
|
130
|
-
}),
|
|
131
|
+
}), reactPage.useStyle(next.useResponsiveStyle([descendant.textAlign], ([textAlign = "left"]) => ({
|
|
131
132
|
textAlign
|
|
132
133
|
})))];
|
|
133
|
-
const quoteStyle =
|
|
134
|
+
const quoteStyle = reactPage.useStyle({
|
|
134
135
|
padding: "0.5em 10px",
|
|
135
136
|
fontSize: "1.25em",
|
|
136
137
|
fontWeight: "300",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadOnlyTextV2.cjs.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { useTypographyClassName } from '../../../../components/builtin/Text/components'\nimport useEnhancedTypography from '../../../../components/builtin/Text/components/Leaf/leaf'\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { RichTextV2Control, RichTextV2ControlData, RichTextV2Mode } from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Text } from 'slate'\nimport { Link } from '../../../../components/shared/Link'\nimport { Inline, InlineType, Block, BlockType } from '../../../../slate'\n\ntype Props = {\n text: RichTextV2ControlData\n control: RichTextV2Control | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: descendants, control }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants)\n\n const mode = control?.descriptor.config.mode ?? RichTextV2Mode.Block\n\n return (\n <div ref={ref}>\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants descendants={descendants} mode={mode} />\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\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 mode: RichTextV2Mode\n}\n\nfunction InlineElement({ descendant, mode }: 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} mode={mode} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} mode={mode} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} mode={mode} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link}>\n <Descendants descendants={descendant.children} mode={mode} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n mode: RichTextV2Mode\n}\n\nexport function BlockElement({ descendant, mode }: 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} mode={mode} />\n </span>\n )\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} mode={mode} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} mode={mode} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n default:\n if (mode === RichTextV2Mode.Inline)\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </p>\n )\n }\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: any): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({ descendants, mode }: { descendants: Descendant[]; mode: RichTextV2Mode }) {\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} mode={mode} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} mode={mode} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if (isText(descendant)) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n case BlockType.Text:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if (isText(descendant)) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","control","ref","descendantsAsString","getText","mode","descriptor","config","RichTextV2Mode","Block","_jsx","useStyle","display","width","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","margin","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","cx","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","Inline","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBMA,MAAAA,iBAAiBC,MAAAA,WAAW,sBAChC;AAAA,EAAEC,MAAMC;AAAAA,EAAaC;AAAAA,GACrBC,KACA;;AACMC,QAAAA,sBAAsBC,QAAQJ,WAAD;AAEnC,QAAMK,OAAOJ,yCAASK,WAAWC,OAAOF,SAA3BJ,YAAmCO,UAAeC,eAAAA;AAG7D,wCAAA,OAAA;AAAA,IAAK;AAAA,IACFN,UAAAA,wBAAwB,KACvBO,2BAAA,IAAC,aAAD,EAAA,IAEAA,2BAAA,IAAC,aAAD;AAAA,MAAa;AAAA,MAA0B;AAAA,IAAA,CAAvC;AAAA,EAAA,CALN;AASD,CAjBgC;AAqBjC,qBAAqB;AAAA,EAAEX,OAAO;AAAA,GAA2C;AAErE,wCAAA,QAAA;AAAA,IACE,WAAWY,KAAAA,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTC,OAAO;AAAA,MACPC,UAAU;AAAA,MACVC,YAA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XmB,YAAmB;AAAA,EAC3B;AAEOA,UAAAA,WAAWQ;AAAAA,SACZC,UAAAA,WAAWK;AAAAA,SACXL,UAAAA,WAAWC;AAAAA,SACXD,UAAAA,WAAWI;AAAAA,SACXJ,UAAWG,WAAAA;AACPZ,aAAAA,iBAAWW,SAASiC,IAAI5C,CAAc+C,gBAAAA,oBAAoB/C,WAAD,CAAzD,EAAuEgD,KAAK,EAA5E,MAAAhD,YAAmF;AAAA,SACvFyB,UAAAA,UAAUI;AAAAA,SACVJ,UAAAA,UAAUK;AAAAA,SACVL,UAAAA,UAAUM;AAAAA,SACVN,UAAAA,UAAUU;AAAAA,SACVV,UAAAA,UAAUG;AAAAA,SACVH,UAAAA,UAAUW;AAAAA,SACVX,UAAAA,UAAUa;AAAAA,SACVb,UAAAA,UAAUc;AAAAA,SACVd,UAAUe,UAAAA;AAEXxC,aAAAA,iBAAWW,SACRiC,IAAI5C,CAAc+C,gBAAAA,oBAAoB/C,WAAD,CADxC,EAEGgD,KAAKhD,WAAWW,SAASsC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAAlD,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAW4C,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;;;"}
|
|
1
|
+
{"version":3,"file":"ReadOnlyTextV2.cjs.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { useTypographyClassName } from '../../../../components/builtin/Text/components'\nimport useEnhancedTypography from '../../../../components/builtin/Text/components/Leaf/leaf'\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { RichTextV2Control, RichTextV2ControlData, RichTextV2Mode } from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Text } from 'slate'\nimport { Link } from '../../../../components/shared/Link'\nimport { Inline, InlineType, Block, BlockType } from '../../../../slate'\n\ntype Props = {\n text: RichTextV2ControlData\n control: RichTextV2Control | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: descendants, control }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants)\n\n const mode = control?.descriptor.config.mode ?? RichTextV2Mode.Block\n\n return (\n <div ref={ref}>\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants descendants={descendants} mode={mode} />\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\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 mode: RichTextV2Mode\n}\n\nfunction InlineElement({ descendant, mode }: 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} mode={mode} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} mode={mode} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} mode={mode} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link}>\n <Descendants descendants={descendant.children} mode={mode} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n mode: RichTextV2Mode\n}\n\nexport function BlockElement({ descendant, mode }: 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} mode={mode} />\n </span>\n )\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} mode={mode} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} mode={mode} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n default:\n if (mode === RichTextV2Mode.Inline)\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </p>\n )\n }\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: any): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({ descendants, mode }: { descendants: Descendant[]; mode: RichTextV2Mode }) {\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} mode={mode} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} mode={mode} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if (isText(descendant)) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n case BlockType.Text:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if (isText(descendant)) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","control","ref","descendantsAsString","getText","mode","descriptor","config","RichTextV2Mode","Block","_jsx","useStyle","display","width","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","margin","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","cx","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","Inline","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBMA,MAAAA,iBAAiBC,MAAAA,WAAW,sBAChC;AAAA,EAAEC,MAAMC;AAAAA,EAAaC;AAAAA,GACrBC,KACA;;AACMC,QAAAA,sBAAsBC,QAAQJ,WAAD;AAEnC,QAAMK,OAAOJ,yCAASK,WAAWC,OAAOF,SAA3BJ,YAAmCO,UAAeC,eAAAA;AAG7D,wCAAA,OAAA;AAAA,IAAK;AAAA,IACFN,UAAAA,wBAAwB,KACvBO,2BAAA,IAAC,aAAD,EAAA,IAEAA,2BAAA,IAAC,aAAD;AAAA,MAAa;AAAA,MAA0B;AAAA,I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a;AAAAA,SACVb,UAAAA,UAAUc;AAAAA,SACVd,UAAAA,UAAUe;AAAAA,SACVf,UAAUC,UAAAA;AACN,aAAA;AAAA;AAGA,aAAA;AAAA;AAEZ;AAED,6BAA6B1B,YAAgC;;AACvD8C,MAAAA,OAAO9C,UAAD,GAAc;AACtB,WAAOA,iBAAWnB,SAAXmB,YAAmB;AAAA,EAC3B;AAEOA,UAAAA,WAAWQ;AAAAA,SACZC,UAAAA,WAAWK;AAAAA,SACXL,UAAAA,WAAWC;AAAAA,SACXD,UAAAA,WAAWI;AAAAA,SACXJ,UAAWG,WAAAA;AACPZ,aAAAA,iBAAWW,SAASiC,IAAI5C,CAAc+C,gBAAAA,oBAAoB/C,WAAD,CAAzD,EAAuEgD,KAAK,EAA5E,MAAAhD,YAAmF;AAAA,SACvFyB,UAAAA,UAAUI;AAAAA,SACVJ,UAAAA,UAAUK;AAAAA,SACVL,UAAAA,UAAUM;AAAAA,SACVN,UAAAA,UAAUU;AAAAA,SACVV,UAAAA,UAAUG;AAAAA,SACVH,UAAAA,UAAUW;AAAAA,SACVX,UAAAA,UAAUa;AAAAA,SACVb,UAAAA,UAAUc;AAAAA,SACVd,UAAUe,UAAAA;AAEXxC,aAAAA,iBAAWW,SACRiC,IAAI5C,CAAc+C,gBAAAA,oBAAoB/C,WAAD,CADxC,EAEGgD,KAAKhD,WAAWW,SAASsC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAAlD,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAW4C,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;;;"}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { cx } from "@emotion/css";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { b7 as RichTextV2Mode, Z as useStyle, bk as BlockType, bl as InlineType } from "./react-page.es.js";
|
|
4
|
+
import { n as useResponsiveStyle } from "./index.es.js";
|
|
4
5
|
import "slate";
|
|
5
6
|
import "./state/breakpoints.es.js";
|
|
6
|
-
import { b1 as RichTextV2Mode, bc as BlockType, bd as InlineType } from "./react-page.es.js";
|
|
7
7
|
import "is-hotkey";
|
|
8
8
|
import "slate-react";
|
|
9
9
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
10
10
|
import { L as Link } from "./index.es3.js";
|
|
11
11
|
import { u as useEnhancedTypography, a as useTypographyClassName } from "./leaf.es.js";
|
|
12
|
-
import "
|
|
13
|
-
import "
|
|
12
|
+
import "redux";
|
|
13
|
+
import "redux-thunk";
|
|
14
14
|
import "./actions.es.js";
|
|
15
15
|
import "@emotion/serialize";
|
|
16
16
|
import "@emotion/utils";
|
|
17
|
+
import "use-sync-external-store/shim/with-selector";
|
|
18
|
+
import "next/dynamic";
|
|
17
19
|
import "./text-input.es.js";
|
|
18
20
|
import "./combobox.es.js";
|
|
19
21
|
import "use-sync-external-store/shim";
|
|
20
|
-
import "redux";
|
|
21
|
-
import "redux-thunk";
|
|
22
22
|
import "./types.es.js";
|
|
23
|
+
import "./deepEqual.es.js";
|
|
23
24
|
import "./box-models.es.js";
|
|
24
25
|
import "css-box-model";
|
|
25
26
|
import "color";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadOnlyTextV2.es.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { useTypographyClassName } from '../../../../components/builtin/Text/components'\nimport useEnhancedTypography from '../../../../components/builtin/Text/components/Leaf/leaf'\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { RichTextV2Control, RichTextV2ControlData, RichTextV2Mode } from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Text } from 'slate'\nimport { Link } from '../../../../components/shared/Link'\nimport { Inline, InlineType, Block, BlockType } from '../../../../slate'\n\ntype Props = {\n text: RichTextV2ControlData\n control: RichTextV2Control | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: descendants, control }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants)\n\n const mode = control?.descriptor.config.mode ?? RichTextV2Mode.Block\n\n return (\n <div ref={ref}>\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants descendants={descendants} mode={mode} />\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\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 mode: RichTextV2Mode\n}\n\nfunction InlineElement({ descendant, mode }: 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} mode={mode} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} mode={mode} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} mode={mode} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link}>\n <Descendants descendants={descendant.children} mode={mode} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n mode: RichTextV2Mode\n}\n\nexport function BlockElement({ descendant, mode }: 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} mode={mode} />\n </span>\n )\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} mode={mode} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} mode={mode} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n default:\n if (mode === RichTextV2Mode.Inline)\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </p>\n )\n }\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: any): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({ descendants, mode }: { descendants: Descendant[]; mode: RichTextV2Mode }) {\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} mode={mode} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} mode={mode} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if (isText(descendant)) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n case BlockType.Text:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if (isText(descendant)) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","control","ref","descendantsAsString","getText","mode","descriptor","config","RichTextV2Mode","Block","_jsx","useStyle","display","width","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","margin","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","cx","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","Inline","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBMA,MAAAA,iBAAiBC,WAAW,sBAChC;AAAA,EAAEC,MAAMC;AAAAA,EAAaC;AAAAA,GACrBC,KACA;;AACMC,QAAAA,sBAAsBC,QAAQJ,WAAD;AAEnC,QAAMK,OAAOJ,yCAASK,WAAWC,OAAOF,SAA3BJ,YAAmCO,eAAeC;AAG7D,6BAAA,OAAA;AAAA,IAAK;AAAA,IACFN,UAAAA,wBAAwB,KACvBO,oBAAC,aAAD,EAAA,IAEAA,oBAAC,aAAD;AAAA,MAAa;AAAA,MAA0B;AAAA,IAAA,CAAvC;AAAA,EAAA,CALN;AASD,CAjBgC;AAqBjC,qBAAqB;AAA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,SACVN,UAAUU;AAAAA,SACVV,UAAUG;AAAAA,SACVH,UAAUW;AAAAA,SACVX,UAAUa;AAAAA,SACVb,UAAUc;AAAAA,SACVd,UAAUe;AAEXxC,aAAAA,iBAAWW,SACRiC,IAAI5C,CAAc+C,gBAAAA,oBAAoB/C,WAAD,CADxC,EAEGgD,KAAKhD,WAAWW,SAASsC,MAAMC,OAA1B,IAAqC,OAAO,EAFpD,MAAAlD,YAE2D;AAAA;AAGtD,aAAA;AAAA;AAEZ;AAED,iBAAiBA,YAAkC;AAC1CA,SAAAA,WAAW4C,IAAIG,mBAAf,EAAoCC,KAAK,IAAzC;AACR;;"}
|
|
1
|
+
{"version":3,"file":"ReadOnlyTextV2.es.js","sources":["../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { ForwardedRef, forwardRef } from 'react'\nimport { useTypographyClassName } from '../../../../components/builtin/Text/components'\nimport useEnhancedTypography from '../../../../components/builtin/Text/components/Leaf/leaf'\nimport { useResponsiveStyle } from '../../../../components/utils/responsive-style'\nimport { RichTextV2Control, RichTextV2ControlData, RichTextV2Mode } from '../../../../controls'\nimport { useStyle } from '../../use-style'\nimport { Descendant, Text } from 'slate'\nimport { Link } from '../../../../components/shared/Link'\nimport { Inline, InlineType, Block, BlockType } from '../../../../slate'\n\ntype Props = {\n text: RichTextV2ControlData\n control: RichTextV2Control | null\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text: descendants, control }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = getText(descendants)\n\n const mode = control?.descriptor.config.mode ?? RichTextV2Mode.Block\n\n return (\n <div ref={ref}>\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants descendants={descendants} mode={mode} />\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\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 mode: RichTextV2Mode\n}\n\nfunction InlineElement({ descendant, mode }: 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} mode={mode} />\n </code>\n )\n\n case InlineType.SuperScript:\n return (\n <sup>\n <Descendants descendants={descendant.children} mode={mode} />\n </sup>\n )\n\n case InlineType.SubScript:\n return (\n <sub>\n <Descendants descendants={descendant.children} mode={mode} />\n </sub>\n )\n\n case InlineType.Link:\n return (\n <Link className={linkClassName} link={descendant.link}>\n <Descendants descendants={descendant.children} mode={mode} />\n </Link>\n )\n }\n}\n\nexport interface BlockProps {\n descendant: Block\n mode: RichTextV2Mode\n}\n\nexport function BlockElement({ descendant, mode }: 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} mode={mode} />\n </span>\n )\n case BlockType.Paragraph:\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote className={cx(...blockStyles, quoteStyle)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} mode={mode} />\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul className={cx(...blockStyles)} style={{ listStylePosition: 'inside' }}>\n <Descendants descendants={descendant.children} mode={mode} />\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n default:\n if (mode === RichTextV2Mode.Inline)\n return (\n <span className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </span>\n )\n return (\n <p className={cx(...blockStyles)}>\n <Descendants descendants={descendant.children} mode={mode} />\n </p>\n )\n }\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: any): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({ descendants, mode }: { descendants: Descendant[]; mode: RichTextV2Mode }) {\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} mode={mode} />\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Text:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return <BlockElement key={index} descendant={descendant} mode={mode} />\n default:\n return null\n }\n })}\n </>\n )\n}\n\nfunction isBlock(descendant: Descendant): descendant is Block {\n if (isText(descendant)) return false\n\n switch (descendant.type) {\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n case BlockType.Text:\n return true\n\n default:\n return false\n }\n}\n\nfunction getTextByDescendant(descendant: Descendant): string {\n if (isText(descendant)) {\n return descendant.text ?? ''\n }\n\n switch (descendant.type) {\n case InlineType.Link:\n case InlineType.Code:\n case InlineType.SubScript:\n case InlineType.SuperScript:\n return descendant.children.map(descendant => getTextByDescendant(descendant)).join('') ?? ''\n case BlockType.Heading1:\n case BlockType.Heading2:\n case BlockType.Heading3:\n case BlockType.BlockQuote:\n case BlockType.Paragraph:\n case BlockType.OrderedList:\n case BlockType.UnorderedList:\n case BlockType.ListItem:\n case BlockType.ListItemChild:\n return (\n descendant.children\n .map(descendant => getTextByDescendant(descendant))\n .join(descendant.children.every(isBlock) ? '\\n' : '') ?? ''\n )\n default:\n return ''\n }\n}\n\nfunction getText(descendant: Descendant[]): string {\n return descendant.map(getTextByDescendant).join('\\n')\n}\n"],"names":["ReadOnlyTextV2","forwardRef","text","descendants","control","ref","descendantsAsString","getText","mode","descriptor","config","RichTextV2Mode","Block","_jsx","useStyle","display","width","maxWidth","whiteSpace","opacity","verticalAlign","descendant","enhancedTypography","useEnhancedTypography","typography","typographyClassName","useTypographyClassName","linkClassName","textDecoration","type","InlineType","Code","children","SuperScript","SubScript","Link","link","blockStyles","margin","useResponsiveStyle","textAlign","quoteStyle","padding","fontSize","fontWeight","borderLeft","BlockType","Text","cx","Paragraph","Heading1","Heading2","Heading3","Heading4","Heading5","Heading6","BlockQuote","OrderedList","listStylePosition","UnorderedList","ListItem","ListItemChild","Inline","node","_Fragment","map","index","isText","getTextByDescendant","join","every","isBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBMA,MAAAA,iBAAiBC,WAAW,sBAChC;AAAA,EAAEC,MAAMC;AAAAA,EAAaC;AAAAA,GACrBC,KACA;;AACMC,QAAAA,sBAAsBC,QAAQJ,WAAD;AAEnC,QAAMK,OAAOJ,yCAASK,WAAWC,OAAOF,SAA3BJ,YAAmCO,eAAeC;AAG7D,6BAAA,OAAA;AAAA,IAAK;AAAA,IACFN,UAAAA,wBAAwB,KACvBO,oBAAC,aAAD,EAAA,IAEAA,oBAAC,aAAD;AAAA,MAAa;AAAA,MAA0B;AAAA,IAAA,CAAvC;AAAA,EAAA,CALN;AASD,CAjBgC;AAqBjC,qBAAqB;AAAA,EAAEX,OAAO;AAAA,GAA2C;AAErE,6BAAA,QAAA;AAAA,IACE,WAAWY,SAAS;AAAA,MAClBC,SAAS;AAAA,MACTC,OAAO;AAAA,MACPC,UAAU;AAAA,MACVC,YAAY;AAAA,MACZC,SAAS;AAAA,MACTC,eAAe;AAAA,IAAA,CANE;AAAA,IASlBlB,UAAAA;AAAAA,EAAAA,CAXL;AAcD;AAM2B,qBAAA;AAAA,EAAEmB;AAAAA,GAAyB;AAC/CC,QAAAA,qBAAqBC,sBAAsBF,WAAWG,UAAZ;AAC1CC,QAAAA,sBAAsBC,uBAAuBJ,kBAAD;A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,IAAzC;AACR;;"}
|
package/dist/Root.cjs.js
CHANGED
|
@@ -3,15 +3,13 @@ var _a;
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
var polished = require("polished");
|
|
5
5
|
var React = require("react");
|
|
6
|
-
var
|
|
6
|
+
var reactPage = require("./react-page.cjs.js");
|
|
7
7
|
var jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var next = require("./index.cjs.js");
|
|
8
9
|
var index = require("./index.cjs2.js");
|
|
9
10
|
var css = require("@emotion/css");
|
|
10
11
|
var serialize = require("@emotion/serialize");
|
|
11
12
|
var utils = require("@emotion/utils");
|
|
12
|
-
require("use-sync-external-store/shim/with-selector");
|
|
13
|
-
require("next/dynamic");
|
|
14
|
-
require("./react-page.cjs.js");
|
|
15
13
|
require("redux");
|
|
16
14
|
require("redux-thunk");
|
|
17
15
|
require("./actions.cjs.js");
|
|
@@ -19,10 +17,13 @@ require("./state/breakpoints.cjs.js");
|
|
|
19
17
|
require("slate");
|
|
20
18
|
require("is-hotkey");
|
|
21
19
|
require("slate-react");
|
|
20
|
+
require("use-sync-external-store/shim/with-selector");
|
|
21
|
+
require("next/dynamic");
|
|
22
22
|
require("./text-input.cjs.js");
|
|
23
23
|
require("./combobox.cjs.js");
|
|
24
24
|
require("use-sync-external-store/shim");
|
|
25
25
|
require("./types.cjs.js");
|
|
26
|
+
require("./deepEqual.cjs.js");
|
|
26
27
|
require("./box-models.cjs.js");
|
|
27
28
|
require("css-box-model");
|
|
28
29
|
require("color");
|
|
@@ -71,7 +72,7 @@ var React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
|
|
71
72
|
var Placeholder = React.forwardRef(function Placeholder2(_props, ref) {
|
|
72
73
|
return /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
73
74
|
ref,
|
|
74
|
-
className:
|
|
75
|
+
className: reactPage.useStyle({
|
|
75
76
|
width: "100%",
|
|
76
77
|
background: "rgba(161, 168, 194, 0.18)",
|
|
77
78
|
height: 80,
|
|
@@ -173,7 +174,7 @@ const Root = React.forwardRef(function Page({
|
|
|
173
174
|
},
|
|
174
175
|
backgrounds,
|
|
175
176
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
176
|
-
className:
|
|
177
|
+
className: reactPage.useStyle({
|
|
177
178
|
display: "flex",
|
|
178
179
|
flexWrap: "wrap",
|
|
179
180
|
width: "100%"
|
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,YAAY;AAAA,MACZC,QAAQ;AAAA,MACRC,SAAS;AAAA,IAAA,CAJQ;AAAA,IAOnB,yCAAA,OAAA;AAAA,MACE,OAAM;AAAA,M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AAA,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,15 +2,13 @@ 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 { Z as useStyle } from "./react-page.es.js";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { E as Element } from "./index.es.js";
|
|
7
8
|
import { B as BackgroundsContainer, G as GridItem } from "./index.es2.js";
|
|
8
9
|
import { injectGlobal, cache } from "@emotion/css";
|
|
9
10
|
import { serializeStyles } from "@emotion/serialize";
|
|
10
11
|
import { insertStyles } from "@emotion/utils";
|
|
11
|
-
import "use-sync-external-store/shim/with-selector";
|
|
12
|
-
import "next/dynamic";
|
|
13
|
-
import "./react-page.es.js";
|
|
14
12
|
import "redux";
|
|
15
13
|
import "redux-thunk";
|
|
16
14
|
import "./actions.es.js";
|
|
@@ -18,10 +16,13 @@ import "./state/breakpoints.es.js";
|
|
|
18
16
|
import "slate";
|
|
19
17
|
import "is-hotkey";
|
|
20
18
|
import "slate-react";
|
|
19
|
+
import "use-sync-external-store/shim/with-selector";
|
|
20
|
+
import "next/dynamic";
|
|
21
21
|
import "./text-input.es.js";
|
|
22
22
|
import "./combobox.es.js";
|
|
23
23
|
import "use-sync-external-store/shim";
|
|
24
24
|
import "./types.es.js";
|
|
25
|
+
import "./deepEqual.es.js";
|
|
25
26
|
import "./box-models.es.js";
|
|
26
27
|
import "css-box-model";
|
|
27
28
|
import "color";
|