@wordpress/block-editor 13.2.0 → 13.3.0
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/CHANGELOG.md +2 -0
- package/README.md +0 -1
- package/build/components/block-breadcrumb/index.js +12 -1
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-lock/toolbar.js +0 -1
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mover/button.js +1 -1
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +1 -1
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +5 -7
- package/build/components/block-patterns-paging/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +20 -17
- package/build/components/block-quick-navigation/index.js.map +1 -1
- package/build/components/block-rename/modal.js +4 -12
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +1 -0
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +7 -58
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/block-toolbar-breadcrumb.js +9 -2
- package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
- package/build/components/block-tools/index.js +14 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +4 -2
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-popover.js +57 -0
- package/build/components/block-tools/zoom-out-popover.js.map +1 -0
- package/build/components/block-tools/zoom-out-toolbar.js +138 -0
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -0
- package/build/components/button-block-appender/index.js +3 -1
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/child-layout-control/index.js +26 -18
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +10 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/dimensions-tool/index.js +6 -4
- package/build/components/dimensions-tool/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +26 -61
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +178 -116
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +2 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +2 -1
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +2 -1
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +8 -0
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +2 -1
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +50 -12
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +50 -0
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +23 -8
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +17 -7
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid/grid-item-movers.js +11 -14
- package/build/components/grid/grid-item-movers.js.map +1 -1
- package/build/components/grid/grid-item-resizer.js +2 -2
- package/build/components/grid/grid-item-resizer.js.map +1 -1
- package/build/components/grid/grid-visualizer.js +116 -36
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/grid/use-grid-layout-sync.js +29 -22
- package/build/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build/components/inner-blocks/index.js +1 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build/components/inserter/menu.js +26 -4
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +2 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/link-control/link-preview.js +1 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/media-placeholder/index.js +19 -23
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +3 -1
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/tabbed-sidebar/index.js +66 -0
- package/build/components/tabbed-sidebar/index.js.map +1 -0
- package/build/components/url-popover/index.js +3 -0
- package/build/components/url-popover/index.js.map +1 -1
- package/build/hooks/background.js +26 -4
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +11 -17
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-style-variation.js +169 -4
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/duotone.js +16 -11
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/grid-visualizer.js +65 -0
- package/build/hooks/grid-visualizer.js.map +1 -0
- package/build/hooks/index.js +15 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +39 -22
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/position.js +2 -9
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +16 -6
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/utils.js +2 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +44 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/grid.js +90 -51
- package/build/layouts/grid.js.map +1 -1
- package/build/private-apis.js +6 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/defaults.js +0 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/defaults.native.js +0 -3
- package/build/store/defaults.native.js.map +1 -1
- package/build/store/private-keys.js +2 -1
- package/build/store/private-keys.js.map +1 -1
- package/build/utils/format-font-style.js +45 -0
- package/build/utils/format-font-style.js.map +1 -0
- package/build/utils/format-font-weight.js +68 -0
- package/build/utils/format-font-weight.js.map +1 -0
- package/build/utils/get-editor-region.js +34 -0
- package/build/utils/get-editor-region.js.map +1 -0
- package/build/utils/get-font-styles-and-weights.js +167 -0
- package/build/utils/get-font-styles-and-weights.js.map +1 -0
- package/build/utils/pasting.js +5 -13
- package/build/utils/pasting.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +12 -1
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +0 -1
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-mover/button.js +1 -1
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +1 -1
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +5 -7
- package/build-module/components/block-patterns-paging/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +20 -17
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js +5 -13
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +1 -0
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +10 -61
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js +9 -2
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
- package/build-module/components/block-tools/index.js +14 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +4 -2
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-popover.js +48 -0
- package/build-module/components/block-tools/zoom-out-popover.js.map +1 -0
- package/build-module/components/block-tools/zoom-out-toolbar.js +131 -0
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -0
- package/build-module/components/button-block-appender/index.js +3 -1
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +27 -19
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +11 -3
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/dimensions-tool/index.js +6 -4
- package/build-module/components/dimensions-tool/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +28 -63
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +181 -119
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -2
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +3 -2
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +3 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +3 -2
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +8 -0
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +3 -2
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +52 -14
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +48 -0
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +23 -8
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +15 -6
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +11 -14
- package/build-module/components/grid/grid-item-movers.js.map +1 -1
- package/build-module/components/grid/grid-item-resizer.js +2 -2
- package/build-module/components/grid/grid-item-resizer.js.map +1 -1
- package/build-module/components/grid/grid-visualizer.js +117 -37
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/grid/use-grid-layout-sync.js +29 -22
- package/build-module/components/grid/use-grid-layout-sync.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +1 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build-module/components/inserter/menu.js +26 -4
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -2
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +1 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +19 -23
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +3 -1
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/tabbed-sidebar/index.js +60 -0
- package/build-module/components/tabbed-sidebar/index.js.map +1 -0
- package/build-module/components/url-popover/index.js +3 -0
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/hooks/background.js +26 -4
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +11 -17
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +168 -4
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/duotone.js +16 -11
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/grid-visualizer.js +64 -0
- package/build-module/hooks/grid-visualizer.js.map +1 -0
- package/build-module/hooks/index.js +3 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout-child.js +39 -22
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/position.js +2 -9
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +16 -6
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/utils.js +2 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +44 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/grid.js +90 -51
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/private-apis.js +8 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/defaults.js +0 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/defaults.native.js +0 -3
- package/build-module/store/defaults.native.js.map +1 -1
- package/build-module/store/private-keys.js +1 -0
- package/build-module/store/private-keys.js.map +1 -1
- package/build-module/utils/format-font-style.js +39 -0
- package/build-module/utils/format-font-style.js.map +1 -0
- package/build-module/utils/format-font-weight.js +62 -0
- package/build-module/utils/format-font-weight.js.map +1 -0
- package/build-module/utils/get-editor-region.js +28 -0
- package/build-module/utils/get-editor-region.js.map +1 -0
- package/build-module/utils/get-font-styles-and-weights.js +160 -0
- package/build-module/utils/get-font-styles-and-weights.js.map +1 -0
- package/build-module/utils/pasting.js +5 -13
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/content-rtl.css +1 -0
- package/build-style/content.css +1 -0
- package/build-style/style-rtl.css +207 -96
- package/build-style/style.css +207 -96
- package/package.json +32 -32
- package/src/components/block-breadcrumb/index.js +16 -1
- package/src/components/block-lock/toolbar.js +0 -1
- package/src/components/block-mover/button.js +1 -1
- package/src/components/block-mover/index.js +1 -1
- package/src/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/src/components/block-patterns-paging/index.js +8 -11
- package/src/components/block-patterns-paging/style.scss +18 -0
- package/src/components/block-quick-navigation/index.js +21 -28
- package/src/components/block-rename/modal.js +2 -8
- package/src/components/block-switcher/test/index.js +6 -6
- package/src/components/block-toolbar/shuffle.js +1 -0
- package/src/components/block-toolbar/style.scss +1 -11
- package/src/components/block-tools/block-selection-button.js +11 -83
- package/src/components/block-tools/block-toolbar-breadcrumb.js +9 -4
- package/src/components/block-tools/index.js +21 -1
- package/src/components/block-tools/style.scss +15 -0
- package/src/components/block-tools/use-show-block-tools.js +14 -6
- package/src/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/src/components/block-tools/zoom-out-popover.js +49 -0
- package/src/components/block-tools/zoom-out-toolbar.js +140 -0
- package/src/components/button-block-appender/index.js +2 -1
- package/src/components/child-layout-control/index.js +41 -23
- package/src/components/date-format-picker/index.js +10 -1
- package/src/components/date-format-picker/style.scss +0 -9
- package/src/components/dimensions-tool/index.js +97 -89
- package/src/components/font-appearance-control/index.js +29 -83
- package/src/components/font-appearance-control/style.scss +3 -5
- package/src/components/global-styles/background-panel.js +249 -170
- package/src/components/global-styles/border-panel.js +3 -2
- package/src/components/global-styles/color-panel.js +3 -2
- package/src/components/global-styles/dimensions-panel.js +3 -2
- package/src/components/global-styles/filters-panel.js +3 -2
- package/src/components/global-styles/hooks.js +9 -0
- package/src/components/global-styles/image-settings-panel.js +3 -2
- package/src/components/global-styles/style.scss +105 -20
- package/src/components/global-styles/test/typography-utils.js +269 -0
- package/src/components/global-styles/typography-panel.js +49 -12
- package/src/components/global-styles/typography-utils.js +63 -0
- package/src/components/global-styles/use-global-styles-output.js +23 -8
- package/src/components/global-styles/utils.js +17 -6
- package/src/components/grid/grid-item-movers.js +11 -27
- package/src/components/grid/grid-item-resizer.js +3 -2
- package/src/components/grid/grid-visualizer.js +171 -54
- package/src/components/grid/style.scss +43 -8
- package/src/components/grid/use-grid-layout-sync.js +31 -28
- package/src/components/iframe/content.scss +1 -0
- package/src/components/inner-blocks/index.js +2 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -16
- package/src/components/inserter/menu.js +47 -13
- package/src/components/inserter/quick-inserter.js +6 -1
- package/src/components/inserter/style.scss +1 -49
- package/src/components/inspector-controls/block-support-tools-panel.js +3 -3
- package/src/components/link-control/link-preview.js +1 -1
- package/src/components/media-placeholder/index.js +22 -32
- package/src/components/navigable-toolbar/index.js +3 -1
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +6 -1
- package/src/components/tabbed-sidebar/README.md +76 -0
- package/src/components/tabbed-sidebar/index.js +70 -0
- package/src/components/tabbed-sidebar/style.scss +53 -0
- package/src/components/url-popover/index.js +3 -0
- package/src/hooks/background.js +25 -10
- package/src/hooks/block-hooks.js +9 -16
- package/src/hooks/block-style-variation.js +202 -3
- package/src/hooks/duotone.js +16 -12
- package/src/hooks/grid-visualizer.js +64 -0
- package/src/hooks/index.js +3 -0
- package/src/hooks/layout-child.js +53 -37
- package/src/hooks/position.js +3 -10
- package/src/hooks/test/get-variation-styles-with-ref-values.js +91 -0
- package/src/hooks/use-bindings-attributes.js +18 -4
- package/src/hooks/utils.js +2 -0
- package/src/layouts/constrained.js +43 -2
- package/src/layouts/grid.js +146 -51
- package/src/private-apis.js +12 -1
- package/src/store/defaults.js +0 -2
- package/src/store/defaults.native.js +0 -3
- package/src/store/private-keys.js +1 -0
- package/src/style.scss +1 -1
- package/src/utils/format-font-style.js +40 -0
- package/src/utils/format-font-weight.js +63 -0
- package/src/utils/get-editor-region.js +31 -0
- package/src/utils/get-font-styles-and-weights.js +191 -0
- package/src/utils/pasting.js +5 -12
- package/src/utils/test/format-font-style.js +34 -0
- package/src/utils/test/format-font-weight.js +66 -0
- package/src/utils/test/get-font-styles-and-weights.js +513 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/hooks/position.scss +0 -18
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { _x, __, sprintf } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { formatFontStyle } from './format-font-style';
|
|
10
|
+
import { formatFontWeight } from './format-font-weight';
|
|
11
|
+
const FONT_STYLES = [{
|
|
12
|
+
name: _x('Regular', 'font style'),
|
|
13
|
+
value: 'normal'
|
|
14
|
+
}, {
|
|
15
|
+
name: _x('Italic', 'font style'),
|
|
16
|
+
value: 'italic'
|
|
17
|
+
}];
|
|
18
|
+
const FONT_WEIGHTS = [{
|
|
19
|
+
name: _x('Thin', 'font weight'),
|
|
20
|
+
value: '100'
|
|
21
|
+
}, {
|
|
22
|
+
name: _x('Extra Light', 'font weight'),
|
|
23
|
+
value: '200'
|
|
24
|
+
}, {
|
|
25
|
+
name: _x('Light', 'font weight'),
|
|
26
|
+
value: '300'
|
|
27
|
+
}, {
|
|
28
|
+
name: _x('Regular', 'font weight'),
|
|
29
|
+
value: '400'
|
|
30
|
+
}, {
|
|
31
|
+
name: _x('Medium', 'font weight'),
|
|
32
|
+
value: '500'
|
|
33
|
+
}, {
|
|
34
|
+
name: _x('Semi Bold', 'font weight'),
|
|
35
|
+
value: '600'
|
|
36
|
+
}, {
|
|
37
|
+
name: _x('Bold', 'font weight'),
|
|
38
|
+
value: '700'
|
|
39
|
+
}, {
|
|
40
|
+
name: _x('Extra Bold', 'font weight'),
|
|
41
|
+
value: '800'
|
|
42
|
+
}, {
|
|
43
|
+
name: _x('Black', 'font weight'),
|
|
44
|
+
value: '900'
|
|
45
|
+
}, {
|
|
46
|
+
name: _x('Extra Black', 'font weight'),
|
|
47
|
+
value: '1000'
|
|
48
|
+
}];
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Builds a list of font style and weight options based on font family faces.
|
|
52
|
+
* Defaults to the standard font styles and weights if no font family faces are provided.
|
|
53
|
+
*
|
|
54
|
+
* @param {Array} fontFamilyFaces font family faces array
|
|
55
|
+
* @return {Object} new object with combined and separated font style and weight properties
|
|
56
|
+
*/
|
|
57
|
+
export function getFontStylesAndWeights(fontFamilyFaces) {
|
|
58
|
+
let fontStyles = [];
|
|
59
|
+
let fontWeights = [];
|
|
60
|
+
const combinedStyleAndWeightOptions = [];
|
|
61
|
+
const isSystemFont = !fontFamilyFaces || fontFamilyFaces?.length === 0;
|
|
62
|
+
let isVariableFont = false;
|
|
63
|
+
fontFamilyFaces?.forEach(face => {
|
|
64
|
+
// Check for variable font by looking for a space in the font weight value. e.g. "100 900"
|
|
65
|
+
if (/\s/.test(face.fontWeight.trim())) {
|
|
66
|
+
isVariableFont = true;
|
|
67
|
+
|
|
68
|
+
// Find font weight start and end values.
|
|
69
|
+
let [startValue, endValue] = face.fontWeight.split(' ');
|
|
70
|
+
startValue = parseInt(startValue.slice(0, 1));
|
|
71
|
+
if (endValue === '1000') {
|
|
72
|
+
endValue = 10;
|
|
73
|
+
} else {
|
|
74
|
+
endValue = parseInt(endValue.slice(0, 1));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Create font weight options for available variable weights.
|
|
78
|
+
for (let i = startValue; i <= endValue; i++) {
|
|
79
|
+
const fontWeightValue = `${i.toString()}00`;
|
|
80
|
+
if (!fontWeights.some(weight => weight.value === fontWeightValue)) {
|
|
81
|
+
fontWeights.push(formatFontWeight(fontWeightValue));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Format font style and weight values.
|
|
87
|
+
const fontWeight = formatFontWeight(face.fontWeight);
|
|
88
|
+
const fontStyle = formatFontStyle(face.fontStyle);
|
|
89
|
+
|
|
90
|
+
// Create font style and font weight lists without duplicates.
|
|
91
|
+
if (fontStyle) {
|
|
92
|
+
if (!fontStyles.some(style => style.value === fontStyle.value)) {
|
|
93
|
+
fontStyles.push(fontStyle);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (fontWeight) {
|
|
97
|
+
if (!fontWeights.some(weight => weight.value === fontWeight.value)) {
|
|
98
|
+
if (!isVariableFont) {
|
|
99
|
+
fontWeights.push(fontWeight);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// If there is no font weight of 600 or above, then include faux bold as an option.
|
|
106
|
+
if (!fontWeights.some(weight => weight.value >= '600')) {
|
|
107
|
+
fontWeights.push({
|
|
108
|
+
name: _x('Bold', 'font weight'),
|
|
109
|
+
value: '700'
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// If there is no italic font style, then include faux italic as an option.
|
|
114
|
+
if (!fontStyles.some(style => style.value === 'italic')) {
|
|
115
|
+
fontStyles.push({
|
|
116
|
+
name: _x('Italic', 'font style'),
|
|
117
|
+
value: 'italic'
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Use default font styles and weights for system fonts.
|
|
122
|
+
if (isSystemFont) {
|
|
123
|
+
fontStyles = FONT_STYLES;
|
|
124
|
+
fontWeights = FONT_WEIGHTS;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Use default styles and weights if there are no available styles or weights from the provided font faces.
|
|
128
|
+
fontStyles = fontStyles.length === 0 ? FONT_STYLES : fontStyles;
|
|
129
|
+
fontWeights = fontWeights.length === 0 ? FONT_WEIGHTS : fontWeights;
|
|
130
|
+
|
|
131
|
+
// Generate combined font style and weight options for available fonts.
|
|
132
|
+
fontStyles.forEach(({
|
|
133
|
+
name: styleName,
|
|
134
|
+
value: styleValue
|
|
135
|
+
}) => {
|
|
136
|
+
fontWeights.forEach(({
|
|
137
|
+
name: weightName,
|
|
138
|
+
value: weightValue
|
|
139
|
+
}) => {
|
|
140
|
+
const optionName = styleValue === 'normal' ? weightName : sprintf( /* translators: 1: Font weight name. 2: Font style name. */
|
|
141
|
+
__('%1$s %2$s'), weightName, styleName);
|
|
142
|
+
combinedStyleAndWeightOptions.push({
|
|
143
|
+
key: `${styleValue}-${weightValue}`,
|
|
144
|
+
name: optionName,
|
|
145
|
+
style: {
|
|
146
|
+
fontStyle: styleValue,
|
|
147
|
+
fontWeight: weightValue
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
fontStyles,
|
|
154
|
+
fontWeights,
|
|
155
|
+
combinedStyleAndWeightOptions,
|
|
156
|
+
isSystemFont,
|
|
157
|
+
isVariableFont
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=get-font-styles-and-weights.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_x","__","sprintf","formatFontStyle","formatFontWeight","FONT_STYLES","name","value","FONT_WEIGHTS","getFontStylesAndWeights","fontFamilyFaces","fontStyles","fontWeights","combinedStyleAndWeightOptions","isSystemFont","length","isVariableFont","forEach","face","test","fontWeight","trim","startValue","endValue","split","parseInt","slice","i","fontWeightValue","toString","some","weight","push","fontStyle","style","styleName","styleValue","weightName","weightValue","optionName","key"],"sources":["@wordpress/block-editor/src/utils/get-font-styles-and-weights.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _x, __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { formatFontStyle } from './format-font-style';\nimport { formatFontWeight } from './format-font-weight';\n\nconst FONT_STYLES = [\n\t{\n\t\tname: _x( 'Regular', 'font style' ),\n\t\tvalue: 'normal',\n\t},\n\t{\n\t\tname: _x( 'Italic', 'font style' ),\n\t\tvalue: 'italic',\n\t},\n];\n\nconst FONT_WEIGHTS = [\n\t{\n\t\tname: _x( 'Thin', 'font weight' ),\n\t\tvalue: '100',\n\t},\n\t{\n\t\tname: _x( 'Extra Light', 'font weight' ),\n\t\tvalue: '200',\n\t},\n\t{\n\t\tname: _x( 'Light', 'font weight' ),\n\t\tvalue: '300',\n\t},\n\t{\n\t\tname: _x( 'Regular', 'font weight' ),\n\t\tvalue: '400',\n\t},\n\t{\n\t\tname: _x( 'Medium', 'font weight' ),\n\t\tvalue: '500',\n\t},\n\t{\n\t\tname: _x( 'Semi Bold', 'font weight' ),\n\t\tvalue: '600',\n\t},\n\t{\n\t\tname: _x( 'Bold', 'font weight' ),\n\t\tvalue: '700',\n\t},\n\t{\n\t\tname: _x( 'Extra Bold', 'font weight' ),\n\t\tvalue: '800',\n\t},\n\t{\n\t\tname: _x( 'Black', 'font weight' ),\n\t\tvalue: '900',\n\t},\n\t{\n\t\tname: _x( 'Extra Black', 'font weight' ),\n\t\tvalue: '1000',\n\t},\n];\n\n/**\n * Builds a list of font style and weight options based on font family faces.\n * Defaults to the standard font styles and weights if no font family faces are provided.\n *\n * @param {Array} fontFamilyFaces font family faces array\n * @return {Object} new object with combined and separated font style and weight properties\n */\nexport function getFontStylesAndWeights( fontFamilyFaces ) {\n\tlet fontStyles = [];\n\tlet fontWeights = [];\n\tconst combinedStyleAndWeightOptions = [];\n\tconst isSystemFont = ! fontFamilyFaces || fontFamilyFaces?.length === 0;\n\tlet isVariableFont = false;\n\n\tfontFamilyFaces?.forEach( ( face ) => {\n\t\t// Check for variable font by looking for a space in the font weight value. e.g. \"100 900\"\n\t\tif ( /\\s/.test( face.fontWeight.trim() ) ) {\n\t\t\tisVariableFont = true;\n\n\t\t\t// Find font weight start and end values.\n\t\t\tlet [ startValue, endValue ] = face.fontWeight.split( ' ' );\n\t\t\tstartValue = parseInt( startValue.slice( 0, 1 ) );\n\t\t\tif ( endValue === '1000' ) {\n\t\t\t\tendValue = 10;\n\t\t\t} else {\n\t\t\t\tendValue = parseInt( endValue.slice( 0, 1 ) );\n\t\t\t}\n\n\t\t\t// Create font weight options for available variable weights.\n\t\t\tfor ( let i = startValue; i <= endValue; i++ ) {\n\t\t\t\tconst fontWeightValue = `${ i.toString() }00`;\n\t\t\t\tif (\n\t\t\t\t\t! fontWeights.some(\n\t\t\t\t\t\t( weight ) => weight.value === fontWeightValue\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tfontWeights.push( formatFontWeight( fontWeightValue ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Format font style and weight values.\n\t\tconst fontWeight = formatFontWeight( face.fontWeight );\n\t\tconst fontStyle = formatFontStyle( face.fontStyle );\n\n\t\t// Create font style and font weight lists without duplicates.\n\t\tif ( fontStyle ) {\n\t\t\tif (\n\t\t\t\t! fontStyles.some(\n\t\t\t\t\t( style ) => style.value === fontStyle.value\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tfontStyles.push( fontStyle );\n\t\t\t}\n\t\t}\n\t\tif ( fontWeight ) {\n\t\t\tif (\n\t\t\t\t! fontWeights.some(\n\t\t\t\t\t( weight ) => weight.value === fontWeight.value\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif ( ! isVariableFont ) {\n\t\t\t\t\tfontWeights.push( fontWeight );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} );\n\n\t// If there is no font weight of 600 or above, then include faux bold as an option.\n\tif ( ! fontWeights.some( ( weight ) => weight.value >= '600' ) ) {\n\t\tfontWeights.push( {\n\t\t\tname: _x( 'Bold', 'font weight' ),\n\t\t\tvalue: '700',\n\t\t} );\n\t}\n\n\t// If there is no italic font style, then include faux italic as an option.\n\tif ( ! fontStyles.some( ( style ) => style.value === 'italic' ) ) {\n\t\tfontStyles.push( {\n\t\t\tname: _x( 'Italic', 'font style' ),\n\t\t\tvalue: 'italic',\n\t\t} );\n\t}\n\n\t// Use default font styles and weights for system fonts.\n\tif ( isSystemFont ) {\n\t\tfontStyles = FONT_STYLES;\n\t\tfontWeights = FONT_WEIGHTS;\n\t}\n\n\t// Use default styles and weights if there are no available styles or weights from the provided font faces.\n\tfontStyles = fontStyles.length === 0 ? FONT_STYLES : fontStyles;\n\tfontWeights = fontWeights.length === 0 ? FONT_WEIGHTS : fontWeights;\n\n\t// Generate combined font style and weight options for available fonts.\n\tfontStyles.forEach( ( { name: styleName, value: styleValue } ) => {\n\t\tfontWeights.forEach( ( { name: weightName, value: weightValue } ) => {\n\t\t\tconst optionName =\n\t\t\t\tstyleValue === 'normal'\n\t\t\t\t\t? weightName\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: 1: Font weight name. 2: Font style name. */\n\t\t\t\t\t\t\t__( '%1$s %2$s' ),\n\t\t\t\t\t\t\tweightName,\n\t\t\t\t\t\t\tstyleName\n\t\t\t\t\t );\n\n\t\t\tcombinedStyleAndWeightOptions.push( {\n\t\t\t\tkey: `${ styleValue }-${ weightValue }`,\n\t\t\t\tname: optionName,\n\t\t\t\tstyle: {\n\t\t\t\t\tfontStyle: styleValue,\n\t\t\t\t\tfontWeight: weightValue,\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\t} );\n\n\treturn {\n\t\tfontStyles,\n\t\tfontWeights,\n\t\tcombinedStyleAndWeightOptions,\n\t\tisSystemFont,\n\t\tisVariableFont,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAEjD;AACA;AACA;AACA,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,gBAAgB,QAAQ,sBAAsB;AAEvD,MAAMC,WAAW,GAAG,CACnB;EACCC,IAAI,EAAEN,EAAE,CAAE,SAAS,EAAE,YAAa,CAAC;EACnCO,KAAK,EAAE;AACR,CAAC,EACD;EACCD,IAAI,EA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AAE+B,UAAU;MAAE9B,KAAK,EAAE+B;IAAY,CAAC,KAAM;MACpE,MAAMC,UAAU,GACfH,UAAU,KAAK,QAAQ,GACpBC,UAAU,GACVnC,OAAO,EACP;MACAD,EAAE,CAAE,WAAY,CAAC,EACjBoC,UAAU,EACVF,SACA,CAAC;MAELtB,6BAA6B,CAACmB,IAAI,CAAE;QACnCQ,GAAG,EAAG,GAAGJ,UAAY,IAAIE,WAAa,EAAC;QACvChC,IAAI,EAAEiC,UAAU;QAChBL,KAAK,EAAE;UACND,SAAS,EAAEG,UAAU;UACrBhB,UAAU,EAAEkB;QACb;MACD,CAAE,CAAC;IACJ,CAAE,CAAC;EACJ,CAAE,CAAC;EAEH,OAAO;IACN3B,UAAU;IACVC,WAAW;IACXC,6BAA6B;IAC7BC,YAAY;IACZE;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -48,22 +48,14 @@ export function getPasteEventData({
|
|
|
48
48
|
}) {
|
|
49
49
|
let plainText = '';
|
|
50
50
|
let html = '';
|
|
51
|
-
|
|
52
|
-
// IE11 only supports `Text` as an argument for `getData` and will
|
|
53
|
-
// otherwise throw an invalid argument error, so we try the standard
|
|
54
|
-
// arguments first, then fallback to `Text` if they fail.
|
|
55
51
|
try {
|
|
56
52
|
plainText = clipboardData.getData('text/plain');
|
|
57
53
|
html = clipboardData.getData('text/html');
|
|
58
|
-
} catch (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// don't support clipboardData at all, so allow default
|
|
64
|
-
// behaviour.
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
54
|
+
} catch (error) {
|
|
55
|
+
// Some browsers like UC Browser paste plain text by default and
|
|
56
|
+
// don't support clipboardData at all, so allow default
|
|
57
|
+
// behaviour.
|
|
58
|
+
return;
|
|
67
59
|
}
|
|
68
60
|
|
|
69
61
|
// Remove Windows-specific metadata appended within copied HTML text.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getFilesFromDataTransfer","removeWindowsFragments","html","startStr","startIdx","indexOf","substring","length","endStr","endIdx","removeCharsetMetaTag","metaTag","startsWith","slice","getPasteEventData","clipboardData","plainText","getData","
|
|
1
|
+
{"version":3,"names":["getFilesFromDataTransfer","removeWindowsFragments","html","startStr","startIdx","indexOf","substring","length","endStr","endIdx","removeCharsetMetaTag","metaTag","startsWith","slice","getPasteEventData","clipboardData","plainText","getData","error","files","shouldDismissPastedFiles","type","IMAGE_TAG","match","IMG_WITH_LOCAL_SRC"],"sources":["@wordpress/block-editor/src/utils/pasting.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Normalizes a given string of HTML to remove the Windows-specific \"Fragment\"\n * comments and any preceding and trailing content.\n *\n * @param {string} html the html to be normalized\n * @return {string} the normalized html\n */\nfunction removeWindowsFragments( html ) {\n\tconst startStr = '<!--StartFragment-->';\n\tconst startIdx = html.indexOf( startStr );\n\tif ( startIdx > -1 ) {\n\t\thtml = html.substring( startIdx + startStr.length );\n\t} else {\n\t\t// No point looking for EndFragment\n\t\treturn html;\n\t}\n\n\tconst endStr = '<!--EndFragment-->';\n\tconst endIdx = html.indexOf( endStr );\n\tif ( endIdx > -1 ) {\n\t\thtml = html.substring( 0, endIdx );\n\t}\n\n\treturn html;\n}\n\n/**\n * Removes the charset meta tag inserted by Chromium.\n * See:\n * - https://github.com/WordPress/gutenberg/issues/33585\n * - https://bugs.chromium.org/p/chromium/issues/detail?id=1264616#c4\n *\n * @param {string} html the html to be stripped of the meta tag.\n * @return {string} the cleaned html\n */\nfunction removeCharsetMetaTag( html ) {\n\tconst metaTag = `<meta charset='utf-8'>`;\n\n\tif ( html.startsWith( metaTag ) ) {\n\t\treturn html.slice( metaTag.length );\n\t}\n\n\treturn html;\n}\n\nexport function getPasteEventData( { clipboardData } ) {\n\tlet plainText = '';\n\tlet html = '';\n\n\ttry {\n\t\tplainText = clipboardData.getData( 'text/plain' );\n\t\thtml = clipboardData.getData( 'text/html' );\n\t} catch ( error ) {\n\t\t// Some browsers like UC Browser paste plain text by default and\n\t\t// don't support clipboardData at all, so allow default\n\t\t// behaviour.\n\t\treturn;\n\t}\n\n\t// Remove Windows-specific metadata appended within copied HTML text.\n\thtml = removeWindowsFragments( html );\n\n\t// Strip meta tag.\n\thtml = removeCharsetMetaTag( html );\n\n\tconst files = getFilesFromDataTransfer( clipboardData );\n\n\tif ( files.length && ! shouldDismissPastedFiles( files, html ) ) {\n\t\treturn { files };\n\t}\n\n\treturn { html, plainText, files: [] };\n}\n\n/**\n * Given a collection of DataTransfer files and HTML and plain text strings,\n * determine whether the files are to be dismissed in favor of the HTML.\n *\n * Certain office-type programs, like Microsoft Word or Apple Numbers,\n * will, upon copy, generate a screenshot of the content being copied and\n * attach it to the clipboard alongside the actual rich text that the user\n * sought to copy. In those cases, we should let Gutenberg handle the rich text\n * content and not the screenshot, since this allows Gutenberg to insert\n * meaningful blocks, like paragraphs, lists or even tables.\n *\n * @param {File[]} files File objects obtained from a paste event\n * @param {string} html HTML content obtained from a paste event\n * @return {boolean} True if the files should be dismissed\n */\nexport function shouldDismissPastedFiles( files, html /*, plainText */ ) {\n\t// The question is only relevant when there is actual HTML content and when\n\t// there is exactly one image file.\n\tif (\n\t\thtml &&\n\t\tfiles?.length === 1 &&\n\t\tfiles[ 0 ].type.indexOf( 'image/' ) === 0\n\t) {\n\t\t// A single <img> tag found in the HTML source suggests that the\n\t\t// content being pasted revolves around an image. Sometimes there are\n\t\t// other elements found, like <figure>, but we assume that the user's\n\t\t// intention is to paste the actual image file.\n\t\tconst IMAGE_TAG = /<\\s*img\\b/gi;\n\t\tif ( html.match( IMAGE_TAG )?.length !== 1 ) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Even when there is exactly one <img> tag in the HTML payload, we\n\t\t// choose to weed out local images, i.e. those whose source starts with\n\t\t// \"file://\". These payloads occur in specific configurations, such as\n\t\t// when copying an entire document from Microsoft Word, that contains\n\t\t// text and exactly one image, and pasting that content using Google\n\t\t// Chrome.\n\t\tconst IMG_WITH_LOCAL_SRC = /<\\s*img\\b[^>]*\\bsrc=\"file:\\/\\//i;\n\t\tif ( html.match( IMG_WITH_LOCAL_SRC ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,wBAAwB,QAAQ,gBAAgB;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,sBAAsBA,CAAEC,IAAI,EAAG;EACvC,MAAMC,QAAQ,GAAG,sBAAsB;EACvC,MAAMC,QAAQ,GAAGF,IAAI,CAACG,OAAO,CAAEF,QAAS,CAAC;EACzC,IAAKC,QAAQ,GAAG,CAAC,CAAC,EAAG;IACpBF,IAAI,GAAGA,IAAI,CAACI,SAAS,CAAEF,QAAQ,GAAGD,QAAQ,CAACI,MAAO,CAAC;EACpD,CAAC,MAAM;IACN;IACA,OAAOL,IAAI;EACZ;EAEA,MAAMM,MAAM,GAAG,oBAAoB;EACnC,MAAMC,MAAM,GAAGP,IAAI,CAACG,OAAO,CAAEG,MAAO,CAAC;EACrC,IAAKC,MAAM,GAAG,CAAC,CAAC,EAAG;IAClBP,IAAI,GAAGA,IAAI,CAACI,SAAS,CAAE,CAAC,EAAEG,MAAO,CAAC;EACnC;EAEA,OAAOP,IAAI;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASQ,oBAAoBA,CAAER,IAAI,EAAG;EACrC,MAAMS,OAAO,GAAI,wBAAuB;EAExC,IAAKT,IAAI,CAACU,UAAU,CAAED,OAAQ,CAAC,EAAG;IACjC,OAAOT,IAAI,CAACW,KAAK,CAAEF,OAAO,CAACJ,MAAO,CAAC;EACpC;EAEA,OAAOL,IAAI;AACZ;AAEA,OAAO,SAASY,iBAAiBA,CAAE;EAAEC;AAAc,CAAC,EAAG;EACtD,IAAIC,SAAS,GAAG,EAAE;EAClB,IAAId,IAAI,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