@wordpress/block-editor 15.8.1-next.16d95556a.0 → 15.9.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/build/components/block-inspector/edit-contents.js +19 -23
- package/build/components/block-inspector/edit-contents.js.map +3 -3
- package/build/components/block-inspector/index.js +7 -1
- package/build/components/block-inspector/index.js.map +2 -2
- package/build/components/block-list/block.js +4 -0
- package/build/components/block-list/block.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/index.js +3 -1
- package/build/components/block-list/use-block-props/index.js.map +2 -2
- package/build/components/block-list/use-block-props/use-is-hovered.js +16 -10
- package/build/components/block-list/use-block-props/use-is-hovered.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/edit-section-menu-item.js +64 -0
- package/build/components/block-settings-menu-controls/edit-section-menu-item.js.map +7 -0
- package/build/components/block-settings-menu-controls/index.js +9 -1
- package/build/components/block-settings-menu-controls/index.js.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.js +9 -9
- package/build/components/block-toolbar/block-toolbar-icon.js.map +2 -2
- package/build/components/block-tools/index.js +56 -45
- package/build/components/block-tools/index.js.map +3 -3
- package/build/components/block-variation-transforms/index.js +32 -5
- package/build/components/block-variation-transforms/index.js.map +2 -2
- package/build/components/block-visibility/toolbar.js +1 -1
- package/build/components/block-visibility/toolbar.js.map +1 -1
- package/build/components/border-radius-control/single-input-control.js +1 -0
- package/build/components/border-radius-control/single-input-control.js.map +2 -2
- 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 +444 -0
- package/build/components/content-only-controls/index.js.map +7 -0
- package/build/components/content-only-controls/link/index.js +193 -0
- package/build/components/content-only-controls/link/index.js.map +7 -0
- package/build/components/content-only-controls/media/index.js +264 -0
- package/build/components/content-only-controls/media/index.js.map +7 -0
- package/build/components/content-only-controls/rich-text/index.js +188 -0
- package/build/components/content-only-controls/rich-text/index.js.map +7 -0
- package/build/components/content-only-controls/use-inspector-popover-placement.js +41 -0
- package/build/components/content-only-controls/use-inspector-popover-placement.js.map +7 -0
- 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/inserter/media-tab/media-tab.js +1 -33
- package/build/components/inserter/media-tab/media-tab.js.map +3 -3
- package/build/components/inspector-controls-tabs/content-tab.js +6 -2
- package/build/components/inspector-controls-tabs/content-tab.js.map +3 -3
- package/build/components/inspector-controls-tabs/index.js +7 -1
- package/build/components/inspector-controls-tabs/index.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 +7 -8
- 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 +18 -35
- package/build/components/media-placeholder/index.js.map +3 -3
- 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 +24 -33
- package/build/components/media-replace-flow/index.js.map +3 -3
- 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-display-information/index.js +21 -1
- package/build/components/use-block-display-information/index.js.map +3 -3
- 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 +52 -61
- 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/use-content-only-section-edit.js +67 -0
- package/build/hooks/use-content-only-section-edit.js.map +7 -0
- package/build/hooks/utils.js +5 -1
- package/build/hooks/utils.js.map +2 -2
- package/build/layouts/constrained.js +2 -2
- package/build/layouts/constrained.js.map +2 -2
- package/build/private-apis.js +2 -3
- package/build/private-apis.js.map +3 -3
- package/build/store/private-keys.js +3 -0
- package/build/store/private-keys.js.map +2 -2
- package/build/store/private-selectors.js +41 -2
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/selectors.js +6 -4
- package/build/store/selectors.js.map +2 -2
- package/build/utils/fit-text-utils.js +9 -1
- package/build/utils/fit-text-utils.js.map +2 -2
- package/build-module/components/block-inspector/edit-contents.js +9 -23
- package/build-module/components/block-inspector/edit-contents.js.map +2 -2
- package/build-module/components/block-inspector/index.js +7 -1
- package/build-module/components/block-inspector/index.js.map +2 -2
- package/build-module/components/block-list/block.js +4 -0
- package/build-module/components/block-list/block.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/index.js +3 -1
- package/build-module/components/block-list/use-block-props/index.js.map +2 -2
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +16 -10
- package/build-module/components/block-list/use-block-props/use-is-hovered.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/edit-section-menu-item.js +29 -0
- package/build-module/components/block-settings-menu-controls/edit-section-menu-item.js.map +7 -0
- package/build-module/components/block-settings-menu-controls/index.js +9 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.js +10 -10
- package/build-module/components/block-toolbar/block-toolbar-icon.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-variation-transforms/index.js +32 -5
- package/build-module/components/block-variation-transforms/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/border-radius-control/single-input-control.js +1 -0
- package/build-module/components/border-radius-control/single-input-control.js.map +2 -2
- 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 +420 -0
- package/build-module/components/content-only-controls/index.js.map +7 -0
- package/build-module/components/content-only-controls/link/index.js +160 -0
- package/build-module/components/content-only-controls/link/index.js.map +7 -0
- package/build-module/components/content-only-controls/media/index.js +242 -0
- package/build-module/components/content-only-controls/media/index.js.map +7 -0
- package/build-module/components/content-only-controls/rich-text/index.js +160 -0
- package/build-module/components/content-only-controls/rich-text/index.js.map +7 -0
- package/build-module/components/content-only-controls/use-inspector-popover-placement.js +16 -0
- package/build-module/components/content-only-controls/use-inspector-popover-placement.js.map +7 -0
- 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/inserter/media-tab/media-tab.js +2 -34
- package/build-module/components/inserter/media-tab/media-tab.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/content-tab.js +7 -3
- package/build-module/components/inspector-controls-tabs/content-tab.js.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.js +7 -1
- package/build-module/components/inspector-controls-tabs/index.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 +14 -9
- 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 +19 -36
- 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 +24 -33
- package/build-module/components/media-replace-flow/index.js.map +2 -2
- 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-display-information/index.js +21 -1
- package/build-module/components/use-block-display-information/index.js.map +3 -3
- 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 +57 -62
- 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/use-content-only-section-edit.js +46 -0
- package/build-module/hooks/use-content-only-section-edit.js.map +7 -0
- package/build-module/hooks/utils.js +5 -1
- package/build-module/hooks/utils.js.map +2 -2
- package/build-module/layouts/constrained.js +2 -2
- package/build-module/layouts/constrained.js.map +2 -2
- package/build-module/private-apis.js +3 -3
- package/build-module/private-apis.js.map +2 -2
- package/build-module/store/private-keys.js +2 -0
- package/build-module/store/private-keys.js.map +2 -2
- package/build-module/store/private-selectors.js +37 -2
- package/build-module/store/private-selectors.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/fit-text-utils.js +9 -1
- package/build-module/utils/fit-text-utils.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 +145 -4
- package/build-style/style.css +145 -4
- package/package.json +38 -37
- package/src/components/block-inspector/edit-contents.js +10 -29
- package/src/components/block-inspector/index.js +4 -2
- package/src/components/block-list/block.js +6 -0
- 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/index.js +3 -1
- package/src/components/block-list/use-block-props/use-is-hovered.js +24 -12
- 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/edit-section-menu-item.js +39 -0
- package/src/components/block-settings-menu-controls/index.js +8 -1
- package/src/components/block-toolbar/block-toolbar-icon.js +14 -10
- package/src/components/block-tools/index.js +15 -2
- package/src/components/block-tools/style.scss +4 -0
- package/src/components/block-variation-transforms/index.js +96 -35
- package/src/components/block-visibility/toolbar.js +1 -1
- package/src/components/border-radius-control/single-input-control.js +1 -0
- package/src/components/content-only-controls/fields-dropdown-menu.js +53 -0
- package/src/components/content-only-controls/index.js +560 -0
- package/src/components/content-only-controls/link/index.js +200 -0
- package/src/components/content-only-controls/link/styles.scss +23 -0
- package/src/components/content-only-controls/media/index.js +306 -0
- package/src/components/content-only-controls/media/styles.scss +47 -0
- package/src/components/content-only-controls/rich-text/index.js +179 -0
- package/src/components/content-only-controls/rich-text/styles.scss +24 -0
- package/src/components/content-only-controls/styles.scss +44 -0
- package/src/components/content-only-controls/use-inspector-popover-placement.js +19 -0
- 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/inserter/media-tab/media-tab.js +2 -44
- package/src/components/inspector-controls-tabs/content-tab.js +12 -4
- package/src/components/inspector-controls-tabs/index.js +4 -1
- 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 +15 -10
- package/src/components/list-view/block.js +9 -7
- package/src/components/media-placeholder/index.js +21 -46
- 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 +25 -42
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-block-display-information/index.js +30 -2
- package/src/components/use-block-drop-zone/index.js +1 -5
- package/src/hooks/block-bindings.js +71 -82
- 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/use-content-only-section-edit.js +63 -0
- package/src/hooks/utils.js +4 -0
- package/src/layouts/constrained.js +8 -2
- package/src/private-apis.js +2 -2
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +121 -5
- package/src/store/selectors.js +6 -4
- package/src/store/test/private-selectors.js +242 -0
- package/src/style.scss +1 -1
- package/src/utils/fit-text-utils.js +19 -1
- package/tsconfig.json +1 -0
- package/build/components/media-upload-modal/index.js +0 -29
- package/build/components/media-upload-modal/index.js.map +0 -7
- package/build-module/components/media-upload-modal/index.js +0 -8
- package/build-module/components/media-upload-modal/index.js.map +0 -7
- package/src/components/font-family/style.scss +0 -7
- package/src/components/media-upload-modal/index.js +0 -18
- /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/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
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/block-editor/src/components/content-only-controls/link/index.js
|
|
31
|
+
var link_exports = {};
|
|
32
|
+
__export(link_exports, {
|
|
33
|
+
NEW_TAB_REL: () => NEW_TAB_REL,
|
|
34
|
+
NEW_TAB_TARGET: () => NEW_TAB_TARGET,
|
|
35
|
+
NOFOLLOW_REL: () => NOFOLLOW_REL,
|
|
36
|
+
default: () => Link,
|
|
37
|
+
getUpdatedLinkAttributes: () => getUpdatedLinkAttributes
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(link_exports);
|
|
40
|
+
var import_components = require("@wordpress/components");
|
|
41
|
+
var import_element = require("@wordpress/element");
|
|
42
|
+
var import_i18n = require("@wordpress/i18n");
|
|
43
|
+
var import_icons = require("@wordpress/icons");
|
|
44
|
+
var import_url = require("@wordpress/url");
|
|
45
|
+
var import_link_control = __toESM(require("../../link-control"));
|
|
46
|
+
var import_use_inspector_popover_placement = require("../use-inspector-popover-placement");
|
|
47
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
|
+
var NEW_TAB_REL = "noreferrer noopener";
|
|
49
|
+
var NEW_TAB_TARGET = "_blank";
|
|
50
|
+
var NOFOLLOW_REL = "nofollow";
|
|
51
|
+
function getUpdatedLinkAttributes({
|
|
52
|
+
rel = "",
|
|
53
|
+
url = "",
|
|
54
|
+
opensInNewTab,
|
|
55
|
+
nofollow
|
|
56
|
+
}) {
|
|
57
|
+
let newLinkTarget;
|
|
58
|
+
let updatedRel = rel;
|
|
59
|
+
if (opensInNewTab) {
|
|
60
|
+
newLinkTarget = NEW_TAB_TARGET;
|
|
61
|
+
updatedRel = updatedRel?.includes(NEW_TAB_REL) ? updatedRel : updatedRel + ` ${NEW_TAB_REL}`;
|
|
62
|
+
} else {
|
|
63
|
+
const relRegex = new RegExp(`\\b${NEW_TAB_REL}\\s*`, "g");
|
|
64
|
+
updatedRel = updatedRel?.replace(relRegex, "").trim();
|
|
65
|
+
}
|
|
66
|
+
if (nofollow) {
|
|
67
|
+
updatedRel = updatedRel?.includes(NOFOLLOW_REL) ? updatedRel : (updatedRel + ` ${NOFOLLOW_REL}`).trim();
|
|
68
|
+
} else {
|
|
69
|
+
const relRegex = new RegExp(`\\b${NOFOLLOW_REL}\\s*`, "g");
|
|
70
|
+
updatedRel = updatedRel?.replace(relRegex, "").trim();
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
url: (0, import_url.prependHTTP)(url),
|
|
74
|
+
linkTarget: newLinkTarget,
|
|
75
|
+
rel: updatedRel || void 0
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function Link({ data, field, config = {} }) {
|
|
79
|
+
const [isLinkControlOpen, setIsLinkControlOpen] = (0, import_element.useState)(false);
|
|
80
|
+
const { popoverProps } = (0, import_use_inspector_popover_placement.useInspectorPopoverPlacement)({
|
|
81
|
+
isControl: true
|
|
82
|
+
});
|
|
83
|
+
const { clientId, updateBlockAttributes, fieldDef } = config;
|
|
84
|
+
const updateAttributes = (newValue) => {
|
|
85
|
+
const mappedChanges = field.setValue({ item: data, value: newValue });
|
|
86
|
+
updateBlockAttributes(clientId, mappedChanges);
|
|
87
|
+
};
|
|
88
|
+
const value = field.getValue({ item: data });
|
|
89
|
+
const url = value?.url;
|
|
90
|
+
const rel = value?.rel || "";
|
|
91
|
+
const target = value?.linkTarget;
|
|
92
|
+
const opensInNewTab = target === NEW_TAB_TARGET;
|
|
93
|
+
const nofollow = rel === NOFOLLOW_REL;
|
|
94
|
+
const linkValue = (0, import_element.useMemo)(
|
|
95
|
+
() => ({ url, opensInNewTab, nofollow }),
|
|
96
|
+
[url, opensInNewTab, nofollow]
|
|
97
|
+
);
|
|
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,
|
|
109
|
+
{
|
|
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
|
+
]
|
|
131
|
+
}
|
|
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,
|
|
144
|
+
{
|
|
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);
|
|
166
|
+
},
|
|
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
|
+
);
|
|
177
|
+
}
|
|
178
|
+
updateAttributes(removeValue);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
] });
|
|
185
|
+
}
|
|
186
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
187
|
+
0 && (module.exports = {
|
|
188
|
+
NEW_TAB_REL,
|
|
189
|
+
NEW_TAB_TARGET,
|
|
190
|
+
NOFOLLOW_REL,
|
|
191
|
+
getUpdatedLinkAttributes
|
|
192
|
+
});
|
|
193
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/content-only-controls/link/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tIcon,\n\t__experimentalGrid as Grid,\n\tPopover,\n} from '@wordpress/components';\nimport { useMemo, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { link } from '@wordpress/icons';\nimport { prependHTTP } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport LinkControl from '../../link-control';\nimport { useInspectorPopoverPlacement } from '../use-inspector-popover-placement';\n\nexport const NEW_TAB_REL = 'noreferrer noopener';\nexport const NEW_TAB_TARGET = '_blank';\nexport const NOFOLLOW_REL = 'nofollow';\n\n/**\n * Updates the link attributes.\n *\n * @param {Object} attributes The current block attributes.\n * @param {string} attributes.rel The current link rel attribute.\n * @param {string} attributes.url The current link url.\n * @param {boolean} attributes.opensInNewTab Whether the link should open in a new window.\n * @param {boolean} attributes.nofollow Whether the link should be marked as nofollow.\n */\nexport function getUpdatedLinkAttributes( {\n\trel = '',\n\turl = '',\n\topensInNewTab,\n\tnofollow,\n} ) {\n\tlet newLinkTarget;\n\t// Since `rel` is editable attribute, we need to check for existing values and proceed accordingly.\n\tlet updatedRel = rel;\n\n\tif ( opensInNewTab ) {\n\t\tnewLinkTarget = NEW_TAB_TARGET;\n\t\tupdatedRel = updatedRel?.includes( NEW_TAB_REL )\n\t\t\t? updatedRel\n\t\t\t: updatedRel + ` ${ NEW_TAB_REL }`;\n\t} else {\n\t\tconst relRegex = new RegExp( `\\\\b${ NEW_TAB_REL }\\\\s*`, 'g' );\n\t\tupdatedRel = updatedRel?.replace( relRegex, '' ).trim();\n\t}\n\n\tif ( nofollow ) {\n\t\tupdatedRel = updatedRel?.includes( NOFOLLOW_REL )\n\t\t\t? updatedRel\n\t\t\t: ( updatedRel + ` ${ NOFOLLOW_REL }` ).trim();\n\t} else {\n\t\tconst relRegex = new RegExp( `\\\\b${ NOFOLLOW_REL }\\\\s*`, 'g' );\n\t\tupdatedRel = updatedRel?.replace( relRegex, '' ).trim();\n\t}\n\n\treturn {\n\t\turl: prependHTTP( url ),\n\t\tlinkTarget: newLinkTarget,\n\t\trel: updatedRel || undefined,\n\t};\n}\n\nexport default function Link( { data, field, config = {} } ) {\n\tconst [ isLinkControlOpen, setIsLinkControlOpen ] = useState( false );\n\tconst { popoverProps } = useInspectorPopoverPlacement( {\n\t\tisControl: true,\n\t} );\n\tconst { clientId, updateBlockAttributes, fieldDef } = config;\n\tconst updateAttributes = ( newValue ) => {\n\t\tconst mappedChanges = field.setValue( { item: data, value: newValue } );\n\t\tupdateBlockAttributes( clientId, mappedChanges );\n\t};\n\n\tconst value = field.getValue( { item: data } );\n\tconst url = value?.url;\n\tconst rel = value?.rel || '';\n\tconst target = value?.linkTarget;\n\n\tconst opensInNewTab = target === NEW_TAB_TARGET;\n\tconst nofollow = rel === NOFOLLOW_REL;\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/51256.\n\tconst linkValue = useMemo(\n\t\t() => ( { url, opensInNewTab, nofollow } ),\n\t\t[ url, opensInNewTab, nofollow ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"block-editor-content-only-controls__link\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsLinkControlOpen( true );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<Grid\n\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\ttemplateColumns=\"24px 1fr\"\n\t\t\t\t\tclassName=\"block-editor-content-only-controls__link-row\"\n\t\t\t\t>\n\t\t\t\t\t{ url && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<Icon icon={ link } size={ 24 } />\n\t\t\t\t\t\t\t<span className=\"block-editor-content-only-controls__link-title\">\n\t\t\t\t\t\t\t\t{ url }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t\t\t\tstyle={ { opacity: 0.3 } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<span className=\"block-editor-content-only-controls__link-title\">\n\t\t\t\t\t\t\t\t{ __( 'Link' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</Grid>\n\t\t\t</Button>\n\t\t\t{ isLinkControlOpen && (\n\t\t\t\t<Popover\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsLinkControlOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\t{ ...( popoverProps ?? {} ) }\n\t\t\t\t>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\tvalue={ linkValue }\n\t\t\t\t\t\tonChange={ ( newValues ) => {\n\t\t\t\t\t\t\tconst updatedAttrs = getUpdatedLinkAttributes( {\n\t\t\t\t\t\t\t\trel,\n\t\t\t\t\t\t\t\t...newValues,\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\t// Build update object dynamically based on what's in the mapping\n\t\t\t\t\t\t\tconst updateValue = { ...value };\n\n\t\t\t\t\t\t\tif ( fieldDef?.mapping ) {\n\t\t\t\t\t\t\t\tObject.keys( fieldDef.mapping ).forEach(\n\t\t\t\t\t\t\t\t\t( key ) => {\n\t\t\t\t\t\t\t\t\t\tif ( key === 'href' || key === 'url' ) {\n\t\t\t\t\t\t\t\t\t\t\tupdateValue[ key ] =\n\t\t\t\t\t\t\t\t\t\t\t\tupdatedAttrs.url;\n\t\t\t\t\t\t\t\t\t\t} else if ( key === 'rel' ) {\n\t\t\t\t\t\t\t\t\t\t\tupdateValue[ key ] =\n\t\t\t\t\t\t\t\t\t\t\t\tupdatedAttrs.rel;\n\t\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\t\tkey === 'target' ||\n\t\t\t\t\t\t\t\t\t\t\tkey === 'linkTarget'\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\tupdateValue[ key ] =\n\t\t\t\t\t\t\t\t\t\t\t\tupdatedAttrs.linkTarget;\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);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tupdateAttributes( updateValue );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t// Remove all link-related properties based on what's in the mapping\n\t\t\t\t\t\t\tconst removeValue = {};\n\n\t\t\t\t\t\t\tif ( fieldDef?.mapping ) {\n\t\t\t\t\t\t\t\tObject.keys( fieldDef.mapping ).forEach(\n\t\t\t\t\t\t\t\t\t( key ) => {\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\tkey === 'href' ||\n\t\t\t\t\t\t\t\t\t\t\tkey === 'url' ||\n\t\t\t\t\t\t\t\t\t\t\tkey === 'rel' ||\n\t\t\t\t\t\t\t\t\t\t\tkey === 'target' ||\n\t\t\t\t\t\t\t\t\t\t\tkey === 'linkTarget'\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\tremoveValue[ key ] = undefined;\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);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tupdateAttributes( removeValue );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t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AC;AAAA,UAAA;AAAA,YACA,OAAQ;AAAA,YACR,UAAW,CAAE,cAAe;AAC3B,oBAAM,eAAe,yBAA0B;AAAA,gBAC9C;AAAA,gBACA,GAAG;AAAA,cACJ,CAAE;AAGF,oBAAM,cAAc,EAAE,GAAG,MAAM;AAE/B,kBAAK,UAAU,SAAU;AACxB,uBAAO,KAAM,SAAS,OAAQ,EAAE;AAAA,kBAC/B,CAAE,QAAS;AACV,wBAAK,QAAQ,UAAU,QAAQ,OAAQ;AACtC,kCAAa,GAAI,IAChB,aAAa;AAAA,oBACf,WAAY,QAAQ,OAAQ;AAC3B,kCAAa,GAAI,IAChB,aAAa;AAAA,oBACf,WACC,QAAQ,YACR,QAAQ,cACP;AACD,kCAAa,GAAI,IAChB,aAAa;AAAA,oBACf;AAAA,kBACD;AAAA,gBACD;AAAA,cACD;AAEA,+BAAkB,WAAY;AAAA,YAC/B;AAAA,YACA,UAAW,MAAM;AAEhB,oBAAM,cAAc,CAAC;AAErB,kBAAK,UAAU,SAAU;AACxB,uBAAO,KAAM,SAAS,OAAQ,EAAE;AAAA,kBAC/B,CAAE,QAAS;AACV,wBACC,QAAQ,UACR,QAAQ,SACR,QAAQ,SACR,QAAQ,YACR,QAAQ,cACP;AACD,kCAAa,GAAI,IAAI;AAAA,oBACtB;AAAA,kBACD;AAAA,gBACD;AAAA,cACD;AAEA,+BAAkB,WAAY;AAAA,YAC/B;AAAA;AAAA,QACD;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;",
|
|
6
|
+
"names": ["Grid", "LinkControl"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/block-editor/src/components/content-only-controls/media/index.js
|
|
31
|
+
var media_exports = {};
|
|
32
|
+
__export(media_exports, {
|
|
33
|
+
default: () => Media
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(media_exports);
|
|
36
|
+
var import_components = require("@wordpress/components");
|
|
37
|
+
var import_data = require("@wordpress/data");
|
|
38
|
+
var import_i18n = require("@wordpress/i18n");
|
|
39
|
+
var import_icons = require("@wordpress/icons");
|
|
40
|
+
var import_media_replace_flow = __toESM(require("../../media-replace-flow"));
|
|
41
|
+
var import_check = __toESM(require("../../media-upload/check"));
|
|
42
|
+
var import_use_inspector_popover_placement = require("../use-inspector-popover-placement");
|
|
43
|
+
var import_private_keys = require("../../../store/private-keys");
|
|
44
|
+
var import_store = require("../../../store");
|
|
45
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
46
|
+
function MediaThumbnail({ data, field, attachment }) {
|
|
47
|
+
const config = field.config || {};
|
|
48
|
+
const { allowedTypes = [], multiple = false } = config;
|
|
49
|
+
if (multiple) {
|
|
50
|
+
return "todo multiple";
|
|
51
|
+
}
|
|
52
|
+
if (attachment?.media_type === "image" || attachment?.poster) {
|
|
53
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
54
|
+
"img",
|
|
55
|
+
{
|
|
56
|
+
className: "block-editor-content-only-controls__media-thumbnail",
|
|
57
|
+
alt: "",
|
|
58
|
+
width: 24,
|
|
59
|
+
height: 24,
|
|
60
|
+
src: attachment.media_type === "image" ? attachment.source_url : attachment.poster
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
if (allowedTypes.length === 1) {
|
|
65
|
+
const value = field.getValue({ item: data });
|
|
66
|
+
const url = value?.url;
|
|
67
|
+
if (url) {
|
|
68
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
69
|
+
"img",
|
|
70
|
+
{
|
|
71
|
+
className: "block-editor-content-only-controls__media-thumbnail",
|
|
72
|
+
alt: "",
|
|
73
|
+
width: 24,
|
|
74
|
+
height: 24,
|
|
75
|
+
src: url
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
let icon;
|
|
80
|
+
if (allowedTypes[0] === "image") {
|
|
81
|
+
icon = import_icons.image;
|
|
82
|
+
} else if (allowedTypes[0] === "video") {
|
|
83
|
+
icon = import_icons.video;
|
|
84
|
+
} else if (allowedTypes[0] === "audio") {
|
|
85
|
+
icon = import_icons.audio;
|
|
86
|
+
} else {
|
|
87
|
+
icon = import_icons.media;
|
|
88
|
+
}
|
|
89
|
+
if (icon) {
|
|
90
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Icon, { icon, size: 24 });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Icon, { icon: import_icons.media, size: 24 });
|
|
94
|
+
}
|
|
95
|
+
function Media({ data, field, config = {} }) {
|
|
96
|
+
const { popoverProps } = (0, import_use_inspector_popover_placement.useInspectorPopoverPlacement)({
|
|
97
|
+
isControl: true
|
|
98
|
+
});
|
|
99
|
+
const value = field.getValue({ item: data });
|
|
100
|
+
const { allowedTypes = [], multiple = false } = field.config || {};
|
|
101
|
+
const { clientId, updateBlockAttributes, fieldDef } = config;
|
|
102
|
+
const updateAttributes = (newFieldValue) => {
|
|
103
|
+
const mappedChanges = field.setValue({
|
|
104
|
+
item: data,
|
|
105
|
+
value: newFieldValue
|
|
106
|
+
});
|
|
107
|
+
updateBlockAttributes(clientId, mappedChanges);
|
|
108
|
+
};
|
|
109
|
+
const hasFeaturedImageSupport = fieldDef?.mapping && "featuredImage" in fieldDef.mapping;
|
|
110
|
+
const id = value?.id;
|
|
111
|
+
const url = value?.url;
|
|
112
|
+
const attachment = (0, import_data.useSelect)(
|
|
113
|
+
(select) => {
|
|
114
|
+
if (!id) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const settings = select(import_store.store).getSettings();
|
|
118
|
+
const getMedia = settings[import_private_keys.getMediaSelectKey];
|
|
119
|
+
if (!getMedia) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
return getMedia(select, id);
|
|
123
|
+
},
|
|
124
|
+
[id]
|
|
125
|
+
);
|
|
126
|
+
let chooseItemLabel;
|
|
127
|
+
if (allowedTypes.length === 1) {
|
|
128
|
+
const allowedType = allowedTypes[0];
|
|
129
|
+
if (allowedType === "image") {
|
|
130
|
+
chooseItemLabel = (0, import_i18n.__)("Choose an image\u2026");
|
|
131
|
+
} else if (allowedType === "video") {
|
|
132
|
+
chooseItemLabel = (0, import_i18n.__)("Choose a video\u2026");
|
|
133
|
+
} else if (allowedType === "application") {
|
|
134
|
+
chooseItemLabel = (0, import_i18n.__)("Choose a file\u2026");
|
|
135
|
+
} else {
|
|
136
|
+
chooseItemLabel = (0, import_i18n.__)("Choose a media item\u2026");
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
chooseItemLabel = (0, import_i18n.__)("Choose a media item\u2026");
|
|
140
|
+
}
|
|
141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_check.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
142
|
+
import_media_replace_flow.default,
|
|
143
|
+
{
|
|
144
|
+
className: "block-editor-content-only-controls__media-replace-flow",
|
|
145
|
+
allowedTypes,
|
|
146
|
+
mediaId: id,
|
|
147
|
+
mediaURL: url,
|
|
148
|
+
multiple,
|
|
149
|
+
popoverProps,
|
|
150
|
+
onReset: () => {
|
|
151
|
+
const resetValue = {};
|
|
152
|
+
if (fieldDef?.mapping) {
|
|
153
|
+
Object.keys(fieldDef.mapping).forEach((key) => {
|
|
154
|
+
if (key === "id" || key === "src" || key === "url") {
|
|
155
|
+
resetValue[key] = void 0;
|
|
156
|
+
} else if (key === "caption" || key === "alt") {
|
|
157
|
+
resetValue[key] = "";
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (hasFeaturedImageSupport) {
|
|
162
|
+
resetValue.featuredImage = false;
|
|
163
|
+
}
|
|
164
|
+
updateAttributes({ ...value, ...resetValue });
|
|
165
|
+
},
|
|
166
|
+
...hasFeaturedImageSupport && {
|
|
167
|
+
useFeaturedImage: !!value?.featuredImage,
|
|
168
|
+
onToggleFeaturedImage: () => {
|
|
169
|
+
updateAttributes({
|
|
170
|
+
...value,
|
|
171
|
+
featuredImage: !value?.featuredImage
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
onSelect: (selectedMedia) => {
|
|
176
|
+
if (selectedMedia.id && selectedMedia.url) {
|
|
177
|
+
let mediaType = "image";
|
|
178
|
+
if (selectedMedia.mime_type) {
|
|
179
|
+
if (selectedMedia.mime_type.startsWith("video/")) {
|
|
180
|
+
mediaType = "video";
|
|
181
|
+
} else if (selectedMedia.mime_type.startsWith("audio/")) {
|
|
182
|
+
mediaType = "audio";
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const newValue = {};
|
|
186
|
+
if (fieldDef?.mapping) {
|
|
187
|
+
Object.keys(fieldDef.mapping).forEach(
|
|
188
|
+
(key) => {
|
|
189
|
+
if (key === "id") {
|
|
190
|
+
newValue[key] = selectedMedia.id;
|
|
191
|
+
} else if (key === "src" || key === "url") {
|
|
192
|
+
newValue[key] = selectedMedia.url;
|
|
193
|
+
} else if (key === "type") {
|
|
194
|
+
newValue[key] = mediaType;
|
|
195
|
+
} else if (key === "link" && selectedMedia.link) {
|
|
196
|
+
newValue[key] = selectedMedia.link;
|
|
197
|
+
} else if (key === "caption" && !value?.caption && selectedMedia.caption) {
|
|
198
|
+
newValue[key] = selectedMedia.caption;
|
|
199
|
+
} else if (key === "alt" && !value?.alt && selectedMedia.alt) {
|
|
200
|
+
newValue[key] = selectedMedia.alt;
|
|
201
|
+
} else if (key === "poster" && selectedMedia.poster) {
|
|
202
|
+
newValue[key] = selectedMedia.poster;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
if (hasFeaturedImageSupport) {
|
|
208
|
+
newValue.featuredImage = false;
|
|
209
|
+
}
|
|
210
|
+
const finalValue = { ...value, ...newValue };
|
|
211
|
+
updateAttributes(finalValue);
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
renderToggle: (buttonProps) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
215
|
+
import_components.Button,
|
|
216
|
+
{
|
|
217
|
+
__next40pxDefaultSize: true,
|
|
218
|
+
className: "block-editor-content-only-controls__media",
|
|
219
|
+
...buttonProps,
|
|
220
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
221
|
+
import_components.__experimentalGrid,
|
|
222
|
+
{
|
|
223
|
+
rowGap: 0,
|
|
224
|
+
columnGap: 8,
|
|
225
|
+
templateColumns: "24px 1fr",
|
|
226
|
+
className: "block-editor-content-only-controls__media-row",
|
|
227
|
+
children: [
|
|
228
|
+
url && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
229
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
230
|
+
MediaThumbnail,
|
|
231
|
+
{
|
|
232
|
+
attachment,
|
|
233
|
+
field,
|
|
234
|
+
data
|
|
235
|
+
}
|
|
236
|
+
),
|
|
237
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
238
|
+
className: "block-editor-content-only-controls__media-title",
|
|
239
|
+
// TODO - truncate long titles or url smartly (e.g. show filename).
|
|
240
|
+
children: attachment?.title?.raw && attachment?.title?.raw !== "" ? attachment?.title?.raw : url
|
|
241
|
+
})
|
|
242
|
+
] }),
|
|
243
|
+
!url && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
244
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
245
|
+
"span",
|
|
246
|
+
{
|
|
247
|
+
className: "block-editor-content-only-controls__media-placeholder",
|
|
248
|
+
style: {
|
|
249
|
+
width: "24px",
|
|
250
|
+
height: "24px"
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
),
|
|
254
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block-editor-content-only-controls__media-title", children: chooseItemLabel })
|
|
255
|
+
] })
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
)
|
|
261
|
+
}
|
|
262
|
+
) });
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/content-only-controls/media/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tIcon,\n\t__experimentalGrid as Grid,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\taudio as audioIcon,\n\timage as imageIcon,\n\tmedia as mediaIcon,\n\tvideo as videoIcon,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport MediaReplaceFlow from '../../media-replace-flow';\nimport MediaUploadCheck from '../../media-upload/check';\nimport { useInspectorPopoverPlacement } from '../use-inspector-popover-placement';\nimport { getMediaSelectKey } from '../../../store/private-keys';\nimport { store as blockEditorStore } from '../../../store';\n\nfunction MediaThumbnail( { data, field, attachment } ) {\n\tconst config = field.config || {};\n\tconst { allowedTypes = [], multiple = false } = config;\n\n\tif ( multiple ) {\n\t\treturn 'todo multiple';\n\t}\n\n\tif ( attachment?.media_type === 'image' || attachment?.poster ) {\n\t\treturn (\n\t\t\t<img\n\t\t\t\tclassName=\"block-editor-content-only-controls__media-thumbnail\"\n\t\t\t\talt=\"\"\n\t\t\t\twidth={ 24 }\n\t\t\t\theight={ 24 }\n\t\t\t\tsrc={\n\t\t\t\t\tattachment.media_type === 'image'\n\t\t\t\t\t\t? attachment.source_url\n\t\t\t\t\t\t: attachment.poster\n\t\t\t\t}\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( allowedTypes.length === 1 ) {\n\t\tconst value = field.getValue( { item: data } );\n\t\tconst url = value?.url;\n\n\t\tif ( url ) {\n\t\t\treturn (\n\t\t\t\t<img\n\t\t\t\t\tclassName=\"block-editor-content-only-controls__media-thumbnail\"\n\t\t\t\t\talt=\"\"\n\t\t\t\t\twidth={ 24 }\n\t\t\t\t\theight={ 24 }\n\t\t\t\t\tsrc={ url }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\tlet icon;\n\t\tif ( allowedTypes[ 0 ] === 'image' ) {\n\t\t\ticon = imageIcon;\n\t\t} else if ( allowedTypes[ 0 ] === 'video' ) {\n\t\t\ticon = videoIcon;\n\t\t} else if ( allowedTypes[ 0 ] === 'audio' ) {\n\t\t\ticon = audioIcon;\n\t\t} else {\n\t\t\ticon = mediaIcon;\n\t\t}\n\n\t\tif ( icon ) {\n\t\t\treturn <Icon icon={ icon } size={ 24 } />;\n\t\t}\n\t}\n\n\treturn <Icon icon={ mediaIcon } size={ 24 } />;\n}\n\nexport default function Media( { data, field, config = {} } ) {\n\tconst { popoverProps } = useInspectorPopoverPlacement( {\n\t\tisControl: true,\n\t} );\n\tconst value = field.getValue( { item: data } );\n\tconst { allowedTypes = [], multiple = false } = field.config || {};\n\tconst { clientId, updateBlockAttributes, fieldDef } = config;\n\tconst updateAttributes = ( newFieldValue ) => {\n\t\tconst mappedChanges = field.setValue( {\n\t\t\titem: data,\n\t\t\tvalue: newFieldValue,\n\t\t} );\n\t\tupdateBlockAttributes( clientId, mappedChanges );\n\t};\n\n\t// Check if featured image is supported by checking if it's in the mapping\n\tconst hasFeaturedImageSupport =\n\t\tfieldDef?.mapping && 'featuredImage' in fieldDef.mapping;\n\n\tconst id = value?.id;\n\tconst url = value?.url;\n\n\tconst attachment = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! id ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\t\tconst getMedia = settings[ getMediaSelectKey ];\n\n\t\t\tif ( ! getMedia ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn getMedia( select, id );\n\t\t},\n\t\t[ id ]\n\t);\n\n\t// TODO - pluralize when multiple.\n\tlet chooseItemLabel;\n\tif ( allowedTypes.length === 1 ) {\n\t\tconst allowedType = allowedTypes[ 0 ];\n\t\tif ( allowedType === 'image' ) {\n\t\t\tchooseItemLabel = __( 'Choose an image\u2026' );\n\t\t} else if ( allowedType === 'video' ) {\n\t\t\tchooseItemLabel = __( 'Choose a video\u2026' );\n\t\t} else if ( allowedType === 'application' ) {\n\t\t\tchooseItemLabel = __( 'Choose a file\u2026' );\n\t\t} else {\n\t\t\tchooseItemLabel = __( 'Choose a media item\u2026' );\n\t\t}\n\t} else {\n\t\tchooseItemLabel = __( 'Choose a media item\u2026' );\n\t}\n\n\treturn (\n\t\t<MediaUploadCheck>\n\t\t\t<MediaReplaceFlow\n\t\t\t\tclassName=\"block-editor-content-only-controls__media-replace-flow\"\n\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\tmediaId={ id }\n\t\t\t\tmediaURL={ url }\n\t\t\t\tmultiple={ multiple }\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tonReset={ () => {\n\t\t\t\t\t// Build reset value dynamically based on mapping\n\t\t\t\t\tconst resetValue = {};\n\n\t\t\t\t\tif ( fieldDef?.mapping ) {\n\t\t\t\t\t\tObject.keys( fieldDef.mapping ).forEach( ( key ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tkey === 'id' ||\n\t\t\t\t\t\t\t\tkey === 'src' ||\n\t\t\t\t\t\t\t\tkey === 'url'\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tresetValue[ key ] = undefined;\n\t\t\t\t\t\t\t} else if ( key === 'caption' || key === 'alt' ) {\n\t\t\t\t\t\t\t\tresetValue[ key ] = '';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Turn off featured image when resetting (only if it's in the mapping)\n\t\t\t\t\tif ( hasFeaturedImageSupport ) {\n\t\t\t\t\t\tresetValue.featuredImage = false;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Merge with existing value to preserve other field properties\n\t\t\t\t\tupdateAttributes( { ...value, ...resetValue } );\n\t\t\t\t} }\n\t\t\t\t{ ...( hasFeaturedImageSupport && {\n\t\t\t\t\tuseFeaturedImage: !! value?.featuredImage,\n\t\t\t\t\tonToggleFeaturedImage: () => {\n\t\t\t\t\t\tupdateAttributes( {\n\t\t\t\t\t\t\t...value,\n\t\t\t\t\t\t\tfeaturedImage: ! value?.featuredImage,\n\t\t\t\t\t\t} );\n\t\t\t\t\t},\n\t\t\t\t} ) }\n\t\t\t\tonSelect={ ( selectedMedia ) => {\n\t\t\t\t\tif ( selectedMedia.id && selectedMedia.url ) {\n\t\t\t\t\t\t// Determine mediaType from MIME type, not from object type\n\t\t\t\t\t\tlet mediaType = 'image'; // default\n\t\t\t\t\t\tif ( selectedMedia.mime_type ) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tselectedMedia.mime_type.startsWith( 'video/' )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tmediaType = 'video';\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tselectedMedia.mime_type.startsWith( 'audio/' )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tmediaType = 'audio';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Build new value dynamically based on what's in the mapping\n\t\t\t\t\t\tconst newValue = {};\n\n\t\t\t\t\t\t// Iterate over mapping keys and set values for supported properties\n\t\t\t\t\t\tif ( fieldDef?.mapping ) {\n\t\t\t\t\t\t\tObject.keys( fieldDef.mapping ).forEach(\n\t\t\t\t\t\t\t\t( key ) => {\n\t\t\t\t\t\t\t\t\tif ( key === 'id' ) {\n\t\t\t\t\t\t\t\t\t\tnewValue[ key ] = selectedMedia.id;\n\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\tkey === 'src' ||\n\t\t\t\t\t\t\t\t\t\tkey === 'url'\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tnewValue[ key ] = selectedMedia.url;\n\t\t\t\t\t\t\t\t\t} else if ( key === 'type' ) {\n\t\t\t\t\t\t\t\t\t\tnewValue[ key ] = mediaType;\n\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\tkey === 'link' &&\n\t\t\t\t\t\t\t\t\t\tselectedMedia.link\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tnewValue[ key ] = selectedMedia.link;\n\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\tkey === 'caption' &&\n\t\t\t\t\t\t\t\t\t\t! value?.caption &&\n\t\t\t\t\t\t\t\t\t\tselectedMedia.caption\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tnewValue[ key ] = selectedMedia.caption;\n\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\tkey === 'alt' &&\n\t\t\t\t\t\t\t\t\t\t! value?.alt &&\n\t\t\t\t\t\t\t\t\t\tselectedMedia.alt\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tnewValue[ key ] = selectedMedia.alt;\n\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\tkey === 'poster' &&\n\t\t\t\t\t\t\t\t\t\tselectedMedia.poster\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tnewValue[ key ] = selectedMedia.poster;\n\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);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Turn off featured image when manually selecting media\n\t\t\t\t\t\tif ( hasFeaturedImageSupport ) {\n\t\t\t\t\t\t\tnewValue.featuredImage = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Merge with existing value to preserve other field properties\n\t\t\t\t\t\tconst finalValue = { ...value, ...newValue };\n\t\t\t\t\t\tupdateAttributes( finalValue );\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\trenderToggle={ ( buttonProps ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tclassName=\"block-editor-content-only-controls__media\"\n\t\t\t\t\t\t{ ...buttonProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t\t\ttemplateColumns=\"24px 1fr\"\n\t\t\t\t\t\t\tclassName=\"block-editor-content-only-controls__media-row\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<MediaThumbnail\n\t\t\t\t\t\t\t\t\t\tattachment={ attachment }\n\t\t\t\t\t\t\t\t\t\tfield={ field }\n\t\t\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-content-only-controls__media-title\">\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t// TODO - truncate long titles or url smartly (e.g. show filename).\n\t\t\t\t\t\t\t\t\t\t\tattachment?.title?.raw &&\n\t\t\t\t\t\t\t\t\t\t\tattachment?.title?.raw !== ''\n\t\t\t\t\t\t\t\t\t\t\t\t? attachment?.title?.raw\n\t\t\t\t\t\t\t\t\t\t\t\t: url\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-content-only-controls__media-placeholder\"\n\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\theight: '24px',\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<span className=\"block-editor-content-only-controls__media-title\">\n\t\t\t\t\t\t\t\t\t\t{ chooseItemLabel }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Grid>\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</MediaUploadCheck>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAIO;AACP,kBAA0B;AAC1B,kBAAmB;AACnB,mBAKO;AAKP,gCAA6B;AAC7B,mBAA6B;AAC7B,6CAA6C;AAC7C,0BAAkC;AAClC,mBAA0C;AAYvC;AAVH,SAAS,eAAgB,EAAE,MAAM,OAAO,WAAW,GAAI;AACtD,QAAM,SAAS,MAAM,UAAU,CAAC;AAChC,QAAM,EAAE,eAAe,CAAC,GAAG,WAAW,MAAM,IAAI;AAEhD,MAAK,UAAW;AACf,WAAO;AAAA,EACR;AAEA,MAAK,YAAY,eAAe,WAAW,YAAY,QAAS;AAC/D,WACC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,KAAI;AAAA,QACJ,OAAQ;AAAA,QACR,QAAS;AAAA,QACT,KACC,WAAW,eAAe,UACvB,WAAW,aACX,WAAW;AAAA;AAAA,IAEhB;AAAA,EAEF;AAEA,MAAK,aAAa,WAAW,GAAI;AAChC,UAAM,QAAQ,MAAM,SAAU,EAAE,MAAM,KAAK,CAAE;AAC7C,UAAM,MAAM,OAAO;AAEnB,QAAK,KAAM;AACV,aACC;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,KAAI;AAAA,UACJ,OAAQ;AAAA,UACR,QAAS;AAAA,UACT,KAAM;AAAA;AAAA,MACP;AAAA,IAEF;AAEA,QAAI;AACJ,QAAK,aAAc,CAAE,MAAM,SAAU;AACpC,aAAO,aAAAA;AAAA,IACR,WA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ACD;AAAA,kBACA,4CAAC;AAAA,oBAAK,WAAU;AAAA;AAAA,oBAGd,sBAAY,OAAO,OACnB,YAAY,OAAO,QAAQ,KACxB,YAAY,OAAO,MACnB;AAAA,mBAEL;AAAA,mBACD;AAAA,gBAEC,CAAE,OACH,4EACC;AAAA;AAAA,oBAAC;AAAA;AAAA,sBACA,WAAU;AAAA,sBACV,OAAQ;AAAA,wBACP,OAAO;AAAA,wBACP,QAAQ;AAAA,sBACT;AAAA;AAAA,kBACD;AAAA,kBACA,4CAAC,UAAK,WAAU,mDACb,2BACH;AAAA,mBACD;AAAA;AAAA;AAAA,UAEF;AAAA;AAAA,MACD;AAAA;AAAA,EAEF,GACD;AAEF;",
|
|
6
|
+
"names": ["imageIcon", "videoIcon", "audioIcon", "mediaIcon", "blockEditorStore", "MediaUploadCheck", "MediaReplaceFlow", "Grid"]
|
|
7
|
+
}
|