@makeswift/runtime 0.28.10-canary.9 → 0.29.0-canary.19
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/cjs/api/graphql-api-client.js +1 -1
- package/dist/cjs/api/rest-api-client.js +2 -2
- package/dist/cjs/api/rest-api-client.js.map +1 -1
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/components/builtin/Box/Box.js +58 -54
- package/dist/cjs/components/builtin/Box/Box.js.map +1 -1
- package/dist/cjs/components/builtin/Box/animations.js +7 -9
- package/dist/cjs/components/builtin/Box/animations.js.map +1 -1
- package/dist/cjs/components/builtin/Box/components/Placeholder/index.js +43 -39
- package/dist/cjs/components/builtin/Box/components/Placeholder/index.js.map +1 -1
- package/dist/cjs/components/builtin/Button/Button.js +165 -176
- package/dist/cjs/components/builtin/Button/Button.js.map +1 -1
- package/dist/cjs/components/builtin/Carousel/Carousel.js +168 -142
- package/dist/cjs/components/builtin/Carousel/Carousel.js.map +1 -1
- package/dist/cjs/components/builtin/Countdown/Countdown.js +165 -171
- package/dist/cjs/components/builtin/Countdown/Countdown.js.map +1 -1
- package/dist/cjs/components/builtin/Divider/Divider.js +56 -64
- package/dist/cjs/components/builtin/Divider/Divider.js.map +1 -1
- package/dist/cjs/components/builtin/Embed/Embed.js +14 -12
- package/dist/cjs/components/builtin/Embed/Embed.js.map +1 -1
- package/dist/cjs/components/builtin/Form/Form.js +65 -74
- package/dist/cjs/components/builtin/Form/Form.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Field/components/Checkbox/index.js +113 -121
- package/dist/cjs/components/builtin/Form/components/Field/components/Checkbox/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Field/components/CheckboxTableField/index.js +29 -31
- package/dist/cjs/components/builtin/Form/components/Field/components/CheckboxTableField/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Field/components/Input/index.js +14 -18
- package/dist/cjs/components/builtin/Form/components/Field/components/Input/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Field/components/Label/index.js +17 -20
- package/dist/cjs/components/builtin/Form/components/Field/components/Label/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Field/components/MultipleSelectTableField/index.js +23 -18
- package/dist/cjs/components/builtin/Form/components/Field/components/MultipleSelectTableField/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Field/components/PlaceholderTableField/index.js +43 -46
- package/dist/cjs/components/builtin/Form/components/Field/components/PlaceholderTableField/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Field/components/RadioButton/index.js +96 -105
- package/dist/cjs/components/builtin/Form/components/Field/components/RadioButton/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnRadioButtonGroup/index.js +20 -19
- package/dist/cjs/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnRadioButtonGroup/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnSingleSelect/index.js +48 -54
- package/dist/cjs/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnSingleSelect/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Field/components/TextArea/index.js +8 -13
- package/dist/cjs/components/builtin/Form/components/Field/components/TextArea/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Field/services/responsiveField.js +2 -2
- package/dist/cjs/components/builtin/Form/components/Field/services/responsiveField.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Placeholder/index.js +57 -64
- package/dist/cjs/components/builtin/Form/components/Placeholder/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Spinner/index.js +19 -19
- package/dist/cjs/components/builtin/Form/components/Spinner/index.js.map +1 -1
- package/dist/cjs/components/builtin/Image/Image.js +33 -17
- package/dist/cjs/components/builtin/Image/Image.js.map +1 -1
- package/dist/cjs/components/builtin/Image/register.js +11 -0
- package/dist/cjs/components/builtin/Image/register.js.map +1 -1
- package/dist/cjs/components/builtin/Navigation/Navigation.js +60 -68
- package/dist/cjs/components/builtin/Navigation/Navigation.js.map +1 -1
- package/dist/cjs/components/builtin/Navigation/components/DropDownButton/index.js +91 -97
- package/dist/cjs/components/builtin/Navigation/components/DropDownButton/index.js.map +1 -1
- package/dist/cjs/components/builtin/Navigation/components/LinksPlaceholder/index.js +12 -13
- package/dist/cjs/components/builtin/Navigation/components/LinksPlaceholder/index.js.map +1 -1
- package/dist/cjs/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.js +44 -33
- package/dist/cjs/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.js.map +1 -1
- package/dist/cjs/components/builtin/Navigation/components/MobileMenu/index.js +67 -70
- package/dist/cjs/components/builtin/Navigation/components/MobileMenu/index.js.map +1 -1
- package/dist/cjs/components/builtin/Root/Root.js +30 -21
- package/dist/cjs/components/builtin/Root/Root.js.map +1 -1
- package/dist/cjs/components/builtin/Root/components/Placeholder/index.js +33 -36
- package/dist/cjs/components/builtin/Root/components/Placeholder/index.js.map +1 -1
- package/dist/cjs/components/builtin/SocialLinks/SocialLinks.js +72 -79
- package/dist/cjs/components/builtin/SocialLinks/SocialLinks.js.map +1 -1
- package/dist/cjs/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.js +11 -12
- package/dist/cjs/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.js.map +1 -1
- package/dist/cjs/components/builtin/Text/Text.js +12 -2
- package/dist/cjs/components/builtin/Text/Text.js.map +1 -1
- package/dist/cjs/components/builtin/Video/Video.js +23 -28
- package/dist/cjs/components/builtin/Video/Video.js.map +1 -1
- package/dist/cjs/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js +30 -35
- package/dist/cjs/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js.map +1 -1
- package/dist/cjs/components/shared/BackgroundsContainer/components/Backgrounds/index.js +84 -66
- package/dist/cjs/components/shared/BackgroundsContainer/components/Backgrounds/index.js.map +1 -1
- package/dist/cjs/components/shared/BackgroundsContainer/index.js +31 -27
- package/dist/cjs/components/shared/BackgroundsContainer/index.js.map +1 -1
- package/dist/cjs/components/shared/FallbackComponent/FallbackComponent.js +27 -26
- package/dist/cjs/components/shared/FallbackComponent/FallbackComponent.js.map +1 -1
- package/dist/cjs/components/shared/GutterContainer/index.js +13 -16
- package/dist/cjs/components/shared/GutterContainer/index.js.map +1 -1
- package/dist/cjs/components/shared/grid-item.js +27 -11
- package/dist/cjs/components/shared/grid-item.js.map +1 -1
- package/dist/cjs/controls/index.js.map +1 -1
- package/dist/cjs/controls/rich-text-v2/rich-text-v2.js +24 -13
- package/dist/cjs/controls/rich-text-v2/rich-text-v2.js.map +1 -1
- package/dist/cjs/controls/serialization/base/visitor.js +5 -3
- package/dist/cjs/controls/serialization/base/visitor.js.map +1 -1
- package/dist/cjs/controls/visitors/merge-translations-visitor.js +1 -1
- package/dist/cjs/controls/visitors/merge-translations-visitor.js.map +1 -1
- package/dist/cjs/next/components/page.js +14 -1
- package/dist/cjs/next/components/page.js.map +1 -1
- package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js +3 -3
- package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
- package/dist/cjs/next/document.js +39 -10
- package/dist/cjs/next/document.js.map +1 -1
- package/dist/cjs/next/root-style-registry.js +2 -9
- package/dist/cjs/next/root-style-registry.js.map +1 -1
- package/dist/cjs/react/server/index.js +0 -2
- package/dist/cjs/react/server/index.js.map +1 -1
- package/dist/cjs/runtimes/react/components/ElementData.js +11 -2
- package/dist/cjs/runtimes/react/components/ElementData.js.map +1 -1
- package/dist/cjs/runtimes/react/components/GoogleFontLink.js +2 -1
- package/dist/cjs/runtimes/react/components/GoogleFontLink.js.map +1 -1
- package/dist/cjs/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/cjs/runtimes/react/components/page/PageHead.js +0 -8
- package/dist/cjs/runtimes/react/components/page/PageHead.js.map +1 -1
- package/dist/cjs/runtimes/react/components/page/head-tags.js +0 -6
- package/dist/cjs/runtimes/react/components/page/head-tags.js.map +1 -1
- package/dist/cjs/runtimes/react/components/resolve-props.js +24 -5
- package/dist/cjs/runtimes/react/components/resolve-props.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/control.js +22 -8
- package/dist/cjs/runtimes/react/controls/control.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text/EditableText/editable-text.js +20 -17
- package/dist/cjs/runtimes/react/controls/rich-text/EditableText/editable-text.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text/ReadOnlyText.js +98 -42
- package/dist/cjs/runtimes/react/controls/rich-text/ReadOnlyText.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text/components/Element/block.js +87 -20
- package/dist/cjs/runtimes/react/controls/rich-text/components/Element/block.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text/components/Element/inline.js +17 -3
- package/dist/cjs/runtimes/react/controls/rich-text/components/Element/inline.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text/components/Leaf/leaf.js +5 -2
- package/dist/cjs/runtimes/react/controls/rich-text/components/Leaf/leaf.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.js +74 -32
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/index.js +2 -18
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/index.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.js +36 -3
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.js +27 -3
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.js +4 -4
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.js +91 -31
- package/dist/cjs/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/index.js +9 -3
- package/dist/cjs/runtimes/react/controls/rich-text-v2/index.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/render-rich-text-v2.js +59 -0
- package/dist/cjs/runtimes/react/controls/rich-text-v2/render-rich-text-v2.js.map +1 -0
- package/dist/cjs/runtimes/react/controls/rich-text-v2/{rich-text-v2.js → rich-text-v2-value.js} +20 -15
- package/dist/cjs/runtimes/react/controls/rich-text-v2/rich-text-v2-value.js.map +1 -0
- package/dist/cjs/runtimes/react/controls/slot/slot-value.js +52 -34
- package/dist/cjs/runtimes/react/controls/slot/slot-value.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/typography.js +6 -5
- package/dist/cjs/runtimes/react/controls/typography.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/use-slate-reset.js +1 -1
- package/dist/cjs/runtimes/react/controls/use-slate-reset.js.map +1 -1
- package/dist/cjs/runtimes/react/css-runtime/browser-dynamic-styles-bridge.js +55 -0
- package/dist/cjs/runtimes/react/css-runtime/browser-dynamic-styles-bridge.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/components/controlled-styles.js +76 -0
- package/dist/cjs/runtimes/react/css-runtime/components/controlled-styles.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/components/makeswift-style.js +42 -0
- package/dist/cjs/runtimes/react/css-runtime/components/makeswift-style.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/components/rsc-emitted-style.js +46 -0
- package/dist/cjs/runtimes/react/css-runtime/components/rsc-emitted-style.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/components/styles-context-provider.js +54 -0
- package/dist/cjs/runtimes/react/css-runtime/components/styles-context-provider.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/constants.js +39 -0
- package/dist/cjs/runtimes/react/css-runtime/constants.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-base-styles.js +67 -0
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-base-styles.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-controlled-styles.js +79 -0
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-controlled-styles.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-css-reset.js +70 -0
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-css-reset.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-dynamic-browser-style-updates.js +41 -0
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-dynamic-browser-style-updates.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-keyframes.js +64 -0
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-keyframes.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-legacy-controlled-style.js +78 -0
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-legacy-controlled-style.js.map +1 -0
- package/dist/cjs/runtimes/react/{use-style.js → css-runtime/hooks/use-style.js} +49 -30
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-style.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-styles-context.js +39 -0
- package/dist/cjs/runtimes/react/css-runtime/hooks/use-styles-context.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/serialize-css.js +51 -0
- package/dist/cjs/runtimes/react/css-runtime/serialize-css.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/style-element-updater.js +56 -0
- package/dist/cjs/runtimes/react/css-runtime/style-element-updater.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/styles-registry.js +283 -0
- package/dist/cjs/runtimes/react/css-runtime/styles-registry.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/stylesheet-engine.js +89 -0
- package/dist/cjs/runtimes/react/css-runtime/stylesheet-engine.js.map +1 -0
- package/dist/cjs/runtimes/react/{hooks/use-css-id.js → css-runtime/types.js} +12 -10
- package/dist/cjs/runtimes/react/css-runtime/types.js.map +1 -0
- package/dist/cjs/runtimes/react/css-runtime/utils.js +53 -0
- package/dist/cjs/runtimes/react/css-runtime/utils.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-resolved-props.js +10 -9
- package/dist/cjs/runtimes/react/hooks/use-resolved-props.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-resolved-value.js +2 -2
- package/dist/cjs/runtimes/react/hooks/use-resolved-value.js.map +1 -1
- package/dist/cjs/runtimes/react/legacy-controls.js +91 -21
- package/dist/cjs/runtimes/react/legacy-controls.js.map +1 -1
- package/dist/cjs/runtimes/react/poll-box-model.js +2 -1
- package/dist/cjs/runtimes/react/poll-box-model.js.map +1 -1
- package/dist/cjs/runtimes/react/root-style-registry.js +32 -75
- package/dist/cjs/runtimes/react/root-style-registry.js.map +1 -1
- package/dist/cjs/runtimes/react/server/components/editable-server-element.js +7 -4
- package/dist/cjs/runtimes/react/server/components/editable-server-element.js.map +1 -1
- package/dist/cjs/runtimes/react/server/components/element-data.js +16 -8
- package/dist/cjs/runtimes/react/server/components/element-data.js.map +1 -1
- package/dist/cjs/runtimes/react/server/components/server-elements-cache.js +1 -2
- package/dist/cjs/runtimes/react/server/components/server-elements-cache.js.map +1 -1
- package/dist/cjs/runtimes/react/server/index.js +0 -3
- package/dist/cjs/runtimes/react/server/index.js.map +1 -1
- package/dist/cjs/runtimes/react/server/render-context.js.map +1 -1
- package/dist/cjs/slate/BlockPlugin/index.js +101 -21
- package/dist/cjs/slate/BlockPlugin/index.js.map +1 -1
- package/dist/cjs/slate/LinkPlugin/index.js +32 -17
- package/dist/cjs/slate/LinkPlugin/index.js.map +1 -1
- package/dist/cjs/slate/TypographyPlugin/index.js +12 -2
- package/dist/cjs/slate/TypographyPlugin/index.js.map +1 -1
- package/dist/cjs/testing/jest-snapshot-serializer.js +134 -0
- package/dist/cjs/testing/jest-snapshot-serializer.js.map +1 -0
- package/dist/cjs/unstable-framework-support/index.js +4 -5
- package/dist/cjs/unstable-framework-support/index.js.map +1 -1
- package/dist/esm/api/graphql-api-client.js +1 -1
- package/dist/esm/api/rest-api-client.js +2 -2
- package/dist/esm/api/rest-api-client.js.map +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/components/builtin/Box/Box.js +59 -55
- package/dist/esm/components/builtin/Box/Box.js.map +1 -1
- package/dist/esm/components/builtin/Box/animations.js +7 -9
- package/dist/esm/components/builtin/Box/animations.js.map +1 -1
- package/dist/esm/components/builtin/Box/components/Placeholder/index.js +44 -40
- package/dist/esm/components/builtin/Box/components/Placeholder/index.js.map +1 -1
- package/dist/esm/components/builtin/Button/Button.js +166 -177
- package/dist/esm/components/builtin/Button/Button.js.map +1 -1
- package/dist/esm/components/builtin/Carousel/Carousel.js +169 -143
- package/dist/esm/components/builtin/Carousel/Carousel.js.map +1 -1
- package/dist/esm/components/builtin/Countdown/Countdown.js +166 -172
- package/dist/esm/components/builtin/Countdown/Countdown.js.map +1 -1
- package/dist/esm/components/builtin/Divider/Divider.js +54 -62
- package/dist/esm/components/builtin/Divider/Divider.js.map +1 -1
- package/dist/esm/components/builtin/Embed/Embed.js +15 -13
- package/dist/esm/components/builtin/Embed/Embed.js.map +1 -1
- package/dist/esm/components/builtin/Form/Form.js +65 -74
- package/dist/esm/components/builtin/Form/Form.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Field/components/Checkbox/index.js +117 -122
- package/dist/esm/components/builtin/Form/components/Field/components/Checkbox/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Field/components/CheckboxTableField/index.js +33 -32
- package/dist/esm/components/builtin/Form/components/Field/components/CheckboxTableField/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Field/components/Input/index.js +18 -19
- package/dist/esm/components/builtin/Form/components/Field/components/Input/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Field/components/Label/index.js +21 -21
- package/dist/esm/components/builtin/Form/components/Field/components/Label/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Field/components/MultipleSelectTableField/index.js +27 -19
- package/dist/esm/components/builtin/Form/components/Field/components/MultipleSelectTableField/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Field/components/PlaceholderTableField/index.js +46 -46
- package/dist/esm/components/builtin/Form/components/Field/components/PlaceholderTableField/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Field/components/RadioButton/index.js +100 -106
- package/dist/esm/components/builtin/Form/components/Field/components/RadioButton/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnRadioButtonGroup/index.js +24 -20
- package/dist/esm/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnRadioButtonGroup/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnSingleSelect/index.js +51 -54
- package/dist/esm/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnSingleSelect/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Field/components/TextArea/index.js +12 -14
- package/dist/esm/components/builtin/Form/components/Field/components/TextArea/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Field/services/responsiveField.js +2 -2
- package/dist/esm/components/builtin/Form/components/Field/services/responsiveField.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Placeholder/index.js +58 -65
- package/dist/esm/components/builtin/Form/components/Placeholder/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Spinner/index.js +20 -20
- package/dist/esm/components/builtin/Form/components/Spinner/index.js.map +1 -1
- package/dist/esm/components/builtin/Image/Image.js +34 -18
- package/dist/esm/components/builtin/Image/Image.js.map +1 -1
- package/dist/esm/components/builtin/Image/register.js +12 -0
- package/dist/esm/components/builtin/Image/register.js.map +1 -1
- package/dist/esm/components/builtin/Navigation/Navigation.js +61 -69
- package/dist/esm/components/builtin/Navigation/Navigation.js.map +1 -1
- package/dist/esm/components/builtin/Navigation/components/DropDownButton/index.js +92 -98
- package/dist/esm/components/builtin/Navigation/components/DropDownButton/index.js.map +1 -1
- package/dist/esm/components/builtin/Navigation/components/LinksPlaceholder/index.js +13 -14
- package/dist/esm/components/builtin/Navigation/components/LinksPlaceholder/index.js.map +1 -1
- package/dist/esm/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.js +44 -33
- package/dist/esm/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.js.map +1 -1
- package/dist/esm/components/builtin/Navigation/components/MobileMenu/index.js +70 -73
- package/dist/esm/components/builtin/Navigation/components/MobileMenu/index.js.map +1 -1
- package/dist/esm/components/builtin/Root/Root.js +31 -22
- package/dist/esm/components/builtin/Root/Root.js.map +1 -1
- package/dist/esm/components/builtin/Root/components/Placeholder/index.js +34 -37
- package/dist/esm/components/builtin/Root/components/Placeholder/index.js.map +1 -1
- package/dist/esm/components/builtin/SocialLinks/SocialLinks.js +73 -80
- package/dist/esm/components/builtin/SocialLinks/SocialLinks.js.map +1 -1
- package/dist/esm/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.js +12 -13
- package/dist/esm/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.js.map +1 -1
- package/dist/esm/components/builtin/Text/Text.js +2 -2
- package/dist/esm/components/builtin/Text/Text.js.map +1 -1
- package/dist/esm/components/builtin/Video/Video.js +24 -29
- package/dist/esm/components/builtin/Video/Video.js.map +1 -1
- package/dist/esm/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js +30 -35
- package/dist/esm/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js.map +1 -1
- package/dist/esm/components/shared/BackgroundsContainer/components/Backgrounds/index.js +85 -67
- package/dist/esm/components/shared/BackgroundsContainer/components/Backgrounds/index.js.map +1 -1
- package/dist/esm/components/shared/BackgroundsContainer/index.js +32 -28
- package/dist/esm/components/shared/BackgroundsContainer/index.js.map +1 -1
- package/dist/esm/components/shared/FallbackComponent/FallbackComponent.js +28 -27
- package/dist/esm/components/shared/FallbackComponent/FallbackComponent.js.map +1 -1
- package/dist/esm/components/shared/GutterContainer/index.js +14 -17
- package/dist/esm/components/shared/GutterContainer/index.js.map +1 -1
- package/dist/esm/components/shared/grid-item.js +18 -12
- package/dist/esm/components/shared/grid-item.js.map +1 -1
- package/dist/esm/controls/index.js.map +1 -1
- package/dist/esm/controls/rich-text-v2/rich-text-v2.js +24 -13
- package/dist/esm/controls/rich-text-v2/rich-text-v2.js.map +1 -1
- package/dist/esm/controls/serialization/base/visitor.js +5 -3
- package/dist/esm/controls/serialization/base/visitor.js.map +1 -1
- package/dist/esm/controls/visitors/merge-translations-visitor.js +1 -1
- package/dist/esm/controls/visitors/merge-translations-visitor.js.map +1 -1
- package/dist/esm/next/components/page.js +15 -2
- package/dist/esm/next/components/page.js.map +1 -1
- package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js +3 -3
- package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
- package/dist/esm/next/document.js +42 -10
- package/dist/esm/next/document.js.map +1 -1
- package/dist/esm/next/root-style-registry.js +3 -12
- package/dist/esm/next/root-style-registry.js.map +1 -1
- package/dist/esm/react/server/index.js +0 -2
- package/dist/esm/react/server/index.js.map +1 -1
- package/dist/esm/runtimes/react/components/ElementData.js +12 -3
- package/dist/esm/runtimes/react/components/ElementData.js.map +1 -1
- package/dist/esm/runtimes/react/components/GoogleFontLink.js +2 -1
- package/dist/esm/runtimes/react/components/GoogleFontLink.js.map +1 -1
- package/dist/esm/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/esm/runtimes/react/components/page/PageHead.js +1 -9
- package/dist/esm/runtimes/react/components/page/PageHead.js.map +1 -1
- package/dist/esm/runtimes/react/components/page/head-tags.js +0 -5
- package/dist/esm/runtimes/react/components/page/head-tags.js.map +1 -1
- package/dist/esm/runtimes/react/components/resolve-props.js +24 -5
- package/dist/esm/runtimes/react/components/resolve-props.js.map +1 -1
- package/dist/esm/runtimes/react/controls/control.js +22 -8
- package/dist/esm/runtimes/react/controls/control.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text/EditableText/editable-text.js +21 -18
- package/dist/esm/runtimes/react/controls/rich-text/EditableText/editable-text.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text/ReadOnlyText.js +100 -44
- package/dist/esm/runtimes/react/controls/rich-text/ReadOnlyText.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text/components/Element/block.js +78 -21
- package/dist/esm/runtimes/react/controls/rich-text/components/Element/block.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text/components/Element/inline.js +8 -4
- package/dist/esm/runtimes/react/controls/rich-text/components/Element/inline.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text/components/Leaf/leaf.js +7 -4
- package/dist/esm/runtimes/react/controls/rich-text/components/Leaf/leaf.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.js +78 -33
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/index.js +2 -3
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/index.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.js +36 -3
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.js +27 -3
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.js +4 -4
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.js +97 -34
- package/dist/esm/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/index.js +4 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/index.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/render-rich-text-v2.js +25 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/render-rich-text-v2.js.map +1 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2-value.js +26 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2-value.js.map +1 -0
- package/dist/esm/runtimes/react/controls/slot/slot-value.js +43 -35
- package/dist/esm/runtimes/react/controls/slot/slot-value.js.map +1 -1
- package/dist/esm/runtimes/react/controls/typography.js +5 -4
- package/dist/esm/runtimes/react/controls/typography.js.map +1 -1
- package/dist/esm/runtimes/react/controls/use-slate-reset.js +1 -1
- package/dist/esm/runtimes/react/controls/use-slate-reset.js.map +1 -1
- package/dist/esm/runtimes/react/css-runtime/browser-dynamic-styles-bridge.js +31 -0
- package/dist/esm/runtimes/react/css-runtime/browser-dynamic-styles-bridge.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/components/controlled-styles.js +51 -0
- package/dist/esm/runtimes/react/css-runtime/components/controlled-styles.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/components/makeswift-style.js +18 -0
- package/dist/esm/runtimes/react/css-runtime/components/makeswift-style.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/components/rsc-emitted-style.js +22 -0
- package/dist/esm/runtimes/react/css-runtime/components/rsc-emitted-style.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/components/styles-context-provider.js +29 -0
- package/dist/esm/runtimes/react/css-runtime/components/styles-context-provider.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/constants.js +12 -0
- package/dist/esm/runtimes/react/css-runtime/constants.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-base-styles.js +33 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-base-styles.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-controlled-styles.js +45 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-controlled-styles.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-css-reset.js +36 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-css-reset.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-dynamic-browser-style-updates.js +17 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-dynamic-browser-style-updates.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-keyframes.js +30 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-keyframes.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-legacy-controlled-style.js +44 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-legacy-controlled-style.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-style.js +56 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-style.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-styles-context.js +15 -0
- package/dist/esm/runtimes/react/css-runtime/hooks/use-styles-context.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/serialize-css.js +25 -0
- package/dist/esm/runtimes/react/css-runtime/serialize-css.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/style-element-updater.js +32 -0
- package/dist/esm/runtimes/react/css-runtime/style-element-updater.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/styles-registry.js +261 -0
- package/dist/esm/runtimes/react/css-runtime/styles-registry.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/stylesheet-engine.js +65 -0
- package/dist/esm/runtimes/react/css-runtime/stylesheet-engine.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/types.js +10 -0
- package/dist/esm/runtimes/react/css-runtime/types.js.map +1 -0
- package/dist/esm/runtimes/react/css-runtime/utils.js +26 -0
- package/dist/esm/runtimes/react/css-runtime/utils.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-resolved-props.js +10 -9
- package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-resolved-value.js +2 -2
- package/dist/esm/runtimes/react/hooks/use-resolved-value.js.map +1 -1
- package/dist/esm/runtimes/react/legacy-controls.js +92 -22
- package/dist/esm/runtimes/react/legacy-controls.js.map +1 -1
- package/dist/esm/runtimes/react/poll-box-model.js +2 -1
- package/dist/esm/runtimes/react/poll-box-model.js.map +1 -1
- package/dist/esm/runtimes/react/root-style-registry.js +36 -60
- package/dist/esm/runtimes/react/root-style-registry.js.map +1 -1
- package/dist/esm/runtimes/react/server/components/editable-server-element.js +8 -5
- package/dist/esm/runtimes/react/server/components/editable-server-element.js.map +1 -1
- package/dist/esm/runtimes/react/server/components/element-data.js +16 -12
- package/dist/esm/runtimes/react/server/components/element-data.js.map +1 -1
- package/dist/esm/runtimes/react/server/components/server-elements-cache.js +1 -2
- package/dist/esm/runtimes/react/server/components/server-elements-cache.js.map +1 -1
- package/dist/esm/runtimes/react/server/index.js +0 -2
- package/dist/esm/runtimes/react/server/index.js.map +1 -1
- package/dist/esm/runtimes/react/server/render-context.js.map +1 -1
- package/dist/esm/slate/BlockPlugin/index.js +102 -22
- package/dist/esm/slate/BlockPlugin/index.js.map +1 -1
- package/dist/esm/slate/LinkPlugin/index.js +23 -18
- package/dist/esm/slate/LinkPlugin/index.js.map +1 -1
- package/dist/esm/slate/TypographyPlugin/index.js +2 -2
- package/dist/esm/slate/TypographyPlugin/index.js.map +1 -1
- package/dist/esm/testing/jest-snapshot-serializer.js +100 -0
- package/dist/esm/testing/jest-snapshot-serializer.js.map +1 -0
- package/dist/esm/unstable-framework-support/index.js +3 -6
- package/dist/esm/unstable-framework-support/index.js.map +1 -1
- package/dist/types/components/builtin/Box/Box.d.ts.map +1 -1
- package/dist/types/components/builtin/Box/animations.d.ts +3 -2
- package/dist/types/components/builtin/Box/animations.d.ts.map +1 -1
- package/dist/types/components/builtin/Box/components/Placeholder/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Button/Button.d.ts.map +1 -1
- package/dist/types/components/builtin/Carousel/Carousel.d.ts.map +1 -1
- package/dist/types/components/builtin/Countdown/Countdown.d.ts.map +1 -1
- package/dist/types/components/builtin/Divider/Divider.d.ts.map +1 -1
- package/dist/types/components/builtin/Embed/Embed.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/Form.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Field/components/Checkbox/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Field/components/CheckboxTableField/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Field/components/Input/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Field/components/Label/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Field/components/MultipleSelectTableField/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Field/components/RadioButton/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnRadioButtonGroup/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnSingleSelect/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Field/components/TextArea/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Placeholder/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Spinner/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Image/Image.d.ts +3 -1
- package/dist/types/components/builtin/Image/Image.d.ts.map +1 -1
- package/dist/types/components/builtin/Image/register.d.ts.map +1 -1
- package/dist/types/components/builtin/Navigation/Navigation.d.ts.map +1 -1
- package/dist/types/components/builtin/Navigation/components/DropDownButton/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Navigation/components/LinksPlaceholder/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Navigation/components/MobileMenu/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Root/Root.d.ts.map +1 -1
- package/dist/types/components/builtin/Root/components/Placeholder/index.d.ts.map +1 -1
- package/dist/types/components/builtin/SocialLinks/SocialLinks.d.ts.map +1 -1
- package/dist/types/components/builtin/Text/Text.d.ts.map +1 -1
- package/dist/types/components/builtin/Video/Video.d.ts.map +1 -1
- package/dist/types/components/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/types/components/hooks/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/dist/types/components/shared/BackgroundsContainer/components/BackgroundVideo/index.d.ts.map +1 -1
- package/dist/types/components/shared/BackgroundsContainer/index.d.ts.map +1 -1
- package/dist/types/components/shared/FallbackComponent/FallbackComponent.d.ts.map +1 -1
- package/dist/types/components/shared/GutterContainer/index.d.ts.map +1 -1
- package/dist/types/components/shared/grid-item.d.ts.map +1 -1
- package/dist/types/controls/__tests__/fixtures/list.d.ts +1 -0
- package/dist/types/controls/__tests__/fixtures/list.d.ts.map +1 -1
- package/dist/types/controls/__tests__/fixtures/shape.d.ts +2 -0
- package/dist/types/controls/__tests__/fixtures/shape.d.ts.map +1 -1
- package/dist/types/controls/index.d.ts +1 -1
- package/dist/types/controls/index.d.ts.map +1 -1
- package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts +161 -24
- package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/controls/serialization/base/visitor.d.ts.map +1 -1
- package/dist/types/next/components/page.d.ts.map +1 -1
- package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts.map +1 -1
- package/dist/types/next/document.d.ts.map +1 -1
- package/dist/types/next/root-style-registry.d.ts +1 -1
- package/dist/types/next/root-style-registry.d.ts.map +1 -1
- package/dist/types/react/server/index.d.ts +1 -1
- package/dist/types/react/server/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/GoogleFontLink.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/framework-context.d.ts +1 -0
- package/dist/types/runtimes/react/components/framework-context.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/page/PageHead.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/page/head-tags.d.ts +0 -6
- package/dist/types/runtimes/react/components/page/head-tags.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/resolve-props.d.ts.map +1 -1
- package/dist/types/{controls/__tests__/slot.test.d.ts → runtimes/react/controls/__tests__/react-node-controls.test.d.ts} +1 -1
- package/dist/types/runtimes/react/controls/__tests__/react-node-controls.test.d.ts.map +1 -0
- package/dist/types/runtimes/react/controls/control.d.ts +3 -1
- package/dist/types/runtimes/react/controls/control.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text/ReadOnlyText.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text/components/Element/block.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text/components/Element/inline.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text/components/Leaf/leaf.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts +7 -10
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/index.d.ts +2 -3
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts +3 -3
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/render-element.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts +3 -3
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts +2 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts +9 -6
- package/dist/types/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/index.d.ts +7 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/render-rich-text-v2.d.ts +10 -0
- package/dist/types/runtimes/react/controls/rich-text-v2/render-rich-text-v2.d.ts.map +1 -0
- package/dist/types/runtimes/react/controls/rich-text-v2/rich-text-v2-value.d.ts +9 -0
- package/dist/types/runtimes/react/controls/rich-text-v2/rich-text-v2-value.d.ts.map +1 -0
- package/dist/types/runtimes/react/controls/slot/slot-value.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/typography.d.ts +8 -1
- package/dist/types/runtimes/react/controls/typography.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/use-slate-reset.d.ts +8 -1
- package/dist/types/runtimes/react/controls/use-slate-reset.d.ts.map +1 -1
- package/dist/types/runtimes/react/css-runtime/__tests__/__fixtures__/sample-js-styles-objects.d.ts +7 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/__fixtures__/sample-js-styles-objects.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/runtime-integration/__fixtures__/sample-stylev1-data.d.ts +9 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/runtime-integration/__fixtures__/sample-stylev1-data.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/runtime-integration/__fixtures__/sample-stylev2-data.d.ts +10 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/runtime-integration/__fixtures__/sample-stylev2-data.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/runtime-integration/controlled-styles-integration.test.d.ts +3 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/runtime-integration/controlled-styles-integration.test.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/runtime-integration/utils.d.ts +24 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/runtime-integration/utils.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/serialize-css.test.d.ts +2 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/serialize-css.test.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/styles-registry.test.d.ts +2 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/styles-registry.test.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/utils.d.ts +6 -0
- package/dist/types/runtimes/react/css-runtime/__tests__/utils.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/browser-dynamic-styles-bridge.d.ts +16 -0
- package/dist/types/runtimes/react/css-runtime/browser-dynamic-styles-bridge.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/components/controlled-styles.d.ts +12 -0
- package/dist/types/runtimes/react/css-runtime/components/controlled-styles.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/components/makeswift-style.d.ts +6 -0
- package/dist/types/runtimes/react/css-runtime/components/makeswift-style.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/components/rsc-emitted-style.d.ts +30 -0
- package/dist/types/runtimes/react/css-runtime/components/rsc-emitted-style.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/components/styles-context-provider.d.ts +20 -0
- package/dist/types/runtimes/react/css-runtime/components/styles-context-provider.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/constants.d.ts +5 -0
- package/dist/types/runtimes/react/css-runtime/constants.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-base-styles.d.ts +12 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-base-styles.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-controlled-styles.d.ts +11 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-controlled-styles.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-css-reset.d.ts +14 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-css-reset.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-dynamic-browser-style-updates.d.ts +3 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-dynamic-browser-style-updates.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-keyframes.d.ts +6 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-keyframes.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-legacy-controlled-style.d.ts +10 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-legacy-controlled-style.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-style.d.ts +62 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-style.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-styles-context.d.ts +3 -0
- package/dist/types/runtimes/react/css-runtime/hooks/use-styles-context.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/serialize-css.d.ts +40 -0
- package/dist/types/runtimes/react/css-runtime/serialize-css.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/style-element-updater.d.ts +10 -0
- package/dist/types/runtimes/react/css-runtime/style-element-updater.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/styles-registry.d.ts +66 -0
- package/dist/types/runtimes/react/css-runtime/styles-registry.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/stylesheet-engine.d.ts +23 -0
- package/dist/types/runtimes/react/css-runtime/stylesheet-engine.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/types.d.ts +52 -0
- package/dist/types/runtimes/react/css-runtime/types.d.ts.map +1 -0
- package/dist/types/runtimes/react/css-runtime/utils.d.ts +20 -0
- package/dist/types/runtimes/react/css-runtime/utils.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts +3 -3
- package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-resolved-value.d.ts +1 -1
- package/dist/types/runtimes/react/hooks/use-resolved-value.d.ts.map +1 -1
- package/dist/types/runtimes/react/legacy-controls.d.ts +1 -1
- package/dist/types/runtimes/react/legacy-controls.d.ts.map +1 -1
- package/dist/types/runtimes/react/poll-box-model.d.ts +2 -2
- package/dist/types/runtimes/react/poll-box-model.d.ts.map +1 -1
- package/dist/types/runtimes/react/root-style-registry.d.ts +9 -30
- package/dist/types/runtimes/react/root-style-registry.d.ts.map +1 -1
- package/dist/types/runtimes/react/server/components/element-data.d.ts.map +1 -1
- package/dist/types/runtimes/react/server/components/server-elements-cache.d.ts.map +1 -1
- package/dist/types/runtimes/react/server/index.d.ts +0 -1
- package/dist/types/runtimes/react/server/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/server/render-context.d.ts +2 -0
- package/dist/types/runtimes/react/server/render-context.d.ts.map +1 -1
- package/dist/types/slate/BlockPlugin/index.d.ts +13 -1
- package/dist/types/slate/BlockPlugin/index.d.ts.map +1 -1
- package/dist/types/slate/InlinePlugin/index.d.ts +13 -1
- package/dist/types/slate/InlinePlugin/index.d.ts.map +1 -1
- package/dist/types/slate/LinkPlugin/index.d.ts.map +1 -1
- package/dist/types/slate/TextAlignPlugin/index.d.ts +13 -1
- package/dist/types/slate/TextAlignPlugin/index.d.ts.map +1 -1
- package/dist/types/slate/TypographyPlugin/index.d.ts.map +1 -1
- package/dist/types/testing/jest-snapshot-serializer.d.ts +2 -0
- package/dist/types/testing/jest-snapshot-serializer.d.ts.map +1 -0
- package/dist/types/unstable-framework-support/index.d.ts +3 -1
- package/dist/types/unstable-framework-support/index.d.ts.map +1 -1
- package/package.json +14 -14
- package/dist/cjs/runtimes/react/controls/rich-text-v2/rich-text-v2.js.map +0 -1
- package/dist/cjs/runtimes/react/hooks/use-css-id.js.map +0 -1
- package/dist/cjs/runtimes/react/hooks/use-editable-element-stylesheet-factory.js +0 -58
- package/dist/cjs/runtimes/react/hooks/use-editable-element-stylesheet-factory.js.map +0 -1
- package/dist/cjs/runtimes/react/hooks/use-stylesheet-factory.js +0 -87
- package/dist/cjs/runtimes/react/hooks/use-stylesheet-factory.js.map +0 -1
- package/dist/cjs/runtimes/react/server/css/client-css.js +0 -112
- package/dist/cjs/runtimes/react/server/css/client-css.js.map +0 -1
- package/dist/cjs/runtimes/react/server/css/css-runtime.js +0 -102
- package/dist/cjs/runtimes/react/server/css/css-runtime.js.map +0 -1
- package/dist/cjs/runtimes/react/server/css/server-css.js +0 -71
- package/dist/cjs/runtimes/react/server/css/server-css.js.map +0 -1
- package/dist/cjs/runtimes/react/stylesheet-factory.js +0 -17
- package/dist/cjs/runtimes/react/stylesheet-factory.js.map +0 -1
- package/dist/cjs/runtimes/react/use-global-style.js +0 -101
- package/dist/cjs/runtimes/react/use-global-style.js.map +0 -1
- package/dist/cjs/runtimes/react/use-style.js.map +0 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2.js +0 -23
- package/dist/esm/runtimes/react/controls/rich-text-v2/rich-text-v2.js.map +0 -1
- package/dist/esm/runtimes/react/hooks/use-css-id.js +0 -8
- package/dist/esm/runtimes/react/hooks/use-css-id.js.map +0 -1
- package/dist/esm/runtimes/react/hooks/use-editable-element-stylesheet-factory.js +0 -34
- package/dist/esm/runtimes/react/hooks/use-editable-element-stylesheet-factory.js.map +0 -1
- package/dist/esm/runtimes/react/hooks/use-stylesheet-factory.js +0 -65
- package/dist/esm/runtimes/react/hooks/use-stylesheet-factory.js.map +0 -1
- package/dist/esm/runtimes/react/server/css/client-css.js +0 -87
- package/dist/esm/runtimes/react/server/css/client-css.js.map +0 -1
- package/dist/esm/runtimes/react/server/css/css-runtime.js +0 -77
- package/dist/esm/runtimes/react/server/css/css-runtime.js.map +0 -1
- package/dist/esm/runtimes/react/server/css/server-css.js +0 -45
- package/dist/esm/runtimes/react/server/css/server-css.js.map +0 -1
- package/dist/esm/runtimes/react/stylesheet-factory.js +0 -1
- package/dist/esm/runtimes/react/stylesheet-factory.js.map +0 -1
- package/dist/esm/runtimes/react/use-global-style.js +0 -67
- package/dist/esm/runtimes/react/use-global-style.js.map +0 -1
- package/dist/esm/runtimes/react/use-style.js +0 -36
- package/dist/esm/runtimes/react/use-style.js.map +0 -1
- package/dist/types/controls/__tests__/slot.test.d.ts.map +0 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts +0 -9
- package/dist/types/runtimes/react/controls/rich-text-v2/rich-text-v2.d.ts.map +0 -1
- package/dist/types/runtimes/react/hooks/use-css-id.d.ts +0 -2
- package/dist/types/runtimes/react/hooks/use-css-id.d.ts.map +0 -1
- package/dist/types/runtimes/react/hooks/use-editable-element-stylesheet-factory.d.ts +0 -5
- package/dist/types/runtimes/react/hooks/use-editable-element-stylesheet-factory.d.ts.map +0 -1
- package/dist/types/runtimes/react/hooks/use-stylesheet-factory.d.ts +0 -3
- package/dist/types/runtimes/react/hooks/use-stylesheet-factory.d.ts.map +0 -1
- package/dist/types/runtimes/react/server/css/client-css.d.ts +0 -10
- package/dist/types/runtimes/react/server/css/client-css.d.ts.map +0 -1
- package/dist/types/runtimes/react/server/css/css-runtime.d.ts +0 -16
- package/dist/types/runtimes/react/server/css/css-runtime.d.ts.map +0 -1
- package/dist/types/runtimes/react/server/css/server-css.d.ts +0 -14
- package/dist/types/runtimes/react/server/css/server-css.d.ts.map +0 -1
- package/dist/types/runtimes/react/stylesheet-factory.d.ts +0 -6
- package/dist/types/runtimes/react/stylesheet-factory.d.ts.map +0 -1
- package/dist/types/runtimes/react/use-global-style.d.ts +0 -3
- package/dist/types/runtimes/react/use-global-style.d.ts.map +0 -1
- package/dist/types/runtimes/react/use-style.d.ts +0 -7
- package/dist/types/runtimes/react/use-style.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/runtimes/react/server/components/element-data.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\n\nimport { partitionRecord } from '../../../../utils/partition'\n\nimport {\n type State,\n type ElementData,\n getReactComponent,\n getBreakpoints,\n getComponentPropControllerDescriptors,\n} from '../../../../state/read-only-state'\n\nimport { FallbackComponent } from '../../../../components/shared/FallbackComponent'\nimport { isLegacyDescriptor } from '../../../../prop-controllers/descriptors'\n\nimport {\
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/server/components/element-data.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\n\nimport { partitionRecord } from '../../../../utils/partition'\n\nimport {\n type State,\n type ElementData,\n getReactComponent,\n getBreakpoints,\n getComponentPropControllerDescriptors,\n} from '../../../../state/read-only-state'\n\nimport { FallbackComponent } from '../../../../components/shared/FallbackComponent'\nimport { isLegacyDescriptor } from '../../../../prop-controllers/descriptors'\n\nimport { type ServerRenderContext, getStore } from '../render-context'\nimport { resolveProps } from '../resolve-props'\nimport { StylesheetEngine } from '../../css-runtime/stylesheet-engine'\nimport { type ControlledStyleData } from '../../css-runtime/types'\nimport { RSCEmittedStyle } from '../../css-runtime/components/rsc-emitted-style'\n\nexport async function ServerElementData({\n documentKey,\n context,\n elementData,\n injectedProps,\n}: {\n documentKey: string\n context: ServerRenderContext\n elementData: ElementData\n injectedProps: Record<string, unknown>\n}): Promise<ReactNode> {\n const state = getStore(context).getState()\n\n const Component = getReactComponent(state, elementData.type)\n if (Component == null) {\n return (\n <FallbackComponent\n text=\"Component not found\"\n details={`Unknown component '${elementData.type}'`}\n />\n )\n }\n\n const [legacyDescriptors, definitions] = getControlDefs(state, elementData)\n const legacyKeys = Object.keys(legacyDescriptors)\n if (legacyKeys.length > 0) {\n console.warn(`Unexpected legacy control data in server element '${elementData.key}`, {\n elementData,\n legacyKeys,\n })\n }\n\n const classStyleData = new Map<string, ControlledStyleData>()\n const stylesheet = new StylesheetEngine({\n breakpointsData: getBreakpoints(state),\n classNamePrefix: context.rootStyleProps?.classNamePrefix,\n documentKey,\n elementKey: elementData.key,\n propPathComponents: [],\n onDefineStyle: styleData => {\n const { onBoxModelChange, ...serializableStyleData } = styleData\n classStyleData.set(styleData.className, serializableStyleData)\n },\n })\n\n const props = {\n ...(await resolveProps(context, elementData, documentKey, definitions, stylesheet)),\n ...injectedProps,\n }\n\n const styleElements = Array.from(classStyleData, ([className, styleData]) => (\n <RSCEmittedStyle key={className} namespace={elementData.key} serializableData={styleData} />\n ))\n\n return (\n <>\n {/* Make the component the first child so that `findDOMNode` resolves to its first\n rendered DOM node (if any) rather than the component's `<style>` element */}\n <Component key={elementData.key} {...props} />\n {styleElements}\n </>\n )\n}\n\nconst getControlDefs = (state: State, elementData: ElementData) => {\n const descriptors = getComponentPropControllerDescriptors(state, elementData.type) ?? {}\n return partitionRecord(descriptors, isLegacyDescriptor)\n}\n"],"mappings":"AAqCM,SAuCF,UAvCE,KAuCF,YAvCE;AAnCN,SAAS,uBAAuB;AAEhC;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AAEnC,SAAmC,gBAAgB;AACnD,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAEjC,SAAS,uBAAuB;AAEhC,eAAsB,kBAAkB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKuB;AACrB,QAAM,QAAQ,SAAS,OAAO,EAAE,SAAS;AAEzC,QAAM,YAAY,kBAAkB,OAAO,YAAY,IAAI;AAC3D,MAAI,aAAa,MAAM;AACrB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAS,sBAAsB,YAAY,IAAI;AAAA;AAAA,IACjD;AAAA,EAEJ;AAEA,QAAM,CAAC,mBAAmB,WAAW,IAAI,eAAe,OAAO,WAAW;AAC1E,QAAM,aAAa,OAAO,KAAK,iBAAiB;AAChD,MAAI,WAAW,SAAS,GAAG;AACzB,YAAQ,KAAK,qDAAqD,YAAY,GAAG,IAAI;AAAA,MACnF;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,iBAAiB,oBAAI,IAAiC;AAC5D,QAAM,aAAa,IAAI,iBAAiB;AAAA,IACtC,iBAAiB,eAAe,KAAK;AAAA,IACrC,iBAAiB,QAAQ,gBAAgB;AAAA,IACzC;AAAA,IACA,YAAY,YAAY;AAAA,IACxB,oBAAoB,CAAC;AAAA,IACrB,eAAe,eAAa;AAC1B,YAAM,EAAE,kBAAkB,GAAG,sBAAsB,IAAI;AACvD,qBAAe,IAAI,UAAU,WAAW,qBAAqB;AAAA,IAC/D;AAAA,EACF,CAAC;AAED,QAAM,QAAQ;AAAA,IACZ,GAAI,MAAM,aAAa,SAAS,aAAa,aAAa,aAAa,UAAU;AAAA,IACjF,GAAG;AAAA,EACL;AAEA,QAAM,gBAAgB,MAAM,KAAK,gBAAgB,CAAC,CAAC,WAAW,SAAS,MACrE,oBAAC,mBAAgC,WAAW,YAAY,KAAK,kBAAkB,aAAzD,SAAoE,CAC3F;AAED,SACE,iCAGE;AAAA,wBAAC,aAAiC,GAAG,SAArB,YAAY,GAAgB;AAAA,IAC3C;AAAA,KACH;AAEJ;AAEA,MAAM,iBAAiB,CAAC,OAAc,gBAA6B;AACjE,QAAM,cAAc,sCAAsC,OAAO,YAAY,IAAI,KAAK,CAAC;AACvF,SAAO,gBAAgB,aAAa,kBAAkB;AACxD;","names":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, useCallback, useContext, useState, useMemo } from "react";
|
|
4
|
-
import { ClientCSSProvider } from "../css/client-css";
|
|
5
4
|
const Context = createContext({
|
|
6
5
|
getElement: () => null,
|
|
7
6
|
updateElement: () => {
|
|
@@ -41,7 +40,7 @@ const ServerElementsCache = ({
|
|
|
41
40
|
const ServerElementsProvider = ({
|
|
42
41
|
children,
|
|
43
42
|
elements
|
|
44
|
-
}) => /* @__PURE__ */ jsx(ServerElementsCache, { value: elements, children
|
|
43
|
+
}) => /* @__PURE__ */ jsx(ServerElementsCache, { value: elements, children });
|
|
45
44
|
const useServerElementsCache = () => useContext(Context);
|
|
46
45
|
export {
|
|
47
46
|
ServerElementsCache,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/runtimes/react/server/components/server-elements-cache.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, ReactNode, useCallback, useContext, useState, useMemo } from 'react'\n\nimport { type ElementsMap } from '../collect-server-elements'\
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/server/components/server-elements-cache.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, ReactNode, useCallback, useContext, useState, useMemo } from 'react'\n\nimport { type ElementsMap } from '../collect-server-elements'\n\ntype ContextValue = {\n getElement: (elementKey: string) => ReactNode\n updateElement: (elementKey: string, node: ReactNode) => void\n removeElement: (elementKey: string) => void\n}\n\nconst Context = createContext<ContextValue>({\n getElement: () => null,\n updateElement: () => {},\n removeElement: () => {},\n})\n\n/**\n * Client-side \"cache\" of server-rendered elements; this is one of the key pieces in our RSC\n * implementation, with React doing the majority of the heavy lifting: when `ReactNode`s are\n * passed as props across a 'use client' boundary, React's flight serializer automatically\n * renders and encodes them in the RSC stream and then reconstructs them on the client. All\n * we need to do on the client is to make these React elements available for lookup/\n * manipulation when editing in the builder.\n */\nexport const ServerElementsCache = ({\n children,\n value,\n}: {\n children: ReactNode\n value: ElementsMap\n}) => {\n // An RSC re-render does not inherently remount client components; React can reconcile\n // the new server tree with the existing client tree, so we need to handle the `value`\n // prop updates\n const [nodes, setNodes] = useState(value)\n const [previousValue, setPreviousValue] = useState(value)\n\n // this is okay to do on render, see https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes\n if (value !== previousValue) {\n setPreviousValue(value)\n setNodes(value)\n }\n\n const getElement = useCallback((elementKey: string): ReactNode => nodes.get(elementKey), [nodes])\n\n const updateElement = useCallback(\n (elementKey: string, node: ReactNode) => setNodes(prev => new Map(prev).set(elementKey, node)),\n [],\n )\n\n const removeElement = useCallback(\n (elementKey: string) =>\n setNodes(prev => {\n const next = new Map(prev)\n next.delete(elementKey)\n return next\n }),\n [],\n )\n\n const cache = useMemo(\n () => ({ getElement, updateElement, removeElement }),\n [getElement, updateElement, removeElement],\n )\n\n return <Context.Provider value={cache}>{children}</Context.Provider>\n}\n\nexport const ServerElementsProvider = ({\n children,\n elements,\n}: {\n children: ReactNode\n elements: ElementsMap\n}) => <ServerElementsCache value={elements}>{children}</ServerElementsCache>\n\nexport const useServerElementsCache = () => useContext(Context)\n"],"mappings":";AAmES;AAjET,SAAS,eAA0B,aAAa,YAAY,UAAU,eAAe;AAUrF,MAAM,UAAU,cAA4B;AAAA,EAC1C,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,eAAe,MAAM;AAAA,EAAC;AACxB,CAAC;AAUM,MAAM,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AACF,MAGM;AAIJ,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,KAAK;AACxC,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,KAAK;AAGxD,MAAI,UAAU,eAAe;AAC3B,qBAAiB,KAAK;AACtB,aAAS,KAAK;AAAA,EAChB;AAEA,QAAM,aAAa,YAAY,CAAC,eAAkC,MAAM,IAAI,UAAU,GAAG,CAAC,KAAK,CAAC;AAEhG,QAAM,gBAAgB;AAAA,IACpB,CAAC,YAAoB,SAAoB,SAAS,UAAQ,IAAI,IAAI,IAAI,EAAE,IAAI,YAAY,IAAI,CAAC;AAAA,IAC7F,CAAC;AAAA,EACH;AAEA,QAAM,gBAAgB;AAAA,IACpB,CAAC,eACC,SAAS,UAAQ;AACf,YAAM,OAAO,IAAI,IAAI,IAAI;AACzB,WAAK,OAAO,UAAU;AACtB,aAAO;AAAA,IACT,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAEA,QAAM,QAAQ;AAAA,IACZ,OAAO,EAAE,YAAY,eAAe,cAAc;AAAA,IAClD,CAAC,YAAY,eAAe,aAAa;AAAA,EAC3C;AAEA,SAAO,oBAAC,QAAQ,UAAR,EAAiB,OAAO,OAAQ,UAAS;AACnD;AAEO,MAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AACF,MAGM,oBAAC,uBAAoB,OAAO,UAAW,UAAS;AAE/C,MAAM,yBAAyB,MAAM,WAAW,OAAO;","names":[]}
|
|
@@ -3,7 +3,6 @@ import { ServerElement } from "./components/element";
|
|
|
3
3
|
import { MakeswiftComponent } from "./components/makeswift-component";
|
|
4
4
|
import { Slot } from "./components/slot";
|
|
5
5
|
import { RSCElementRenderer } from "./components/renderer";
|
|
6
|
-
import { ServerCSSCollector } from "./css/server-css";
|
|
7
6
|
import {
|
|
8
7
|
RenderContext,
|
|
9
8
|
setRenderContext,
|
|
@@ -15,7 +14,6 @@ export {
|
|
|
15
14
|
RSCElementRenderer,
|
|
16
15
|
RenderContext,
|
|
17
16
|
RenderElementPayload,
|
|
18
|
-
ServerCSSCollector,
|
|
19
17
|
ServerElement,
|
|
20
18
|
Slot,
|
|
21
19
|
collectServerElements,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/server/index.ts"],"sourcesContent":["export { collectServerElements } from './collect-server-elements'\nexport { ServerElement } from './components/element'\nexport { MakeswiftComponent } from './components/makeswift-component'\nexport { Slot } from './components/slot'\nexport { RSCElementRenderer } from './components/renderer'\nexport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/server/index.ts"],"sourcesContent":["export { collectServerElements } from './collect-server-elements'\nexport { ServerElement } from './components/element'\nexport { MakeswiftComponent } from './components/makeswift-component'\nexport { Slot } from './components/slot'\nexport { RSCElementRenderer } from './components/renderer'\nexport {\n type ServerRenderContext,\n RenderContext,\n setRenderContext,\n getRenderContext,\n} from './render-context'\nexport { RenderElementPayload } from './render-element-payload'\n"],"mappings":"AAAA,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AACnC,SAAS,YAAY;AACrB,SAAS,0BAA0B;AACnC;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/server/render-context.tsx"],"sourcesContent":["import { cache, type PropsWithChildren } from 'react'\n\nimport { ReactRuntime } from '../../react/react-runtime'\nimport { type Store } from '../../../state/store'\n\nimport { type SiteVersion } from '../../../api/site-version'\nimport { MakeswiftClient } from '../../../client'\n\n/**\n * Request-scoped dependencies used to render Makeswift server elements.\n *\n * Framework integrations create a context for each request and install it with\n * `RenderContext` or `setRenderContext` so nested renderers can access it without\n * threading it through every component. The runtime must be request-bound;\n * together with `siteVersion` and `locale`, it selects the store and API resource\n * cache used during rendering.\n */\nexport type ServerRenderContext = {\n request: Request\n runtime: ReactRuntime\n client: MakeswiftClient\n siteVersion: SiteVersion | null\n locale: string | undefined\n store: Store\n}\n\nconst requestContext = cache((): { current?: ServerRenderContext } => ({}))\n\nexport const setRenderContext = (context: ServerRenderContext) => {\n requestContext().current = context\n}\n\nexport const getRenderContext = (): ServerRenderContext => {\n const context = requestContext().current\n if (!context) throw Error('Makeswift render context was not set.')\n return context\n}\n\nexport const getStore = ({ store }: ServerRenderContext): Store => store\n\nexport const RenderContext = ({\n context,\n children,\n}: PropsWithChildren<{ context: ServerRenderContext }>) => {\n setRenderContext(context)\n return children\n}\n"],"mappings":"AAAA,SAAS,aAAqC;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/server/render-context.tsx"],"sourcesContent":["import { cache, type PropsWithChildren } from 'react'\n\nimport { ReactRuntime } from '../../react/react-runtime'\nimport { type Store } from '../../../state/store'\n\nimport { type SiteVersion } from '../../../api/site-version'\nimport { MakeswiftClient } from '../../../client'\nimport { type RootStyleProps } from '../root-style-registry'\n\n/**\n * Request-scoped dependencies used to render Makeswift server elements.\n *\n * Framework integrations create a context for each request and install it with\n * `RenderContext` or `setRenderContext` so nested renderers can access it without\n * threading it through every component. The runtime must be request-bound;\n * together with `siteVersion` and `locale`, it selects the store and API resource\n * cache used during rendering.\n */\nexport type ServerRenderContext = {\n request: Request\n runtime: ReactRuntime\n client: MakeswiftClient\n siteVersion: SiteVersion | null\n locale: string | undefined\n store: Store\n rootStyleProps?: RootStyleProps\n}\n\nconst requestContext = cache((): { current?: ServerRenderContext } => ({}))\n\nexport const setRenderContext = (context: ServerRenderContext) => {\n requestContext().current = context\n}\n\nexport const getRenderContext = (): ServerRenderContext => {\n const context = requestContext().current\n if (!context) throw Error('Makeswift render context was not set.')\n return context\n}\n\nexport const getStore = ({ store }: ServerRenderContext): Store => store\n\nexport const RenderContext = ({\n context,\n children,\n}: PropsWithChildren<{ context: ServerRenderContext }>) => {\n setRenderContext(context)\n return children\n}\n"],"mappings":"AAAA,SAAS,aAAqC;AA4B9C,MAAM,iBAAiB,MAAM,OAA0C,CAAC,EAAE;AAEnE,MAAM,mBAAmB,CAAC,YAAiC;AAChE,iBAAe,EAAE,UAAU;AAC7B;AAEO,MAAM,mBAAmB,MAA2B;AACzD,QAAM,UAAU,eAAe,EAAE;AACjC,MAAI,CAAC;AAAS,UAAM,MAAM,uCAAuC;AACjE,SAAO;AACT;AAEO,MAAM,WAAW,CAAC,EAAE,MAAM,MAAkC;AAE5D,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AACF,MAA2D;AACzD,mBAAiB,OAAO;AACxB,SAAO;AACT;","names":[]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { cx } from "@emotion/css";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { Editor, Transforms, Range, Node, Text } from "slate";
|
|
4
3
|
import { Select, Slate } from "@makeswift/controls";
|
|
5
4
|
import { setBlockKeyForDevice } from "./setBlockKeyForDevice";
|
|
@@ -17,9 +16,10 @@ import { toggleList } from "./toggleList";
|
|
|
17
16
|
import { EditorUtils } from "../utils/editor";
|
|
18
17
|
import isHotkey from "is-hotkey";
|
|
19
18
|
import { LIST_ITEM_CHILD_POSITION } from "./constants";
|
|
20
|
-
import { useStyle } from "../../runtimes/react/use-style";
|
|
21
19
|
import { Plugin } from "../../controls/rich-text-v2/plugin";
|
|
22
20
|
import { BlockType } from "../../slate/types";
|
|
21
|
+
import { useStyle } from "../../runtimes/react/css-runtime/hooks/use-style";
|
|
22
|
+
import clsx from "clsx";
|
|
23
23
|
const BlockActions = {
|
|
24
24
|
setBlockKeyForDevice,
|
|
25
25
|
clearBlockKeyForDevice,
|
|
@@ -265,14 +265,17 @@ function BlockPluginComponent({
|
|
|
265
265
|
renderElement,
|
|
266
266
|
...props
|
|
267
267
|
}) {
|
|
268
|
-
const
|
|
269
|
-
|
|
268
|
+
const { className: blockStylesClassName, styleElement: blockStylesStyleElement } = useStyle({
|
|
269
|
+
margin: 0
|
|
270
|
+
});
|
|
271
|
+
const quoteStyles = {
|
|
270
272
|
padding: "0.5em 10px",
|
|
271
273
|
fontSize: "1.25em",
|
|
272
274
|
fontWeight: "300",
|
|
273
275
|
borderLeft: "5px solid rgba(0, 0, 0, 0.1)"
|
|
274
|
-
}
|
|
275
|
-
const
|
|
276
|
+
};
|
|
277
|
+
const { className: quoteStylesClassName, styleElement: quoteStylesStyleElement } = useStyle(quoteStyles);
|
|
278
|
+
const unorderedListStyles = {
|
|
276
279
|
listStylePosition: "inside",
|
|
277
280
|
paddingInlineStart: "20px",
|
|
278
281
|
listStyleType: "disc",
|
|
@@ -282,38 +285,115 @@ function BlockPluginComponent({
|
|
|
282
285
|
"ul ul": {
|
|
283
286
|
listStyleType: "square"
|
|
284
287
|
}
|
|
285
|
-
}
|
|
286
|
-
const
|
|
288
|
+
};
|
|
289
|
+
const { className: unorderedListStylesClassName, styleElement: unorderedListStyleElement } = useStyle(unorderedListStyles);
|
|
290
|
+
const orderedListStyles = {
|
|
287
291
|
listStylePosition: "inside",
|
|
288
292
|
paddingInlineStart: "20px",
|
|
289
293
|
listStyleType: "decimal"
|
|
290
|
-
}
|
|
294
|
+
};
|
|
295
|
+
const { className: orderedListStylesClassName, styleElement: orderedListStyleElement } = useStyle(orderedListStyles);
|
|
291
296
|
switch (props.element.type) {
|
|
292
297
|
case BlockType.Default:
|
|
293
298
|
case BlockType.Paragraph:
|
|
294
|
-
return /* @__PURE__ */
|
|
299
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
300
|
+
blockStylesStyleElement,
|
|
301
|
+
/* @__PURE__ */ jsx("p", { ...props.attributes, className: clsx(blockStylesClassName, props.element.className), children: renderElement(props) })
|
|
302
|
+
] });
|
|
295
303
|
case BlockType.Heading1:
|
|
296
|
-
return /* @__PURE__ */
|
|
304
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
305
|
+
blockStylesStyleElement,
|
|
306
|
+
/* @__PURE__ */ jsx("h1", { ...props.attributes, className: clsx(blockStylesClassName, props.element.className), children: renderElement(props) })
|
|
307
|
+
] });
|
|
297
308
|
case BlockType.Heading2:
|
|
298
|
-
return /* @__PURE__ */
|
|
309
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
310
|
+
blockStylesStyleElement,
|
|
311
|
+
/* @__PURE__ */ jsx("h2", { ...props.attributes, className: clsx(blockStylesClassName, props.element.className), children: renderElement(props) })
|
|
312
|
+
] });
|
|
299
313
|
case BlockType.Heading3:
|
|
300
|
-
return /* @__PURE__ */
|
|
314
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
315
|
+
blockStylesStyleElement,
|
|
316
|
+
/* @__PURE__ */ jsx("h3", { ...props.attributes, className: clsx(blockStylesClassName, props.element.className), children: renderElement(props) })
|
|
317
|
+
] });
|
|
301
318
|
case BlockType.Heading4:
|
|
302
|
-
return /* @__PURE__ */
|
|
319
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
320
|
+
blockStylesStyleElement,
|
|
321
|
+
/* @__PURE__ */ jsx("h4", { ...props.attributes, className: clsx(blockStylesClassName, props.element.className), children: renderElement(props) })
|
|
322
|
+
] });
|
|
303
323
|
case BlockType.Heading5:
|
|
304
|
-
return /* @__PURE__ */
|
|
324
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
325
|
+
blockStylesStyleElement,
|
|
326
|
+
/* @__PURE__ */ jsx("h5", { ...props.attributes, className: clsx(blockStylesClassName, props.element.className), children: renderElement(props) })
|
|
327
|
+
] });
|
|
305
328
|
case BlockType.Heading6:
|
|
306
|
-
return /* @__PURE__ */
|
|
329
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
330
|
+
blockStylesStyleElement,
|
|
331
|
+
/* @__PURE__ */ jsx("h6", { ...props.attributes, className: clsx(blockStylesClassName, props.element.className), children: renderElement(props) })
|
|
332
|
+
] });
|
|
307
333
|
case BlockType.BlockQuote:
|
|
308
|
-
return /* @__PURE__ */
|
|
334
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
335
|
+
blockStylesStyleElement,
|
|
336
|
+
quoteStylesStyleElement,
|
|
337
|
+
/* @__PURE__ */ jsx(
|
|
338
|
+
"blockquote",
|
|
339
|
+
{
|
|
340
|
+
...props.attributes,
|
|
341
|
+
className: clsx(blockStylesClassName, quoteStylesClassName, props.element.className),
|
|
342
|
+
children: renderElement(props)
|
|
343
|
+
}
|
|
344
|
+
)
|
|
345
|
+
] });
|
|
309
346
|
case BlockType.OrderedList:
|
|
310
|
-
return /* @__PURE__ */
|
|
347
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
348
|
+
blockStylesStyleElement,
|
|
349
|
+
orderedListStyleElement,
|
|
350
|
+
/* @__PURE__ */ jsx(
|
|
351
|
+
"ol",
|
|
352
|
+
{
|
|
353
|
+
...props.attributes,
|
|
354
|
+
className: clsx(
|
|
355
|
+
blockStylesClassName,
|
|
356
|
+
orderedListStylesClassName,
|
|
357
|
+
props.element.className
|
|
358
|
+
),
|
|
359
|
+
children: renderElement(props)
|
|
360
|
+
}
|
|
361
|
+
)
|
|
362
|
+
] });
|
|
311
363
|
case BlockType.UnorderedList:
|
|
312
|
-
return /* @__PURE__ */
|
|
364
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
365
|
+
blockStylesStyleElement,
|
|
366
|
+
unorderedListStyleElement,
|
|
367
|
+
/* @__PURE__ */ jsx(
|
|
368
|
+
"ul",
|
|
369
|
+
{
|
|
370
|
+
...props.attributes,
|
|
371
|
+
className: clsx(
|
|
372
|
+
blockStylesClassName,
|
|
373
|
+
unorderedListStylesClassName,
|
|
374
|
+
props.element.className
|
|
375
|
+
),
|
|
376
|
+
children: renderElement(props)
|
|
377
|
+
}
|
|
378
|
+
)
|
|
379
|
+
] });
|
|
313
380
|
case BlockType.ListItem:
|
|
314
|
-
return /* @__PURE__ */
|
|
381
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
382
|
+
blockStylesStyleElement,
|
|
383
|
+
/* @__PURE__ */ jsx("li", { ...props.attributes, className: clsx(blockStylesClassName, props.element.className), children: renderElement(props) })
|
|
384
|
+
] });
|
|
315
385
|
case BlockType.ListItemChild:
|
|
316
|
-
return /* @__PURE__ */
|
|
386
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
387
|
+
blockStylesStyleElement,
|
|
388
|
+
/* @__PURE__ */ jsx(
|
|
389
|
+
"span",
|
|
390
|
+
{
|
|
391
|
+
...props.attributes,
|
|
392
|
+
className: clsx(blockStylesClassName, props.element.className),
|
|
393
|
+
children: renderElement(props)
|
|
394
|
+
}
|
|
395
|
+
)
|
|
396
|
+
] });
|
|
317
397
|
default:
|
|
318
398
|
return /* @__PURE__ */ jsx(Fragment, { children: renderElement(props) });
|
|
319
399
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/slate/BlockPlugin/index.tsx"],"sourcesContent":["import type { KeyboardEvent } from 'react'\nimport { cx } from '@emotion/css'\nimport { Editor, Transforms, Range, Node, PathRef, Text } from 'slate'\nimport { type RenderElementProps } from 'slate-react'\nimport { Select, Slate, type DataType } from '@makeswift/controls'\n\nimport { setBlockKeyForDevice } from './setBlockKeyForDevice'\nimport { clearBlockKeyForDevice } from './clearBlockKeyForDevice'\nimport { wrapInline } from './wrapInline'\nimport { unwrapInline } from './unwrapInline'\nimport { getSelection } from '../selectors'\nimport { ElementUtils } from '../utils/element'\nimport { getActiveBlockType } from '../selectors'\nimport { unwrapList } from './unwrapList'\nimport { wrapList } from './wrapList'\nimport { indent } from './indent'\nimport { dedent } from './dedent'\nimport { toggleList } from './toggleList'\nimport { EditorUtils } from '../utils/editor'\nimport isHotkey from 'is-hotkey'\nimport { LIST_ITEM_CHILD_POSITION } from './constants'\nimport { useStyle } from '../../runtimes/react/use-style'\nimport { type RenderElement, Plugin } from '../../controls/rich-text-v2/plugin'\nimport { BlockType } from '../../slate/types'\n\nexport const BlockActions = {\n setBlockKeyForDevice,\n clearBlockKeyForDevice,\n wrapInline,\n unwrapInline,\n}\n\n// TODO: This API is still litered with artifacts from the list plugin being seperated out.\n// This plugin needs to be rewritten to be assumptionless.\nexport const ListActions = {\n unwrapList,\n wrapList,\n indent,\n dedent,\n toggleList,\n}\n\nexport function onKeyDown(e: KeyboardEvent, editor: Editor) {\n if (\n !editor.selection ||\n Array.from(Editor.nodes(editor, { match: node => Slate.isListItem(node) })).length === 0\n )\n return\n\n if (isHotkey('shift+tab', e)) {\n e.preventDefault()\n ListActions.dedent(editor)\n }\n\n if (isHotkey('tab', e)) {\n e.preventDefault()\n ListActions.indent(editor)\n }\n\n if (isHotkey('backspace', e)) {\n if (!editor.selection) return\n if (Range.isExpanded(editor.selection)) return\n const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path)\n if (editor.selection.anchor.offset === 0 && listItem) {\n e.preventDefault()\n const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1])\n const list = EditorUtils.getFirstAncestorList(editor, listItem[1])\n\n if (parentListItem) {\n ListActions.dedent(editor)\n } else if (list) {\n ListActions.unwrapList(editor)\n }\n return\n }\n }\n\n if (isHotkey('enter', e)) {\n e.preventDefault()\n\n if (!editor.selection) return\n\n if (Range.isExpanded(editor.selection)) {\n Transforms.delete(editor)\n return\n }\n\n const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path)\n if (\n editor.selection.anchor.offset === 0 &&\n listItem &&\n Editor.string(editor, listItem[1]) === ''\n ) {\n const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1])\n\n if (parentListItem) {\n ListActions.dedent(editor)\n } else {\n ListActions.unwrapList(editor)\n }\n return\n }\n\n Transforms.splitNodes(editor, {\n at: editor.selection,\n always: true,\n match: node => Slate.isListItem(node),\n })\n }\n\n if (isHotkey('shift+enter', e)) {\n e.preventDefault()\n editor.insertText('\\n')\n }\n}\n\nexport function withBlock(editor: Editor) {\n const { normalizeNode } = editor\n\n editor.isInline = entry => {\n return Slate.isInline(entry)\n }\n\n editor.normalizeNode = entry => {\n const [normalizationNode, normalizationPath] = entry\n // Normalization textAlign with empty array of values\n if (Slate.isBlock(normalizationNode) && normalizationNode?.textAlign?.length == 0) {\n Transforms.unsetNodes(editor, 'textAlign', { at: normalizationPath })\n return\n }\n\n // Normalization for preventing non-list root blocks from being nested.\n if (\n normalizationPath.length === 1 &&\n Slate.isRootBlock(normalizationNode) &&\n !Slate.isList(normalizationNode)\n ) {\n const children = Array.from(Node.children(editor, normalizationPath))\n if (children.findIndex(([child]) => Slate.isRootBlock(child)) !== -1) {\n Transforms.unwrapNodes(editor, { at: normalizationPath })\n return\n }\n }\n\n // Normalization for converting children of list items to list item children\n // In the case of backspace from position 0 of node into a list this converts the node into a list item.\n if (Slate.isListItem(normalizationNode)) {\n const pathToListItemText = [...normalizationPath, LIST_ITEM_CHILD_POSITION]\n\n if (Node.has(editor, pathToListItemText)) {\n const nodeInListItemTextPosition = Node.get(editor, pathToListItemText)\n if (Slate.isRootBlock(nodeInListItemTextPosition)) {\n Transforms.setNodes(\n editor,\n { type: BlockType.ListItemChild },\n {\n at: pathToListItemText,\n },\n )\n return\n }\n } else {\n Transforms.insertNodes(editor, ElementUtils.createListItem(), {\n at: pathToListItemText,\n })\n return\n }\n }\n\n // Normalization for merging adjacent lists of the same type\n if (!Text.isText(normalizationNode)) {\n const mergeableChildren = Array.from(Node.children(editor, normalizationPath))\n .map((child, index, children) => {\n const potentialNodeToBeMerged = children.at(index + 1)\n if (\n !potentialNodeToBeMerged ||\n !Slate.isList(potentialNodeToBeMerged[0]) ||\n !Slate.isList(child[0]) ||\n potentialNodeToBeMerged[0].type !== child[0].type\n ) {\n return null\n }\n return [\n Editor.pathRef(editor, child[1]),\n Editor.pathRef(editor, potentialNodeToBeMerged[1]),\n ]\n })\n .filter((mergeableNodes): mergeableNodes is PathRef[] => Boolean(mergeableNodes))\n\n if (mergeableChildren.length !== 0) {\n mergeableChildren.reverse().forEach(([nodePathRef, nodeToBeMergedPathRef]) => {\n const nodePath = nodePathRef.current\n const nodeToBeMergedPath = nodeToBeMergedPathRef.current\n if (nodePath == null || nodeToBeMergedPath == null) return\n const nodeChildren = Array.from(Node.children(editor, nodePath))\n const childrenToBeMerged = Array.from(Node.children(editor, nodeToBeMergedPath))\n Editor.withoutNormalizing(editor, () => {\n childrenToBeMerged.reverse().forEach(([_, childPath]) => {\n Transforms.moveNodes(editor, {\n at: childPath,\n to: [...nodePath, nodeChildren.length],\n })\n })\n Transforms.removeNodes(editor, { at: nodeToBeMergedPath })\n })\n nodePathRef.unref()\n nodeToBeMergedPathRef.unref()\n })\n return\n }\n }\n\n normalizeNode(entry)\n }\n\n return editor\n}\n\nconst definition = Select({\n label: 'Block',\n labelOrientation: 'horizontal',\n options: [\n {\n value: BlockType.Paragraph,\n label: 'Paragraph',\n },\n {\n value: BlockType.Heading1,\n label: 'Heading 1',\n },\n {\n value: BlockType.Heading2,\n label: 'Heading 2',\n },\n {\n value: BlockType.Heading3,\n label: 'Heading 3',\n },\n {\n value: BlockType.Heading4,\n label: 'Heading 4',\n },\n {\n value: BlockType.Heading5,\n label: 'Heading 5',\n },\n {\n value: BlockType.Heading6,\n label: 'Heading 6',\n },\n {\n value: BlockType.UnorderedList,\n label: 'Bulleted list',\n },\n {\n value: BlockType.OrderedList,\n label: 'Numbered list',\n },\n {\n value: BlockType.BlockQuote,\n label: 'Quote',\n },\n ],\n defaultValue: BlockType.Paragraph,\n})\n\nexport function BlockPlugin() {\n return Plugin({\n withPlugin: withBlock,\n onKeyDown: onKeyDown,\n control: {\n definition,\n onChange: (editor, value: DataType<typeof definition>) => {\n // TODO: This onChange being so complex is an artifact of how the List plugin used to be seperated out from the block plugin.\n // Would be great to refactor and simplify here.\n\n const activeBlockType = getActiveBlockType(editor)\n if (value === BlockType.UnorderedList || value === BlockType.OrderedList) {\n ListActions.toggleList(editor, {\n type: value,\n at: getSelection(editor),\n })\n } else if (activeBlockType === value) {\n Transforms.setNodes(\n editor,\n {\n type: BlockType.Default,\n },\n { at: getSelection(editor) },\n )\n } else {\n ListActions.unwrapList(editor, {\n at: getSelection(editor),\n })\n Transforms.setNodes(\n editor,\n {\n type: value ?? BlockType.Default,\n },\n { at: getSelection(editor) },\n )\n }\n },\n getValue: editor => {\n const activeBlock = getActiveBlockType(editor)\n\n if (activeBlock == null) return undefined\n if (activeBlock === Slate.RootBlockType.Default) return undefined\n\n return activeBlock\n },\n },\n renderElement: renderElement => props => (\n <BlockPluginComponent {...props} renderElement={renderElement} />\n ),\n })\n}\n\nfunction BlockPluginComponent({\n renderElement,\n ...props\n}: RenderElementProps & { renderElement: RenderElement }) {\n const blockStyles = [useStyle({ margin: 0 }), props.element.className]\n const quoteStyles = 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 const unorderedListStyles = useStyle({\n listStylePosition: 'inside',\n paddingInlineStart: '20px',\n listStyleType: 'disc',\n ul: {\n listStyleType: 'circle',\n },\n 'ul ul': {\n listStyleType: 'square',\n },\n })\n\n const orderedListStyles = useStyle({\n listStylePosition: 'inside',\n paddingInlineStart: '20px',\n listStyleType: 'decimal',\n })\n\n switch (props.element.type) {\n case BlockType.Default:\n case BlockType.Paragraph:\n return (\n <p {...props.attributes} className={cx(...blockStyles)}>\n {renderElement(props)}\n </p>\n )\n case BlockType.Heading1:\n return (\n <h1 {...props.attributes} className={cx(...blockStyles)}>\n {renderElement(props)}\n </h1>\n )\n case BlockType.Heading2:\n return (\n <h2 {...props.attributes} className={cx(...blockStyles)}>\n {renderElement(props)}\n </h2>\n )\n case BlockType.Heading3:\n return (\n <h3 {...props.attributes} className={cx(...blockStyles)}>\n {renderElement(props)}\n </h3>\n )\n case BlockType.Heading4:\n return (\n <h4 {...props.attributes} className={cx(...blockStyles)}>\n {renderElement(props)}\n </h4>\n )\n case BlockType.Heading5:\n return (\n <h5 {...props.attributes} className={cx(...blockStyles)}>\n {renderElement(props)}\n </h5>\n )\n case BlockType.Heading6:\n return (\n <h6 {...props.attributes} className={cx(...blockStyles)}>\n {renderElement(props)}\n </h6>\n )\n case BlockType.BlockQuote:\n return (\n <blockquote {...props.attributes} className={cx(...blockStyles, quoteStyles)}>\n {renderElement(props)}\n </blockquote>\n )\n case BlockType.OrderedList:\n return (\n <ol {...props.attributes} className={cx(...blockStyles, orderedListStyles)}>\n {renderElement(props)}\n </ol>\n )\n case BlockType.UnorderedList:\n return (\n <ul {...props.attributes} className={cx(...blockStyles, unorderedListStyles)}>\n {renderElement(props)}\n </ul>\n )\n case BlockType.ListItem:\n return (\n <li {...props.attributes} className={cx(...blockStyles)}>\n {renderElement(props)}\n </li>\n )\n case BlockType.ListItemChild:\n return (\n <span {...props.attributes} className={cx(...blockStyles)}>\n {renderElement(props)}\n </span>\n )\n default:\n return <>{renderElement(props)}</>\n }\n}\n"],"mappings":"AAyTM,SA8GO,UA9GP;AAxTN,SAAS,UAAU;AACnB,SAAS,QAAQ,YAAY,OAAO,MAAe,YAAY;AAE/D,SAAS,QAAQ,aAA4B;AAE7C,SAAS,4BAA4B;AACrC,SAAS,8BAA8B;AACvC,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,OAAO,cAAc;AACrB,SAAS,gCAAgC;AACzC,SAAS,gBAAgB;AACzB,SAA6B,cAAc;AAC3C,SAAS,iBAAiB;AAEnB,MAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIO,MAAM,cAAc;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,SAAS,UAAU,GAAkB,QAAgB;AAC1D,MACE,CAAC,OAAO,aACR,MAAM,KAAK,OAAO,MAAM,QAAQ,EAAE,OAAO,UAAQ,MAAM,WAAW,IAAI,EAAE,CAAC,CAAC,EAAE,WAAW;AAEvF;AAEF,MAAI,SAAS,aAAa,CAAC,GAAG;AAC5B,MAAE,eAAe;AACjB,gBAAY,OAAO,MAAM;AAAA,EAC3B;AAEA,MAAI,SAAS,OAAO,CAAC,GAAG;AACtB,MAAE,eAAe;AACjB,gBAAY,OAAO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AAM,YAAY,WAAW,GAAG,GAAG,WAAW,GACrD,wBAAc,KAAK,GACtB;AAAA,IAEJ;AACE,aAAO,gCAAG,wBAAc,KAAK,GAAE;AAAA,EACnC;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/slate/BlockPlugin/index.tsx"],"sourcesContent":["import type { KeyboardEvent } from 'react'\nimport { Editor, Transforms, Range, Node, PathRef, Text } from 'slate'\nimport { type RenderElementProps } from 'slate-react'\nimport { Select, Slate, type DataType } from '@makeswift/controls'\n\nimport { setBlockKeyForDevice } from './setBlockKeyForDevice'\nimport { clearBlockKeyForDevice } from './clearBlockKeyForDevice'\nimport { wrapInline } from './wrapInline'\nimport { unwrapInline } from './unwrapInline'\nimport { getSelection } from '../selectors'\nimport { ElementUtils } from '../utils/element'\nimport { getActiveBlockType } from '../selectors'\nimport { unwrapList } from './unwrapList'\nimport { wrapList } from './wrapList'\nimport { indent } from './indent'\nimport { dedent } from './dedent'\nimport { toggleList } from './toggleList'\nimport { EditorUtils } from '../utils/editor'\nimport isHotkey from 'is-hotkey'\nimport { LIST_ITEM_CHILD_POSITION } from './constants'\nimport { type RenderElement, Plugin } from '../../controls/rich-text-v2/plugin'\nimport { BlockType } from '../../slate/types'\nimport { useStyle } from '../../runtimes/react/css-runtime/hooks/use-style'\nimport clsx from 'clsx'\nimport { CSSObject } from '@emotion/serialize'\n\nexport const BlockActions = {\n setBlockKeyForDevice,\n clearBlockKeyForDevice,\n wrapInline,\n unwrapInline,\n}\n\n// TODO: This API is still litered with artifacts from the list plugin being seperated out.\n// This plugin needs to be rewritten to be assumptionless.\nexport const ListActions = {\n unwrapList,\n wrapList,\n indent,\n dedent,\n toggleList,\n}\n\nexport function onKeyDown(e: KeyboardEvent, editor: Editor) {\n if (\n !editor.selection ||\n Array.from(Editor.nodes(editor, { match: node => Slate.isListItem(node) })).length === 0\n )\n return\n\n if (isHotkey('shift+tab', e)) {\n e.preventDefault()\n ListActions.dedent(editor)\n }\n\n if (isHotkey('tab', e)) {\n e.preventDefault()\n ListActions.indent(editor)\n }\n\n if (isHotkey('backspace', e)) {\n if (!editor.selection) return\n if (Range.isExpanded(editor.selection)) return\n const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path)\n if (editor.selection.anchor.offset === 0 && listItem) {\n e.preventDefault()\n const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1])\n const list = EditorUtils.getFirstAncestorList(editor, listItem[1])\n\n if (parentListItem) {\n ListActions.dedent(editor)\n } else if (list) {\n ListActions.unwrapList(editor)\n }\n return\n }\n }\n\n if (isHotkey('enter', e)) {\n e.preventDefault()\n\n if (!editor.selection) return\n\n if (Range.isExpanded(editor.selection)) {\n Transforms.delete(editor)\n return\n }\n\n const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path)\n if (\n editor.selection.anchor.offset === 0 &&\n listItem &&\n Editor.string(editor, listItem[1]) === ''\n ) {\n const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1])\n\n if (parentListItem) {\n ListActions.dedent(editor)\n } else {\n ListActions.unwrapList(editor)\n }\n return\n }\n\n Transforms.splitNodes(editor, {\n at: editor.selection,\n always: true,\n match: node => Slate.isListItem(node),\n })\n }\n\n if (isHotkey('shift+enter', e)) {\n e.preventDefault()\n editor.insertText('\\n')\n }\n}\n\nexport function withBlock(editor: Editor) {\n const { normalizeNode } = editor\n\n editor.isInline = entry => {\n return Slate.isInline(entry)\n }\n\n editor.normalizeNode = entry => {\n const [normalizationNode, normalizationPath] = entry\n // Normalization textAlign with empty array of values\n if (Slate.isBlock(normalizationNode) && normalizationNode?.textAlign?.length == 0) {\n Transforms.unsetNodes(editor, 'textAlign', { at: normalizationPath })\n return\n }\n\n // Normalization for preventing non-list root blocks from being nested.\n if (\n normalizationPath.length === 1 &&\n Slate.isRootBlock(normalizationNode) &&\n !Slate.isList(normalizationNode)\n ) {\n const children = Array.from(Node.children(editor, normalizationPath))\n if (children.findIndex(([child]) => Slate.isRootBlock(child)) !== -1) {\n Transforms.unwrapNodes(editor, { at: normalizationPath })\n return\n }\n }\n\n // Normalization for converting children of list items to list item children\n // In the case of backspace from position 0 of node into a list this converts the node into a list item.\n if (Slate.isListItem(normalizationNode)) {\n const pathToListItemText = [...normalizationPath, LIST_ITEM_CHILD_POSITION]\n\n if (Node.has(editor, pathToListItemText)) {\n const nodeInListItemTextPosition = Node.get(editor, pathToListItemText)\n if (Slate.isRootBlock(nodeInListItemTextPosition)) {\n Transforms.setNodes(\n editor,\n { type: BlockType.ListItemChild },\n {\n at: pathToListItemText,\n },\n )\n return\n }\n } else {\n Transforms.insertNodes(editor, ElementUtils.createListItem(), {\n at: pathToListItemText,\n })\n return\n }\n }\n\n // Normalization for merging adjacent lists of the same type\n if (!Text.isText(normalizationNode)) {\n const mergeableChildren = Array.from(Node.children(editor, normalizationPath))\n .map((child, index, children) => {\n const potentialNodeToBeMerged = children.at(index + 1)\n if (\n !potentialNodeToBeMerged ||\n !Slate.isList(potentialNodeToBeMerged[0]) ||\n !Slate.isList(child[0]) ||\n potentialNodeToBeMerged[0].type !== child[0].type\n ) {\n return null\n }\n return [\n Editor.pathRef(editor, child[1]),\n Editor.pathRef(editor, potentialNodeToBeMerged[1]),\n ]\n })\n .filter((mergeableNodes): mergeableNodes is PathRef[] => Boolean(mergeableNodes))\n\n if (mergeableChildren.length !== 0) {\n mergeableChildren.reverse().forEach(([nodePathRef, nodeToBeMergedPathRef]) => {\n const nodePath = nodePathRef.current\n const nodeToBeMergedPath = nodeToBeMergedPathRef.current\n if (nodePath == null || nodeToBeMergedPath == null) return\n const nodeChildren = Array.from(Node.children(editor, nodePath))\n const childrenToBeMerged = Array.from(Node.children(editor, nodeToBeMergedPath))\n Editor.withoutNormalizing(editor, () => {\n childrenToBeMerged.reverse().forEach(([_, childPath]) => {\n Transforms.moveNodes(editor, {\n at: childPath,\n to: [...nodePath, nodeChildren.length],\n })\n })\n Transforms.removeNodes(editor, { at: nodeToBeMergedPath })\n })\n nodePathRef.unref()\n nodeToBeMergedPathRef.unref()\n })\n return\n }\n }\n\n normalizeNode(entry)\n }\n\n return editor\n}\n\nconst definition = Select({\n label: 'Block',\n labelOrientation: 'horizontal',\n options: [\n {\n value: BlockType.Paragraph,\n label: 'Paragraph',\n },\n {\n value: BlockType.Heading1,\n label: 'Heading 1',\n },\n {\n value: BlockType.Heading2,\n label: 'Heading 2',\n },\n {\n value: BlockType.Heading3,\n label: 'Heading 3',\n },\n {\n value: BlockType.Heading4,\n label: 'Heading 4',\n },\n {\n value: BlockType.Heading5,\n label: 'Heading 5',\n },\n {\n value: BlockType.Heading6,\n label: 'Heading 6',\n },\n {\n value: BlockType.UnorderedList,\n label: 'Bulleted list',\n },\n {\n value: BlockType.OrderedList,\n label: 'Numbered list',\n },\n {\n value: BlockType.BlockQuote,\n label: 'Quote',\n },\n ],\n defaultValue: BlockType.Paragraph,\n})\n\nexport function BlockPlugin() {\n return Plugin({\n withPlugin: withBlock,\n onKeyDown: onKeyDown,\n control: {\n definition,\n onChange: (editor, value: DataType<typeof definition>) => {\n // TODO: This onChange being so complex is an artifact of how the List plugin used to be seperated out from the block plugin.\n // Would be great to refactor and simplify here.\n\n const activeBlockType = getActiveBlockType(editor)\n if (value === BlockType.UnorderedList || value === BlockType.OrderedList) {\n ListActions.toggleList(editor, {\n type: value,\n at: getSelection(editor),\n })\n } else if (activeBlockType === value) {\n Transforms.setNodes(\n editor,\n {\n type: BlockType.Default,\n },\n { at: getSelection(editor) },\n )\n } else {\n ListActions.unwrapList(editor, {\n at: getSelection(editor),\n })\n Transforms.setNodes(\n editor,\n {\n type: value ?? BlockType.Default,\n },\n { at: getSelection(editor) },\n )\n }\n },\n getValue: editor => {\n const activeBlock = getActiveBlockType(editor)\n\n if (activeBlock == null) return undefined\n if (activeBlock === Slate.RootBlockType.Default) return undefined\n\n return activeBlock\n },\n },\n renderElement: renderElement => props => (\n <BlockPluginComponent {...props} renderElement={renderElement} />\n ),\n })\n}\n\nfunction BlockPluginComponent({\n renderElement,\n ...props\n}: RenderElementProps & { renderElement: RenderElement }) {\n const { className: blockStylesClassName, styleElement: blockStylesStyleElement } = useStyle({\n margin: 0,\n })\n const quoteStyles = {\n padding: '0.5em 10px',\n fontSize: '1.25em',\n fontWeight: '300',\n borderLeft: '5px solid rgba(0, 0, 0, 0.1)',\n }\n const { className: quoteStylesClassName, styleElement: quoteStylesStyleElement } =\n useStyle(quoteStyles)\n\n const unorderedListStyles: CSSObject = {\n listStylePosition: 'inside',\n paddingInlineStart: '20px',\n listStyleType: 'disc',\n ul: {\n listStyleType: 'circle',\n },\n 'ul ul': {\n listStyleType: 'square',\n },\n }\n const { className: unorderedListStylesClassName, styleElement: unorderedListStyleElement } =\n useStyle(unorderedListStyles)\n\n const orderedListStyles: CSSObject = {\n listStylePosition: 'inside',\n paddingInlineStart: '20px',\n listStyleType: 'decimal',\n }\n const { className: orderedListStylesClassName, styleElement: orderedListStyleElement } =\n useStyle(orderedListStyles)\n\n switch (props.element.type) {\n case BlockType.Default:\n case BlockType.Paragraph:\n return (\n <>\n {blockStylesStyleElement}\n <p {...props.attributes} className={clsx(blockStylesClassName, props.element.className)}>\n {renderElement(props)}\n </p>\n </>\n )\n case BlockType.Heading1:\n return (\n <>\n {blockStylesStyleElement}\n <h1 {...props.attributes} className={clsx(blockStylesClassName, props.element.className)}>\n {renderElement(props)}\n </h1>\n </>\n )\n case BlockType.Heading2:\n return (\n <>\n {blockStylesStyleElement}\n <h2 {...props.attributes} className={clsx(blockStylesClassName, props.element.className)}>\n {renderElement(props)}\n </h2>\n </>\n )\n case BlockType.Heading3:\n return (\n <>\n {blockStylesStyleElement}\n <h3 {...props.attributes} className={clsx(blockStylesClassName, props.element.className)}>\n {renderElement(props)}\n </h3>\n </>\n )\n case BlockType.Heading4:\n return (\n <>\n {blockStylesStyleElement}\n <h4 {...props.attributes} className={clsx(blockStylesClassName, props.element.className)}>\n {renderElement(props)}\n </h4>\n </>\n )\n case BlockType.Heading5:\n return (\n <>\n {blockStylesStyleElement}\n <h5 {...props.attributes} className={clsx(blockStylesClassName, props.element.className)}>\n {renderElement(props)}\n </h5>\n </>\n )\n case BlockType.Heading6:\n return (\n <>\n {blockStylesStyleElement}\n <h6 {...props.attributes} className={clsx(blockStylesClassName, props.element.className)}>\n {renderElement(props)}\n </h6>\n </>\n )\n case BlockType.BlockQuote:\n return (\n <>\n {blockStylesStyleElement}\n {quoteStylesStyleElement}\n <blockquote\n {...props.attributes}\n className={clsx(blockStylesClassName, quoteStylesClassName, props.element.className)}\n >\n {renderElement(props)}\n </blockquote>\n </>\n )\n case BlockType.OrderedList:\n return (\n <>\n {blockStylesStyleElement}\n {orderedListStyleElement}\n <ol\n {...props.attributes}\n className={clsx(\n blockStylesClassName,\n orderedListStylesClassName,\n props.element.className,\n )}\n >\n {renderElement(props)}\n </ol>\n </>\n )\n case BlockType.UnorderedList:\n return (\n <>\n {blockStylesStyleElement}\n {unorderedListStyleElement}\n <ul\n {...props.attributes}\n className={clsx(\n blockStylesClassName,\n unorderedListStylesClassName,\n props.element.className,\n )}\n >\n {renderElement(props)}\n </ul>\n </>\n )\n case BlockType.ListItem:\n return (\n <>\n {blockStylesStyleElement}\n <li {...props.attributes} className={clsx(blockStylesClassName, props.element.className)}>\n {renderElement(props)}\n </li>\n </>\n )\n case BlockType.ListItemChild:\n return (\n <>\n {blockStylesStyleElement}\n <span\n {...props.attributes}\n className={clsx(blockStylesClassName, props.element.className)}\n >\n {renderElement(props)}\n </span>\n </>\n )\n default:\n return <>{renderElement(props)}</>\n }\n}\n"],"mappings":"AA0TM,SA+CE,UA/CF,KA+CE,YA/CF;AAzTN,SAAS,QAAQ,YAAY,OAAO,MAAe,YAAY;AAE/D,SAAS,QAAQ,aAA4B;AAE7C,SAAS,4BAA4B;AACrC,SAAS,8BAA8B;AACvC,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACn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AAAA,UAAC;AAAA;AAAA,YACE,GAAG,MAAM;AAAA,YACV,WAAW;AAAA,cACT;AAAA,cACA;AAAA,cACA,MAAM,QAAQ;AAAA,YAChB;AAAA,YAEC,wBAAc,KAAK;AAAA;AAAA,QACtB;AAAA,SACF;AAAA,IAEJ,KAAK,UAAU;AACb,aACE,iCACG;AAAA;AAAA,QACD,oBAAC,QAAI,GAAG,MAAM,YAAY,WAAW,KAAK,sBAAsB,MAAM,QAAQ,SAAS,GACpF,wBAAc,KAAK,GACtB;AAAA,SACF;AAAA,IAEJ,KAAK,UAAU;AACb,aACE,iCACG;AAAA;AAAA,QACD;AAAA,UAAC;AAAA;AAAA,YACE,GAAG,MAAM;AAAA,YACV,WAAW,KAAK,sBAAsB,MAAM,QAAQ,SAAS;AAAA,YAE5D,wBAAc,KAAK;AAAA;AAAA,QACtB;AAAA,SACF;AAAA,IAEJ;AACE,aAAO,gCAAG,wBAAc,KAAK,GAAE;AAAA,EACnC;AACF;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { cx } from "@emotion/css";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { Slate } from "@makeswift/controls";
|
|
4
3
|
import { Link } from "../../controls/link";
|
|
5
|
-
import { useStyle } from "../../runtimes/react/use-style";
|
|
6
4
|
import { Link as LinkComponent } from "../../components/shared/Link";
|
|
7
5
|
import { Plugin } from "../../controls/rich-text-v2/plugin";
|
|
8
6
|
import { onChange } from "./onChange";
|
|
9
7
|
import { getValue } from "./getValue";
|
|
8
|
+
import { useStyle } from "../../runtimes/react/css-runtime/hooks/use-style";
|
|
9
|
+
import clsx from "clsx";
|
|
10
10
|
const withLink = (editor) => {
|
|
11
11
|
const { isInline } = editor;
|
|
12
12
|
editor.isInline = (entry) => {
|
|
@@ -20,22 +20,27 @@ function InlinePluginComponent({
|
|
|
20
20
|
children,
|
|
21
21
|
renderElement
|
|
22
22
|
}) {
|
|
23
|
-
const
|
|
23
|
+
const { className: linkClassName, styleElement: linkStyleElement } = useStyle({
|
|
24
|
+
textDecoration: "none"
|
|
25
|
+
});
|
|
24
26
|
switch (element.type) {
|
|
25
27
|
case Slate.InlineType.Link:
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
element,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
29
|
+
linkStyleElement,
|
|
30
|
+
/* @__PURE__ */ jsx(
|
|
31
|
+
LinkComponent,
|
|
32
|
+
{
|
|
33
|
+
...attributes,
|
|
34
|
+
link: element.link ?? void 0,
|
|
35
|
+
className: clsx(linkClassName, element.className),
|
|
36
|
+
children: renderElement({
|
|
37
|
+
element,
|
|
38
|
+
attributes,
|
|
39
|
+
children
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
] });
|
|
39
44
|
default:
|
|
40
45
|
return /* @__PURE__ */ jsx(Fragment, { children: renderElement({
|
|
41
46
|
element,
|
|
@@ -48,7 +53,7 @@ function LinkPlugin() {
|
|
|
48
53
|
return Plugin({
|
|
49
54
|
control: {
|
|
50
55
|
definition: Link({
|
|
51
|
-
label: "On
|
|
56
|
+
label: "On click"
|
|
52
57
|
}),
|
|
53
58
|
onChange,
|
|
54
59
|
getValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/slate/LinkPlugin/index.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/slate/LinkPlugin/index.tsx"],"sourcesContent":["import { type Editor, Element } from 'slate'\nimport { type RenderElementProps } from 'slate-react'\nimport { Slate } from '@makeswift/controls'\n\nimport { Link } from '../../controls/link'\nimport { Link as LinkComponent } from '../../components/shared/Link'\nimport { type RenderElement, Plugin } from '../../controls/rich-text-v2/plugin'\n\nimport { onChange } from './onChange'\nimport { getValue } from './getValue'\nimport { useStyle } from '../../runtimes/react/css-runtime/hooks/use-style'\nimport clsx from 'clsx'\n\nexport const withLink = (editor: Editor) => {\n const { isInline } = editor\n\n editor.isInline = entry => {\n return Slate.isInline(entry) && isInline(entry)\n }\n\n return editor\n}\n\nfunction InlinePluginComponent({\n element,\n attributes,\n children,\n renderElement,\n}: RenderElementProps & { renderElement: RenderElement }) {\n const { className: linkClassName, styleElement: linkStyleElement } = useStyle({\n textDecoration: 'none',\n })\n switch (element.type) {\n case Slate.InlineType.Link:\n return (\n <>\n {linkStyleElement}\n <LinkComponent\n {...attributes}\n link={element.link ?? undefined}\n className={clsx(linkClassName, element.className)}\n >\n {renderElement({\n element,\n attributes,\n children,\n })}\n </LinkComponent>\n </>\n )\n\n default:\n return (\n <>\n {renderElement({\n element,\n attributes,\n children,\n })}\n </>\n )\n }\n}\n\nexport function LinkPlugin() {\n return Plugin({\n control: {\n definition: Link({\n label: 'On click',\n }),\n onChange,\n getValue,\n getElementValue: (element: Element) => {\n return Slate.isLink(element) ? element.link : undefined\n },\n },\n withPlugin: withLink,\n renderElement: renderElement => props => {\n return <InlinePluginComponent {...props} renderElement={renderElement} />\n },\n })\n}\n"],"mappings":"AAmCQ,mBAEE,KAFF;AAjCR,SAAS,aAAa;AAEtB,SAAS,YAAY;AACrB,SAAS,QAAQ,qBAAqB;AACtC,SAA6B,cAAc;AAE3C,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,OAAO,UAAU;AAEV,MAAM,WAAW,CAAC,WAAmB;AAC1C,QAAM,EAAE,SAAS,IAAI;AAErB,SAAO,WAAW,WAAS;AACzB,WAAO,MAAM,SAAS,KAAK,KAAK,SAAS,KAAK;AAAA,EAChD;AAEA,SAAO;AACT;AAEA,SAAS,sBAAsB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA0D;AACxD,QAAM,EAAE,WAAW,eAAe,cAAc,iBAAiB,IAAI,SAAS;AAAA,IAC5E,gBAAgB;AAAA,EAClB,CAAC;AACD,UAAQ,QAAQ,MAAM;AAAA,IACpB,KAAK,MAAM,WAAW;AACpB,aACE,iCACG;AAAA;AAAA,QACD;AAAA,UAAC;AAAA;AAAA,YACE,GAAG;AAAA,YACJ,MAAM,QAAQ,QAAQ;AAAA,YACtB,WAAW,KAAK,eAAe,QAAQ,SAAS;AAAA,YAE/C,wBAAc;AAAA,cACb;AAAA,cACA;AAAA,cACA;AAAA,YACF,CAAC;AAAA;AAAA,QACH;AAAA,SACF;AAAA,IAGJ;AACE,aACE,gCACG,wBAAc;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC,GACH;AAAA,EAEN;AACF;AAEO,SAAS,aAAa;AAC3B,SAAO,OAAO;AAAA,IACZ,SAAS;AAAA,MACP,YAAY,KAAK;AAAA,QACf,OAAO;AAAA,MACT,CAAC;AAAA,MACD;AAAA,MACA;AAAA,MACA,iBAAiB,CAAC,YAAqB;AACrC,eAAO,MAAM,OAAO,OAAO,IAAI,QAAQ,OAAO;AAAA,MAChD;AAAA,IACF;AAAA,IACA,YAAY;AAAA,IACZ,eAAe,mBAAiB,WAAS;AACvC,aAAO,oBAAC,yBAAuB,GAAG,OAAO,eAA8B;AAAA,IACzE;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Editor, Text, Transforms } from "slate";
|
|
2
|
-
import { cx } from "@emotion/css";
|
|
3
2
|
import { unstable_Typography } from "@makeswift/controls";
|
|
4
3
|
import { clearActiveTypographyStyle } from "./clearActiveTypographyStyle";
|
|
5
4
|
import { clearDeviceActiveTypography } from "./clearDeviceActiveTypography";
|
|
@@ -12,6 +11,7 @@ import { Plugin } from "../../controls/rich-text-v2/plugin";
|
|
|
12
11
|
import { normalizeTypographyUp } from "./normalizeTypographyUp";
|
|
13
12
|
import { normalizeTypographyDown } from "./normalizeTypographyDown";
|
|
14
13
|
import { normalizeSimilarText } from "./normalizeSimilarText";
|
|
14
|
+
import clsx from "clsx";
|
|
15
15
|
const TypographyActions = {
|
|
16
16
|
setActiveTypographyId,
|
|
17
17
|
setActiveTypographyStyle,
|
|
@@ -101,7 +101,7 @@ function TypographyPlugin() {
|
|
|
101
101
|
...props,
|
|
102
102
|
leaf: {
|
|
103
103
|
...props.leaf,
|
|
104
|
-
className:
|
|
104
|
+
className: clsx(props.leaf.className, className)
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/slate/TypographyPlugin/index.ts"],"sourcesContent":["import { BaseEditor, Descendant, Editor, NodeEntry, Text, Transforms } from 'slate'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/slate/TypographyPlugin/index.ts"],"sourcesContent":["import { BaseEditor, Descendant, Editor, NodeEntry, Text, Transforms } from 'slate'\nimport { unstable_Typography } from '@makeswift/controls'\n\nimport { clearActiveTypographyStyle } from './clearActiveTypographyStyle'\nimport { clearDeviceActiveTypography } from './clearDeviceActiveTypography'\nimport { detachActiveTypography } from './detachActiveTypography'\nimport { setActiveTypographyId } from './setActiveTypographyId'\nimport { setActiveTypographyStyle } from './setActiveTypographyStyle'\nimport { getValue } from './getValue'\nimport { getSelection } from '../selectors'\nimport { Plugin } from '../../controls/rich-text-v2/plugin'\nimport { normalizeTypographyUp } from './normalizeTypographyUp'\nimport { normalizeTypographyDown } from './normalizeTypographyDown'\nimport { normalizeSimilarText } from './normalizeSimilarText'\nimport clsx from 'clsx'\n\nexport const TypographyActions = {\n setActiveTypographyId,\n setActiveTypographyStyle,\n clearActiveTypographyStyle,\n clearDeviceActiveTypography,\n detachActiveTypography,\n}\n\nexport const TYPOGRAPHY_KEY = 'typography'\n\nexport interface TypographyEditor extends BaseEditor {\n typographyNormalizationDirection?: 'up' | 'neutral' | 'down'\n}\n\nexport function withTypography(editor: Editor) {\n const { normalizeNode } = editor\n editor.normalizeNode = entry => {\n const [normalizationNode, normalizationPath] = entry\n\n if (\n 'typography' in normalizationNode &&\n normalizationNode?.typography?.id == null &&\n normalizationNode?.typography?.style.length === 0\n ) {\n Transforms.unsetNodes(editor, TYPOGRAPHY_KEY, { at: normalizationPath })\n return\n }\n\n if ('slice' in normalizationNode && normalizationNode?.slice != null) {\n Transforms.unsetNodes(editor, 'slice', { at: normalizationPath })\n return\n }\n\n if (normalizeSimilarText(editor, entry)) return\n\n if (editor.typographyNormalizationDirection === 'up' && normalizeTypographyUp(editor, entry))\n return\n\n if (\n (editor.typographyNormalizationDirection === 'down' ||\n editor.typographyNormalizationDirection == null) &&\n normalizeTypographyDown(editor, entry)\n )\n return\n\n normalizeNode(entry)\n }\n\n return editor\n}\n\nexport function TypographyPlugin() {\n return Plugin({\n withPlugin: withTypography,\n control: {\n definition: unstable_Typography(),\n onChange: (editor, value) => {\n Editor.withoutNormalizing(editor, () => {\n const at = getSelection(editor)\n if (!at) return\n const atRef = Editor.rangeRef(editor, at)\n if (atRef.current) {\n Transforms.setNodes<Descendant>(\n editor,\n {\n slice: true,\n },\n {\n at: atRef.current,\n match: Text.isText,\n split: true,\n },\n )\n }\n\n if (atRef.current) {\n const nodesToUpdate = Array.from(\n Editor.nodes(editor, {\n at: atRef.current,\n match: node => Text.isText(node) && node.slice === true,\n }),\n ) as NodeEntry<Text>[]\n\n if (nodesToUpdate.length !== value?.length)\n return console.error(\n `TypographyControl.onChange received the wrong number of arguments.\n Called with ${value?.length} values mapping to ${nodesToUpdate.length} nodes.`,\n )\n\n for (const [index, [, path]] of nodesToUpdate.entries()) {\n Transforms.setNodes(\n editor,\n {\n typography: value?.at(index),\n },\n { at: path, match: Text.isText },\n )\n }\n }\n\n atRef.unref()\n })\n },\n getValue,\n getLeafValue: (text: Text) => {\n return Text.isText(text) ? text.typography : undefined\n },\n },\n renderLeaf: (renderLeaf, className) => props => {\n return renderLeaf({\n ...props,\n leaf: {\n ...props.leaf,\n className: clsx(props.leaf.className, className),\n },\n })\n },\n })\n}\n"],"mappings":"AAAA,SAAiC,QAAmB,MAAM,kBAAkB;AAC5E,SAAS,2BAA2B;AAEpC,SAAS,kCAAkC;AAC3C,SAAS,mCAAmC;AAC5C,SAAS,8BAA8B;AACvC,SAAS,6BAA6B;AACtC,SAAS,gCAAgC;AACzC,SAAS,gBAAgB;AACzB,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,6BAA6B;AACtC,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AACrC,OAAO,UAAU;AAEV,MAAM,oBAAoB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,iBAAiB;AAMvB,SAAS,eAAe,QAAgB;AAC7C,QAAM,EAAE,cAAc,IAAI;AAC1B,SAAO,gBAAgB,WAAS;AAC9B,UAAM,CAAC,mBAAmB,iBAAiB,IAAI;AAE/C,QACE,gBAAgB,qBAChB,mBAAmB,YAAY,MAAM,QACrC,mBAAmB,YAAY,MAAM,WAAW,GAChD;AACA,iBAAW,WAAW,QAAQ,gBAAgB,EAAE,IAAI,kBAAkB,CAAC;AACvE;AAAA,IACF;AAEA,QAAI,WAAW,qBAAqB,mBAAmB,SAAS,MAAM;AACpE,iBAAW,WAAW,QAAQ,SAAS,EAAE,IAAI,kBAAkB,CAAC;AAChE;AAAA,IACF;AAEA,QAAI,qBAAqB,QAAQ,KAAK;AAAG;AAEzC,QAAI,OAAO,qCAAqC,QAAQ,sBAAsB,QAAQ,KAAK;AACzF;AAEF,SACG,OAAO,qCAAqC,UAC3C,OAAO,oCAAoC,SAC7C,wBAAwB,QAAQ,KAAK;AAErC;AAEF,kBAAc,KAAK;AAAA,EACrB;AAEA,SAAO;AACT;AAEO,SAAS,mBAAmB;AACjC,SAAO,OAAO;AAAA,IACZ,YAAY;AAAA,IACZ,SAAS;AAAA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AM;AAAA,UACT,WAAW,KAAK,MAAM,KAAK,WAAW,SAAS;AAAA,QACjD;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { DEFAULT_CSS_CLASS_NAME_PREFIX } from "../runtimes/react/css-runtime/constants";
|
|
2
|
+
import synchronizedPrettier from "@prettier/sync";
|
|
3
|
+
function getClassNamesInTree(root, filter) {
|
|
4
|
+
const discoveredClassnames = /* @__PURE__ */ new Set();
|
|
5
|
+
function process(current) {
|
|
6
|
+
if (!current)
|
|
7
|
+
return;
|
|
8
|
+
if (current instanceof Element) {
|
|
9
|
+
for (const className of current.classList) {
|
|
10
|
+
if (filter(className)) {
|
|
11
|
+
discoveredClassnames.add(className);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const children = current.children;
|
|
15
|
+
for (const child of children) {
|
|
16
|
+
process(child);
|
|
17
|
+
}
|
|
18
|
+
} else if (current instanceof Node) {
|
|
19
|
+
const children = current.childNodes;
|
|
20
|
+
for (const child of children) {
|
|
21
|
+
process(child);
|
|
22
|
+
}
|
|
23
|
+
} else if (current instanceof NodeList) {
|
|
24
|
+
for (const child of current) {
|
|
25
|
+
process(child);
|
|
26
|
+
}
|
|
27
|
+
} else if (Array.isArray(current)) {
|
|
28
|
+
for (const arrElement of current) {
|
|
29
|
+
process(arrElement);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
process(root);
|
|
34
|
+
return discoveredClassnames;
|
|
35
|
+
}
|
|
36
|
+
function getCssRulesForClassNames(classNames) {
|
|
37
|
+
if (classNames.size === 0)
|
|
38
|
+
return [];
|
|
39
|
+
const rules = [];
|
|
40
|
+
const styleElements = document.querySelectorAll("style");
|
|
41
|
+
for (const styleElement of styleElements) {
|
|
42
|
+
if (styleElement.sheet == null)
|
|
43
|
+
continue;
|
|
44
|
+
const cssRules = Array.from(styleElement.sheet.cssRules);
|
|
45
|
+
for (const cssRule of cssRules) {
|
|
46
|
+
for (const className of classNames) {
|
|
47
|
+
if (cssRule.cssText.includes(`.${className}`)) {
|
|
48
|
+
rules.push(cssRule);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return rules;
|
|
55
|
+
}
|
|
56
|
+
function isElementArray(val) {
|
|
57
|
+
return val && Array.isArray(val) && val.every((v) => v instanceof Element);
|
|
58
|
+
}
|
|
59
|
+
function isMakeswiftClassName(className) {
|
|
60
|
+
return className.startsWith(`${DEFAULT_CSS_CLASS_NAME_PREFIX}-`);
|
|
61
|
+
}
|
|
62
|
+
function formatRule(rule) {
|
|
63
|
+
const formatted = synchronizedPrettier.format(rule.cssText, {
|
|
64
|
+
parser: "css",
|
|
65
|
+
tabWidth: 2,
|
|
66
|
+
semi: true
|
|
67
|
+
});
|
|
68
|
+
return formatted;
|
|
69
|
+
}
|
|
70
|
+
function createMakeswiftStylesSnapshotSerializer() {
|
|
71
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
72
|
+
const isVisited = (val) => visited.has(val);
|
|
73
|
+
function test(val) {
|
|
74
|
+
return val && !isVisited(val) && (val instanceof Element || val instanceof Node || val instanceof NodeList || isElementArray(val));
|
|
75
|
+
}
|
|
76
|
+
function serialize(val, config, indentation, depth, refs, printer) {
|
|
77
|
+
visited.add(val);
|
|
78
|
+
try {
|
|
79
|
+
if (depth === 0) {
|
|
80
|
+
const classNames = getClassNamesInTree(val, isMakeswiftClassName);
|
|
81
|
+
const matchingCssRules = getCssRulesForClassNames(classNames);
|
|
82
|
+
const formattedRules = matchingCssRules.map((rule) => formatRule(rule));
|
|
83
|
+
const rulesToAppendToSnapshot = formattedRules.length > 0 ? formattedRules.join("\n") + "\n\n" : "";
|
|
84
|
+
return `${rulesToAppendToSnapshot}${printer(val, config, indentation, depth, refs)}`;
|
|
85
|
+
} else {
|
|
86
|
+
return printer(val, config, indentation, depth, refs);
|
|
87
|
+
}
|
|
88
|
+
} finally {
|
|
89
|
+
visited.delete(val);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
test,
|
|
94
|
+
serialize
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
createMakeswiftStylesSnapshotSerializer
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=jest-snapshot-serializer.js.map
|