@wordpress/block-editor 16.0.0 → 16.1.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 +18 -0
- package/README.md +8 -0
- package/build/components/alignment-control/ui.cjs +2 -4
- package/build/components/alignment-control/ui.cjs.map +2 -2
- package/build/components/background-image-control/index.cjs +40 -10
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-alignment-control/ui.cjs +5 -3
- package/build/components/block-alignment-control/ui.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +73 -46
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/block-html.cjs +4 -1
- package/build/components/block-list/block-html.cjs.map +2 -2
- package/build/components/block-list/use-block-props/index.cjs +5 -2
- package/build/components/block-list/use-block-props/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-handler.cjs +2 -3
- package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-register-block-event-handlers.cjs +48 -0
- package/build/components/block-list/use-block-props/use-register-block-event-handlers.cjs.map +7 -0
- package/build/components/block-parent-selector/index.cjs +2 -2
- package/build/components/block-parent-selector/index.cjs.map +2 -2
- package/build/components/block-toolbar/switch-section-style.cjs +4 -2
- package/build/components/block-toolbar/switch-section-style.cjs.map +3 -3
- package/build/components/block-tools/empty-block-inserter.cjs +2 -7
- package/build/components/block-tools/empty-block-inserter.cjs.map +2 -2
- package/build/components/block-vertical-alignment-control/ui.cjs +3 -5
- package/build/components/block-vertical-alignment-control/ui.cjs.map +2 -2
- package/build/components/border-radius-control/utils.cjs +8 -58
- package/build/components/border-radius-control/utils.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +5 -3
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/dimension-control/index.cjs +30 -20
- package/build/components/dimension-control/index.cjs.map +3 -3
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs +9 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +3 -3
- package/build/components/editor-styles/index.cjs +9 -1
- package/build/components/editor-styles/index.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +66 -25
- package/build/components/global-styles/background-panel.cjs.map +3 -3
- package/build/components/global-styles/border-panel.cjs +153 -55
- package/build/components/global-styles/border-panel.cjs.map +3 -3
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +46 -14
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +3 -3
- package/build/components/global-styles/color-panel.cjs +63 -17
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +242 -64
- package/build/components/global-styles/dimensions-panel.cjs.map +3 -3
- package/build/components/global-styles/filters-panel.cjs +59 -20
- package/build/components/global-styles/filters-panel.cjs.map +3 -3
- package/build/components/global-styles/hooks.cjs +4 -1
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/inheritance/index.cjs +142 -0
- package/build/components/global-styles/inheritance/index.cjs.map +7 -0
- package/build/components/global-styles/inherited-value-context.cjs +173 -0
- package/build/components/global-styles/inherited-value-context.cjs.map +7 -0
- package/build/components/global-styles/shadow-panel-components.cjs +38 -20
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/state-control.cjs +1 -1
- package/build/components/global-styles/state-control.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +271 -78
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/styles-tab.cjs +10 -1
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/line-height-control/index.cjs +1 -1
- package/build/components/line-height-control/index.cjs.map +2 -2
- package/build/components/link-control/index.cjs +3 -1
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/preset-input-control/index.cjs +2 -1
- package/build/components/preset-input-control/index.cjs.map +2 -2
- package/build/components/provider/block-refs-provider.cjs +8 -2
- package/build/components/provider/block-refs-provider.cjs.map +2 -2
- package/build/components/provider/index.cjs +1 -1
- package/build/components/provider/index.cjs.map +2 -2
- package/build/components/provider/use-block-sync.cjs +18 -6
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/provider/use-media-upload-settings.cjs +3 -1
- package/build/components/provider/use-media-upload-settings.cjs.map +2 -2
- package/build/components/rich-text/index.cjs +23 -13
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/spacing-sizes-control/utils.cjs +6 -19
- package/build/components/spacing-sizes-control/utils.cjs.map +2 -2
- package/build/components/text-indent-control/index.cjs +8 -2
- package/build/components/text-indent-control/index.cjs.map +2 -2
- package/build/components/url-input/index.cjs +303 -344
- package/build/components/url-input/index.cjs.map +3 -3
- package/build/components/writing-flow/index.cjs +2 -0
- package/build/components/writing-flow/index.cjs.map +3 -3
- package/build/components/writing-flow/use-arrow-nav.cjs +24 -1
- package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
- package/build/components/writing-flow/use-click-selection.cjs +28 -2
- package/build/components/writing-flow/use-click-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-editable-root-event-handlers.cjs +179 -0
- package/build/components/writing-flow/use-editable-root-event-handlers.cjs.map +7 -0
- package/build/components/writing-flow/use-editable-root.cjs +5 -42
- package/build/components/writing-flow/use-editable-root.cjs.map +2 -2
- package/build/components/writing-flow/use-home-end.cjs +1 -1
- package/build/components/writing-flow/use-home-end.cjs.map +2 -2
- package/build/components/writing-flow/use-selection-observer.cjs +17 -13
- package/build/components/writing-flow/use-selection-observer.cjs.map +2 -2
- package/build/components/writing-flow/utils.cjs +3 -14
- package/build/components/writing-flow/utils.cjs.map +2 -2
- package/build/hooks/background.cjs +13 -10
- package/build/hooks/background.cjs.map +2 -2
- package/build/hooks/block-style-variation.cjs +4 -45
- package/build/hooks/block-style-variation.cjs.map +3 -3
- package/build/hooks/border.cjs +19 -4
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/custom-css.cjs +6 -2
- package/build/hooks/custom-css.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +15 -4
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/duotone.cjs +26 -14
- package/build/hooks/duotone.cjs.map +3 -3
- package/build/hooks/elements.cjs +14 -4
- package/build/hooks/elements.cjs.map +2 -2
- package/build/hooks/line-height.cjs +1 -2
- package/build/hooks/line-height.cjs.map +2 -2
- package/build/hooks/typography.cjs +13 -4
- package/build/hooks/typography.cjs.map +2 -2
- package/build/private-apis.cjs +9 -5
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs +9 -4
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +28 -1
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +6 -6
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +23 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/native-undo.cjs +55 -0
- package/build/utils/native-undo.cjs.map +7 -0
- package/build-module/components/alignment-control/ui.mjs +2 -4
- package/build-module/components/alignment-control/ui.mjs.map +2 -2
- package/build-module/components/background-image-control/index.mjs +43 -10
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-alignment-control/ui.mjs +5 -3
- package/build-module/components/block-alignment-control/ui.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +74 -46
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block-html.mjs +4 -1
- package/build-module/components/block-list/block-html.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/index.mjs +5 -2
- package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +2 -3
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-register-block-event-handlers.mjs +28 -0
- package/build-module/components/block-list/use-block-props/use-register-block-event-handlers.mjs.map +7 -0
- package/build-module/components/block-parent-selector/index.mjs +2 -2
- package/build-module/components/block-parent-selector/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs +4 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs.map +2 -2
- package/build-module/components/block-tools/empty-block-inserter.mjs +2 -7
- package/build-module/components/block-tools/empty-block-inserter.mjs.map +2 -2
- package/build-module/components/block-vertical-alignment-control/ui.mjs +4 -6
- package/build-module/components/block-vertical-alignment-control/ui.mjs.map +2 -2
- package/build-module/components/border-radius-control/utils.mjs +11 -53
- package/build-module/components/border-radius-control/utils.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +5 -3
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/dimension-control/index.mjs +30 -20
- package/build-module/components/dimension-control/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +10 -6
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/editor-styles/index.mjs +9 -1
- package/build-module/components/editor-styles/index.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +71 -29
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +157 -56
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +51 -15
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +63 -17
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +248 -66
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +64 -21
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +4 -1
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/inheritance/index.mjs +108 -0
- package/build-module/components/global-styles/inheritance/index.mjs.map +7 -0
- package/build-module/components/global-styles/inherited-value-context.mjs +141 -0
- package/build-module/components/global-styles/inherited-value-context.mjs.map +7 -0
- package/build-module/components/global-styles/shadow-panel-components.mjs +38 -20
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/state-control.mjs +1 -1
- package/build-module/components/global-styles/state-control.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +276 -79
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +6 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/line-height-control/index.mjs +1 -1
- package/build-module/components/line-height-control/index.mjs.map +2 -2
- package/build-module/components/link-control/index.mjs +4 -2
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs +2 -1
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/provider/block-refs-provider.mjs +8 -2
- package/build-module/components/provider/block-refs-provider.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +1 -1
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-sync.mjs +18 -6
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/provider/use-media-upload-settings.mjs +3 -1
- package/build-module/components/provider/use-media-upload-settings.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +28 -14
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/spacing-sizes-control/utils.mjs +6 -18
- package/build-module/components/spacing-sizes-control/utils.mjs.map +2 -2
- package/build-module/components/text-indent-control/index.mjs +8 -2
- package/build-module/components/text-indent-control/index.mjs.map +2 -2
- package/build-module/components/url-input/index.mjs +306 -353
- package/build-module/components/url-input/index.mjs.map +2 -2
- package/build-module/components/writing-flow/index.mjs +2 -0
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs +24 -1
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
- package/build-module/components/writing-flow/use-click-selection.mjs +28 -2
- package/build-module/components/writing-flow/use-click-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-editable-root-event-handlers.mjs +154 -0
- package/build-module/components/writing-flow/use-editable-root-event-handlers.mjs.map +7 -0
- package/build-module/components/writing-flow/use-editable-root.mjs +5 -37
- package/build-module/components/writing-flow/use-editable-root.mjs.map +2 -2
- package/build-module/components/writing-flow/use-home-end.mjs +1 -1
- package/build-module/components/writing-flow/use-home-end.mjs.map +2 -2
- package/build-module/components/writing-flow/use-selection-observer.mjs +18 -14
- package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
- package/build-module/components/writing-flow/utils.mjs +2 -11
- package/build-module/components/writing-flow/utils.mjs.map +2 -2
- package/build-module/hooks/background.mjs +13 -10
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-style-variation.mjs +8 -44
- package/build-module/hooks/block-style-variation.mjs.map +2 -2
- package/build-module/hooks/border.mjs +19 -4
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/custom-css.mjs +7 -3
- package/build-module/hooks/custom-css.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +15 -4
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/duotone.mjs +20 -9
- package/build-module/hooks/duotone.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +14 -4
- package/build-module/hooks/elements.mjs.map +2 -2
- package/build-module/hooks/line-height.mjs +1 -2
- package/build-module/hooks/line-height.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +13 -4
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/private-apis.mjs +7 -3
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +9 -4
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +29 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +6 -6
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +23 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/native-undo.mjs +29 -0
- package/build-module/utils/native-undo.mjs.map +7 -0
- package/build-style/content-rtl.css +10 -18
- package/build-style/content.css +10 -18
- package/build-style/style-rtl.css +150 -7
- package/build-style/style.css +150 -7
- package/package.json +40 -41
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +1 -1
- package/src/components/alignment-control/ui.js +2 -4
- package/src/components/background-image-control/index.js +74 -37
- package/src/components/background-image-control/style.scss +13 -4
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +3 -3
- package/src/components/block-alignment-control/test/index.js +1 -1
- package/src/components/block-alignment-control/ui.js +4 -2
- package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +1 -1
- package/src/components/block-compare/test/__snapshots__/block-view.js.snap +1 -1
- package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -1
- package/src/components/block-inspector/index.js +60 -31
- package/src/components/block-list/block-html.js +5 -0
- package/src/components/block-list/content.scss +1 -11
- package/src/components/block-list/use-block-props/index.js +5 -1
- package/src/components/block-list/use-block-props/use-focus-handler.js +9 -8
- package/src/components/block-list/use-block-props/use-register-block-event-handlers.js +45 -0
- package/src/components/block-parent-selector/index.js +5 -2
- package/src/components/block-toolbar/switch-section-style.js +5 -2
- package/src/components/block-tools/empty-block-inserter.js +3 -7
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +3 -3
- package/src/components/block-vertical-alignment-control/test/index.js +18 -2
- package/src/components/block-vertical-alignment-control/ui.js +3 -5
- package/src/components/border-radius-control/test/utils.js +0 -41
- package/src/components/border-radius-control/utils.js +16 -107
- package/src/components/button-block-appender/content.scss +6 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/colors-gradients/control.js +6 -3
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +1 -1
- package/src/components/dimension-control/index.js +13 -1
- package/src/components/dimensions-tool/aspect-ratio-tool.js +13 -6
- package/src/components/editor-styles/index.js +16 -1
- package/src/components/global-styles/background-panel.js +107 -34
- package/src/components/global-styles/border-panel.js +219 -48
- package/src/components/global-styles/color-gradient-dropdown-item.js +93 -28
- package/src/components/global-styles/color-panel.js +92 -11
- package/src/components/global-styles/dimensions-panel.js +422 -71
- package/src/components/global-styles/filters-panel.js +88 -28
- package/src/components/global-styles/hooks.js +8 -1
- package/src/components/global-styles/inheritance/index.js +204 -0
- package/src/components/global-styles/inheritance/style.scss +184 -0
- package/src/components/global-styles/inheritance/test/index.js +281 -0
- package/src/components/global-styles/inherited-value-context.js +271 -0
- package/src/components/global-styles/shadow-panel-components.js +48 -26
- package/src/components/global-styles/state-control.js +2 -2
- package/src/components/global-styles/test/background-panel.js +338 -1
- package/src/components/global-styles/test/border-panel.js +441 -0
- package/src/components/global-styles/test/color-panel.js +182 -2
- package/src/components/global-styles/test/dimensions-panel.js +753 -0
- package/src/components/global-styles/test/filters-panel.js +194 -0
- package/src/components/global-styles/test/inherited-value-context-core.js +98 -0
- package/src/components/global-styles/test/inherited-value-context.js +454 -0
- package/src/components/global-styles/test/typography-panel-core.js +185 -0
- package/src/components/global-styles/test/typography-panel.js +849 -12
- package/src/components/global-styles/typography-panel.js +449 -100
- package/src/components/image-editor/style.scss +33 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +5 -1
- package/src/components/line-height-control/index.js +1 -1
- package/src/components/link-control/index.js +7 -2
- package/src/components/preset-input-control/index.js +4 -1
- package/src/components/provider/block-refs-provider.js +12 -2
- package/src/components/provider/index.js +2 -2
- package/src/components/provider/use-block-sync.js +18 -6
- package/src/components/provider/use-media-upload-settings.js +2 -0
- package/src/components/rich-text/index.js +37 -16
- package/src/components/spacing-sizes-control/test/utils.js +16 -5
- package/src/components/spacing-sizes-control/utils.js +11 -28
- package/src/components/text-indent-control/index.js +8 -0
- package/src/components/url-input/index.js +363 -431
- package/src/components/url-input/test/index.js +592 -0
- package/src/components/warning/test/__snapshots__/index.js.snap +1 -1
- package/src/components/writing-flow/index.js +2 -0
- package/src/components/writing-flow/use-arrow-nav.js +51 -1
- package/src/components/writing-flow/use-click-selection.js +54 -3
- package/src/components/writing-flow/use-editable-root-event-handlers.js +266 -0
- package/src/components/writing-flow/use-editable-root.js +7 -77
- package/src/components/writing-flow/use-home-end.js +17 -9
- package/src/components/writing-flow/use-selection-observer.js +32 -15
- package/src/components/writing-flow/utils.js +3 -24
- package/src/hooks/background.js +26 -21
- package/src/hooks/block-fields/rich-text/styles.scss +1 -1
- package/src/hooks/block-style-variation.js +8 -74
- package/src/hooks/border.js +19 -4
- package/src/hooks/custom-css.js +15 -6
- package/src/hooks/dimensions.js +17 -4
- package/src/hooks/duotone.js +26 -8
- package/src/hooks/elements.js +14 -3
- package/src/hooks/line-height.js +0 -1
- package/src/hooks/test/inherited-value-wiring.js +411 -0
- package/src/hooks/test/preset-round-trip.js +456 -0
- package/src/hooks/typography.js +35 -23
- package/src/private-apis.js +11 -2
- package/src/store/actions.js +10 -4
- package/src/store/private-selectors.js +57 -1
- package/src/store/reducer.js +9 -9
- package/src/store/selectors.js +56 -8
- package/src/store/test/private-selectors.js +160 -1
- package/src/style.scss +2 -0
- package/src/utils/native-undo.js +56 -0
- package/build/components/duotone/utils.cjs +0 -87
- package/build/components/duotone/utils.cjs.map +0 -7
- package/build-module/components/duotone/utils.mjs +0 -59
- package/build-module/components/duotone/utils.mjs.map +0 -7
- package/src/components/duotone/utils.js +0 -90
- package/src/hooks/test/get-variation-styles-with-ref-values.js +0 -91
package/src/store/reducer.js
CHANGED
|
@@ -1442,19 +1442,19 @@ export function selection( state = {}, action ) {
|
|
|
1442
1442
|
selectionEnd,
|
|
1443
1443
|
};
|
|
1444
1444
|
case 'MULTI_SELECT':
|
|
1445
|
-
const
|
|
1445
|
+
const nextSelection = {
|
|
1446
|
+
selectionStart: { clientId: action.start },
|
|
1447
|
+
selectionEnd: { clientId: action.end },
|
|
1448
|
+
};
|
|
1446
1449
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
) {
|
|
1450
|
+
// A text selection between the same blocks is not the same
|
|
1451
|
+
// selection: it carries attribute keys and offsets, making it
|
|
1452
|
+
// partial rather than a block multi-selection.
|
|
1453
|
+
if ( fastDeepEqual( state, nextSelection ) ) {
|
|
1451
1454
|
return state;
|
|
1452
1455
|
}
|
|
1453
1456
|
|
|
1454
|
-
return
|
|
1455
|
-
selectionStart: { clientId: start },
|
|
1456
|
-
selectionEnd: { clientId: end },
|
|
1457
|
-
};
|
|
1457
|
+
return nextSelection;
|
|
1458
1458
|
case 'RESET_BLOCKS':
|
|
1459
1459
|
const startClientId = state?.selectionStart?.clientId;
|
|
1460
1460
|
const endClientId = state?.selectionEnd?.clientId;
|
package/src/store/selectors.js
CHANGED
|
@@ -149,14 +149,26 @@ export function getBlockAttributes( state, clientId ) {
|
|
|
149
149
|
* blocks module registration store.
|
|
150
150
|
*
|
|
151
151
|
* getBlock recurses through its inner blocks until all its children blocks have
|
|
152
|
-
* been retrieved
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
152
|
+
* been retrieved, with one exception: the children of an "inner block
|
|
153
|
+
* controller" are not part of its tree, so `innerBlocks` usually comes back
|
|
154
|
+
* empty even though the block clearly has children in the editor. Never rely on
|
|
155
|
+
* a controller's `innerBlocks`; ask for its children directly:
|
|
156
|
+
*
|
|
157
|
+
* ```js
|
|
158
|
+
* getBlock( syncedPatternClientId ).innerBlocks; // Usually [].
|
|
159
|
+
* getBlocks( syncedPatternClientId ); // The pattern's blocks.
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
* A block is an inner block controller when its children belong to, and are
|
|
163
|
+
* synced with, an entity other than the one being edited. Synced patterns
|
|
164
|
+
* (`core/block`) and template parts (`core/template-part`) are the usual
|
|
165
|
+
* examples: each owns its own blocks, and editing them saves to that pattern or
|
|
166
|
+
* template part, not to the post or template it sits in. Leaving their children
|
|
167
|
+
* out of the tree is what keeps the two entities separate, so walking a
|
|
168
|
+
* template's blocks stops at a template part placed inside it.
|
|
169
|
+
*
|
|
170
|
+
* `areInnerBlocksControlled( clientId )` tells whether a block is such a
|
|
171
|
+
* controller.
|
|
160
172
|
*
|
|
161
173
|
* @param {Object} state Editor state.
|
|
162
174
|
* @param {string} clientId Block client ID.
|
|
@@ -789,6 +801,30 @@ export function getSelectedBlocksInitialCaretPosition( state ) {
|
|
|
789
801
|
return state.initialPosition;
|
|
790
802
|
}
|
|
791
803
|
|
|
804
|
+
/**
|
|
805
|
+
* Returns the ancestor client ID when one selection endpoint is nested
|
|
806
|
+
* inside the other, or undefined for any other selection shape. Such a
|
|
807
|
+
* selection has no sibling range; the ancestor contains all of it.
|
|
808
|
+
*
|
|
809
|
+
* @param {Object} state Editor state.
|
|
810
|
+
* @return {?string} The ancestor client ID, if any.
|
|
811
|
+
*/
|
|
812
|
+
function getSelectionNestingAncestor( state ) {
|
|
813
|
+
const { selectionStart, selectionEnd } = state.selection;
|
|
814
|
+
const startClientId = selectionStart.clientId;
|
|
815
|
+
const endClientId = selectionEnd.clientId;
|
|
816
|
+
if ( ! startClientId || ! endClientId || startClientId === endClientId ) {
|
|
817
|
+
return undefined;
|
|
818
|
+
}
|
|
819
|
+
if ( getBlockParents( state, endClientId ).includes( startClientId ) ) {
|
|
820
|
+
return startClientId;
|
|
821
|
+
}
|
|
822
|
+
if ( getBlockParents( state, startClientId ).includes( endClientId ) ) {
|
|
823
|
+
return endClientId;
|
|
824
|
+
}
|
|
825
|
+
return undefined;
|
|
826
|
+
}
|
|
827
|
+
|
|
792
828
|
/**
|
|
793
829
|
* Returns the current selection set of block client IDs (multiselection or single selection).
|
|
794
830
|
*
|
|
@@ -808,6 +844,11 @@ export const getSelectedBlockClientIds = createSelector(
|
|
|
808
844
|
return [ selectionStart.clientId ];
|
|
809
845
|
}
|
|
810
846
|
|
|
847
|
+
const nestingAncestorClientId = getSelectionNestingAncestor( state );
|
|
848
|
+
if ( nestingAncestorClientId ) {
|
|
849
|
+
return [ nestingAncestorClientId ];
|
|
850
|
+
}
|
|
851
|
+
|
|
811
852
|
// Retrieve root client ID to aid in retrieving relevant nested block
|
|
812
853
|
// order, being careful to allow the falsey empty string top-level root
|
|
813
854
|
// by explicitly testing against null.
|
|
@@ -832,6 +873,7 @@ export const getSelectedBlockClientIds = createSelector(
|
|
|
832
873
|
},
|
|
833
874
|
( state ) => [
|
|
834
875
|
state.blocks.order,
|
|
876
|
+
state.blocks.parents,
|
|
835
877
|
state.selection.selectionStart.clientId,
|
|
836
878
|
state.selection.selectionEnd.clientId,
|
|
837
879
|
]
|
|
@@ -1014,6 +1056,12 @@ export function getMultiSelectedBlocksEndClientId( state ) {
|
|
|
1014
1056
|
* @return {boolean} Whether the selection is mergeable.
|
|
1015
1057
|
*/
|
|
1016
1058
|
export function __unstableIsFullySelected( state ) {
|
|
1059
|
+
// A text selection with one endpoint nested inside the other has no
|
|
1060
|
+
// sibling range; it resolves to the ancestor, which is presented and
|
|
1061
|
+
// treated as fully selected.
|
|
1062
|
+
if ( getSelectionNestingAncestor( state ) ) {
|
|
1063
|
+
return true;
|
|
1064
|
+
}
|
|
1017
1065
|
const selectionAnchor = getSelectionStart( state );
|
|
1018
1066
|
const selectionFocus = getSelectionEnd( state );
|
|
1019
1067
|
return (
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
registerBlockType,
|
|
6
|
+
unregisterBlockType,
|
|
7
|
+
privateApis as blocksPrivateApis,
|
|
8
|
+
} from '@wordpress/blocks';
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* Internal dependencies
|
|
@@ -29,9 +33,15 @@ import {
|
|
|
29
33
|
hasSelectedStyleState,
|
|
30
34
|
isSelectedBlockStyleStateShownOnCanvas,
|
|
31
35
|
shouldRenderBlockListView,
|
|
36
|
+
getStyleOverrides,
|
|
37
|
+
canHostEditableRoot,
|
|
32
38
|
} from '../private-selectors';
|
|
33
39
|
import { getBlockEditingMode } from '../selectors';
|
|
34
40
|
import { deviceTypeKey } from '../private-keys';
|
|
41
|
+
import reducer from '../reducer';
|
|
42
|
+
import { unlock } from '../../lock-unlock';
|
|
43
|
+
|
|
44
|
+
const { editableRootKey } = unlock( blocksPrivateApis );
|
|
35
45
|
|
|
36
46
|
describe( 'private selectors', () => {
|
|
37
47
|
describe( 'isBlockInterfaceHidden', () => {
|
|
@@ -1349,6 +1359,27 @@ describe( 'private selectors', () => {
|
|
|
1349
1359
|
} );
|
|
1350
1360
|
} );
|
|
1351
1361
|
|
|
1362
|
+
describe( 'getStyleOverrides', () => {
|
|
1363
|
+
it( 'sorts overrides by the order of the blocks they belong to', () => {
|
|
1364
|
+
const state = {
|
|
1365
|
+
blocks: {
|
|
1366
|
+
order: new Map( [ [ '', [ 'block-1', 'block-2' ] ] ] ),
|
|
1367
|
+
},
|
|
1368
|
+
styleOverrides: new Map( [
|
|
1369
|
+
[ 'override-2', { clientId: 'block-2', css: '.b{}' } ],
|
|
1370
|
+
[ 'override-1', { clientId: 'block-1', css: '.a{}' } ],
|
|
1371
|
+
[ 'override-global', { css: '.global{}' } ],
|
|
1372
|
+
] ),
|
|
1373
|
+
};
|
|
1374
|
+
|
|
1375
|
+
expect( getStyleOverrides( state ) ).toEqual( [
|
|
1376
|
+
[ 'override-global', { css: '.global{}' } ],
|
|
1377
|
+
[ 'override-1', { clientId: 'block-1', css: '.a{}' } ],
|
|
1378
|
+
[ 'override-2', { clientId: 'block-2', css: '.b{}' } ],
|
|
1379
|
+
] );
|
|
1380
|
+
} );
|
|
1381
|
+
} );
|
|
1382
|
+
|
|
1352
1383
|
describe( 'getBlockStyles', () => {
|
|
1353
1384
|
it( 'should return an empty object when no client IDs are provided', () => {
|
|
1354
1385
|
const state = {
|
|
@@ -2528,4 +2559,132 @@ describe( 'private selectors', () => {
|
|
|
2528
2559
|
);
|
|
2529
2560
|
} );
|
|
2530
2561
|
} );
|
|
2562
|
+
|
|
2563
|
+
describe( 'canHostEditableRoot', () => {
|
|
2564
|
+
beforeEach( () => {
|
|
2565
|
+
registerBlockType( 'core/test-editable-root', {
|
|
2566
|
+
apiVersion: 3,
|
|
2567
|
+
save: () => null,
|
|
2568
|
+
category: 'text',
|
|
2569
|
+
title: 'Editable root',
|
|
2570
|
+
[ editableRootKey ]: true,
|
|
2571
|
+
} );
|
|
2572
|
+
registerBlockType( 'core/test-plain', {
|
|
2573
|
+
apiVersion: 3,
|
|
2574
|
+
save: () => null,
|
|
2575
|
+
category: 'text',
|
|
2576
|
+
title: 'Plain',
|
|
2577
|
+
} );
|
|
2578
|
+
} );
|
|
2579
|
+
|
|
2580
|
+
afterEach( () => {
|
|
2581
|
+
unregisterBlockType( 'core/test-editable-root' );
|
|
2582
|
+
unregisterBlockType( 'core/test-plain' );
|
|
2583
|
+
} );
|
|
2584
|
+
|
|
2585
|
+
const createState = () => ( {
|
|
2586
|
+
blocks: {
|
|
2587
|
+
byClientId: new Map( [
|
|
2588
|
+
[ 'a', { name: 'core/test-editable-root' } ],
|
|
2589
|
+
[ 'b', { name: 'core/test-editable-root' } ],
|
|
2590
|
+
] ),
|
|
2591
|
+
attributes: new Map( [
|
|
2592
|
+
[ 'a', { content: 'a' } ],
|
|
2593
|
+
[ 'b', { content: 'b' } ],
|
|
2594
|
+
] ),
|
|
2595
|
+
order: new Map( [
|
|
2596
|
+
[ '', [ 'a', 'b' ] ],
|
|
2597
|
+
[ 'a', [] ],
|
|
2598
|
+
[ 'b', [] ],
|
|
2599
|
+
] ),
|
|
2600
|
+
parents: new Map( [
|
|
2601
|
+
[ 'a', '' ],
|
|
2602
|
+
[ 'b', '' ],
|
|
2603
|
+
] ),
|
|
2604
|
+
blockEditingModes: new Map(),
|
|
2605
|
+
},
|
|
2606
|
+
derivedBlockEditingModes: new Map(),
|
|
2607
|
+
blocksMode: {},
|
|
2608
|
+
} );
|
|
2609
|
+
|
|
2610
|
+
it( 'should return true for a block supporting editableRoot with editable siblings', () => {
|
|
2611
|
+
expect( canHostEditableRoot( createState(), 'a' ) ).toBe( true );
|
|
2612
|
+
} );
|
|
2613
|
+
|
|
2614
|
+
it( 'should return false for a lone block', () => {
|
|
2615
|
+
const state = createState();
|
|
2616
|
+
state.blocks.order = new Map( [
|
|
2617
|
+
[ '', [ 'a' ] ],
|
|
2618
|
+
[ 'a', [] ],
|
|
2619
|
+
] );
|
|
2620
|
+
|
|
2621
|
+
expect( canHostEditableRoot( state, 'a' ) ).toBe( false );
|
|
2622
|
+
} );
|
|
2623
|
+
|
|
2624
|
+
it( 'should return false when a sibling is not editable', () => {
|
|
2625
|
+
const state = createState();
|
|
2626
|
+
state.derivedBlockEditingModes = new Map( [ [ 'b', 'disabled' ] ] );
|
|
2627
|
+
|
|
2628
|
+
expect( canHostEditableRoot( state, 'a' ) ).toBe( false );
|
|
2629
|
+
} );
|
|
2630
|
+
|
|
2631
|
+
// The sibling scan is O(siblings) and runs in every rich text instance.
|
|
2632
|
+
it( 'should not recompute when only block attributes change', () => {
|
|
2633
|
+
const state = createState();
|
|
2634
|
+
expect( canHostEditableRoot( state, 'a' ) ).toBe( true );
|
|
2635
|
+
|
|
2636
|
+
// Change the uncached result without touching a dependant.
|
|
2637
|
+
state.blocks.byClientId.set( 'a', { name: 'core/test-plain' } );
|
|
2638
|
+
|
|
2639
|
+
const nextState = {
|
|
2640
|
+
...state,
|
|
2641
|
+
blocks: {
|
|
2642
|
+
...state.blocks,
|
|
2643
|
+
attributes: new Map( [
|
|
2644
|
+
[ 'a', { content: 'typed' } ],
|
|
2645
|
+
[ 'b', { content: 'b' } ],
|
|
2646
|
+
] ),
|
|
2647
|
+
},
|
|
2648
|
+
};
|
|
2649
|
+
|
|
2650
|
+
expect( canHostEditableRoot( nextState, 'a' ) ).toBe( true );
|
|
2651
|
+
|
|
2652
|
+
nextState.blocks.byClientId = new Map( state.blocks.byClientId );
|
|
2653
|
+
expect( canHostEditableRoot( nextState, 'a' ) ).toBe( false );
|
|
2654
|
+
} );
|
|
2655
|
+
|
|
2656
|
+
// The memoization above is only reachable if the reducer preserves
|
|
2657
|
+
// these references through a keystroke.
|
|
2658
|
+
it( 'should keep its dependants referentially stable while typing', () => {
|
|
2659
|
+
const block = ( clientId ) => ( {
|
|
2660
|
+
clientId,
|
|
2661
|
+
name: 'core/test-editable-root',
|
|
2662
|
+
attributes: { content: clientId },
|
|
2663
|
+
innerBlocks: [],
|
|
2664
|
+
} );
|
|
2665
|
+
const state = reducer( reducer( undefined, { type: '@@init' } ), {
|
|
2666
|
+
type: 'RESET_BLOCKS',
|
|
2667
|
+
blocks: [ block( 'a' ), block( 'b' ) ],
|
|
2668
|
+
} );
|
|
2669
|
+
|
|
2670
|
+
const next = reducer( state, {
|
|
2671
|
+
type: 'UPDATE_BLOCK_ATTRIBUTES',
|
|
2672
|
+
clientIds: [ 'a' ],
|
|
2673
|
+
attributes: { content: 'typed' },
|
|
2674
|
+
} );
|
|
2675
|
+
|
|
2676
|
+
// Guards against the assertions below passing vacuously.
|
|
2677
|
+
expect( next.blocks.attributes ).not.toBe(
|
|
2678
|
+
state.blocks.attributes
|
|
2679
|
+
);
|
|
2680
|
+
|
|
2681
|
+
const before = canHostEditableRoot.getDependants( state );
|
|
2682
|
+
const after = canHostEditableRoot.getDependants( next );
|
|
2683
|
+
|
|
2684
|
+
expect( after ).toHaveLength( before.length );
|
|
2685
|
+
after.forEach( ( dependant, index ) => {
|
|
2686
|
+
expect( dependant ).toBe( before[ index ] );
|
|
2687
|
+
} );
|
|
2688
|
+
} );
|
|
2689
|
+
} );
|
|
2531
2690
|
} );
|
package/src/style.scss
CHANGED
|
@@ -35,9 +35,11 @@
|
|
|
35
35
|
@use "./components/fit-text-size-warning/style.scss" as *;
|
|
36
36
|
@use "./components/font-appearance-control/style.scss" as *;
|
|
37
37
|
@use "./components/global-styles/style.scss" as *;
|
|
38
|
+
@use "./components/global-styles/inheritance/style.scss" as *;
|
|
38
39
|
@use "./components/grid/style.scss" as *;
|
|
39
40
|
@use "./components/height-control/style.scss" as *;
|
|
40
41
|
@use "./components/iframe/style.scss" as *;
|
|
42
|
+
@use "./components/image-editor/style.scss" as *;
|
|
41
43
|
@use "./components/inserter-list-item/style.scss" as *;
|
|
42
44
|
@use "./components/inspector-controls/styles.scss" as *;
|
|
43
45
|
@use "./components/inspector-controls-tabs/style.scss" as *;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Elements whose content the browser's own undo acts on (a dialog input, an
|
|
8
|
+
* HTML editing field, a search field), registered through `useNativeUndo`.
|
|
9
|
+
* The editor history must not act on events originating within them.
|
|
10
|
+
*/
|
|
11
|
+
const nativeUndoNodes = new WeakSet();
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Returns a ref that marks an element (and its descendants) as relying on
|
|
15
|
+
* the browser's own undo, so the editor history leaves the undo and redo
|
|
16
|
+
* shortcuts alone within it.
|
|
17
|
+
*
|
|
18
|
+
* @return {Function} Ref callback.
|
|
19
|
+
*/
|
|
20
|
+
export function useNativeUndo() {
|
|
21
|
+
return useRefEffect( ( node ) => {
|
|
22
|
+
nativeUndoNodes.add( node );
|
|
23
|
+
return () => {
|
|
24
|
+
nativeUndoNodes.delete( node );
|
|
25
|
+
};
|
|
26
|
+
}, [] );
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Returns true when the event originates from an element registered through
|
|
31
|
+
* `useNativeUndo`.
|
|
32
|
+
*
|
|
33
|
+
* Events coming from the editor canvas are re-dispatched on the iframe
|
|
34
|
+
* element, so the real target is resolved through the frame's focused
|
|
35
|
+
* element.
|
|
36
|
+
*
|
|
37
|
+
* @param {KeyboardEvent} event Keyboard event.
|
|
38
|
+
*
|
|
39
|
+
* @return {boolean} Whether the element relies on the browser's own undo.
|
|
40
|
+
*/
|
|
41
|
+
export function usesNativeUndo( event ) {
|
|
42
|
+
let { target } = event;
|
|
43
|
+
|
|
44
|
+
if ( target?.nodeName === 'IFRAME' ) {
|
|
45
|
+
target = target.contentDocument?.activeElement;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
while ( target ) {
|
|
49
|
+
if ( nativeUndoNodes.has( target ) ) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
target = target.parentElement;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/block-editor/src/components/duotone/utils.js
|
|
21
|
-
var utils_exports = {};
|
|
22
|
-
__export(utils_exports, {
|
|
23
|
-
getDuotoneFilter: () => getDuotoneFilter,
|
|
24
|
-
getDuotoneStylesheet: () => getDuotoneStylesheet,
|
|
25
|
-
getDuotoneUnsetStylesheet: () => getDuotoneUnsetStylesheet,
|
|
26
|
-
getValuesFromColors: () => getValuesFromColors
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(utils_exports);
|
|
29
|
-
var import_colord = require("colord");
|
|
30
|
-
function getValuesFromColors(colors = []) {
|
|
31
|
-
const values = { r: [], g: [], b: [], a: [] };
|
|
32
|
-
colors.forEach((color) => {
|
|
33
|
-
const rgbColor = (0, import_colord.colord)(color).toRgb();
|
|
34
|
-
values.r.push(rgbColor.r / 255);
|
|
35
|
-
values.g.push(rgbColor.g / 255);
|
|
36
|
-
values.b.push(rgbColor.b / 255);
|
|
37
|
-
values.a.push(rgbColor.a);
|
|
38
|
-
});
|
|
39
|
-
return values;
|
|
40
|
-
}
|
|
41
|
-
function getDuotoneUnsetStylesheet(selector) {
|
|
42
|
-
return `${selector}{filter:none}`;
|
|
43
|
-
}
|
|
44
|
-
function getDuotoneStylesheet(selector, id) {
|
|
45
|
-
return `${selector}{filter:url(#${id})}`;
|
|
46
|
-
}
|
|
47
|
-
function getDuotoneFilter(id, colors) {
|
|
48
|
-
const values = getValuesFromColors(colors);
|
|
49
|
-
return `
|
|
50
|
-
<svg
|
|
51
|
-
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
52
|
-
viewBox="0 0 0 0"
|
|
53
|
-
width="0"
|
|
54
|
-
height="0"
|
|
55
|
-
focusable="false"
|
|
56
|
-
role="none"
|
|
57
|
-
aria-hidden="true"
|
|
58
|
-
style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
|
|
59
|
-
>
|
|
60
|
-
<defs>
|
|
61
|
-
<filter id="${id}">
|
|
62
|
-
<!--
|
|
63
|
-
Use sRGB instead of linearRGB so transparency looks correct.
|
|
64
|
-
Use perceptual brightness to convert to grayscale.
|
|
65
|
-
-->
|
|
66
|
-
<feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix>
|
|
67
|
-
<!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->
|
|
68
|
-
<feComponentTransfer color-interpolation-filters="sRGB">
|
|
69
|
-
<feFuncR type="table" tableValues="${values.r.join(" ")}"></feFuncR>
|
|
70
|
-
<feFuncG type="table" tableValues="${values.g.join(" ")}"></feFuncG>
|
|
71
|
-
<feFuncB type="table" tableValues="${values.b.join(" ")}"></feFuncB>
|
|
72
|
-
<feFuncA type="table" tableValues="${values.a.join(" ")}"></feFuncA>
|
|
73
|
-
</feComponentTransfer>
|
|
74
|
-
<!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->
|
|
75
|
-
<feComposite in2="SourceGraphic" operator="in"></feComposite>
|
|
76
|
-
</filter>
|
|
77
|
-
</defs>
|
|
78
|
-
</svg>`;
|
|
79
|
-
}
|
|
80
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
-
0 && (module.exports = {
|
|
82
|
-
getDuotoneFilter,
|
|
83
|
-
getDuotoneStylesheet,
|
|
84
|
-
getDuotoneUnsetStylesheet,
|
|
85
|
-
getValuesFromColors
|
|
86
|
-
});
|
|
87
|
-
//# sourceMappingURL=utils.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/duotone/utils.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { colord } from 'colord';\n\n/**\n * Convert a list of colors to an object of R, G, and B values.\n *\n * @param {string[]} colors Array of RBG color strings.\n *\n * @return {Object} R, G, and B values.\n */\nexport function getValuesFromColors( colors = [] ) {\n\tconst values = { r: [], g: [], b: [], a: [] };\n\n\tcolors.forEach( ( color ) => {\n\t\tconst rgbColor = colord( color ).toRgb();\n\t\tvalues.r.push( rgbColor.r / 255 );\n\t\tvalues.g.push( rgbColor.g / 255 );\n\t\tvalues.b.push( rgbColor.b / 255 );\n\t\tvalues.a.push( rgbColor.a );\n\t} );\n\n\treturn values;\n}\n\n/**\n * Stylesheet for disabling a global styles duotone filter.\n *\n * @param {string} selector Selector to disable the filter for.\n *\n * @return {string} Filter none style.\n */\nexport function getDuotoneUnsetStylesheet( selector ) {\n\treturn `${ selector }{filter:none}`;\n}\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {string} selector Selector to apply the filter to.\n * @param {string} id Unique id for this duotone filter.\n *\n * @return {string} Duotone filter style.\n */\nexport function getDuotoneStylesheet( selector, id ) {\n\treturn `${ selector }{filter:url(#${ id })}`;\n}\n\n/**\n * The SVG part of the duotone filter.\n *\n * @param {string} id Unique id for this duotone filter.\n * @param {string[]} colors Color strings from dark to light.\n *\n * @return {string} Duotone SVG.\n */\nexport function getDuotoneFilter( id, colors ) {\n\tconst values = getValuesFromColors( colors );\n\treturn `\n<svg\n\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\n\tviewBox=\"0 0 0 0\"\n\twidth=\"0\"\n\theight=\"0\"\n\tfocusable=\"false\"\n\trole=\"none\"\n\taria-hidden=\"true\"\n\tstyle=\"visibility: hidden; position: absolute; left: -9999px; overflow: hidden;\"\n>\n\t<defs>\n\t\t<filter id=\"${ id }\">\n\t\t\t<!--\n\t\t\t\tUse sRGB instead of linearRGB so transparency looks correct.\n\t\t\t\tUse perceptual brightness to convert to grayscale.\n\t\t\t-->\n\t\t\t<feColorMatrix color-interpolation-filters=\"sRGB\" type=\"matrix\" values=\" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 \"></feColorMatrix>\n\t\t\t<!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->\n\t\t\t<feComponentTransfer color-interpolation-filters=\"sRGB\">\n\t\t\t\t<feFuncR type=\"table\" tableValues=\"${ values.r.join( ' ' ) }\"></feFuncR>\n\t\t\t\t<feFuncG type=\"table\" tableValues=\"${ values.g.join( ' ' ) }\"></feFuncG>\n\t\t\t\t<feFuncB type=\"table\" tableValues=\"${ values.b.join( ' ' ) }\"></feFuncB>\n\t\t\t\t<feFuncA type=\"table\" tableValues=\"${ values.a.join( ' ' ) }\"></feFuncA>\n\t\t\t</feComponentTransfer>\n\t\t\t<!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->\n\t\t\t<feComposite in2=\"SourceGraphic\" operator=\"in\"></feComposite>\n\t\t</filter>\n\t</defs>\n</svg>`;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAuB;AAShB,SAAS,oBAAqB,SAAS,CAAC,GAAI;AAClD,QAAM,SAAS,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,EAAE;AAE5C,SAAO,QAAS,CAAE,UAAW;AAC5B,UAAM,eAAW,sBAAQ,KAAM,EAAE,MAAM;AACvC,WAAO,EAAE,KAAM,SAAS,IAAI,GAAI;AAChC,WAAO,EAAE,KAAM,SAAS,IAAI,GAAI;AAChC,WAAO,EAAE,KAAM,SAAS,IAAI,GAAI;AAChC,WAAO,EAAE,KAAM,SAAS,CAAE;AAAA,EAC3B,CAAE;AAEF,SAAO;AACR;AASO,SAAS,0BAA2B,UAAW;AACrD,SAAO,GAAI,QAAS;AACrB;AAUO,SAAS,qBAAsB,UAAU,IAAK;AACpD,SAAO,GAAI,QAAS,gBAAiB,EAAG;AACzC;AAUO,SAAS,iBAAkB,IAAI,QAAS;AAC9C,QAAM,SAAS,oBAAqB,MAAO;AAC3C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAYS,EAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yCAQsB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA,yCACrB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA,yCACrB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA,yCACrB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAO/D;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// packages/block-editor/src/components/duotone/utils.js
|
|
2
|
-
import { colord } from "colord";
|
|
3
|
-
function getValuesFromColors(colors = []) {
|
|
4
|
-
const values = { r: [], g: [], b: [], a: [] };
|
|
5
|
-
colors.forEach((color) => {
|
|
6
|
-
const rgbColor = colord(color).toRgb();
|
|
7
|
-
values.r.push(rgbColor.r / 255);
|
|
8
|
-
values.g.push(rgbColor.g / 255);
|
|
9
|
-
values.b.push(rgbColor.b / 255);
|
|
10
|
-
values.a.push(rgbColor.a);
|
|
11
|
-
});
|
|
12
|
-
return values;
|
|
13
|
-
}
|
|
14
|
-
function getDuotoneUnsetStylesheet(selector) {
|
|
15
|
-
return `${selector}{filter:none}`;
|
|
16
|
-
}
|
|
17
|
-
function getDuotoneStylesheet(selector, id) {
|
|
18
|
-
return `${selector}{filter:url(#${id})}`;
|
|
19
|
-
}
|
|
20
|
-
function getDuotoneFilter(id, colors) {
|
|
21
|
-
const values = getValuesFromColors(colors);
|
|
22
|
-
return `
|
|
23
|
-
<svg
|
|
24
|
-
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
25
|
-
viewBox="0 0 0 0"
|
|
26
|
-
width="0"
|
|
27
|
-
height="0"
|
|
28
|
-
focusable="false"
|
|
29
|
-
role="none"
|
|
30
|
-
aria-hidden="true"
|
|
31
|
-
style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
|
|
32
|
-
>
|
|
33
|
-
<defs>
|
|
34
|
-
<filter id="${id}">
|
|
35
|
-
<!--
|
|
36
|
-
Use sRGB instead of linearRGB so transparency looks correct.
|
|
37
|
-
Use perceptual brightness to convert to grayscale.
|
|
38
|
-
-->
|
|
39
|
-
<feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix>
|
|
40
|
-
<!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->
|
|
41
|
-
<feComponentTransfer color-interpolation-filters="sRGB">
|
|
42
|
-
<feFuncR type="table" tableValues="${values.r.join(" ")}"></feFuncR>
|
|
43
|
-
<feFuncG type="table" tableValues="${values.g.join(" ")}"></feFuncG>
|
|
44
|
-
<feFuncB type="table" tableValues="${values.b.join(" ")}"></feFuncB>
|
|
45
|
-
<feFuncA type="table" tableValues="${values.a.join(" ")}"></feFuncA>
|
|
46
|
-
</feComponentTransfer>
|
|
47
|
-
<!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->
|
|
48
|
-
<feComposite in2="SourceGraphic" operator="in"></feComposite>
|
|
49
|
-
</filter>
|
|
50
|
-
</defs>
|
|
51
|
-
</svg>`;
|
|
52
|
-
}
|
|
53
|
-
export {
|
|
54
|
-
getDuotoneFilter,
|
|
55
|
-
getDuotoneStylesheet,
|
|
56
|
-
getDuotoneUnsetStylesheet,
|
|
57
|
-
getValuesFromColors
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=utils.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/duotone/utils.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { colord } from 'colord';\n\n/**\n * Convert a list of colors to an object of R, G, and B values.\n *\n * @param {string[]} colors Array of RBG color strings.\n *\n * @return {Object} R, G, and B values.\n */\nexport function getValuesFromColors( colors = [] ) {\n\tconst values = { r: [], g: [], b: [], a: [] };\n\n\tcolors.forEach( ( color ) => {\n\t\tconst rgbColor = colord( color ).toRgb();\n\t\tvalues.r.push( rgbColor.r / 255 );\n\t\tvalues.g.push( rgbColor.g / 255 );\n\t\tvalues.b.push( rgbColor.b / 255 );\n\t\tvalues.a.push( rgbColor.a );\n\t} );\n\n\treturn values;\n}\n\n/**\n * Stylesheet for disabling a global styles duotone filter.\n *\n * @param {string} selector Selector to disable the filter for.\n *\n * @return {string} Filter none style.\n */\nexport function getDuotoneUnsetStylesheet( selector ) {\n\treturn `${ selector }{filter:none}`;\n}\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {string} selector Selector to apply the filter to.\n * @param {string} id Unique id for this duotone filter.\n *\n * @return {string} Duotone filter style.\n */\nexport function getDuotoneStylesheet( selector, id ) {\n\treturn `${ selector }{filter:url(#${ id })}`;\n}\n\n/**\n * The SVG part of the duotone filter.\n *\n * @param {string} id Unique id for this duotone filter.\n * @param {string[]} colors Color strings from dark to light.\n *\n * @return {string} Duotone SVG.\n */\nexport function getDuotoneFilter( id, colors ) {\n\tconst values = getValuesFromColors( colors );\n\treturn `\n<svg\n\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\n\tviewBox=\"0 0 0 0\"\n\twidth=\"0\"\n\theight=\"0\"\n\tfocusable=\"false\"\n\trole=\"none\"\n\taria-hidden=\"true\"\n\tstyle=\"visibility: hidden; position: absolute; left: -9999px; overflow: hidden;\"\n>\n\t<defs>\n\t\t<filter id=\"${ id }\">\n\t\t\t<!--\n\t\t\t\tUse sRGB instead of linearRGB so transparency looks correct.\n\t\t\t\tUse perceptual brightness to convert to grayscale.\n\t\t\t-->\n\t\t\t<feColorMatrix color-interpolation-filters=\"sRGB\" type=\"matrix\" values=\" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 \"></feColorMatrix>\n\t\t\t<!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->\n\t\t\t<feComponentTransfer color-interpolation-filters=\"sRGB\">\n\t\t\t\t<feFuncR type=\"table\" tableValues=\"${ values.r.join( ' ' ) }\"></feFuncR>\n\t\t\t\t<feFuncG type=\"table\" tableValues=\"${ values.g.join( ' ' ) }\"></feFuncG>\n\t\t\t\t<feFuncB type=\"table\" tableValues=\"${ values.b.join( ' ' ) }\"></feFuncB>\n\t\t\t\t<feFuncA type=\"table\" tableValues=\"${ values.a.join( ' ' ) }\"></feFuncA>\n\t\t\t</feComponentTransfer>\n\t\t\t<!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->\n\t\t\t<feComposite in2=\"SourceGraphic\" operator=\"in\"></feComposite>\n\t\t</filter>\n\t</defs>\n</svg>`;\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,cAAc;AAShB,SAAS,oBAAqB,SAAS,CAAC,GAAI;AAClD,QAAM,SAAS,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,EAAE;AAE5C,SAAO,QAAS,CAAE,UAAW;AAC5B,UAAM,WAAW,OAAQ,KAAM,EAAE,MAAM;AACvC,WAAO,EAAE,KAAM,SAAS,IAAI,GAAI;AAChC,WAAO,EAAE,KAAM,SAAS,IAAI,GAAI;AAChC,WAAO,EAAE,KAAM,SAAS,IAAI,GAAI;AAChC,WAAO,EAAE,KAAM,SAAS,CAAE;AAAA,EAC3B,CAAE;AAEF,SAAO;AACR;AASO,SAAS,0BAA2B,UAAW;AACrD,SAAO,GAAI,QAAS;AACrB;AAUO,SAAS,qBAAsB,UAAU,IAAK;AACpD,SAAO,GAAI,QAAS,gBAAiB,EAAG;AACzC;AAUO,SAAS,iBAAkB,IAAI,QAAS;AAC9C,QAAM,SAAS,oBAAqB,MAAO;AAC3C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAYS,EAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yCAQsB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA,yCACrB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA,yCACrB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA,yCACrB,OAAO,EAAE,KAAM,GAAI,CAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAO/D;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { colord } from 'colord';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Convert a list of colors to an object of R, G, and B values.
|
|
8
|
-
*
|
|
9
|
-
* @param {string[]} colors Array of RBG color strings.
|
|
10
|
-
*
|
|
11
|
-
* @return {Object} R, G, and B values.
|
|
12
|
-
*/
|
|
13
|
-
export function getValuesFromColors( colors = [] ) {
|
|
14
|
-
const values = { r: [], g: [], b: [], a: [] };
|
|
15
|
-
|
|
16
|
-
colors.forEach( ( color ) => {
|
|
17
|
-
const rgbColor = colord( color ).toRgb();
|
|
18
|
-
values.r.push( rgbColor.r / 255 );
|
|
19
|
-
values.g.push( rgbColor.g / 255 );
|
|
20
|
-
values.b.push( rgbColor.b / 255 );
|
|
21
|
-
values.a.push( rgbColor.a );
|
|
22
|
-
} );
|
|
23
|
-
|
|
24
|
-
return values;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Stylesheet for disabling a global styles duotone filter.
|
|
29
|
-
*
|
|
30
|
-
* @param {string} selector Selector to disable the filter for.
|
|
31
|
-
*
|
|
32
|
-
* @return {string} Filter none style.
|
|
33
|
-
*/
|
|
34
|
-
export function getDuotoneUnsetStylesheet( selector ) {
|
|
35
|
-
return `${ selector }{filter:none}`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* SVG and stylesheet needed for rendering the duotone filter.
|
|
40
|
-
*
|
|
41
|
-
* @param {string} selector Selector to apply the filter to.
|
|
42
|
-
* @param {string} id Unique id for this duotone filter.
|
|
43
|
-
*
|
|
44
|
-
* @return {string} Duotone filter style.
|
|
45
|
-
*/
|
|
46
|
-
export function getDuotoneStylesheet( selector, id ) {
|
|
47
|
-
return `${ selector }{filter:url(#${ id })}`;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* The SVG part of the duotone filter.
|
|
52
|
-
*
|
|
53
|
-
* @param {string} id Unique id for this duotone filter.
|
|
54
|
-
* @param {string[]} colors Color strings from dark to light.
|
|
55
|
-
*
|
|
56
|
-
* @return {string} Duotone SVG.
|
|
57
|
-
*/
|
|
58
|
-
export function getDuotoneFilter( id, colors ) {
|
|
59
|
-
const values = getValuesFromColors( colors );
|
|
60
|
-
return `
|
|
61
|
-
<svg
|
|
62
|
-
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
63
|
-
viewBox="0 0 0 0"
|
|
64
|
-
width="0"
|
|
65
|
-
height="0"
|
|
66
|
-
focusable="false"
|
|
67
|
-
role="none"
|
|
68
|
-
aria-hidden="true"
|
|
69
|
-
style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
|
|
70
|
-
>
|
|
71
|
-
<defs>
|
|
72
|
-
<filter id="${ id }">
|
|
73
|
-
<!--
|
|
74
|
-
Use sRGB instead of linearRGB so transparency looks correct.
|
|
75
|
-
Use perceptual brightness to convert to grayscale.
|
|
76
|
-
-->
|
|
77
|
-
<feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix>
|
|
78
|
-
<!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. -->
|
|
79
|
-
<feComponentTransfer color-interpolation-filters="sRGB">
|
|
80
|
-
<feFuncR type="table" tableValues="${ values.r.join( ' ' ) }"></feFuncR>
|
|
81
|
-
<feFuncG type="table" tableValues="${ values.g.join( ' ' ) }"></feFuncG>
|
|
82
|
-
<feFuncB type="table" tableValues="${ values.b.join( ' ' ) }"></feFuncB>
|
|
83
|
-
<feFuncA type="table" tableValues="${ values.a.join( ' ' ) }"></feFuncA>
|
|
84
|
-
</feComponentTransfer>
|
|
85
|
-
<!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. -->
|
|
86
|
-
<feComposite in2="SourceGraphic" operator="in"></feComposite>
|
|
87
|
-
</filter>
|
|
88
|
-
</defs>
|
|
89
|
-
</svg>`;
|
|
90
|
-
}
|