@wordpress/block-editor 16.2.0 → 17.0.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 +39 -0
- package/build/components/block-inspector/index.cjs +9 -6
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-keyboard-shortcuts/index.cjs +201 -0
- package/build/components/block-keyboard-shortcuts/index.cjs.map +7 -0
- package/build/components/block-list/block.cjs +10 -3
- package/build/components/block-list/block.cjs.map +2 -2
- package/build/components/block-list/index.cjs +6 -1
- package/build/components/block-list/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-first-element.cjs +4 -0
- package/build/components/block-list/use-block-props/use-focus-first-element.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +6 -7
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
- package/build/components/block-parent-selector/index.cjs +98 -29
- package/build/components/block-parent-selector/index.cjs.map +3 -3
- package/build/components/block-popover/inbetween.cjs +2 -2
- package/build/components/block-popover/inbetween.cjs.map +2 -2
- package/build/components/block-preview/index.cjs +0 -4
- package/build/components/block-preview/index.cjs.map +2 -2
- package/build/components/block-styles/index.cjs +77 -33
- package/build/components/block-styles/index.cjs.map +3 -3
- package/build/components/block-visibility/constants.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors/with-colors.cjs +55 -71
- package/build/components/colors/with-colors.cjs.map +2 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs +4 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/index.cjs +18 -16
- package/build/components/dimensions-tool/index.cjs.map +2 -2
- package/build/components/dimensions-tool/utils.cjs +61 -0
- package/build/components/dimensions-tool/utils.cjs.map +7 -0
- package/build/components/duotone-control/index.cjs +2 -0
- package/build/components/duotone-control/index.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs.map +3 -3
- package/build/components/global-styles/border-panel.cjs +2 -5
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/color-panel.cjs +14 -2
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +9 -5
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/filters-panel.cjs +12 -8
- package/build/components/global-styles/filters-panel.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs +16 -11
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/utils.cjs +9 -0
- package/build/components/global-styles/utils.cjs.map +2 -2
- package/build/components/inner-blocks/index.cjs +5 -3
- package/build/components/inner-blocks/index.cjs.map +2 -2
- package/build/components/inserter/block-patterns-explorer/index.cjs +39 -22
- package/build/components/inserter/block-patterns-explorer/index.cjs.map +2 -2
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.cjs +21 -55
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.cjs.map +2 -2
- package/build/components/inserter/block-patterns-explorer/pattern-list.cjs +19 -44
- package/build/components/inserter/block-patterns-explorer/pattern-list.cjs.map +3 -3
- package/build/components/inserter/hooks/use-insertion-point.cjs +4 -4
- package/build/components/inserter/hooks/use-insertion-point.cjs.map +2 -2
- package/build/components/inserter/menu.cjs +18 -7
- package/build/components/inserter/menu.cjs.map +2 -2
- package/build/components/inserter/quick-inserter.cjs +30 -27
- package/build/components/inserter/quick-inserter.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/list-view/index.cjs +31 -5
- package/build/components/list-view/index.cjs.map +3 -3
- package/build/components/list-view/utils.cjs +13 -1
- package/build/components/list-view/utils.cjs.map +2 -2
- package/build/components/media-placeholder/index.cjs +1 -1
- package/build/components/media-placeholder/index.cjs.map +3 -3
- package/build/components/provider/index.cjs +5 -1
- package/build/components/provider/index.cjs.map +3 -3
- package/build/components/publish-date-time-picker/index.cjs +3 -2
- package/build/components/publish-date-time-picker/index.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/enter.cjs +46 -39
- package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
- package/build/components/rich-text/index.cjs +7 -5
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/rich-text/multiline.cjs +105 -70
- package/build/components/rich-text/multiline.cjs.map +3 -3
- package/build/components/url-input/index.cjs.map +2 -2
- package/build/components/writing-flow/use-input.cjs +65 -13
- package/build/components/writing-flow/use-input.cjs.map +3 -3
- package/build/hooks/border.cjs +25 -3
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +9 -2
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/duotone.cjs +4 -3
- package/build/hooks/duotone.cjs.map +2 -2
- package/build/hooks/gap.cjs +8 -2
- package/build/hooks/gap.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +35 -13
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +23 -1
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/states.cjs +7 -4
- package/build/hooks/states.cjs.map +2 -2
- package/build/layouts/constrained.cjs +8 -1
- package/build/layouts/constrained.cjs.map +2 -2
- package/build/layouts/flex.cjs +9 -0
- package/build/layouts/flex.cjs.map +2 -2
- package/build/layouts/flow.cjs +4 -1
- package/build/layouts/flow.cjs.map +2 -2
- package/build/layouts/grid.cjs +5 -1
- package/build/layouts/grid.cjs.map +2 -2
- package/build/private-apis.cjs +3 -1
- package/build/private-apis.cjs.map +2 -2
- package/build/store/actions.cjs +1 -1
- package/build/store/actions.cjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +9 -6
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-keyboard-shortcuts/index.mjs +173 -0
- package/build-module/components/block-keyboard-shortcuts/index.mjs.map +7 -0
- package/build-module/components/block-list/block.mjs +10 -3
- package/build-module/components/block-list/block.mjs.map +2 -2
- package/build-module/components/block-list/index.mjs +6 -1
- package/build-module/components/block-list/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs +4 -0
- package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +6 -7
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
- package/build-module/components/block-parent-selector/index.mjs +101 -32
- package/build-module/components/block-parent-selector/index.mjs.map +2 -2
- package/build-module/components/block-popover/inbetween.mjs +2 -2
- package/build-module/components/block-popover/inbetween.mjs.map +2 -2
- package/build-module/components/block-preview/index.mjs +0 -4
- package/build-module/components/block-preview/index.mjs.map +2 -2
- package/build-module/components/block-styles/index.mjs +79 -35
- package/build-module/components/block-styles/index.mjs.map +2 -2
- package/build-module/components/block-visibility/constants.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +5 -5
- package/build-module/components/child-layout-control/index.mjs.map +1 -1
- package/build-module/components/colors/with-colors.mjs +56 -72
- package/build-module/components/colors/with-colors.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +4 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/index.mjs +19 -17
- package/build-module/components/dimensions-tool/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/utils.mjs +35 -0
- package/build-module/components/dimensions-tool/utils.mjs.map +7 -0
- package/build-module/components/duotone-control/index.mjs +2 -0
- package/build-module/components/duotone-control/index.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +5 -2
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +2 -5
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +14 -2
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +9 -5
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +16 -9
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs +16 -11
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/utils.mjs +8 -0
- package/build-module/components/global-styles/utils.mjs.map +2 -2
- package/build-module/components/inner-blocks/index.mjs +5 -3
- package/build-module/components/inner-blocks/index.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-explorer/index.mjs +39 -22
- package/build-module/components/inserter/block-patterns-explorer/index.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.mjs +22 -56
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.mjs +20 -45
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-insertion-point.mjs +4 -4
- package/build-module/components/inserter/hooks/use-insertion-point.mjs.map +2 -2
- package/build-module/components/inserter/menu.mjs +19 -8
- package/build-module/components/inserter/menu.mjs.map +2 -2
- package/build-module/components/inserter/quick-inserter.mjs +30 -27
- package/build-module/components/inserter/quick-inserter.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/list-view/index.mjs +32 -5
- package/build-module/components/list-view/index.mjs.map +3 -3
- package/build-module/components/list-view/utils.mjs +13 -1
- package/build-module/components/list-view/utils.mjs.map +2 -2
- package/build-module/components/media-placeholder/index.mjs +3 -3
- package/build-module/components/media-placeholder/index.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +6 -2
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/publish-date-time-picker/index.mjs +3 -2
- package/build-module/components/publish-date-time-picker/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +46 -39
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +7 -5
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/rich-text/multiline.mjs +112 -72
- package/build-module/components/rich-text/multiline.mjs.map +2 -2
- package/build-module/components/url-input/index.mjs +2 -2
- package/build-module/components/url-input/index.mjs.map +1 -1
- package/build-module/components/writing-flow/use-input.mjs +66 -14
- package/build-module/components/writing-flow/use-input.mjs.map +3 -3
- package/build-module/hooks/border.mjs +26 -8
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +9 -2
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/duotone.mjs +8 -4
- package/build-module/hooks/duotone.mjs.map +2 -2
- package/build-module/hooks/gap.mjs +6 -1
- package/build-module/hooks/gap.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +36 -13
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +22 -1
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/states.mjs +8 -5
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/layouts/constrained.mjs +8 -1
- package/build-module/layouts/constrained.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +9 -0
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/flow.mjs +4 -1
- package/build-module/layouts/flow.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +5 -1
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/private-apis.mjs +3 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +1 -1
- package/build-module/store/actions.mjs.map +2 -2
- package/build-style/style-rtl.css +108 -71
- package/build-style/style.css +108 -71
- package/build-types/components/block-visibility/constants.d.ts +4 -3
- package/build-types/components/block-visibility/constants.d.ts.map +1 -1
- package/package.json +43 -43
- package/src/components/background-image-control/README.md +122 -0
- package/src/components/block-edit-visually-button/README.md +39 -0
- package/src/components/block-editing-mode/README.md +72 -0
- package/src/components/block-inspector/index.js +6 -6
- package/src/components/block-keyboard-shortcuts/index.js +256 -0
- package/src/components/block-list/block.js +7 -0
- package/src/components/block-list/index.js +7 -1
- package/src/components/block-list/use-block-props/use-focus-first-element.js +5 -0
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +6 -8
- package/src/components/block-parent-selector/index.js +111 -30
- package/src/components/block-popover/README.md +10 -3
- package/src/components/block-popover/inbetween.js +8 -2
- package/src/components/block-popover/stories/index.story.jsx +143 -0
- package/src/components/block-preview/index.js +0 -2
- package/src/components/block-styles/index.js +95 -43
- package/src/components/block-styles/style.scss +5 -34
- package/src/components/block-tools/style.scss +94 -0
- package/src/components/block-visibility/constants.ts +4 -3
- package/src/components/child-layout-control/index.js +5 -5
- package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -29
- package/src/components/colors/test/with-colors.js +6 -7
- package/src/components/colors/with-colors.js +79 -105
- package/src/components/dimensions-tool/aspect-ratio-tool.js +16 -4
- package/src/components/dimensions-tool/index.js +34 -22
- package/src/components/dimensions-tool/test/index.js +166 -2
- package/src/components/dimensions-tool/test/utils.js +51 -0
- package/src/components/dimensions-tool/utils.js +67 -0
- package/src/components/duotone-control/index.js +2 -0
- package/src/components/duotone-control/test/index.js +100 -0
- package/src/components/global-styles/advanced-panel.js +5 -2
- package/src/components/global-styles/border-panel.js +11 -9
- package/src/components/global-styles/color-panel.js +13 -1
- package/src/components/global-styles/dimensions-panel.js +17 -5
- package/src/components/global-styles/filters-panel.js +24 -10
- package/src/components/global-styles/shadow-panel-components.js +38 -11
- package/src/components/global-styles/test/border-panel.js +230 -0
- package/src/components/global-styles/test/color-panel.js +24 -0
- package/src/components/global-styles/test/dimensions-panel.js +98 -7
- package/src/components/global-styles/test/filters-panel.js +84 -0
- package/src/components/global-styles/test/utils.js +30 -0
- package/src/components/global-styles/utils.js +23 -0
- package/src/components/inner-blocks/index.js +11 -2
- package/src/components/inner-blocks/stories/index.story.jsx +246 -0
- package/src/components/inserter/block-patterns-explorer/index.js +24 -11
- package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +18 -56
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +22 -47
- package/src/components/inserter/hooks/use-insertion-point.js +9 -4
- package/src/components/inserter/menu.js +23 -10
- package/src/components/inserter/quick-inserter.js +15 -13
- package/src/components/inserter/style.scss +44 -62
- package/src/components/inspector-controls-tabs/README.md +92 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -1
- package/src/components/link-control/test/index.js +5 -0
- package/src/components/list-view/index.js +50 -7
- package/src/components/list-view/utils.js +16 -1
- package/src/components/media-placeholder/index.js +9 -4
- package/src/components/plain-text/stories/index.story.jsx +3 -0
- package/src/components/provider/index.js +7 -1
- package/src/components/publish-date-time-picker/README.md +10 -0
- package/src/components/publish-date-time-picker/index.js +17 -14
- package/src/components/rich-text/event-listeners/enter.js +58 -45
- package/src/components/rich-text/index.js +9 -4
- package/src/components/rich-text/multiline.js +126 -86
- package/src/components/url-input/index.js +2 -2
- package/src/components/url-input/test/fixtures/validated-input-control-deprecation.js +27 -0
- package/src/components/url-input/test/index.js +5 -0
- package/src/components/url-popover/README.md +7 -0
- package/src/components/url-popover/stories/index.story.jsx +133 -47
- package/src/components/writing-flow/use-input.js +105 -15
- package/src/hooks/border.js +27 -8
- package/src/hooks/dimensions.js +8 -1
- package/src/hooks/duotone.js +23 -7
- package/src/hooks/gap.js +16 -0
- package/src/hooks/layout-child.js +41 -9
- package/src/hooks/layout.js +117 -71
- package/src/hooks/states.js +8 -5
- package/src/hooks/test/gap.js +31 -1
- package/src/hooks/test/layout-child.js +60 -1
- package/src/hooks/test/layout.js +27 -0
- package/src/layouts/constrained.js +9 -1
- package/src/layouts/flex.js +15 -0
- package/src/layouts/flow.js +4 -1
- package/src/layouts/grid.js +9 -1
- package/src/layouts/test/constrained.js +26 -0
- package/src/layouts/test/flow.js +26 -0
- package/src/layouts/test/grid.js +46 -0
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +14 -1
- package/build/components/floating-toolbar/nav-up-icon.cjs +0 -52
- package/build/components/floating-toolbar/nav-up-icon.cjs.map +0 -7
- package/build/components/gradients/with-gradient.cjs +0 -36
- package/build/components/gradients/with-gradient.cjs.map +0 -7
- package/build/components/inserter-button/sparkles.cjs +0 -36
- package/build/components/inserter-button/sparkles.cjs.map +0 -7
- package/build-module/components/floating-toolbar/nav-up-icon.mjs +0 -31
- package/build-module/components/floating-toolbar/nav-up-icon.mjs.map +0 -7
- package/build-module/components/gradients/with-gradient.mjs +0 -11
- package/build-module/components/gradients/with-gradient.mjs.map +0 -7
- package/build-module/components/inserter-button/sparkles.mjs +0 -15
- package/build-module/components/inserter-button/sparkles.mjs.map +0 -7
- package/build-style/default-editor-styles-rtl.css +0 -68
- package/build-style/default-editor-styles.css +0 -68
- package/src/components/floating-toolbar/nav-up-icon.js +0 -22
- package/src/components/gradients/with-gradient.js +0 -9
- package/src/components/inserter-button/README.md +0 -62
- package/src/components/inserter-button/sparkles.js +0 -12
- package/src/default-editor-styles.scss +0 -25
|
@@ -37,54 +37,123 @@ var import_components = require("@wordpress/components");
|
|
|
37
37
|
var import_data = require("@wordpress/data");
|
|
38
38
|
var import_i18n = require("@wordpress/i18n");
|
|
39
39
|
var import_element = require("@wordpress/element");
|
|
40
|
+
var import_blocks = require("@wordpress/blocks");
|
|
41
|
+
var import_icons = require("@wordpress/icons");
|
|
40
42
|
var import_use_block_display_information = __toESM(require("../use-block-display-information/index.cjs"));
|
|
41
43
|
var import_block_icon = __toESM(require("../block-icon/index.cjs"));
|
|
44
|
+
var import_inserter = __toESM(require("../inserter/index.cjs"));
|
|
42
45
|
var import_utils = require("../block-toolbar/utils.cjs");
|
|
43
46
|
var import_store = require("../../store/index.cjs");
|
|
44
47
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
45
48
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
46
49
|
function BlockParentSelector() {
|
|
47
50
|
const { selectBlock } = (0, import_data.useDispatch)(import_store.store);
|
|
48
|
-
const { parentClientId } = (0, import_data.useSelect)(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
const { parentClientId, nextSiblingClientId, showInserter } = (0, import_data.useSelect)(
|
|
52
|
+
(select) => {
|
|
53
|
+
const {
|
|
54
|
+
getBlockParents,
|
|
55
|
+
getSelectedBlockClientIds,
|
|
56
|
+
getParentSectionBlock,
|
|
57
|
+
getBlockName,
|
|
58
|
+
getNextBlockClientId
|
|
59
|
+
} = (0, import_lock_unlock.unlock)(select(import_store.store));
|
|
60
|
+
const [selectedBlockClientId] = getSelectedBlockClientIds();
|
|
61
|
+
const parentSection = getParentSectionBlock(
|
|
62
|
+
selectedBlockClientId
|
|
63
|
+
);
|
|
64
|
+
const parents = getBlockParents(selectedBlockClientId);
|
|
65
|
+
const immediateParentClientId = parents[parents.length - 1];
|
|
66
|
+
const _parentClientId = parentSection ?? immediateParentClientId;
|
|
67
|
+
const parentBlockType = (0, import_blocks.getBlockType)(
|
|
68
|
+
getBlockName(_parentClientId)
|
|
69
|
+
);
|
|
70
|
+
const isTextFlowWrapper = parentBlockType?.merge || (0, import_blocks.hasBlockSupport)(parentBlockType, "__experimentalOnMerge");
|
|
71
|
+
return {
|
|
72
|
+
parentClientId: _parentClientId,
|
|
73
|
+
nextSiblingClientId: getNextBlockClientId(
|
|
74
|
+
selectedBlockClientId
|
|
75
|
+
),
|
|
76
|
+
// When the shown parent is a section further up the tree
|
|
77
|
+
// rather than the direct parent, its content is locked and
|
|
78
|
+
// nothing can be inserted, so no button.
|
|
79
|
+
showInserter: !!_parentClientId && _parentClientId === immediateParentClientId && !isTextFlowWrapper
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
[]
|
|
83
|
+
);
|
|
62
84
|
const blockInformation = (0, import_use_block_display_information.default)(parentClientId);
|
|
63
85
|
const nodeRef = (0, import_element.useRef)();
|
|
64
86
|
const showHoveredOrFocusedGestures = (0, import_utils.useShowHoveredOrFocusedGestures)({
|
|
65
87
|
ref: nodeRef,
|
|
66
88
|
highlightParent: true
|
|
67
89
|
});
|
|
68
|
-
|
|
90
|
+
const parentButton = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
91
|
+
import_components.ToolbarButton,
|
|
92
|
+
{
|
|
93
|
+
className: "block-editor-block-parent-selector__button",
|
|
94
|
+
onClick: () => selectBlock(parentClientId),
|
|
95
|
+
label: (0, import_i18n.sprintf)(
|
|
96
|
+
/* translators: %s: Name of the block's parent. */
|
|
97
|
+
(0, import_i18n.__)("Select parent block: %s"),
|
|
98
|
+
blockInformation?.title
|
|
99
|
+
),
|
|
100
|
+
showTooltip: true,
|
|
101
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_icon.default, { icon: blockInformation?.icon })
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
69
105
|
"div",
|
|
70
106
|
{
|
|
71
107
|
className: "block-editor-block-parent-selector",
|
|
72
108
|
ref: nodeRef,
|
|
73
109
|
...showHoveredOrFocusedGestures,
|
|
74
|
-
children:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
110
|
+
children: [
|
|
111
|
+
!showInserter && parentButton,
|
|
112
|
+
showInserter && // A real toolbar group, so the buttons get the standard
|
|
113
|
+
// toolbar sizing, and the group overlaps the container
|
|
114
|
+
// border the way toolbar groups overlap the toolbar box.
|
|
115
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.ToolbarGroup, { children: [
|
|
116
|
+
parentButton,
|
|
117
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
118
|
+
import_inserter.default,
|
|
119
|
+
{
|
|
120
|
+
position: "bottom right",
|
|
121
|
+
rootClientId: parentClientId,
|
|
122
|
+
clientId: nextSiblingClientId,
|
|
123
|
+
isAppender: !nextSiblingClientId,
|
|
124
|
+
__experimentalIsQuick: true,
|
|
125
|
+
renderToggle: ({
|
|
126
|
+
onToggle,
|
|
127
|
+
isOpen,
|
|
128
|
+
disabled,
|
|
129
|
+
blockTitle,
|
|
130
|
+
hasSingleBlockType
|
|
131
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
132
|
+
import_components.ToolbarButton,
|
|
133
|
+
{
|
|
134
|
+
className: "block-editor-block-parent-selector__inserter",
|
|
135
|
+
onClick: onToggle,
|
|
136
|
+
"aria-expanded": isOpen,
|
|
137
|
+
disabled,
|
|
138
|
+
label: hasSingleBlockType ? (0, import_i18n.sprintf)(
|
|
139
|
+
// translators: %s: the name of the block when there is only one
|
|
140
|
+
(0, import_i18n._x)(
|
|
141
|
+
"Add %s",
|
|
142
|
+
"directly add the only allowed block"
|
|
143
|
+
),
|
|
144
|
+
blockTitle.toLowerCase()
|
|
145
|
+
) : (0, import_i18n._x)(
|
|
146
|
+
"Add block",
|
|
147
|
+
"Generic label for block inserter button"
|
|
148
|
+
),
|
|
149
|
+
showTooltip: true,
|
|
150
|
+
icon: import_icons.plus
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
] })
|
|
156
|
+
]
|
|
88
157
|
},
|
|
89
158
|
parentClientId
|
|
90
159
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-parent-selector/index.js"],
|
|
4
|
-
"sourcesContent": ["import { ToolbarButton } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef } from '@wordpress/element';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport BlockIcon from '../block-icon';\nimport { useShowHoveredOrFocusedGestures } from '../block-toolbar/utils';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Block parent selector component, displaying the hierarchy of the\n * current block selection as a single icon to \"go up\" a level.\n *\n * @return {Component} Parent block selector.\n */\nexport default function BlockParentSelector() {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst { parentClientId } = useSelect(
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
6
|
-
"names": ["blockEditorStore", "useBlockDisplayInformation", "BlockIcon"]
|
|
4
|
+
"sourcesContent": ["import { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useRef } from '@wordpress/element';\nimport { getBlockType, hasBlockSupport } from '@wordpress/blocks';\nimport { plus } from '@wordpress/icons';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport BlockIcon from '../block-icon';\nimport Inserter from '../inserter';\nimport { useShowHoveredOrFocusedGestures } from '../block-toolbar/utils';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Block parent selector component, displaying the hierarchy of the\n * current block selection as a single icon to \"go up\" a level.\n *\n * @return {Component} Parent block selector.\n */\nexport default function BlockParentSelector() {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst { parentClientId, nextSiblingClientId, showInserter } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockParents,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\tgetParentSectionBlock,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetNextBlockClientId,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\t// Not getSelectedBlockClientId: a text selection crossing into a\n\t\t\t// nested block resolves to the ancestor alone, but its selection\n\t\t\t// start and end differ.\n\t\t\tconst [ selectedBlockClientId ] = getSelectedBlockClientIds();\n\t\t\tconst parentSection = getParentSectionBlock(\n\t\t\t\tselectedBlockClientId\n\t\t\t);\n\t\t\tconst parents = getBlockParents( selectedBlockClientId );\n\t\t\tconst immediateParentClientId = parents[ parents.length - 1 ];\n\t\t\tconst _parentClientId = parentSection ?? immediateParentClientId;\n\t\t\tconst parentBlockType = getBlockType(\n\t\t\t\tgetBlockName( _parentClientId )\n\t\t\t);\n\t\t\t// A wrapper that merges with the text flow (list, quote) grows\n\t\t\t// by typing: Enter continues it, and users know that. Any\n\t\t\t// other parent gets a plus button to add a child; the Inserter\n\t\t\t// hides itself when nothing is insertable.\n\t\t\tconst isTextFlowWrapper =\n\t\t\t\tparentBlockType?.merge ||\n\t\t\t\thasBlockSupport( parentBlockType, '__experimentalOnMerge' );\n\t\t\treturn {\n\t\t\t\tparentClientId: _parentClientId,\n\t\t\t\tnextSiblingClientId: getNextBlockClientId(\n\t\t\t\t\tselectedBlockClientId\n\t\t\t\t),\n\t\t\t\t// When the shown parent is a section further up the tree\n\t\t\t\t// rather than the direct parent, its content is locked and\n\t\t\t\t// nothing can be inserted, so no button.\n\t\t\t\tshowInserter:\n\t\t\t\t\t!! _parentClientId &&\n\t\t\t\t\t_parentClientId === immediateParentClientId &&\n\t\t\t\t\t! isTextFlowWrapper,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst blockInformation = useBlockDisplayInformation( parentClientId );\n\n\t// Allows highlighting the parent block outline when focusing or hovering\n\t// the parent block selector within the child.\n\tconst nodeRef = useRef();\n\tconst showHoveredOrFocusedGestures = useShowHoveredOrFocusedGestures( {\n\t\tref: nodeRef,\n\t\thighlightParent: true,\n\t} );\n\n\tconst parentButton = (\n\t\t<ToolbarButton\n\t\t\tclassName=\"block-editor-block-parent-selector__button\"\n\t\t\tonClick={ () => selectBlock( parentClientId ) }\n\t\t\tlabel={ sprintf(\n\t\t\t\t/* translators: %s: Name of the block's parent. */\n\t\t\t\t__( 'Select parent block: %s' ),\n\t\t\t\tblockInformation?.title\n\t\t\t) }\n\t\t\tshowTooltip\n\t\t\ticon={ <BlockIcon icon={ blockInformation?.icon } /> }\n\t\t/>\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-parent-selector\"\n\t\t\tkey={ parentClientId }\n\t\t\tref={ nodeRef }\n\t\t\t{ ...showHoveredOrFocusedGestures }\n\t\t>\n\t\t\t{ ! showInserter && parentButton }\n\t\t\t{ showInserter && (\n\t\t\t\t// A real toolbar group, so the buttons get the standard\n\t\t\t\t// toolbar sizing, and the group overlaps the container\n\t\t\t\t// border the way toolbar groups overlap the toolbar box.\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ parentButton }\n\t\t\t\t\t<Inserter\n\t\t\t\t\t\tposition=\"bottom right\"\n\t\t\t\t\t\trootClientId={ parentClientId }\n\t\t\t\t\t\tclientId={ nextSiblingClientId }\n\t\t\t\t\t\tisAppender={ ! nextSiblingClientId }\n\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t\trenderToggle={ ( {\n\t\t\t\t\t\t\tonToggle,\n\t\t\t\t\t\t\tisOpen,\n\t\t\t\t\t\t\tdisabled,\n\t\t\t\t\t\t\tblockTitle,\n\t\t\t\t\t\t\thasSingleBlockType,\n\t\t\t\t\t\t} ) => (\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-parent-selector__inserter\"\n\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\thasSingleBlockType\n\t\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t\t\t\t\t\t\t\t\t\t_x(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Add %s',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'directly add the only allowed block'\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\tblockTitle.toLowerCase()\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: _x(\n\t\t\t\t\t\t\t\t\t\t\t\t'Add block',\n\t\t\t\t\t\t\t\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA4C;AAC5C,kBAAuC;AACvC,kBAAgC;AAChC,qBAAuB;AACvB,oBAA8C;AAC9C,mBAAqB;AACrB,2CAAuC;AACvC,wBAAsB;AACtB,sBAAqB;AACrB,mBAAgD;AAChD,mBAA0C;AAC1C,yBAAuB;AA2Eb;AAnEK,SAAR,sBAAuC;AAC7C,QAAM,EAAE,YAAY,QAAI,yBAAa,aAAAA,KAAiB;AACtD,QAAM,EAAE,gBAAgB,qBAAqB,aAAa,QAAI;AAAA,IAC7D,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,QAAI,2BAAQ,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AA,cACX,YAAa,CAAE;AAAA,cACf,uBAAqB;AAAA,cACrB,cAAe,CAAE;AAAA,gBAChB;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,cACD,MACC;AAAA,gBAAC;AAAA;AAAA,kBACA,WAAU;AAAA,kBACV,SAAU;AAAA,kBACV,iBAAgB;AAAA,kBAChB;AAAA,kBACA,OACC,yBACG;AAAA;AAAA,wBAEA;AAAA,sBACC;AAAA,sBACA;AAAA,oBACD;AAAA,oBACA,WAAW,YAAY;AAAA,kBACvB,QACA;AAAA,oBACA;AAAA,oBACA;AAAA,kBACA;AAAA,kBAEJ,aAAW;AAAA,kBACX,MAAO;AAAA;AAAA,cACR;AAAA;AAAA,UAEF;AAAA,WACD;AAAA;AAAA;AAAA,IAjDK;AAAA,EAmDP;AAEF;",
|
|
6
|
+
"names": ["blockEditorStore", "useBlockDisplayInformation", "BlockIcon", "Inserter"]
|
|
7
7
|
}
|
|
@@ -106,9 +106,9 @@ function BlockPopoverInbetween({
|
|
|
106
106
|
left = nearestSide === "left" ? targetRect.left - 2 : targetRect.right - 2;
|
|
107
107
|
} else if (isVertical) {
|
|
108
108
|
top = previousRect ? previousRect.bottom : nextRect.top;
|
|
109
|
-
width = previousRect ? previousRect.width : nextRect.width;
|
|
109
|
+
width = nextRect && previousRect ? (previousRect.width + nextRect.width) / 2 : (previousRect || nextRect).width;
|
|
110
110
|
height = nextRect && previousRect ? nextRect.top - previousRect.bottom : 0;
|
|
111
|
-
left = previousRect ? previousRect.left : nextRect.left;
|
|
111
|
+
left = nextRect && previousRect ? (previousRect.left + nextRect.left) / 2 : (previousRect || nextRect).left;
|
|
112
112
|
} else {
|
|
113
113
|
top = previousRect ? previousRect.top : nextRect.top;
|
|
114
114
|
height = previousRect ? previousRect.height : nextRect.height;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-popover/inbetween.js"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo, useReducer, useLayoutEffect } from '@wordpress/element';\nimport { Popover } from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nfunction BlockPopoverInbetween( {\n\tpreviousClientId,\n\tnextClientId,\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\toperation = 'insert',\n\tnearestSide = 'right',\n\t...props\n} ) {\n\t// This is a temporary hack to get the inbetween inserter to recompute properly.\n\tconst [ popoverRecomputeCounter, forcePopoverRecompute ] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\tconst { orientation, rootClientId, isVisible } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tisBlockVisible,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\tpreviousClientId ?? nextClientId\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torientation:\n\t\t\t\t\tgetBlockListSettings( _rootClientId )?.orientation ||\n\t\t\t\t\t'vertical',\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisVisible:\n\t\t\t\t\tisBlockVisible( previousClientId ) &&\n\t\t\t\t\tisBlockVisible( nextClientId ),\n\t\t\t};\n\t\t},\n\t\t[ previousClientId, nextClientId ]\n\t);\n\tconst previousElement = useBlockElement( previousClientId );\n\tconst nextElement = useBlockElement( nextClientId );\n\tconst isVertical = orientation === 'vertical';\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverRecomputeCounter is by definition always equal or greater than 0.\n\t\t\t// This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverRecomputeCounter < 0 ||\n\t\t\t( ! previousElement && ! nextElement ) ||\n\t\t\t! isVisible\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst contextElement =\n\t\t\toperation === 'group'\n\t\t\t\t? nextElement || previousElement\n\t\t\t\t: previousElement || nextElement;\n\n\t\treturn {\n\t\t\tcontextElement,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst previousRect = previousElement\n\t\t\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\t\t\t\tconst nextRect = nextElement\n\t\t\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\n\t\t\t\tlet left = 0;\n\t\t\t\tlet top = 0;\n\t\t\t\tlet width = 0;\n\t\t\t\tlet height = 0;\n\n\t\t\t\tif ( operation === 'group' ) {\n\t\t\t\t\tconst targetRect = nextRect || previousRect;\n\t\t\t\t\ttop = targetRect.top;\n\t\t\t\t\t// No spacing is likely around blocks in this operation.\n\t\t\t\t\t// So width of the inserter containing rect is set to 0.\n\t\t\t\t\twidth = 0;\n\t\t\t\t\theight = targetRect.bottom - targetRect.top;\n\t\t\t\t\t// Popover calculates its distance from mid-block so some\n\t\t\t\t\t// adjustments are needed to make it appear in the right place.\n\t\t\t\t\tleft =\n\t\t\t\t\t\tnearestSide === 'left'\n\t\t\t\t\t\t\t? targetRect.left - 2\n\t\t\t\t\t\t\t: targetRect.right - 2;\n\t\t\t\t} else if ( isVertical ) {\n\t\t\t\t\t// vertical\n\t\t\t\t\ttop = previousRect ? previousRect.bottom : nextRect.top;\n\t\t\t\t\twidth
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAA0B;AAC1B,qBAAqD;AACrD,wBAAwB;AACxB,kBAAsB;AACtB,mBAA0C;AAC1C,4BAAgC;AAChC,gCAA6B;
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo, useReducer, useLayoutEffect } from '@wordpress/element';\nimport { Popover } from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nfunction BlockPopoverInbetween( {\n\tpreviousClientId,\n\tnextClientId,\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\toperation = 'insert',\n\tnearestSide = 'right',\n\t...props\n} ) {\n\t// This is a temporary hack to get the inbetween inserter to recompute properly.\n\tconst [ popoverRecomputeCounter, forcePopoverRecompute ] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\tconst { orientation, rootClientId, isVisible } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tisBlockVisible,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\tpreviousClientId ?? nextClientId\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torientation:\n\t\t\t\t\tgetBlockListSettings( _rootClientId )?.orientation ||\n\t\t\t\t\t'vertical',\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisVisible:\n\t\t\t\t\tisBlockVisible( previousClientId ) &&\n\t\t\t\t\tisBlockVisible( nextClientId ),\n\t\t\t};\n\t\t},\n\t\t[ previousClientId, nextClientId ]\n\t);\n\tconst previousElement = useBlockElement( previousClientId );\n\tconst nextElement = useBlockElement( nextClientId );\n\tconst isVertical = orientation === 'vertical';\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverRecomputeCounter is by definition always equal or greater than 0.\n\t\t\t// This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverRecomputeCounter < 0 ||\n\t\t\t( ! previousElement && ! nextElement ) ||\n\t\t\t! isVisible\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst contextElement =\n\t\t\toperation === 'group'\n\t\t\t\t? nextElement || previousElement\n\t\t\t\t: previousElement || nextElement;\n\n\t\treturn {\n\t\t\tcontextElement,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst previousRect = previousElement\n\t\t\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\t\t\t\tconst nextRect = nextElement\n\t\t\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\n\t\t\t\tlet left = 0;\n\t\t\t\tlet top = 0;\n\t\t\t\tlet width = 0;\n\t\t\t\tlet height = 0;\n\n\t\t\t\tif ( operation === 'group' ) {\n\t\t\t\t\tconst targetRect = nextRect || previousRect;\n\t\t\t\t\ttop = targetRect.top;\n\t\t\t\t\t// No spacing is likely around blocks in this operation.\n\t\t\t\t\t// So width of the inserter containing rect is set to 0.\n\t\t\t\t\twidth = 0;\n\t\t\t\t\theight = targetRect.bottom - targetRect.top;\n\t\t\t\t\t// Popover calculates its distance from mid-block so some\n\t\t\t\t\t// adjustments are needed to make it appear in the right place.\n\t\t\t\t\tleft =\n\t\t\t\t\t\tnearestSide === 'left'\n\t\t\t\t\t\t\t? targetRect.left - 2\n\t\t\t\t\t\t\t: targetRect.right - 2;\n\t\t\t\t} else if ( isVertical ) {\n\t\t\t\t\t// vertical\n\t\t\t\t\ttop = previousRect ? previousRect.bottom : nextRect.top;\n\t\t\t\t\twidth =\n\t\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t\t? ( previousRect.width + nextRect.width ) / 2\n\t\t\t\t\t\t\t: ( previousRect || nextRect ).width;\n\t\t\t\t\theight =\n\t\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tleft =\n\t\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t\t? ( previousRect.left + nextRect.left ) / 2\n\t\t\t\t\t\t\t: ( previousRect || nextRect ).left;\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\n\t\t\t\t\theight = previousRect\n\t\t\t\t\t\t? previousRect.height\n\t\t\t\t\t\t: nextRect.height;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// non vertical, rtl\n\t\t\t\t\t\tleft = nextRect ? nextRect.right : previousRect.left;\n\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\tpreviousRect && nextRect\n\t\t\t\t\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// non vertical, ltr\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.left;\n\t\t\t\t\t\twidth =\n\t\t\t\t\t\t\tpreviousRect && nextRect\n\t\t\t\t\t\t\t\t? nextRect.left - previousRect.right\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Avoid a negative width which happens when the next rect\n\t\t\t\t\t// is on the next line.\n\t\t\t\t\twidth = Math.max( width, 0 );\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tpopoverRecomputeCounter,\n\t\tisVertical,\n\t\tisVisible,\n\t\toperation,\n\t\tnearestSide,\n\t] );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\n\t// This is only needed for a smooth transition when moving blocks.\n\t// When blocks are moved up/down, their position can be set by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( previousElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ previousElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! nextElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( nextElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ nextElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tpreviousElement.ownerDocument.defaultView.addEventListener(\n\t\t\t'resize',\n\t\t\tforcePopoverRecompute\n\t\t);\n\t\treturn () => {\n\t\t\tpreviousElement.ownerDocument.defaultView?.removeEventListener(\n\t\t\t\t'resize',\n\t\t\t\tforcePopoverRecompute\n\t\t\t);\n\t\t};\n\t}, [ previousElement ] );\n\n\t// If there's either a previous or a next element, show the inbetween popover.\n\t// Note that drag and drop uses the inbetween popover to show the drop indicator\n\t// before the first block and after the last block.\n\tif ( ( ! previousElement && ! nextElement ) || ! isVisible ) {\n\t\treturn null;\n\t}\n\n\t// While ideally it would be enough to capture the\n\t// bubbling focus event from the Inserter, due to the\n\t// characteristics of click focusing of `button`s in\n\t// Firefox and Safari, it is not reliable.\n\t//\n\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot }\n\t\t\tinline={ ! __unstablePopoverSlot }\n\t\t\t// Forces a remount of the popover when its position changes\n\t\t\t// This makes sure the popover doesn't animate from its previous position.\n\t\t\tkey={ nextClientId + '--' + rootClientId }\n\t\t\t{ ...props }\n\t\t\tclassName={ clsx(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\t'block-editor-block-popover__inbetween',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tplacement=\"overlay\"\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"block-editor-block-popover__inbetween-container\">\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</Popover>\n\t);\n}\n\nexport default BlockPopoverInbetween;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAA0B;AAC1B,qBAAqD;AACrD,wBAAwB;AACxB,kBAAsB;AACtB,mBAA0C;AAC1C,4BAAgC;AAChC,gCAA6B;AA6O1B;AA3OH,IAAM,gCAAgC,OAAO;AAE7C,SAAS,sBAAuB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,GAAG;AACJ,GAAI;AAEH,QAAM,CAAE,yBAAyB,qBAAsB,QAAI;AAAA;AAAA,IAE1D,CAAE,OAAS,IAAI,KAAM;AAAA,IACrB;AAAA,EACD;AAEA,QAAM,EAAE,aAAa,cAAc,UAAU,QAAI;AAAA,IAChD,CAAE,W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;AACA,WAAO,MAAM;AACZ,sBAAgB,cAAc,aAAa;AAAA,QAC1C;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,EACD,GAAG,CAAE,eAAgB,CAAE;AAKvB,MAAO,CAAE,mBAAmB,CAAE,eAAiB,CAAE,WAAY;AAC5D,WAAO;AAAA,EACR;AAQA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,KAAM;AAAA,MACN,SAAU;AAAA,MACV,QAAS;AAAA,MACT,cAAe;AAAA,MAGf,oBAAqB;AAAA,MACrB,QAAS,CAAE;AAAA,MAIT,GAAG;AAAA,MACL,eAAY,YAAAC;AAAA,QACX;AAAA,QACA;AAAA,QACA,MAAM;AAAA,MACP;AAAA,MACA,QAAS;AAAA,MACT,MAAO;AAAA,MACP,WAAU;AAAA,MACV,SAAQ;AAAA,MAER,sDAAC,SAAI,WAAU,mDACZ,UACH;AAAA;AAAA,IAdM,eAAe,OAAO;AAAA,EAe7B;AAEF;AAEA,IAAO,oBAAQ;",
|
|
6
6
|
"names": ["blockEditorStore", "usePopoverScroll", "clsx"]
|
|
7
7
|
}
|
|
@@ -83,8 +83,6 @@ function BlockPreview({
|
|
|
83
83
|
const settings = (0, import_element.useMemo)(
|
|
84
84
|
() => ({
|
|
85
85
|
...originalSettings,
|
|
86
|
-
focusMode: false,
|
|
87
|
-
// Disable "Spotlight mode".
|
|
88
86
|
isPreviewMode: true
|
|
89
87
|
}),
|
|
90
88
|
[originalSettings]
|
|
@@ -125,8 +123,6 @@ function useBlockPreview({ blocks, props = {}, layout }) {
|
|
|
125
123
|
...originalSettings,
|
|
126
124
|
styles: void 0,
|
|
127
125
|
// Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.
|
|
128
|
-
focusMode: false,
|
|
129
|
-
// Disable "Spotlight mode".
|
|
130
126
|
isPreviewMode: true
|
|
131
127
|
}),
|
|
132
128
|
[originalSettings]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-preview/index.js"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { useDisabled, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { memo, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\nimport { ExperimentalBlockEditorProvider } from '../provider';\nimport AutoHeightBlockPreview from './auto';\nimport EditorStyles from '../editor-styles';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockListItems } from '../block-list';\nimport { Async } from './async';\n\nconst EMPTY_ADDITIONAL_STYLES = [];\n\nexport function BlockPreview( {\n\tblocks,\n\tviewportWidth = 1200,\n\tminHeight,\n\tadditionalStyles = EMPTY_ADDITIONAL_STYLES,\n\t// Deprecated props:\n\t__experimentalMinHeight,\n\t__experimentalPadding,\n} ) {\n\tif ( __experimentalMinHeight ) {\n\t\tminHeight = __experimentalMinHeight;\n\t\tdeprecated( 'The __experimentalMinHeight prop', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'minHeight',\n\t\t} );\n\t}\n\tif ( __experimentalPadding ) {\n\t\tadditionalStyles = [\n\t\t\t...additionalStyles,\n\t\t\t{ css: `body { padding: ${ __experimentalPadding }px; }` },\n\t\t];\n\t\tdeprecated( 'The __experimentalPadding prop of BlockPreview', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'additionalStyles',\n\t\t} );\n\t}\n\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,qBAA0C;AAC1C,kBAA0B;AAC1B,qBAA8B;AAC9B,wBAAuB;AACvB,sBAAgD;AAChD,kBAAmC;AACnC,2BAAyB;AACzB,mBAA0C;AAC1C,wBAA+B;AAC/B,mBAAsB;
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { useDisabled, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { memo, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\nimport { ExperimentalBlockEditorProvider } from '../provider';\nimport AutoHeightBlockPreview from './auto';\nimport EditorStyles from '../editor-styles';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockListItems } from '../block-list';\nimport { Async } from './async';\n\nconst EMPTY_ADDITIONAL_STYLES = [];\n\nexport function BlockPreview( {\n\tblocks,\n\tviewportWidth = 1200,\n\tminHeight,\n\tadditionalStyles = EMPTY_ADDITIONAL_STYLES,\n\t// Deprecated props:\n\t__experimentalMinHeight,\n\t__experimentalPadding,\n} ) {\n\tif ( __experimentalMinHeight ) {\n\t\tminHeight = __experimentalMinHeight;\n\t\tdeprecated( 'The __experimentalMinHeight prop', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'minHeight',\n\t\t} );\n\t}\n\tif ( __experimentalPadding ) {\n\t\tadditionalStyles = [\n\t\t\t...additionalStyles,\n\t\t\t{ css: `body { padding: ${ __experimentalPadding }px; }` },\n\t\t];\n\t\tdeprecated( 'The __experimentalPadding prop of BlockPreview', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'additionalStyles',\n\t\t} );\n\t}\n\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ originalSettings ]\n\t);\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tif ( ! blocks || blocks.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<AutoHeightBlockPreview\n\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tadditionalStyles={ additionalStyles }\n\t\t\t/>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n\nconst MemoizedBlockPreview = memo( BlockPreview );\n\nMemoizedBlockPreview.Async = Async;\n\n/**\n * BlockPreview renders a preview of a block or array of blocks.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md\n *\n * @param {Object} preview options for how the preview should be shown\n * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.\n * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.\n *\n * @return {Component} The component to be rendered.\n */\nexport default MemoizedBlockPreview;\n\n/**\n * This hook is used to lightly mark an element as a block preview wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * a block preview wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} options Preview options.\n * @param {WPBlock[]} options.blocks Block objects.\n * @param {Object} options.props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options.layout Layout settings to be used in the preview.\n */\nexport function useBlockPreview( { blocks, props = {}, layout } ) {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tstyles: undefined, // Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ originalSettings ]\n\t);\n\tconst disabledRef = useDisabled();\n\tconst ref = useMergeRefs( [ props.ref, disabledRef ] );\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tconst children = (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<EditorStyles />\n\t\t\t<BlockListItems renderAppender={ false } layout={ layout } />\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: clsx(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-preview__live-content',\n\t\t\t'components-disabled'\n\t\t),\n\t\tchildren: blocks?.length ? children : null,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,qBAA0C;AAC1C,kBAA0B;AAC1B,qBAA8B;AAC9B,wBAAuB;AACvB,sBAAgD;AAChD,kBAAmC;AACnC,2BAAyB;AACzB,mBAA0C;AAC1C,wBAA+B;AAC/B,mBAAsB;AA0DnB;AAxDH,IAAM,0BAA0B,CAAC;AAE1B,SAAS,aAAc;AAAA,EAC7B;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA,mBAAmB;AAAA;AAAA,EAEnB;AAAA,EACA;AACD,GAAI;AACH,MAAK,yBAA0B;AAC9B,gBAAY;AACZ,0BAAAA,SAAY,oCAAoC;AAAA,MAC/C,OAAO;AAAA,MACP,SAAS;AAAA,MACT,aAAa;AAAA,IACd,CAAE;AAAA,EACH;AACA,MAAK,uBAAwB;AAC5B,uBAAmB;AAAA,MAClB,GAAG;AAAA,MACH,EAAE,KAAK,mBAAoB,qBAAsB,QAAQ;AAAA,IAC1D;AACA,0BAAAA,SAAY,kDAAkD;AAAA,MAC7D,OAAO;AAAA,MACP,SAAS;AAAA,MACT,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C;AAAA;AAAA,MACA,OAAQ;AAAA,MACR;AAAA,MAEA;AAAA,oDAAC,qBAAAE,SAAA,EAAa;AAAA,QACd,4CAAC,oCAAe,gBAAiB,OAAQ,QAAkB;AAAA;AAAA;AAAA,EAC5D;AAGD,SAAO;AAAA,IACN,GAAG;AAAA,IACH;AAAA,IACA,eAAW,YAAAC;AAAA,MACV,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IACD;AAAA,IACA,UAAU,QAAQ,SAAS,WAAW;AAAA,EACvC;AACD;",
|
|
6
6
|
"names": ["deprecated", "blockEditorStore", "AutoHeightBlockPreview", "EditorStyles", "clsx"]
|
|
7
7
|
}
|
|
@@ -33,11 +33,11 @@ __export(block_styles_exports, {
|
|
|
33
33
|
default: () => block_styles_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(block_styles_exports);
|
|
36
|
-
var import_clsx = __toESM(require("clsx"));
|
|
37
36
|
var import_element = require("@wordpress/element");
|
|
38
37
|
var import_data = require("@wordpress/data");
|
|
39
38
|
var import_compose = require("@wordpress/compose");
|
|
40
39
|
var import_components = require("@wordpress/components");
|
|
40
|
+
var import_ui = require("@wordpress/ui");
|
|
41
41
|
var import_i18n = require("@wordpress/i18n");
|
|
42
42
|
var import_preview_block_popover = __toESM(require("../block-switcher/preview-block-popover.cjs"));
|
|
43
43
|
var import_use_styles_for_block = __toESM(require("./use-styles-for-block.cjs"));
|
|
@@ -47,6 +47,7 @@ var import_store = require("../../store/index.cjs");
|
|
|
47
47
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
48
|
var noop = () => {
|
|
49
49
|
};
|
|
50
|
+
var getCompositeItemId = (instanceId, style) => `${instanceId}-${style.name}`;
|
|
50
51
|
function BlockStyles({ clientId, onSwitch = noop, onHoverClassName = noop }) {
|
|
51
52
|
const canEdit = (0, import_data.useSelect)(
|
|
52
53
|
(select) => select(import_store.store).canEditBlock(clientId),
|
|
@@ -65,6 +66,17 @@ function BlockStyles({ clientId, onSwitch = noop, onHoverClassName = noop }) {
|
|
|
65
66
|
const [hoveredStyle, setHoveredStyle] = (0, import_element.useState)(null);
|
|
66
67
|
const [blockStylesAnchor, setBlockStylesAnchor] = (0, import_element.useState)(null);
|
|
67
68
|
const dropdownMenuProps = (0, import_utils.useToolsPanelDropdownMenuProps)();
|
|
69
|
+
const instanceId = (0, import_compose.useInstanceId)(
|
|
70
|
+
BlockStyles,
|
|
71
|
+
"block-editor-block-styles"
|
|
72
|
+
);
|
|
73
|
+
const styleRows = (0, import_element.useMemo)(() => {
|
|
74
|
+
const rows = [];
|
|
75
|
+
for (let i = 0; i < (stylesToRender?.length ?? 0); i += 2) {
|
|
76
|
+
rows.push(stylesToRender.slice(i, i + 2));
|
|
77
|
+
}
|
|
78
|
+
return rows;
|
|
79
|
+
}, [stylesToRender]);
|
|
68
80
|
const previewBlocks = (0, import_element.useMemo)(() => {
|
|
69
81
|
if (!hoveredStyle || !genericPreviewBlock) {
|
|
70
82
|
return null;
|
|
@@ -102,6 +114,14 @@ function BlockStyles({ clientId, onSwitch = noop, onHoverClassName = noop }) {
|
|
|
102
114
|
debouncedSetHoveredStyle(item);
|
|
103
115
|
onHoverClassName(item?.name ?? null);
|
|
104
116
|
};
|
|
117
|
+
const onSetActiveId = (nextActiveId) => {
|
|
118
|
+
const nextStyle = stylesToRender.find(
|
|
119
|
+
(style) => getCompositeItemId(instanceId, style) === nextActiveId
|
|
120
|
+
);
|
|
121
|
+
if (nextStyle && nextStyle.name !== activeStyle.name) {
|
|
122
|
+
onSelectStylePreview(nextStyle);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
105
125
|
const defaultStyle = (0, import_utils2.getDefaultStyle)(stylesToRender);
|
|
106
126
|
const hasValue = () => {
|
|
107
127
|
return activeStyle?.name !== defaultStyle?.name;
|
|
@@ -131,38 +151,62 @@ function BlockStyles({ clientId, onSwitch = noop, onHoverClassName = noop }) {
|
|
|
131
151
|
ref: setBlockStylesAnchor,
|
|
132
152
|
className: "block-editor-block-styles",
|
|
133
153
|
children: [
|
|
134
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
154
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
155
|
+
import_components.Composite,
|
|
156
|
+
{
|
|
157
|
+
role: "radiogroup",
|
|
158
|
+
"aria-label": (0, import_i18n.__)("Styles"),
|
|
159
|
+
className: "block-editor-block-styles__variants",
|
|
160
|
+
activeId: getCompositeItemId(
|
|
161
|
+
instanceId,
|
|
162
|
+
activeStyle
|
|
163
|
+
),
|
|
164
|
+
setActiveId: onSetActiveId,
|
|
165
|
+
focusLoop: true,
|
|
166
|
+
focusWrap: true,
|
|
167
|
+
focusShift: true,
|
|
168
|
+
children: styleRows.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
169
|
+
import_components.Composite.Row,
|
|
170
|
+
{
|
|
171
|
+
className: "block-editor-block-styles__row",
|
|
172
|
+
children: row.map((style) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
173
|
+
import_components.Composite.Item,
|
|
174
|
+
{
|
|
175
|
+
id: getCompositeItemId(
|
|
176
|
+
instanceId,
|
|
177
|
+
style
|
|
178
|
+
),
|
|
179
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
180
|
+
import_ui.Button,
|
|
181
|
+
{
|
|
182
|
+
className: "block-editor-block-styles__item",
|
|
183
|
+
tone: "neutral",
|
|
184
|
+
variant: activeStyle.name === style.name ? "solid" : "outline"
|
|
185
|
+
}
|
|
186
|
+
),
|
|
187
|
+
role: "radio",
|
|
188
|
+
"aria-checked": activeStyle.name === style.name,
|
|
189
|
+
onMouseEnter: () => styleItemHandler(style),
|
|
190
|
+
onFocus: () => styleItemHandler(style),
|
|
191
|
+
onMouseLeave: () => styleItemHandler(null),
|
|
192
|
+
onBlur: () => styleItemHandler(null),
|
|
193
|
+
onClick: () => onSelectStylePreview(style),
|
|
194
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
195
|
+
import_components.__experimentalTruncate,
|
|
196
|
+
{
|
|
197
|
+
numberOfLines: 3,
|
|
198
|
+
className: "block-editor-block-styles__item-text",
|
|
199
|
+
children: style.label || style.name
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
},
|
|
203
|
+
style.name
|
|
204
|
+
))
|
|
205
|
+
},
|
|
206
|
+
rowIndex
|
|
207
|
+
))
|
|
208
|
+
}
|
|
209
|
+
),
|
|
166
210
|
previewBlocks && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
167
211
|
import_preview_block_popover.default,
|
|
168
212
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-styles/index.js"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
6
|
-
"names": ["import_utils", "blockEditorStore", "useStylesForBlocks", "ToolsPanel", "ToolsPanelItem", "
|
|
4
|
+
"sourcesContent": ["import { useState, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { debounce, useInstanceId } from '@wordpress/compose';\nimport {\n\tComposite,\n\t__experimentalTruncate as Truncate,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { Button } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport PreviewBlockPopover from '../block-switcher/preview-block-popover';\nimport useStylesForBlocks from './use-styles-for-block';\nimport { useToolsPanelDropdownMenuProps } from '../global-styles/utils';\nimport { getDefaultStyle, replaceActiveStyle } from './utils';\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\nconst getCompositeItemId = ( instanceId, style ) =>\n\t`${ instanceId }-${ style.name }`;\n\n// Block Styles component for the Settings Sidebar.\nfunction BlockStyles( { clientId, onSwitch = noop, onHoverClassName = noop } ) {\n\tconst canEdit = useSelect(\n\t\t( select ) => select( blockEditorStore ).canEditBlock( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst {\n\t\tonSelect,\n\t\tstylesToRender,\n\t\tactiveStyle,\n\t\tgenericPreviewBlock,\n\t\tclassName,\n\t} = useStylesForBlocks( {\n\t\tclientId,\n\t\tonSwitch,\n\t} );\n\tconst [ hoveredStyle, setHoveredStyle ] = useState( null );\n\tconst [ blockStylesAnchor, setBlockStylesAnchor ] = useState( null );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst instanceId = useInstanceId(\n\t\tBlockStyles,\n\t\t'block-editor-block-styles'\n\t);\n\n\tconst styleRows = useMemo( () => {\n\t\tconst rows = [];\n\t\tfor ( let i = 0; i < ( stylesToRender?.length ?? 0 ); i += 2 ) {\n\t\t\trows.push( stylesToRender.slice( i, i + 2 ) );\n\t\t}\n\t\treturn rows;\n\t}, [ stylesToRender ] );\n\n\tconst previewBlocks = useMemo( () => {\n\t\tif ( ! hoveredStyle || ! genericPreviewBlock ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst previewClassName = replaceActiveStyle(\n\t\t\tclassName,\n\t\t\tactiveStyle,\n\t\t\thoveredStyle\n\t\t);\n\t\treturn [\n\t\t\t{\n\t\t\t\t...genericPreviewBlock,\n\t\t\t\tattributes: {\n\t\t\t\t\t...( genericPreviewBlock.attributes || {} ),\n\t\t\t\t\tclassName: previewClassName,\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}, [ hoveredStyle, genericPreviewBlock, className, activeStyle ] );\n\n\tif ( ! canEdit || ! stylesToRender || stylesToRender.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst debouncedSetHoveredStyle = debounce( setHoveredStyle, 250 );\n\n\tconst onSelectStylePreview = ( style ) => {\n\t\tonSelect( style );\n\t\tonHoverClassName( null );\n\t\tsetHoveredStyle( null );\n\t\tdebouncedSetHoveredStyle.cancel();\n\t};\n\n\tconst styleItemHandler = ( item ) => {\n\t\tif ( hoveredStyle === item ) {\n\t\t\tdebouncedSetHoveredStyle.cancel();\n\t\t\treturn;\n\t\t}\n\t\tdebouncedSetHoveredStyle( item );\n\t\tonHoverClassName( item?.name ?? null );\n\t};\n\n\tconst onSetActiveId = ( nextActiveId ) => {\n\t\tconst nextStyle = stylesToRender.find(\n\t\t\t( style ) =>\n\t\t\t\tgetCompositeItemId( instanceId, style ) === nextActiveId\n\t\t);\n\t\tif ( nextStyle && nextStyle.name !== activeStyle.name ) {\n\t\t\tonSelectStylePreview( nextStyle );\n\t\t}\n\t};\n\n\tconst defaultStyle = getDefaultStyle( stylesToRender );\n\n\tconst hasValue = () => {\n\t\treturn activeStyle?.name !== defaultStyle?.name;\n\t};\n\n\tconst onDeselect = () => {\n\t\tonSelectStylePreview( defaultStyle );\n\t};\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ __( 'Styles' ) }\n\t\t\tresetAll={ onDeselect }\n\t\t\tpanelId={ clientId }\n\t\t\thasInnerWrapper\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ hasValue }\n\t\t\t\tlabel={ __( 'Variation' ) }\n\t\t\t\tonDeselect={ onDeselect }\n\t\t\t\tisShownByDefault\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tref={ setBlockStylesAnchor }\n\t\t\t\t\tclassName=\"block-editor-block-styles\"\n\t\t\t\t>\n\t\t\t\t\t<Composite\n\t\t\t\t\t\trole=\"radiogroup\"\n\t\t\t\t\t\taria-label={ __( 'Styles' ) }\n\t\t\t\t\t\tclassName=\"block-editor-block-styles__variants\"\n\t\t\t\t\t\tactiveId={ getCompositeItemId(\n\t\t\t\t\t\t\tinstanceId,\n\t\t\t\t\t\t\tactiveStyle\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tsetActiveId={ onSetActiveId }\n\t\t\t\t\t\tfocusLoop\n\t\t\t\t\t\tfocusWrap\n\t\t\t\t\t\tfocusShift\n\t\t\t\t\t>\n\t\t\t\t\t\t{ styleRows.map( ( row, rowIndex ) => (\n\t\t\t\t\t\t\t<Composite.Row\n\t\t\t\t\t\t\t\tkey={ rowIndex }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-styles__row\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ row.map( ( style ) => (\n\t\t\t\t\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\t\t\t\t\tkey={ style.name }\n\t\t\t\t\t\t\t\t\t\tid={ getCompositeItemId(\n\t\t\t\t\t\t\t\t\t\t\tinstanceId,\n\t\t\t\t\t\t\t\t\t\t\tstyle\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-styles__item\"\n\t\t\t\t\t\t\t\t\t\t\t\ttone=\"neutral\"\n\t\t\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\t\t\tactiveStyle.name ===\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle.name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 'solid'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: 'outline'\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\trole=\"radio\"\n\t\t\t\t\t\t\t\t\t\taria-checked={\n\t\t\t\t\t\t\t\t\t\t\tactiveStyle.name === style.name\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonMouseEnter={ () =>\n\t\t\t\t\t\t\t\t\t\t\tstyleItemHandler( style )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonFocus={ () =>\n\t\t\t\t\t\t\t\t\t\t\tstyleItemHandler( style )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonMouseLeave={ () =>\n\t\t\t\t\t\t\t\t\t\t\tstyleItemHandler( null )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonBlur={ () =>\n\t\t\t\t\t\t\t\t\t\t\tstyleItemHandler( null )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\tonSelectStylePreview( style )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\t\t\t\t\tnumberOfLines={ 3 }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-styles__item-text\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ style.label || style.name }\n\t\t\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t\t\t</Composite.Item>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</Composite.Row>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Composite>\n\t\t\t\t\t{ previewBlocks && (\n\t\t\t\t\t\t<PreviewBlockPopover\n\t\t\t\t\t\t\tblocks={ previewBlocks }\n\t\t\t\t\t\t\tplacement=\"left-start\"\n\t\t\t\t\t\t\toffset={ 34 }\n\t\t\t\t\t\t\tanchor={ blockStylesAnchor }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</ToolsPanelItem>\n\t\t</ToolsPanel>\n\t);\n}\n\nexport default BlockStyles;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAkC;AAClC,kBAA0B;AAC1B,qBAAwC;AACxC,wBAKO;AAEP,gBAAuB;AACvB,kBAAmB;AACnB,mCAAgC;AAChC,kCAA+B;AAC/B,mBAA+C;AAC/C,IAAAA,gBAAoD;AACpD,mBAA0C;AAoHtC;AAlHJ,IAAM,OAAO,MAAM;AAAC;AAEpB,IAAM,qBAAqB,CAAE,YAAY,UACxC,GAAI,UAAW,IAAK,MAAM,IAAK;AAGhC,SAAS,YAAa,EAAE,UAAU,WAAW,MAAM,mBAAmB,KAAK,GAAI;AAC9E,QAAM,cAAU;AAAA,IACf,CAAE,WAAY,OAAQ,aAAAC,KAAiB,EAAE,aAAc,QAAS;AAAA,IAChE,CAAE,QAAS;AAAA,EACZ;AACA,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,4BAAAC,SAAoB;AAAA,IACvB;AAAA,IACA;AAAA,EACD,CAAE;AACF,QAAM,CAAE,cAAc,eAAgB,QAAI,yBAAU,IAAK;AACzD,QAAM,CAAE,mBAAmB,oBAAqB,QAAI,yBAAU,IAAK;AACnE,QAAM,wBAAoB,6CAA+B;AACzD,QAAM,iBAAa;AAAA,IAClB;AAAA,IACA;AAAA,EACD;AAEA,QAAM,gBAAY,wBAAS,MAAM;AAChC,UAAM,OAAO,CAAC;AACd,aAAU,IAAI,GAAG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sB,KAAM;AAAA,4BAG7B;AAAA,8BAAC,kBAAAC;AAAA,8BAAA;AAAA,gCACA,eAAgB;AAAA,gCAChB,WAAU;AAAA,gCAER,gBAAM,SAAS,MAAM;AAAA;AAAA,4BACxB;AAAA;AAAA,0BA1CM,MAAM;AAAA,wBA2Cb,CACC;AAAA;AAAA,sBAjDI;AAAA,oBAkDP,CACC;AAAA;AAAA,gBACH;AAAA,gBACE,iBACD;AAAA,kBAAC,6BAAAC;AAAA,kBAAA;AAAA,oBACA,QAAS;AAAA,oBACT,WAAU;AAAA,oBACV,QAAS;AAAA,oBACT,QAAS;AAAA;AAAA,gBACV;AAAA;AAAA;AAAA,UAEF;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,uBAAQ;",
|
|
6
|
+
"names": ["import_utils", "blockEditorStore", "useStylesForBlocks", "ToolsPanel", "ToolsPanelItem", "Truncate", "PreviewBlockPopover"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-visibility/constants.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ReactElement } from 'react';\nimport { __ } from '@wordpress/i18n';\nimport { desktop, tablet, mobile } from '@wordpress/icons';\n\n/**\n * The viewports for which block visibility can be controlled.\n */\nexport type BlockVisibilityViewport = 'desktop' | 'tablet' | 'mobile';\n\n/**\n * The choices for the block visibility.\n *\n * Duplicated in packages/editor/src/components/preview-dropdown/index.js (choices
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAmB;AACnB,mBAAwC;
|
|
4
|
+
"sourcesContent": ["import type { ReactElement } from 'react';\nimport { __ } from '@wordpress/i18n';\nimport { desktop, tablet, mobile } from '@wordpress/icons';\n\n/**\n * The viewports for which block visibility can be controlled.\n */\nexport type BlockVisibilityViewport = 'desktop' | 'tablet' | 'mobile';\n\n/**\n * The choices for the block visibility.\n *\n * Duplicated in packages/editor/src/components/preview-dropdown/index.js (choices\n * array), packages/edit-site/src/components/block-editor/viewport.js and\n * packages/boot/src/components/canvas/viewport.ts (VALID_VIEWPORTS). Update all\n * four when adding new viewport types.\n *\n * @todo create a single source of truth for the viewport types.\n */\nexport const BLOCK_VISIBILITY_VIEWPORTS = {\n\tdesktop: {\n\t\tlabel: __( 'Desktop' ),\n\t\ticon: desktop,\n\t\tkey: 'desktop',\n\t},\n\ttablet: {\n\t\tlabel: __( 'Tablet' ),\n\t\ticon: tablet,\n\t\tkey: 'tablet',\n\t},\n\tmobile: {\n\t\tlabel: __( 'Mobile' ),\n\t\ticon: mobile,\n\t\tkey: 'mobile',\n\t},\n} satisfies Record<\n\tBlockVisibilityViewport,\n\t{ label: string; icon: ReactElement; key: BlockVisibilityViewport }\n>;\n\nexport const BLOCK_VISIBILITY_VIEWPORT_ENTRIES = Object.entries(\n\tBLOCK_VISIBILITY_VIEWPORTS\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAmB;AACnB,mBAAwC;AAiBjC,IAAM,6BAA6B;AAAA,EACzC,SAAS;AAAA,IACR,WAAO,gBAAI,SAAU;AAAA,IACrB,MAAM;AAAA,IACN,KAAK;AAAA,EACN;AAAA,EACA,QAAQ;AAAA,IACP,WAAO,gBAAI,QAAS;AAAA,IACpB,MAAM;AAAA,IACN,KAAK;AAAA,EACN;AAAA,EACA,QAAQ;AAAA,IACP,WAAO,gBAAI,QAAS;AAAA,IACpB,MAAM;AAAA,IACN,KAAK;AAAA,EACN;AACD;AAKO,IAAM,oCAAoC,OAAO;AAAA,EACvD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|