@wordpress/block-editor 15.8.1-next.dc3f6d3c1.0 → 15.9.1-next.6deb34194.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +12 -0
- package/build/components/block-alignment-matrix-control/index.js +1 -8
- package/build/components/block-alignment-matrix-control/index.js.map +2 -2
- package/build/components/block-bindings/attribute-control.js +172 -0
- package/build/components/block-bindings/attribute-control.js.map +7 -0
- package/build/components/block-bindings/index.js +47 -0
- package/build/components/block-bindings/index.js.map +7 -0
- package/build/components/block-bindings/source-fields-list.js +135 -0
- package/build/components/block-bindings/source-fields-list.js.map +7 -0
- package/build/components/block-bindings/use-block-bindings-utils.js +66 -0
- package/build/components/block-bindings/use-block-bindings-utils.js.map +7 -0
- package/build/components/block-edit/edit.js +1 -3
- package/build/components/block-edit/edit.js.map +2 -2
- package/build/components/block-list/index.js +2 -1
- package/build/components/block-list/index.js.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
- package/build/components/block-lock/modal.js +5 -5
- package/build/components/block-lock/modal.js.map +2 -2
- package/build/components/block-lock/use-block-lock.js +10 -13
- package/build/components/block-lock/use-block-lock.js.map +2 -2
- package/build/components/block-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +2 -2
- package/build/components/block-styles/preview-panel.js +3 -5
- package/build/components/block-styles/preview-panel.js.map +2 -2
- package/build/components/block-styles/use-styles-for-block.js +2 -2
- package/build/components/block-styles/use-styles-for-block.js.map +2 -2
- package/build/components/block-toolbar/index.js +1 -8
- package/build/components/block-toolbar/index.js.map +3 -3
- package/build/components/block-tools/index.js +56 -45
- package/build/components/block-tools/index.js.map +3 -3
- package/build/components/block-visibility/toolbar.js +1 -1
- package/build/components/block-visibility/toolbar.js.map +1 -1
- package/build/components/content-only-controls/fields-dropdown-menu.js +66 -0
- package/build/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
- package/build/components/content-only-controls/index.js +202 -44
- package/build/components/content-only-controls/index.js.map +3 -3
- package/build/components/content-only-controls/link/index.js +92 -103
- package/build/components/content-only-controls/link/index.js.map +3 -3
- package/build/components/content-only-controls/media/index.js +134 -134
- package/build/components/content-only-controls/media/index.js.map +3 -3
- package/build/components/content-only-controls/rich-text/index.js +66 -74
- package/build/components/content-only-controls/rich-text/index.js.map +3 -3
- package/build/components/dimensions-tool/width-height-tool.js +4 -16
- package/build/components/dimensions-tool/width-height-tool.js.map +3 -3
- package/build/components/font-family/index.js +1 -15
- package/build/components/font-family/index.js.map +2 -2
- package/build/components/global-styles/dimensions-panel.js +35 -2
- package/build/components/global-styles/dimensions-panel.js.map +2 -2
- package/build/components/global-styles/hooks.js +1 -1
- package/build/components/global-styles/hooks.js.map +2 -2
- package/build/components/global-styles/typography-panel.js +1 -2
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/image-editor/cropper.js +3 -34
- package/build/components/image-editor/cropper.js.map +3 -3
- package/build/components/image-editor/index.js +9 -3
- package/build/components/image-editor/index.js.map +2 -2
- package/build/components/image-editor/use-transform-image.js +62 -32
- package/build/components/image-editor/use-transform-image.js.map +2 -2
- package/build/components/image-editor/zoom-dropdown.js +2 -2
- package/build/components/image-editor/zoom-dropdown.js.map +2 -2
- package/build/components/index.js +10 -3
- package/build/components/index.js.map +2 -2
- package/build/components/inserter-draggable-blocks/index.js +8 -4
- package/build/components/inserter-draggable-blocks/index.js.map +2 -2
- package/build/components/inspector-controls-tabs/content-tab.js +3 -2
- package/build/components/inspector-controls-tabs/content-tab.js.map +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
- package/build/components/link-control/index.js +15 -7
- package/build/components/link-control/index.js.map +2 -2
- package/build/components/list-view/block-select-button.js +3 -11
- package/build/components/list-view/block-select-button.js.map +2 -2
- package/build/components/list-view/block.js +9 -7
- package/build/components/list-view/block.js.map +2 -2
- package/build/components/media-placeholder/index.js +17 -4
- package/build/components/media-placeholder/index.js.map +2 -2
- package/build/components/media-placeholder/utils.js +60 -0
- package/build/components/media-placeholder/utils.js.map +7 -0
- package/build/components/media-replace-flow/index.js +20 -3
- package/build/components/media-replace-flow/index.js.map +2 -2
- package/build/components/tool-selector/index.js +46 -0
- package/build/components/tool-selector/index.js.map +7 -0
- package/build/components/use-block-commands/index.js +1 -1
- package/build/components/use-block-commands/index.js.map +2 -2
- package/build/components/use-block-drop-zone/index.js +1 -5
- package/build/components/use-block-drop-zone/index.js.map +2 -2
- package/build/hooks/block-bindings.js +22 -260
- package/build/hooks/block-bindings.js.map +3 -3
- package/build/hooks/dimensions.js +3 -3
- package/build/hooks/dimensions.js.map +2 -2
- package/build/hooks/metadata.js +1 -1
- package/build/hooks/metadata.js.map +2 -2
- package/build/hooks/utils.js +5 -1
- package/build/hooks/utils.js.map +2 -2
- package/build/layouts/grid.js +23 -28
- package/build/layouts/grid.js.map +2 -2
- package/build/store/private-selectors.js +43 -3
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/reducer.js +2 -1
- package/build/store/reducer.js.map +2 -2
- package/build/store/selectors.js +6 -4
- package/build/store/selectors.js.map +2 -2
- package/build/utils/block-bindings.js +2 -44
- package/build/utils/block-bindings.js.map +3 -3
- package/build/utils/index.js +2 -5
- package/build/utils/index.js.map +2 -2
- package/build-module/components/block-alignment-matrix-control/index.js +1 -8
- package/build-module/components/block-alignment-matrix-control/index.js.map +2 -2
- package/build-module/components/block-bindings/attribute-control.js +150 -0
- package/build-module/components/block-bindings/attribute-control.js.map +7 -0
- package/build-module/components/block-bindings/index.js +10 -0
- package/build-module/components/block-bindings/index.js.map +7 -0
- package/build-module/components/block-bindings/source-fields-list.js +104 -0
- package/build-module/components/block-bindings/source-fields-list.js.map +7 -0
- package/build-module/components/block-bindings/use-block-bindings-utils.js +45 -0
- package/build-module/components/block-bindings/use-block-bindings-utils.js.map +7 -0
- package/build-module/components/block-edit/edit.js +1 -3
- package/build-module/components/block-edit/edit.js.map +2 -2
- package/build-module/components/block-list/index.js +2 -1
- package/build-module/components/block-list/index.js.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +27 -5
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +2 -2
- package/build-module/components/block-lock/modal.js +5 -5
- package/build-module/components/block-lock/modal.js.map +2 -2
- package/build-module/components/block-lock/use-block-lock.js +10 -13
- package/build-module/components/block-lock/use-block-lock.js.map +2 -2
- package/build-module/components/block-settings-menu-controls/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
- package/build-module/components/block-styles/preview-panel.js +3 -5
- package/build-module/components/block-styles/preview-panel.js.map +2 -2
- package/build-module/components/block-styles/use-styles-for-block.js +2 -2
- package/build-module/components/block-styles/use-styles-for-block.js.map +2 -2
- package/build-module/components/block-toolbar/index.js +1 -8
- package/build-module/components/block-toolbar/index.js.map +2 -2
- package/build-module/components/block-tools/index.js +56 -45
- package/build-module/components/block-tools/index.js.map +2 -2
- package/build-module/components/block-visibility/toolbar.js +1 -1
- package/build-module/components/block-visibility/toolbar.js.map +1 -1
- package/build-module/components/content-only-controls/fields-dropdown-menu.js +45 -0
- package/build-module/components/content-only-controls/fields-dropdown-menu.js.map +7 -0
- package/build-module/components/content-only-controls/index.js +206 -46
- package/build-module/components/content-only-controls/index.js.map +2 -2
- package/build-module/components/content-only-controls/link/index.js +92 -104
- package/build-module/components/content-only-controls/link/index.js.map +2 -2
- package/build-module/components/content-only-controls/media/index.js +134 -135
- package/build-module/components/content-only-controls/media/index.js.map +2 -2
- package/build-module/components/content-only-controls/rich-text/index.js +68 -81
- package/build-module/components/content-only-controls/rich-text/index.js.map +2 -2
- package/build-module/components/dimensions-tool/width-height-tool.js +4 -6
- package/build-module/components/dimensions-tool/width-height-tool.js.map +2 -2
- package/build-module/components/font-family/index.js +1 -15
- package/build-module/components/font-family/index.js.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.js +35 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
- package/build-module/components/global-styles/hooks.js +1 -1
- package/build-module/components/global-styles/hooks.js.map +2 -2
- package/build-module/components/global-styles/typography-panel.js +1 -2
- package/build-module/components/global-styles/typography-panel.js.map +2 -2
- package/build-module/components/image-editor/cropper.js +3 -34
- package/build-module/components/image-editor/cropper.js.map +2 -2
- package/build-module/components/image-editor/index.js +9 -3
- package/build-module/components/image-editor/index.js.map +2 -2
- package/build-module/components/image-editor/use-transform-image.js +63 -33
- package/build-module/components/image-editor/use-transform-image.js.map +2 -2
- package/build-module/components/image-editor/zoom-dropdown.js +2 -2
- package/build-module/components/image-editor/zoom-dropdown.js.map +2 -2
- package/build-module/components/index.js +74 -66
- package/build-module/components/index.js.map +2 -2
- package/build-module/components/inserter-draggable-blocks/index.js +8 -4
- package/build-module/components/inserter-draggable-blocks/index.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/content-tab.js +3 -2
- package/build-module/components/inspector-controls-tabs/content-tab.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
- package/build-module/components/link-control/index.js +16 -8
- package/build-module/components/link-control/index.js.map +2 -2
- package/build-module/components/list-view/block-select-button.js +3 -11
- package/build-module/components/list-view/block-select-button.js.map +2 -2
- package/build-module/components/list-view/block.js +9 -7
- package/build-module/components/list-view/block.js.map +2 -2
- package/build-module/components/media-placeholder/index.js +18 -5
- package/build-module/components/media-placeholder/index.js.map +2 -2
- package/build-module/components/media-placeholder/utils.js +35 -0
- package/build-module/components/media-placeholder/utils.js.map +7 -0
- package/build-module/components/media-replace-flow/index.js +20 -3
- package/build-module/components/media-replace-flow/index.js.map +2 -2
- package/build-module/components/tool-selector/index.js +15 -0
- package/build-module/components/tool-selector/index.js.map +7 -0
- package/build-module/components/use-block-commands/index.js +1 -1
- package/build-module/components/use-block-commands/index.js.map +2 -2
- package/build-module/components/use-block-drop-zone/index.js +1 -5
- package/build-module/components/use-block-drop-zone/index.js.map +2 -2
- package/build-module/hooks/block-bindings.js +27 -270
- package/build-module/hooks/block-bindings.js.map +2 -2
- package/build-module/hooks/dimensions.js +3 -3
- package/build-module/hooks/dimensions.js.map +2 -2
- package/build-module/hooks/metadata.js +1 -1
- package/build-module/hooks/metadata.js.map +2 -2
- package/build-module/hooks/utils.js +5 -1
- package/build-module/hooks/utils.js.map +2 -2
- package/build-module/layouts/grid.js +23 -28
- package/build-module/layouts/grid.js.map +2 -2
- package/build-module/store/private-selectors.js +39 -3
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/reducer.js +2 -1
- package/build-module/store/reducer.js.map +2 -2
- package/build-module/store/selectors.js +6 -4
- package/build-module/store/selectors.js.map +2 -2
- package/build-module/utils/block-bindings.js +1 -42
- package/build-module/utils/block-bindings.js.map +2 -2
- package/build-module/utils/index.js +1 -3
- package/build-module/utils/index.js.map +2 -2
- package/build-style/content-rtl.css +3 -0
- package/build-style/content.css +3 -0
- package/build-style/style-rtl.css +20 -11
- package/build-style/style.css +20 -11
- package/package.json +39 -39
- package/src/components/block-alignment-matrix-control/index.js +1 -5
- package/src/components/block-bindings/attribute-control.js +174 -0
- package/src/components/block-bindings/index.js +6 -0
- package/src/components/block-bindings/source-fields-list.js +130 -0
- package/src/components/block-bindings/use-block-bindings-utils.js +156 -0
- package/src/components/block-edit/edit.js +1 -3
- package/src/components/block-list/content.scss +5 -0
- package/src/components/block-list/index.js +3 -1
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +34 -3
- package/src/components/block-lock/modal.js +6 -5
- package/src/components/block-lock/use-block-lock.js +10 -14
- package/src/components/block-patterns-list/stories/{index.story.js → index.story.jsx} +3 -1
- package/src/components/block-settings-menu-controls/index.js +1 -1
- package/src/components/block-styles/preview-panel.js +3 -5
- package/src/components/block-styles/use-styles-for-block.js +2 -2
- package/src/components/block-toolbar/index.js +1 -6
- package/src/components/block-toolbar/style.scss +6 -6
- package/src/components/block-tools/index.js +15 -2
- package/src/components/block-tools/style.scss +4 -0
- package/src/components/block-visibility/toolbar.js +1 -1
- package/src/components/content-only-controls/fields-dropdown-menu.js +53 -0
- package/src/components/content-only-controls/index.js +289 -50
- package/src/components/content-only-controls/link/index.js +62 -57
- package/src/components/content-only-controls/media/index.js +177 -156
- package/src/components/content-only-controls/rich-text/index.js +31 -44
- package/src/components/content-only-controls/styles.scss +10 -1
- package/src/components/dimensions-tool/width-height-tool.js +6 -13
- package/src/components/font-family/README.md +0 -9
- package/src/components/font-family/index.js +1 -16
- package/src/components/font-family/stories/{index.story.js → index.story.jsx} +0 -1
- package/src/components/global-styles/dimensions-panel.js +36 -0
- package/src/components/global-styles/hooks.js +1 -1
- package/src/components/global-styles/typography-panel.js +0 -1
- package/src/components/image-editor/cropper.js +3 -32
- package/src/components/image-editor/index.js +34 -29
- package/src/components/image-editor/use-transform-image.js +80 -34
- package/src/components/image-editor/zoom-dropdown.js +2 -2
- package/src/components/index.js +9 -1
- package/src/components/inserter/style.scss +1 -1
- package/src/components/inserter-draggable-blocks/index.js +19 -8
- package/src/components/inspector-controls-tabs/content-tab.js +6 -2
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -5
- package/src/components/link-control/index.js +36 -12
- package/src/components/list-view/block-select-button.js +22 -30
- package/src/components/list-view/block.js +9 -7
- package/src/components/media-placeholder/index.js +20 -5
- package/src/components/media-placeholder/test/get-computed-accept-attribute.js +164 -0
- package/src/components/media-placeholder/utils.js +65 -0
- package/src/components/media-replace-flow/index.js +22 -3
- package/src/components/tool-selector/index.js +19 -0
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-block-drop-zone/index.js +1 -5
- package/src/hooks/block-bindings.js +27 -347
- package/src/hooks/dimensions.js +8 -3
- package/src/hooks/metadata.js +1 -1
- package/src/hooks/test/metadata.js +1 -1
- package/src/hooks/utils.js +4 -0
- package/src/layouts/grid.js +40 -72
- package/src/layouts/test/grid.js +14 -0
- package/src/store/private-selectors.js +123 -6
- package/src/store/reducer.js +3 -0
- package/src/store/selectors.js +6 -4
- package/src/store/test/private-selectors.js +242 -0
- package/src/store/test/reducer.js +17 -7
- package/src/style.scss +0 -1
- package/src/utils/block-bindings.js +0 -157
- package/src/utils/index.js +0 -1
- package/tsconfig.json +2 -0
- package/build/components/block-toolbar/block-name-context.js +0 -30
- package/build/components/block-toolbar/block-name-context.js.map +0 -7
- package/build/components/content-only-controls/plain-text/index.js +0 -68
- package/build/components/content-only-controls/plain-text/index.js.map +0 -7
- package/build-module/components/block-toolbar/block-name-context.js +0 -9
- package/build-module/components/block-toolbar/block-name-context.js.map +0 -7
- package/build-module/components/content-only-controls/plain-text/index.js +0 -50
- package/build-module/components/content-only-controls/plain-text/index.js.map +0 -7
- package/src/components/block-toolbar/block-name-context.js +0 -9
- package/src/components/content-only-controls/plain-text/index.js +0 -49
- package/src/components/font-family/style.scss +0 -7
- /package/src/components/alignment-control/stories/{aliginment-toolbar.story.js → aliginment-toolbar.story.jsx} +0 -0
- /package/src/components/alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-alignment-matrix-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/{utils → components/block-bindings}/test/use-block-bindings-utils.js +0 -0
- /package/src/components/block-draggable/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-heading-level-dropdown/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-mover/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/block-title/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/border-radius-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/date-format-picker/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{aspect-ratio-tool.story.js → aspect-ratio-tool.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{scale-tool.story.js → scale-tool.story.jsx} +0 -0
- /package/src/components/dimensions-tool/stories/{width-height-tool.story.js → width-height-tool.story.jsx} +0 -0
- /package/src/components/height-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/inserter/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/line-height-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/plain-text/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/resolution-tool/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/tabbed-sidebar/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-alignment-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-decoration-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/text-transform-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/unit-control/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/url-popover/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/warning/stories/{index.story.js → index.story.jsx} +0 -0
- /package/src/components/writing-mode-control/stories/{index.story.js → index.story.jsx} +0 -0
|
@@ -38,44 +38,99 @@ var import_components = require("@wordpress/components");
|
|
|
38
38
|
var import_data = require("@wordpress/data");
|
|
39
39
|
var import_i18n = require("@wordpress/i18n");
|
|
40
40
|
var import_icons = require("@wordpress/icons");
|
|
41
|
+
var import_dataviews = require("@wordpress/dataviews");
|
|
42
|
+
var import_element = require("@wordpress/element");
|
|
41
43
|
var import_lock_unlock = require("../../lock-unlock");
|
|
42
44
|
var import_store = require("../../store");
|
|
43
45
|
var import_block_icon = __toESM(require("../block-icon"));
|
|
44
46
|
var import_use_block_display_title = __toESM(require("../block-title/use-block-display-title"));
|
|
45
47
|
var import_use_block_display_information = __toESM(require("../use-block-display-information"));
|
|
46
|
-
var
|
|
47
|
-
var import_plain_text = __toESM(require("./plain-text"));
|
|
48
|
+
var import_fields_dropdown_menu = __toESM(require("./fields-dropdown-menu"));
|
|
48
49
|
var import_rich_text = __toESM(require("./rich-text"));
|
|
49
50
|
var import_media = __toESM(require("./media"));
|
|
50
51
|
var import_link = __toESM(require("./link"));
|
|
51
52
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
var { fieldsKey, formKey } = (0, import_lock_unlock.unlock)(import_blocks.privateApis);
|
|
54
|
+
var CONTROLS = {
|
|
55
|
+
richtext: import_rich_text.default,
|
|
56
|
+
media: import_media.default,
|
|
57
|
+
link: import_link.default
|
|
57
58
|
};
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
control
|
|
61
|
-
blockType,
|
|
62
|
-
attributeValues
|
|
63
|
-
}) {
|
|
64
|
-
const { updateBlockAttributes } = (0, import_data.useDispatch)(import_store.store);
|
|
65
|
-
const ControlComponent = controls[control.type];
|
|
59
|
+
function createConfiguredControl(config) {
|
|
60
|
+
const { control, ...controlConfig } = config;
|
|
61
|
+
const ControlComponent = CONTROLS[control];
|
|
66
62
|
if (!ControlComponent) {
|
|
67
|
-
|
|
63
|
+
throw new Error(`Control type "${control}" not found`);
|
|
68
64
|
}
|
|
69
|
-
return
|
|
70
|
-
ControlComponent,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
return function ConfiguredControl(props) {
|
|
66
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlComponent, { ...props, config: controlConfig });
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function normalizeMediaValue(value, fieldDef) {
|
|
70
|
+
const defaults = {
|
|
71
|
+
id: null,
|
|
72
|
+
url: "",
|
|
73
|
+
caption: "",
|
|
74
|
+
alt: "",
|
|
75
|
+
type: "image",
|
|
76
|
+
poster: "",
|
|
77
|
+
featuredImage: false,
|
|
78
|
+
link: ""
|
|
79
|
+
};
|
|
80
|
+
const result = {};
|
|
81
|
+
if (fieldDef?.mapping) {
|
|
82
|
+
Object.keys(fieldDef.mapping).forEach((key) => {
|
|
83
|
+
result[key] = value?.[key] ?? defaults[key] ?? "";
|
|
84
|
+
});
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
Object.keys(defaults).forEach((key) => {
|
|
88
|
+
result[key] = value?.[key] ?? defaults[key];
|
|
89
|
+
});
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
function denormalizeMediaValue(value, fieldDef) {
|
|
93
|
+
if (!fieldDef.mapping) {
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
const result = {};
|
|
97
|
+
Object.entries(fieldDef.mapping).forEach(([key]) => {
|
|
98
|
+
if (key in value) {
|
|
99
|
+
result[key] = value[key];
|
|
77
100
|
}
|
|
78
|
-
);
|
|
101
|
+
});
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
function normalizeLinkValue(value, fieldDef) {
|
|
105
|
+
const defaults = {
|
|
106
|
+
url: "",
|
|
107
|
+
rel: "",
|
|
108
|
+
linkTarget: "",
|
|
109
|
+
destination: ""
|
|
110
|
+
};
|
|
111
|
+
const result = {};
|
|
112
|
+
if (fieldDef?.mapping) {
|
|
113
|
+
Object.keys(fieldDef.mapping).forEach((key) => {
|
|
114
|
+
result[key] = value?.[key] ?? defaults[key] ?? "";
|
|
115
|
+
});
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
Object.keys(defaults).forEach((key) => {
|
|
119
|
+
result[key] = value?.[key] ?? defaults[key];
|
|
120
|
+
});
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
function denormalizeLinkValue(value, fieldDef) {
|
|
124
|
+
if (!fieldDef.mapping) {
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
const result = {};
|
|
128
|
+
Object.entries(fieldDef.mapping).forEach(([key]) => {
|
|
129
|
+
if (key in value) {
|
|
130
|
+
result[key] = value[key];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
return result;
|
|
79
134
|
}
|
|
80
135
|
function BlockFields({ clientId }) {
|
|
81
136
|
const { attributes, blockType } = (0, import_data.useSelect)(
|
|
@@ -90,36 +145,139 @@ function BlockFields({ clientId }) {
|
|
|
90
145
|
},
|
|
91
146
|
[clientId]
|
|
92
147
|
);
|
|
148
|
+
const { updateBlockAttributes } = (0, import_data.useDispatch)(import_store.store);
|
|
93
149
|
const blockTitle = (0, import_use_block_display_title.default)({
|
|
94
150
|
clientId,
|
|
95
151
|
context: "list-view"
|
|
96
152
|
});
|
|
97
153
|
const blockInformation = (0, import_use_block_display_information.default)(clientId);
|
|
98
|
-
const
|
|
99
|
-
|
|
154
|
+
const blockTypeFields = blockType?.[fieldsKey];
|
|
155
|
+
const [form, setForm] = (0, import_element.useState)(() => {
|
|
156
|
+
return blockType?.[formKey];
|
|
157
|
+
});
|
|
158
|
+
const dataFormFields = (0, import_element.useMemo)(() => {
|
|
159
|
+
if (!blockTypeFields?.length) {
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
return blockTypeFields.map((fieldDef) => {
|
|
163
|
+
const ControlComponent = CONTROLS[fieldDef.type];
|
|
164
|
+
const defaultValues = {};
|
|
165
|
+
if (fieldDef.mapping && blockType?.attributes) {
|
|
166
|
+
Object.entries(fieldDef.mapping).forEach(
|
|
167
|
+
([key, attrKey]) => {
|
|
168
|
+
defaultValues[key] = blockType.attributes[attrKey]?.defaultValue ?? void 0;
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
const field = {
|
|
173
|
+
id: fieldDef.id,
|
|
174
|
+
label: fieldDef.label,
|
|
175
|
+
type: fieldDef.type,
|
|
176
|
+
// Use the field's type; DataForm will use built-in or custom Edit
|
|
177
|
+
config: { ...fieldDef.args, defaultValues },
|
|
178
|
+
hideLabelFromVision: fieldDef.id === "content",
|
|
179
|
+
// getValue and setValue handle the mapping to block attributes
|
|
180
|
+
getValue: ({ item }) => {
|
|
181
|
+
if (fieldDef.mapping) {
|
|
182
|
+
const mappedValue = {};
|
|
183
|
+
Object.entries(fieldDef.mapping).forEach(
|
|
184
|
+
([key, attrKey]) => {
|
|
185
|
+
mappedValue[key] = item[attrKey];
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
if (fieldDef.type === "media") {
|
|
189
|
+
return normalizeMediaValue(mappedValue, fieldDef);
|
|
190
|
+
}
|
|
191
|
+
if (fieldDef.type === "link") {
|
|
192
|
+
return normalizeLinkValue(mappedValue, fieldDef);
|
|
193
|
+
}
|
|
194
|
+
return mappedValue;
|
|
195
|
+
}
|
|
196
|
+
return item[fieldDef.id];
|
|
197
|
+
},
|
|
198
|
+
setValue: ({ item, value }) => {
|
|
199
|
+
if (fieldDef.mapping) {
|
|
200
|
+
let denormalizedValue = value;
|
|
201
|
+
if (fieldDef.type === "media") {
|
|
202
|
+
denormalizedValue = denormalizeMediaValue(
|
|
203
|
+
value,
|
|
204
|
+
fieldDef
|
|
205
|
+
);
|
|
206
|
+
} else if (fieldDef.type === "link") {
|
|
207
|
+
denormalizedValue = denormalizeLinkValue(
|
|
208
|
+
value,
|
|
209
|
+
fieldDef
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
const updates = {};
|
|
213
|
+
Object.entries(fieldDef.mapping).forEach(
|
|
214
|
+
([key, attrKey]) => {
|
|
215
|
+
if (key in denormalizedValue) {
|
|
216
|
+
updates[attrKey] = denormalizedValue[key];
|
|
217
|
+
} else {
|
|
218
|
+
updates[attrKey] = item[attrKey];
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
return updates;
|
|
223
|
+
}
|
|
224
|
+
return { [fieldDef.id]: value };
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
if (ControlComponent) {
|
|
228
|
+
field.Edit = createConfiguredControl({
|
|
229
|
+
control: fieldDef.type,
|
|
230
|
+
clientId,
|
|
231
|
+
fieldDef
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
return field;
|
|
235
|
+
});
|
|
236
|
+
}, [blockTypeFields, blockType?.attributes, clientId]);
|
|
237
|
+
const handleToggleField = (fieldId) => {
|
|
238
|
+
setForm((prev) => {
|
|
239
|
+
if (prev.fields?.includes(fieldId)) {
|
|
240
|
+
return {
|
|
241
|
+
...prev,
|
|
242
|
+
fields: prev.fields.filter((id) => id !== fieldId)
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
...prev,
|
|
247
|
+
fields: [...prev.fields || [], fieldId]
|
|
248
|
+
};
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
if (!blockTypeFields?.length) {
|
|
100
252
|
return null;
|
|
101
253
|
}
|
|
102
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
103
|
-
import_components.
|
|
104
|
-
|
|
105
|
-
label: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { spacing: 1, children: [
|
|
254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "block-editor-content-only-controls__fields-container", children: [
|
|
255
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "block-editor-content-only-controls__fields-header", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { spacing: 1, justify: "space-between", expanded: true, children: [
|
|
256
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalHStack, { spacing: 1, justify: "flex-start", children: [
|
|
106
257
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_icon.default, { icon: blockInformation?.icon }),
|
|
107
258
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: blockTitle })
|
|
108
259
|
] }),
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
children: blockType?.fields?.map((field, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
112
|
-
BlockAttributeToolsPanelItem,
|
|
260
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
261
|
+
import_fields_dropdown_menu.default,
|
|
113
262
|
{
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
263
|
+
fields: dataFormFields,
|
|
264
|
+
visibleFields: form.fields,
|
|
265
|
+
onToggleField: handleToggleField
|
|
266
|
+
}
|
|
267
|
+
)
|
|
268
|
+
] }) }),
|
|
269
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
270
|
+
import_dataviews.DataForm,
|
|
271
|
+
{
|
|
272
|
+
data: attributes,
|
|
273
|
+
fields: dataFormFields,
|
|
274
|
+
form,
|
|
275
|
+
onChange: (changes) => {
|
|
276
|
+
updateBlockAttributes(clientId, changes);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
] });
|
|
123
281
|
}
|
|
124
282
|
function DrillDownButton({ clientId }) {
|
|
125
283
|
const blockTitle = (0, import_use_block_display_title.default)({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/content-only-controls/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalHStack as HStack,\n\tIcon,\n\tNavigator,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { arrowLeft, arrowRight } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as blockEditorStore } from '../../store';\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { useInspectorPopoverPlacement } from './use-inspector-popover-placement';\n\n// controls\nimport PlainText from './plain-text';\nimport RichText from './rich-text';\nimport Media from './media';\nimport Link from './link';\n\nconst controls = {\n\tPlainText,\n\tRichText,\n\tMedia,\n\tLink,\n};\n\nfunction BlockAttributeToolsPanelItem( {\n\tclientId,\n\tcontrol,\n\tblockType,\n\tattributeValues,\n} ) {\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst ControlComponent = controls[ control.type ];\n\n\tif ( ! ControlComponent ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ControlComponent\n\t\t\tclientId={ clientId }\n\t\t\tcontrol={ control }\n\t\t\tblockType={ blockType }\n\t\t\tattributeValues={ attributeValues }\n\t\t\tupdateAttributes={ ( attributes ) =>\n\t\t\t\tupdateBlockAttributes( clientId, attributes )\n\t\t\t}\n\t\t/>\n\t);\n}\n\nfunction BlockFields( { clientId } ) {\n\tconst { attributes, blockType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getBlockType } = select( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\treturn {\n\t\t\t\tattributes: getBlockAttributes( clientId ),\n\t\t\t\tblockType: getBlockType( blockName ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst popoverPlacementProps = useInspectorPopoverPlacement();\n\n\tif ( ! blockType?.fields?.length ) {\n\t\t// TODO - we might still want to show a placeholder for blocks with no fields.\n\t\t// for example, a way to select the block.\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={\n\t\t\t\t<HStack spacing={ 1 }>\n\t\t\t\t\t<BlockIcon icon={ blockInformation?.icon } />\n\t\t\t\t\t<div>{ blockTitle }</div>\n\t\t\t\t</HStack>\n\t\t\t}\n\t\t\tpanelId={ clientId }\n\t\t\tdropdownMenuProps={ popoverPlacementProps }\n\t\t>\n\t\t\t{ blockType?.fields?.map( ( field, index ) => (\n\t\t\t\t<BlockAttributeToolsPanelItem\n\t\t\t\t\tkey={ `${ clientId }/${ index }` }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tcontrol={ field }\n\t\t\t\t\tblockType={ blockType }\n\t\t\t\t\tattributeValues={ attributes }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</ToolsPanel>\n\t);\n}\n\nfunction DrillDownButton( { clientId } ) {\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\treturn (\n\t\t<div className=\"block-editor-content-only-controls__button-panel\">\n\t\t\t<Navigator.Button\n\t\t\t\tpath={ `/${ clientId }` }\n\t\t\t\tclassName=\"block-editor-content-only-controls__drill-down-button\"\n\t\t\t>\n\t\t\t\t<HStack expanded justify=\"space-between\">\n\t\t\t\t\t<HStack justify=\"flex-start\" spacing={ 1 }>\n\t\t\t\t\t\t<BlockIcon icon={ blockInformation?.icon } />\n\t\t\t\t\t\t<div>{ blockTitle }</div>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<Icon icon={ arrowRight } />\n\t\t\t\t</HStack>\n\t\t\t</Navigator.Button>\n\t\t</div>\n\t);\n}\n\nfunction ContentOnlyControlsScreen( {\n\trootClientId,\n\tcontentClientIds,\n\tparentClientIds,\n\tisNested,\n} ) {\n\tconst isRootContentBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName } = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( rootClientId );\n\t\t\tconst { hasContentRoleAttribute } = unlock( select( blocksStore ) );\n\t\t\treturn hasContentRoleAttribute( blockName );\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tif ( ! isRootContentBlock && ! contentClientIds.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isNested && (\n\t\t\t\t<div className=\"block-editor-content-only-controls__button-panel\">\n\t\t\t\t\t<Navigator.BackButton className=\"block-editor-content-only-controls__back-button\">\n\t\t\t\t\t\t<HStack expanded spacing={ 1 } justify=\"flex-start\">\n\t\t\t\t\t\t\t<Icon icon={ arrowLeft } />\n\t\t\t\t\t\t\t<div>{ __( 'Back' ) }</div>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</Navigator.BackButton>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ isRootContentBlock && <BlockFields clientId={ rootClientId } /> }\n\t\t\t{ contentClientIds.map( ( clientId ) => {\n\t\t\t\tif ( parentClientIds?.[ clientId ] ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DrillDownButton\n\t\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn <BlockFields key={ clientId } clientId={ clientId } />;\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlyControls( { rootClientId } ) {\n\tconst { updatedRootClientId, nestedContentClientIds, contentClientIds } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getClientIdsOfDescendants, getBlockEditingMode } =\n\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t// _nestedContentClientIds is for content blocks within 'drilldowns'.\n\t\t\t\t// It's an object where the key is the parent clientId, and the element is\n\t\t\t\t// an array of child clientIds whose controls are shown within the drilldown.\n\t\t\t\tconst _nestedContentClientIds = {};\n\n\t\t\t\t// _contentClientIds is the list of contentClientIds for blocks being\n\t\t\t\t// shown at the root level. Includes parent blocks that might have a drilldown,\n\t\t\t\t// but not the children of those blocks.\n\t\t\t\tconst _contentClientIds = [];\n\n\t\t\t\t// An array of all nested client ids. Used for ensuring blocks within drilldowns\n\t\t\t\t// don't appear at the root level.\n\t\t\t\tlet allNestedClientIds = [];\n\n\t\t\t\t// A flattened list of all content clientIds to arrange into the\n\t\t\t\t// groups above.\n\t\t\t\tconst allContentClientIds = getClientIdsOfDescendants(\n\t\t\t\t\trootClientId\n\t\t\t\t).filter(\n\t\t\t\t\t( clientId ) =>\n\t\t\t\t\t\tgetBlockEditingMode( clientId ) === 'contentOnly'\n\t\t\t\t);\n\n\t\t\t\tfor ( const clientId of allContentClientIds ) {\n\t\t\t\t\tconst childClientIds = getClientIdsOfDescendants(\n\t\t\t\t\t\tclientId\n\t\t\t\t\t).filter(\n\t\t\t\t\t\t( childClientId ) =>\n\t\t\t\t\t\t\tgetBlockEditingMode( childClientId ) ===\n\t\t\t\t\t\t\t'contentOnly'\n\t\t\t\t\t);\n\n\t\t\t\t\t// If there's more than one child block, use a drilldown.\n\t\t\t\t\tif (\n\t\t\t\t\t\tchildClientIds.length > 1 &&\n\t\t\t\t\t\t! allNestedClientIds.includes( clientId )\n\t\t\t\t\t) {\n\t\t\t\t\t\t_nestedContentClientIds[ clientId ] = childClientIds;\n\t\t\t\t\t\tallNestedClientIds = [\n\t\t\t\t\t\t\tallNestedClientIds,\n\t\t\t\t\t\t\t...childClientIds,\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( ! allNestedClientIds.includes( clientId ) ) {\n\t\t\t\t\t\t_contentClientIds.push( clientId );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Avoid showing only one drilldown block at the root.\n\t\t\t\tif (\n\t\t\t\t\t_contentClientIds.length === 1 &&\n\t\t\t\t\tObject.keys( _nestedContentClientIds ).length === 1\n\t\t\t\t) {\n\t\t\t\t\tconst onlyParentClientId = Object.keys(\n\t\t\t\t\t\t_nestedContentClientIds\n\t\t\t\t\t)[ 0 ];\n\t\t\t\t\treturn {\n\t\t\t\t\t\tupdatedRootClientId: onlyParentClientId,\n\t\t\t\t\t\tcontentClientIds:\n\t\t\t\t\t\t\t_nestedContentClientIds[ onlyParentClientId ],\n\t\t\t\t\t\tnestedContentClientIds: {},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tnestedContentClientIds: _nestedContentClientIds,\n\t\t\t\t\tcontentClientIds: _contentClientIds,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ rootClientId ]\n\t\t);\n\n\treturn (\n\t\t<Navigator initialPath=\"/\">\n\t\t\t<Navigator.Screen\n\t\t\t\tpath=\"/\"\n\t\t\t\tclassName=\"block-editor-content-only-controls__screen\"\n\t\t\t>\n\t\t\t\t<ContentOnlyControlsScreen\n\t\t\t\t\trootClientId={ updatedRootClientId ?? rootClientId }\n\t\t\t\t\tcontentClientIds={ contentClientIds }\n\t\t\t\t\tparentClientIds={ nestedContentClientIds }\n\t\t\t\t/>\n\t\t\t</Navigator.Screen>\n\t\t\t{ Object.keys( nestedContentClientIds ).map( ( clientId ) => (\n\t\t\t\t<Navigator.Screen\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t\tpath={ `/${ clientId }` }\n\t\t\t\t\tclassName=\"block-editor-content-only-controls__screen\"\n\t\t\t\t>\n\t\t\t\t\t<ContentOnlyControlsScreen\n\t\t\t\t\t\tisNested\n\t\t\t\t\t\trootClientId={ clientId }\n\t\t\t\t\t\tcontentClientIds={ nestedContentClientIds[ clientId ] }\n\t\t\t\t\t/>\n\t\t\t\t</Navigator.Screen>\n\t\t\t) ) }\n\t\t</Navigator>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tprivateApis as blocksPrivateApis,\n} from '@wordpress/blocks';\nimport {\n\t__experimentalHStack as HStack,\n\tIcon,\n\tNavigator,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { arrowLeft, arrowRight } from '@wordpress/icons';\nimport { DataForm } from '@wordpress/dataviews';\nimport { useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as blockEditorStore } from '../../store';\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport useBlockDisplayInformation from '../use-block-display-information';\nconst { fieldsKey, formKey } = unlock( blocksPrivateApis );\nimport FieldsDropdownMenu from './fields-dropdown-menu';\n\n// controls\nimport RichText from './rich-text';\nimport Media from './media';\nimport Link from './link';\n\nconst CONTROLS = {\n\trichtext: RichText,\n\tmedia: Media,\n\tlink: Link,\n};\n\n/**\n * Creates a configured control component that wraps a custom control\n * and passes configuration as props.\n *\n * @param {Object} config - The control configuration\n * @param {string} config.control - The control type (key in CONTROLS map)\n * @return {Function} A wrapped control component\n */\nfunction createConfiguredControl( config ) {\n\tconst { control, ...controlConfig } = config;\n\tconst ControlComponent = CONTROLS[ control ];\n\n\tif ( ! ControlComponent ) {\n\t\tthrow new Error( `Control type \"${ control }\" not found` );\n\t}\n\n\treturn function ConfiguredControl( props ) {\n\t\treturn <ControlComponent { ...props } config={ controlConfig } />;\n\t};\n}\n\n/**\n * Normalize a media value to a canonical structure.\n * Only includes properties that are present in the field's mapping (if provided).\n *\n * @param {Object} value - The mapped value from the block attributes (with canonical keys)\n * @param {Object} fieldDef - Optional field definition containing the mapping\n * @return {Object} Normalized media value with canonical properties\n */\nfunction normalizeMediaValue( value, fieldDef ) {\n\tconst defaults = {\n\t\tid: null,\n\t\turl: '',\n\t\tcaption: '',\n\t\talt: '',\n\t\ttype: 'image',\n\t\tposter: '',\n\t\tfeaturedImage: false,\n\t\tlink: '',\n\t};\n\n\tconst result = {};\n\n\t// If there's a mapping, only include properties that are in it\n\tif ( fieldDef?.mapping ) {\n\t\tObject.keys( fieldDef.mapping ).forEach( ( key ) => {\n\t\t\tresult[ key ] = value?.[ key ] ?? defaults[ key ] ?? '';\n\t\t} );\n\t\treturn result;\n\t}\n\n\t// Without mapping, include all default properties\n\tObject.keys( defaults ).forEach( ( key ) => {\n\t\tresult[ key ] = value?.[ key ] ?? defaults[ key ];\n\t} );\n\treturn result;\n}\n\n/**\n * Denormalize a media value from canonical structure back to mapped keys.\n * Only includes properties that are present in the field's mapping.\n *\n * @param {Object} value - The normalized media value\n * @param {Object} fieldDef - The field definition containing the mapping\n * @return {Object} Value with only mapped properties\n */\nfunction denormalizeMediaValue( value, fieldDef ) {\n\tif ( ! fieldDef.mapping ) {\n\t\treturn value;\n\t}\n\n\tconst result = {};\n\tObject.entries( fieldDef.mapping ).forEach( ( [ key ] ) => {\n\t\tif ( key in value ) {\n\t\t\tresult[ key ] = value[ key ];\n\t\t}\n\t} );\n\treturn result;\n}\n\n/**\n * Normalize a link value to a canonical structure.\n * Only includes properties that are present in the field's mapping (if provided).\n *\n * @param {Object} value - The mapped value from the block attributes (with canonical keys)\n * @param {Object} fieldDef - Optional field definition containing the mapping\n * @return {Object} Normalized link value with canonical properties\n */\nfunction normalizeLinkValue( value, fieldDef ) {\n\tconst defaults = {\n\t\turl: '',\n\t\trel: '',\n\t\tlinkTarget: '',\n\t\tdestination: '',\n\t};\n\n\tconst result = {};\n\n\t// If there's a mapping, only include properties that are in it\n\tif ( fieldDef?.mapping ) {\n\t\tObject.keys( fieldDef.mapping ).forEach( ( key ) => {\n\t\t\tresult[ key ] = value?.[ key ] ?? defaults[ key ] ?? '';\n\t\t} );\n\t\treturn result;\n\t}\n\n\t// Without mapping, include all default properties\n\tObject.keys( defaults ).forEach( ( key ) => {\n\t\tresult[ key ] = value?.[ key ] ?? defaults[ key ];\n\t} );\n\treturn result;\n}\n\n/**\n * Denormalize a link value from canonical structure back to mapped keys.\n * Only includes properties that are present in the field's mapping.\n *\n * @param {Object} value - The normalized link value\n * @param {Object} fieldDef - The field definition containing the mapping\n * @return {Object} Value with only mapped properties\n */\nfunction denormalizeLinkValue( value, fieldDef ) {\n\tif ( ! fieldDef.mapping ) {\n\t\treturn value;\n\t}\n\n\tconst result = {};\n\tObject.entries( fieldDef.mapping ).forEach( ( [ key ] ) => {\n\t\tif ( key in value ) {\n\t\t\tresult[ key ] = value[ key ];\n\t\t}\n\t} );\n\treturn result;\n}\n\nfunction BlockFields( { clientId } ) {\n\tconst { attributes, blockType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getBlockType } = select( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\treturn {\n\t\t\t\tattributes: getBlockAttributes( clientId ),\n\t\t\t\tblockType: getBlockType( blockName ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\tconst blockTypeFields = blockType?.[ fieldsKey ];\n\n\tconst [ form, setForm ] = useState( () => {\n\t\treturn blockType?.[ formKey ];\n\t} );\n\n\t// Build DataForm fields with proper structure\n\tconst dataFormFields = useMemo( () => {\n\t\tif ( ! blockTypeFields?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn blockTypeFields.map( ( fieldDef ) => {\n\t\t\tconst ControlComponent = CONTROLS[ fieldDef.type ];\n\n\t\t\tconst defaultValues = {};\n\t\t\tif ( fieldDef.mapping && blockType?.attributes ) {\n\t\t\t\tObject.entries( fieldDef.mapping ).forEach(\n\t\t\t\t\t( [ key, attrKey ] ) => {\n\t\t\t\t\t\tdefaultValues[ key ] =\n\t\t\t\t\t\t\tblockType.attributes[ attrKey ]?.defaultValue ??\n\t\t\t\t\t\t\tundefined;\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst field = {\n\t\t\t\tid: fieldDef.id,\n\t\t\t\tlabel: fieldDef.label,\n\t\t\t\ttype: fieldDef.type, // Use the field's type; DataForm will use built-in or custom Edit\n\t\t\t\tconfig: { ...fieldDef.args, defaultValues },\n\t\t\t\thideLabelFromVision: fieldDef.id === 'content',\n\t\t\t\t// getValue and setValue handle the mapping to block attributes\n\t\t\t\tgetValue: ( { item } ) => {\n\t\t\t\t\tif ( fieldDef.mapping ) {\n\t\t\t\t\t\t// Extract mapped properties from the block attributes\n\t\t\t\t\t\tconst mappedValue = {};\n\t\t\t\t\t\tObject.entries( fieldDef.mapping ).forEach(\n\t\t\t\t\t\t\t( [ key, attrKey ] ) => {\n\t\t\t\t\t\t\t\tmappedValue[ key ] = item[ attrKey ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Normalize to canonical structure based on field type\n\t\t\t\t\t\tif ( fieldDef.type === 'media' ) {\n\t\t\t\t\t\t\treturn normalizeMediaValue( mappedValue, fieldDef );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( fieldDef.type === 'link' ) {\n\t\t\t\t\t\t\treturn normalizeLinkValue( mappedValue, fieldDef );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// For other types, return as-is\n\t\t\t\t\t\treturn mappedValue;\n\t\t\t\t\t}\n\t\t\t\t\t// For simple id-based fields, use the id as the attribute key\n\t\t\t\t\treturn item[ fieldDef.id ];\n\t\t\t\t},\n\t\t\t\tsetValue: ( { item, value } ) => {\n\t\t\t\t\tif ( fieldDef.mapping ) {\n\t\t\t\t\t\t// Denormalize from canonical structure back to mapped keys\n\t\t\t\t\t\tlet denormalizedValue = value;\n\t\t\t\t\t\tif ( fieldDef.type === 'media' ) {\n\t\t\t\t\t\t\tdenormalizedValue = denormalizeMediaValue(\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\tfieldDef\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if ( fieldDef.type === 'link' ) {\n\t\t\t\t\t\t\tdenormalizedValue = denormalizeLinkValue(\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\tfieldDef\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Build an object with all mapped attributes\n\t\t\t\t\t\tconst updates = {};\n\t\t\t\t\t\tObject.entries( fieldDef.mapping ).forEach(\n\t\t\t\t\t\t\t( [ key, attrKey ] ) => {\n\t\t\t\t\t\t\t\t// If key is explicitly in value, use it (even if undefined to allow clearing)\n\t\t\t\t\t\t\t\t// Otherwise, preserve the old value\n\t\t\t\t\t\t\t\tif ( key in denormalizedValue ) {\n\t\t\t\t\t\t\t\t\tupdates[ attrKey ] =\n\t\t\t\t\t\t\t\t\t\tdenormalizedValue[ key ];\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tupdates[ attrKey ] = item[ attrKey ];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn updates;\n\t\t\t\t\t}\n\t\t\t\t\t// For simple id-based fields, use the id as the attribute key\n\t\t\t\t\treturn { [ fieldDef.id ]: value };\n\t\t\t\t},\n\t\t\t};\n\n\t\t\t// Only add custom Edit component if one exists for this type\n\t\t\tif ( ControlComponent ) {\n\t\t\t\t// Use EditConfig pattern: Edit is an object with control type and config props\n\t\t\t\tfield.Edit = createConfiguredControl( {\n\t\t\t\t\tcontrol: fieldDef.type,\n\t\t\t\t\tclientId,\n\t\t\t\t\tfieldDef,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn field;\n\t\t} );\n\t}, [ blockTypeFields, blockType?.attributes, clientId ] );\n\n\tconst handleToggleField = ( fieldId ) => {\n\t\tsetForm( ( prev ) => {\n\t\t\tif ( prev.fields?.includes( fieldId ) ) {\n\t\t\t\treturn {\n\t\t\t\t\t...prev,\n\t\t\t\t\tfields: prev.fields.filter( ( id ) => id !== fieldId ),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...prev,\n\t\t\t\tfields: [ ...( prev.fields || [] ), fieldId ],\n\t\t\t};\n\t\t} );\n\t};\n\n\tif ( ! blockTypeFields?.length ) {\n\t\t// TODO - we might still want to show a placeholder for blocks with no fields.\n\t\t// for example, a way to select the block.\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-editor-content-only-controls__fields-container\">\n\t\t\t<div className=\"block-editor-content-only-controls__fields-header\">\n\t\t\t\t<HStack spacing={ 1 } justify=\"space-between\" expanded>\n\t\t\t\t\t<HStack spacing={ 1 } justify=\"flex-start\">\n\t\t\t\t\t\t<BlockIcon icon={ blockInformation?.icon } />\n\t\t\t\t\t\t<div>{ blockTitle }</div>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<FieldsDropdownMenu\n\t\t\t\t\t\tfields={ dataFormFields }\n\t\t\t\t\t\tvisibleFields={ form.fields }\n\t\t\t\t\t\tonToggleField={ handleToggleField }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t</div>\n\t\t\t<DataForm\n\t\t\t\tdata={ attributes }\n\t\t\t\tfields={ dataFormFields }\n\t\t\t\tform={ form }\n\t\t\t\tonChange={ ( changes ) => {\n\t\t\t\t\tupdateBlockAttributes( clientId, changes );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction DrillDownButton( { clientId } ) {\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\treturn (\n\t\t<div className=\"block-editor-content-only-controls__button-panel\">\n\t\t\t<Navigator.Button\n\t\t\t\tpath={ `/${ clientId }` }\n\t\t\t\tclassName=\"block-editor-content-only-controls__drill-down-button\"\n\t\t\t>\n\t\t\t\t<HStack expanded justify=\"space-between\">\n\t\t\t\t\t<HStack justify=\"flex-start\" spacing={ 1 }>\n\t\t\t\t\t\t<BlockIcon icon={ blockInformation?.icon } />\n\t\t\t\t\t\t<div>{ blockTitle }</div>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<Icon icon={ arrowRight } />\n\t\t\t\t</HStack>\n\t\t\t</Navigator.Button>\n\t\t</div>\n\t);\n}\n\nfunction ContentOnlyControlsScreen( {\n\trootClientId,\n\tcontentClientIds,\n\tparentClientIds,\n\tisNested,\n} ) {\n\tconst isRootContentBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName } = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( rootClientId );\n\t\t\tconst { hasContentRoleAttribute } = unlock( select( blocksStore ) );\n\t\t\treturn hasContentRoleAttribute( blockName );\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tif ( ! isRootContentBlock && ! contentClientIds.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isNested && (\n\t\t\t\t<div className=\"block-editor-content-only-controls__button-panel\">\n\t\t\t\t\t<Navigator.BackButton className=\"block-editor-content-only-controls__back-button\">\n\t\t\t\t\t\t<HStack expanded spacing={ 1 } justify=\"flex-start\">\n\t\t\t\t\t\t\t<Icon icon={ arrowLeft } />\n\t\t\t\t\t\t\t<div>{ __( 'Back' ) }</div>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</Navigator.BackButton>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ isRootContentBlock && <BlockFields clientId={ rootClientId } /> }\n\t\t\t{ contentClientIds.map( ( clientId ) => {\n\t\t\t\tif ( parentClientIds?.[ clientId ] ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DrillDownButton\n\t\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn <BlockFields key={ clientId } clientId={ clientId } />;\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlyControls( { rootClientId } ) {\n\tconst { updatedRootClientId, nestedContentClientIds, contentClientIds } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getClientIdsOfDescendants, getBlockEditingMode } =\n\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t// _nestedContentClientIds is for content blocks within 'drilldowns'.\n\t\t\t\t// It's an object where the key is the parent clientId, and the element is\n\t\t\t\t// an array of child clientIds whose controls are shown within the drilldown.\n\t\t\t\tconst _nestedContentClientIds = {};\n\n\t\t\t\t// _contentClientIds is the list of contentClientIds for blocks being\n\t\t\t\t// shown at the root level. Includes parent blocks that might have a drilldown,\n\t\t\t\t// but not the children of those blocks.\n\t\t\t\tconst _contentClientIds = [];\n\n\t\t\t\t// An array of all nested client ids. Used for ensuring blocks within drilldowns\n\t\t\t\t// don't appear at the root level.\n\t\t\t\tlet allNestedClientIds = [];\n\n\t\t\t\t// A flattened list of all content clientIds to arrange into the\n\t\t\t\t// groups above.\n\t\t\t\tconst allContentClientIds = getClientIdsOfDescendants(\n\t\t\t\t\trootClientId\n\t\t\t\t).filter(\n\t\t\t\t\t( clientId ) =>\n\t\t\t\t\t\tgetBlockEditingMode( clientId ) === 'contentOnly'\n\t\t\t\t);\n\n\t\t\t\tfor ( const clientId of allContentClientIds ) {\n\t\t\t\t\tconst childClientIds = getClientIdsOfDescendants(\n\t\t\t\t\t\tclientId\n\t\t\t\t\t).filter(\n\t\t\t\t\t\t( childClientId ) =>\n\t\t\t\t\t\t\tgetBlockEditingMode( childClientId ) ===\n\t\t\t\t\t\t\t'contentOnly'\n\t\t\t\t\t);\n\n\t\t\t\t\t// If there's more than one child block, use a drilldown.\n\t\t\t\t\tif (\n\t\t\t\t\t\tchildClientIds.length > 1 &&\n\t\t\t\t\t\t! allNestedClientIds.includes( clientId )\n\t\t\t\t\t) {\n\t\t\t\t\t\t_nestedContentClientIds[ clientId ] = childClientIds;\n\t\t\t\t\t\tallNestedClientIds = [\n\t\t\t\t\t\t\tallNestedClientIds,\n\t\t\t\t\t\t\t...childClientIds,\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( ! allNestedClientIds.includes( clientId ) ) {\n\t\t\t\t\t\t_contentClientIds.push( clientId );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Avoid showing only one drilldown block at the root.\n\t\t\t\tif (\n\t\t\t\t\t_contentClientIds.length === 1 &&\n\t\t\t\t\tObject.keys( _nestedContentClientIds ).length === 1\n\t\t\t\t) {\n\t\t\t\t\tconst onlyParentClientId = Object.keys(\n\t\t\t\t\t\t_nestedContentClientIds\n\t\t\t\t\t)[ 0 ];\n\t\t\t\t\treturn {\n\t\t\t\t\t\tupdatedRootClientId: onlyParentClientId,\n\t\t\t\t\t\tcontentClientIds:\n\t\t\t\t\t\t\t_nestedContentClientIds[ onlyParentClientId ],\n\t\t\t\t\t\tnestedContentClientIds: {},\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tnestedContentClientIds: _nestedContentClientIds,\n\t\t\t\t\tcontentClientIds: _contentClientIds,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ rootClientId ]\n\t\t);\n\n\treturn (\n\t\t<Navigator initialPath=\"/\">\n\t\t\t<Navigator.Screen\n\t\t\t\tpath=\"/\"\n\t\t\t\tclassName=\"block-editor-content-only-controls__screen\"\n\t\t\t>\n\t\t\t\t<ContentOnlyControlsScreen\n\t\t\t\t\trootClientId={ updatedRootClientId ?? rootClientId }\n\t\t\t\t\tcontentClientIds={ contentClientIds }\n\t\t\t\t\tparentClientIds={ nestedContentClientIds }\n\t\t\t\t/>\n\t\t\t</Navigator.Screen>\n\t\t\t{ Object.keys( nestedContentClientIds ).map( ( clientId ) => (\n\t\t\t\t<Navigator.Screen\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t\tpath={ `/${ clientId }` }\n\t\t\t\t\tclassName=\"block-editor-content-only-controls__screen\"\n\t\t\t\t>\n\t\t\t\t\t<ContentOnlyControlsScreen\n\t\t\t\t\t\tisNested\n\t\t\t\t\t\trootClientId={ clientId }\n\t\t\t\t\t\tcontentClientIds={ nestedContentClientIds[ clientId ] }\n\t\t\t\t\t/>\n\t\t\t\t</Navigator.Screen>\n\t\t\t) ) }\n\t\t</Navigator>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAGO;AACP,wBAIO;AACP,kBAAuC;AACvC,kBAAmB;AACnB,mBAAsC;AACtC,uBAAyB;AACzB,qBAAkC;AAKlC,yBAAuB;AACvB,mBAA0C;AAC1C,wBAAsB;AACtB,qCAAiC;AACjC,2CAAuC;AAEvC,kCAA+B;AAG/B,uBAAqB;AACrB,mBAAkB;AAClB,kBAAiB;AAyBR;AA/BT,IAAM,EAAE,WAAW,QAAQ,QAAI,2BAAQ,cAAAA,WAAkB;AAQzD,IAAM,WAAW;AAAA,EAChB,UAAU,iBAAAC;AAAA,EACV,OAAO,aAAAC;AAAA,EACP,MAAM,YAAAC;AACP;AAUA,SAAS,wBAAyB,QAAS;AAC1C,QAAM,EAAE,SAAS,GAAG,cAAc,IAAI;AACtC,QAAM,mBAAmB,SAAU,OAAQ;AAE3C,MAAK,CAAE,kBAAmB;AACzB,UAAM,IAAI,MAAO,iBAAkB,OAAQ,aAAc;AAAA,EAC1D;AAEA,SAAO,SAAS,kBAAmB,OAAQ;AAC1C,WAAO,4CAAC,oBAAmB,GAAG,OAAQ,QAAS,eAAgB;AAAA,EAChE;AACD;AAUA,SAAS,oBAAqB,OAAO,UAAW;AAC/C,QAAM,WAAW;AAAA,IAChB,IAAI;AAAA,IACJ,KAAK;AAAA,IACL,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,MAAM;AAAA,EACP;AAEA,QAAM,SAAS,CAAC;AAGhB,MAAK,UAAU,SA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wBAAyB,kBAAmB;AAAA,UAC7C,wBAAwB,CAAC;AAAA,QAC1B;AAAA,MACD;AAEA,aAAO;AAAA,QACN,wBAAwB;AAAA,QACxB,kBAAkB;AAAA,MACnB;AAAA,IACD;AAAA,IACA,CAAE,YAAa;AAAA,EAChB;AAED,SACC,6CAAC,+BAAU,aAAY,KACtB;AAAA;AAAA,MAAC,4BAAU;AAAA,MAAV;AAAA,QACA,MAAK;AAAA,QACL,WAAU;AAAA,QAEV;AAAA,UAAC;AAAA;AAAA,YACA,cAAe,uBAAuB;AAAA,YACtC;AAAA,YACA,iBAAkB;AAAA;AAAA,QACnB;AAAA;AAAA,IACD;AAAA,IACE,OAAO,KAAM,sBAAuB,EAAE,IAAK,CAAE,aAC9C;AAAA,MAAC,4BAAU;AAAA,MAAV;AAAA,QAEA,MAAO,IAAK,QAAS;AAAA,QACrB,WAAU;AAAA,QAEV;AAAA,UAAC;AAAA;AAAA,YACA,UAAQ;AAAA,YACR,cAAe;AAAA,YACf,kBAAmB,uBAAwB,QAAS;AAAA;AAAA,QACrD;AAAA;AAAA,MARM;AAAA,IASP,CACC;AAAA,KACH;AAEF;",
|
|
6
|
+
"names": ["blocksPrivateApis", "RichText", "Media", "Link", "blockEditorStore", "blocksStore", "useBlockDisplayTitle", "useBlockDisplayInformation", "HStack", "BlockIcon", "FieldsDropdownMenu"]
|
|
7
7
|
}
|
|
@@ -75,124 +75,113 @@ function getUpdatedLinkAttributes({
|
|
|
75
75
|
rel: updatedRel || void 0
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
function Link({
|
|
79
|
-
clientId,
|
|
80
|
-
control,
|
|
81
|
-
blockType,
|
|
82
|
-
attributeValues,
|
|
83
|
-
updateAttributes
|
|
84
|
-
}) {
|
|
78
|
+
function Link({ data, field, onChange, config = {} }) {
|
|
85
79
|
const [isLinkControlOpen, setIsLinkControlOpen] = (0, import_element.useState)(false);
|
|
86
80
|
const { popoverProps } = (0, import_use_inspector_popover_placement.useInspectorPopoverPlacement)({
|
|
87
81
|
isControl: true
|
|
88
82
|
});
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
const relDefaultValue = blockType.attributes[rel]?.defaultValue ?? void 0;
|
|
99
|
-
const targetDefaultValue = blockType.attributes[target]?.defaultValue ?? void 0;
|
|
100
|
-
const destinationDefaultValue = blockType.attributes[destination]?.defaultValue ?? void 0;
|
|
83
|
+
const { fieldDef } = config;
|
|
84
|
+
const updateAttributes = (newValue) => {
|
|
85
|
+
const mappedChanges = field.setValue({ item: data, value: newValue });
|
|
86
|
+
onChange(mappedChanges);
|
|
87
|
+
};
|
|
88
|
+
const value = field.getValue({ item: data });
|
|
89
|
+
const url = value?.url;
|
|
90
|
+
const rel = value?.rel || "";
|
|
91
|
+
const target = value?.linkTarget;
|
|
101
92
|
const opensInNewTab = target === NEW_TAB_TARGET;
|
|
102
93
|
const nofollow = rel === NOFOLLOW_REL;
|
|
103
94
|
const linkValue = (0, import_element.useMemo)(
|
|
104
|
-
() => ({ url
|
|
105
|
-
[
|
|
95
|
+
() => ({ url, opensInNewTab, nofollow }),
|
|
96
|
+
[url, opensInNewTab, nofollow]
|
|
106
97
|
);
|
|
107
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
[destinationKey]: destinationDefaultValue
|
|
119
|
-
});
|
|
120
|
-
},
|
|
121
|
-
isShownByDefault: control.shownByDefault,
|
|
122
|
-
children: [
|
|
123
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
124
|
-
import_components.Button,
|
|
98
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
99
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
100
|
+
import_components.Button,
|
|
101
|
+
{
|
|
102
|
+
__next40pxDefaultSize: true,
|
|
103
|
+
className: "block-editor-content-only-controls__link",
|
|
104
|
+
onClick: () => {
|
|
105
|
+
setIsLinkControlOpen(true);
|
|
106
|
+
},
|
|
107
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
108
|
+
import_components.__experimentalGrid,
|
|
125
109
|
{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
icon: import_icons.link,
|
|
148
|
-
size: 24,
|
|
149
|
-
style: { opacity: 0.3 }
|
|
150
|
-
}
|
|
151
|
-
),
|
|
152
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block-editor-content-only-controls__link-title", children: (0, import_i18n.__)("Link") })
|
|
153
|
-
] })
|
|
154
|
-
]
|
|
155
|
-
}
|
|
156
|
-
)
|
|
110
|
+
rowGap: 0,
|
|
111
|
+
columnGap: 8,
|
|
112
|
+
templateColumns: "24px 1fr",
|
|
113
|
+
className: "block-editor-content-only-controls__link-row",
|
|
114
|
+
children: [
|
|
115
|
+
url && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
116
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Icon, { icon: import_icons.link, size: 24 }),
|
|
117
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block-editor-content-only-controls__link-title", children: url })
|
|
118
|
+
] }),
|
|
119
|
+
!url && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
120
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
121
|
+
import_components.Icon,
|
|
122
|
+
{
|
|
123
|
+
icon: import_icons.link,
|
|
124
|
+
size: 24,
|
|
125
|
+
style: { opacity: 0.3 }
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block-editor-content-only-controls__link-title", children: (0, import_i18n.__)("Link") })
|
|
129
|
+
] })
|
|
130
|
+
]
|
|
157
131
|
}
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
),
|
|
135
|
+
isLinkControlOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
136
|
+
import_components.Popover,
|
|
137
|
+
{
|
|
138
|
+
onClose: () => {
|
|
139
|
+
setIsLinkControlOpen(false);
|
|
140
|
+
},
|
|
141
|
+
...popoverProps ?? {},
|
|
142
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
143
|
+
import_link_control.default,
|
|
161
144
|
{
|
|
162
|
-
|
|
163
|
-
|
|
145
|
+
value: linkValue,
|
|
146
|
+
onChange: (newValues) => {
|
|
147
|
+
const updatedAttrs = getUpdatedLinkAttributes({
|
|
148
|
+
rel,
|
|
149
|
+
...newValues
|
|
150
|
+
});
|
|
151
|
+
const updateValue = { ...value };
|
|
152
|
+
if (fieldDef?.mapping) {
|
|
153
|
+
Object.keys(fieldDef.mapping).forEach(
|
|
154
|
+
(key) => {
|
|
155
|
+
if (key === "href" || key === "url") {
|
|
156
|
+
updateValue[key] = updatedAttrs.url;
|
|
157
|
+
} else if (key === "rel") {
|
|
158
|
+
updateValue[key] = updatedAttrs.rel;
|
|
159
|
+
} else if (key === "target" || key === "linkTarget") {
|
|
160
|
+
updateValue[key] = updatedAttrs.linkTarget;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
updateAttributes(updateValue);
|
|
164
166
|
},
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
updateAttributes({
|
|
176
|
-
[hrefKey]: updatedAttrs.url,
|
|
177
|
-
[relKey]: updatedAttrs.rel,
|
|
178
|
-
[targetKey]: updatedAttrs.linkTarget
|
|
179
|
-
});
|
|
180
|
-
},
|
|
181
|
-
onRemove: () => {
|
|
182
|
-
updateAttributes({
|
|
183
|
-
[hrefKey]: hrefDefaultValue,
|
|
184
|
-
[relKey]: relDefaultValue,
|
|
185
|
-
[targetKey]: targetDefaultValue,
|
|
186
|
-
[destinationKey]: destinationDefaultValue
|
|
187
|
-
});
|
|
188
|
-
}
|
|
167
|
+
onRemove: () => {
|
|
168
|
+
const removeValue = {};
|
|
169
|
+
if (fieldDef?.mapping) {
|
|
170
|
+
Object.keys(fieldDef.mapping).forEach(
|
|
171
|
+
(key) => {
|
|
172
|
+
if (key === "href" || key === "url" || key === "rel" || key === "target" || key === "linkTarget") {
|
|
173
|
+
removeValue[key] = void 0;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
);
|
|
189
177
|
}
|
|
190
|
-
|
|
178
|
+
updateAttributes(removeValue);
|
|
179
|
+
}
|
|
191
180
|
}
|
|
192
181
|
)
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
);
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
] });
|
|
196
185
|
}
|
|
197
186
|
// Annotate the CommonJS export names for ESM import in node:
|
|
198
187
|
0 && (module.exports = {
|