@wordpress/block-editor 7.0.3 → 7.0.4
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/build/components/block-actions/index.js +6 -5
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js +17 -4
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-inspector/index.js +1 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-html.js +5 -0
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-list/block.native.js +2 -2
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list-appender/index.js +9 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +10 -3
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/block-styles-menu.js +1 -1
- package/build/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build/components/block-tools/index.js +4 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +96 -7
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/utils.js +17 -8
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/colors-gradients/control.js +17 -13
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/copy-handler/index.js +3 -3
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/default-block-appender/index.js +2 -2
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +3 -5
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/index.js +0 -18
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +11 -1
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-clipboard-block.native.js +5 -4
- package/build/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
- package/build/components/inserter/preview-panel.js +1 -1
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inspector-controls/block-support-slot-container.js +28 -0
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -0
- package/build/components/inspector-controls/block-support-tools-panel.js +7 -4
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.js +16 -1
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/slot.js +5 -2
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/list-view/block-contents.js +1 -20
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block.js +5 -36
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/list-item.js +3 -2
- package/build/components/list-view/list-item.js.map +1 -1
- package/build/components/media-placeholder/index.js +26 -17
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +3 -2
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +30 -1
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/rich-text/embed-handler-picker.native.js +65 -0
- package/build/components/rich-text/embed-handler-picker.native.js.map +1 -0
- package/build/components/rich-text/index.js +5 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +41 -2
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +28 -9
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/rich-text/utils.js +22 -0
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/hooks/align.js +10 -7
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/anchor.js +1 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/font-family.js +93 -23
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/style.js +6 -3
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flow.js +4 -1
- package/build/layouts/flow.js.map +1 -1
- package/build/store/reducer.js +11 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +1 -3
- package/build/store/selectors.js.map +1 -1
- package/build/utils/transform-styles/transforms/wrap.js +16 -0
- package/build/utils/transform-styles/transforms/wrap.js.map +1 -1
- package/build-module/components/block-actions/index.js +6 -5
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +17 -4
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-inspector/index.js +1 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-html.js +5 -0
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -2
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +9 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +10 -3
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build-module/components/block-tools/index.js +4 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +96 -8
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +16 -9
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +18 -14
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/copy-handler/index.js +3 -3
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/default-block-appender/index.js +2 -2
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +3 -5
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/index.js +0 -2
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +11 -1
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-clipboard-block.native.js +5 -4
- package/build-module/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +1 -1
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js +18 -0
- package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -0
- package/build-module/components/inspector-controls/block-support-tools-panel.js +7 -4
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +16 -2
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +4 -2
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +1 -18
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block.js +7 -37
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/list-item.js +3 -2
- package/build-module/components/list-view/list-item.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +26 -17
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +3 -2
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +29 -2
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/embed-handler-picker.native.js +53 -0
- package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -0
- package/build-module/components/rich-text/index.js +4 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +41 -3
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +28 -9
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/utils.js +20 -0
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/hooks/align.js +10 -7
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/anchor.js +1 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/font-family.js +91 -24
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/style.js +6 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flow.js +4 -1
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/reducer.js +11 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +2 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/transform-styles/transforms/wrap.js +16 -0
- package/build-module/utils/transform-styles/transforms/wrap.js.map +1 -1
- package/build-style/style-rtl.css +52 -76
- package/build-style/style.css +52 -76
- package/package.json +14 -14
- package/src/components/block-actions/index.js +5 -5
- package/src/components/block-alignment-control/use-available-alignments.js +18 -3
- package/src/components/block-inspector/index.js +1 -1
- package/src/components/block-list/block-html.js +5 -0
- package/src/components/block-list/block.native.js +2 -2
- package/src/components/block-list-appender/index.js +8 -0
- package/src/components/block-preview/README.md +1 -1
- package/src/components/block-preview/style.scss +0 -17
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/src/components/block-settings-menu-controls/index.js +9 -6
- package/src/components/block-switcher/block-styles-menu.js +1 -1
- package/src/components/block-tools/index.js +5 -2
- package/src/components/block-tools/insertion-point.js +97 -9
- package/src/components/block-tools/style.scss +4 -35
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/test/utils.js +216 -0
- package/src/components/border-radius-control/utils.js +18 -10
- package/src/components/color-palette/test/__snapshots__/control.js.snap +103 -72
- package/src/components/colors-gradients/control.js +64 -61
- package/src/components/colors-gradients/style.scss +8 -5
- package/src/components/colors-gradients/test/control.js +43 -52
- package/src/components/copy-handler/index.js +1 -1
- package/src/components/default-block-appender/index.js +2 -2
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +3 -3
- package/src/components/font-appearance-control/index.js +12 -14
- package/src/components/font-appearance-control/style.scss +1 -1
- package/src/components/index.js +0 -2
- package/src/components/inserter/block-patterns-tab.js +11 -4
- package/src/components/inserter/hooks/use-clipboard-block.native.js +3 -2
- package/src/components/inserter/preview-panel.js +1 -1
- package/src/components/inserter/style.scss +1 -2
- package/src/components/inspector-controls/block-support-slot-container.js +10 -0
- package/src/components/inspector-controls/block-support-tools-panel.js +4 -2
- package/src/components/inspector-controls/fill.js +23 -2
- package/src/components/inspector-controls/slot.js +6 -1
- package/src/components/link-control/style.scss +9 -5
- package/src/components/list-view/block-contents.js +17 -38
- package/src/components/list-view/block.js +6 -51
- package/src/components/list-view/list-item.js +5 -4
- package/src/components/list-view/style.scss +56 -30
- package/src/components/media-placeholder/index.js +24 -17
- package/src/components/media-replace-flow/README.md +7 -0
- package/src/components/media-replace-flow/index.js +2 -0
- package/src/components/plain-text/index.native.js +26 -4
- package/src/components/rich-text/embed-handler-picker.native.js +67 -0
- package/src/components/rich-text/index.js +12 -8
- package/src/components/rich-text/index.native.js +35 -1
- package/src/components/rich-text/use-paste-handler.js +30 -12
- package/src/components/rich-text/utils.js +16 -0
- package/src/components/skip-to-selected-block/README.md +39 -0
- package/src/hooks/align.js +11 -7
- package/src/hooks/anchor.js +2 -2
- package/src/hooks/font-family.js +107 -27
- package/src/hooks/style.js +14 -8
- package/src/layouts/flow.js +4 -1
- package/src/store/reducer.js +17 -0
- package/src/store/selectors.js +2 -3
- package/src/store/test/reducer.js +22 -0
- package/src/utils/transform-styles/transforms/test/wrap.js +1 -1
- package/src/utils/transform-styles/transforms/wrap.js +16 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/list-view/block-slot.js +0 -121
- package/build/components/list-view/block-slot.js.map +0 -1
- package/build/components/list-view/editor.js +0 -35
- package/build/components/list-view/editor.js.map +0 -1
- package/build-module/components/list-view/block-slot.js +0 -96
- package/build-module/components/list-view/block-slot.js.map +0 -1
- package/build-module/components/list-view/editor.js +0 -25
- package/build-module/components/list-view/editor.js.map +0 -1
- package/src/components/list-view/block-slot.js +0 -120
- package/src/components/list-view/editor.js +0 -29
|
@@ -13,8 +13,6 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
13
13
|
|
|
14
14
|
var _components = require("@wordpress/components");
|
|
15
15
|
|
|
16
|
-
var _i18n = require("@wordpress/i18n");
|
|
17
|
-
|
|
18
16
|
var _icons = require("@wordpress/icons");
|
|
19
17
|
|
|
20
18
|
var _data = require("@wordpress/data");
|
|
@@ -63,17 +61,13 @@ function ListViewBlock({
|
|
|
63
61
|
const {
|
|
64
62
|
clientId
|
|
65
63
|
} = block;
|
|
66
|
-
const blockParents = (0, _data.useSelect)(select => {
|
|
67
|
-
return select(_store.store).getBlockParents(clientId);
|
|
68
|
-
}, [clientId]);
|
|
69
64
|
const {
|
|
70
|
-
selectBlock: selectEditorBlock,
|
|
71
65
|
toggleBlockHighlight
|
|
72
66
|
} = (0, _data.useDispatch)(_store.store);
|
|
73
67
|
const hasSiblings = siblingBlockCount > 0;
|
|
74
68
|
const hasRenderedMovers = showBlockMovers && hasSiblings;
|
|
75
69
|
const moverCellClassName = (0, _classnames.default)('block-editor-list-view-block__mover-cell', {
|
|
76
|
-
'is-visible': isHovered
|
|
70
|
+
'is-visible': isHovered || isSelected
|
|
77
71
|
});
|
|
78
72
|
const {
|
|
79
73
|
__experimentalFeatures: withExperimentalFeatures,
|
|
@@ -81,7 +75,7 @@ function ListViewBlock({
|
|
|
81
75
|
isTreeGridMounted
|
|
82
76
|
} = (0, _context.useListViewContext)();
|
|
83
77
|
const listViewBlockSettingsClassName = (0, _classnames.default)('block-editor-list-view-block__menu-cell', {
|
|
84
|
-
'is-visible': isHovered
|
|
78
|
+
'is-visible': isHovered || isSelected
|
|
85
79
|
}); // If ListView has experimental features related to the Persistent List View,
|
|
86
80
|
// only focus the selected list item on mount; otherwise the list would always
|
|
87
81
|
// try to steal the focus from the editor canvas.
|
|
@@ -90,14 +84,7 @@ function ListViewBlock({
|
|
|
90
84
|
if (withExperimentalPersistentListViewFeatures && !isTreeGridMounted && isSelected) {
|
|
91
85
|
cellRef.current.focus();
|
|
92
86
|
}
|
|
93
|
-
}, []);
|
|
94
|
-
// leave the focus handling as it was before, to avoid accidental regressions.
|
|
95
|
-
|
|
96
|
-
(0, _element.useEffect)(() => {
|
|
97
|
-
if (withExperimentalFeatures && isSelected) {
|
|
98
|
-
cellRef.current.focus();
|
|
99
|
-
}
|
|
100
|
-
}, [withExperimentalFeatures, isSelected]);
|
|
87
|
+
}, []);
|
|
101
88
|
const highlightBlock = withExperimentalPersistentListViewFeatures ? toggleBlockHighlight : () => {};
|
|
102
89
|
|
|
103
90
|
const onMouseEnter = () => {
|
|
@@ -184,30 +171,12 @@ function ListViewBlock({
|
|
|
184
171
|
icon: _icons.moreVertical,
|
|
185
172
|
toggleProps: {
|
|
186
173
|
ref,
|
|
174
|
+
className: 'block-editor-list-view-block__menu',
|
|
187
175
|
tabIndex,
|
|
188
176
|
onFocus
|
|
189
177
|
},
|
|
190
178
|
disableOpenOnArrowDown: true,
|
|
191
179
|
__experimentalSelectBlock: onClick
|
|
192
|
-
}
|
|
193
|
-
onClose
|
|
194
|
-
}) => (0, _element.createElement)(_components.MenuGroup, null, (0, _element.createElement)(_components.MenuItem, {
|
|
195
|
-
onClick: async () => {
|
|
196
|
-
if (blockParents.length) {
|
|
197
|
-
// If the block to select is inside a dropdown, we need to open the dropdown.
|
|
198
|
-
// Otherwise focus won't transfer to the block.
|
|
199
|
-
for (const parent of blockParents) {
|
|
200
|
-
await selectEditorBlock(parent);
|
|
201
|
-
}
|
|
202
|
-
} else {
|
|
203
|
-
// If clientId is already selected, it won't be focused (see block-wrapper.js)
|
|
204
|
-
// This removes the selection first to ensure the focus will always switch.
|
|
205
|
-
await selectEditorBlock(null);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
await selectEditorBlock(clientId);
|
|
209
|
-
onClose();
|
|
210
|
-
}
|
|
211
|
-
}, (0, _i18n.__)('Go to block'))))));
|
|
180
|
+
})));
|
|
212
181
|
}
|
|
213
182
|
//# sourceMappingURL=block.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block.js"],"names":["ListViewBlock","block","isSelected","isDragged","isBranchSelected","isLastOfSelectedBranch","onClick","onToggleExpanded","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","cellRef","isHovered","setIsHovered","clientId","blockParents","select","blockEditorStore","getBlockParents","selectBlock","selectEditorBlock","toggleBlockHighlight","hasSiblings","hasRenderedMovers","moverCellClassName","__experimentalFeatures","withExperimentalFeatures","__experimentalPersistentListViewFeatures","withExperimentalPersistentListViewFeatures","isTreeGridMounted","listViewBlockSettingsClassName","current","focus","highlightBlock","onMouseEnter","onMouseLeave","classes","undefined","ref","tabIndex","onFocus","moreVertical","onClose","length","parent"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAKA;;AAMA;;AACA;;AAEA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;AAWe,SAASA,aAAT,CAAwB;AACtCC,EAAAA,KADsC;AAEtCC,EAAAA,UAFsC;AAGtCC,EAAAA,SAHsC;AAItCC,EAAAA,gBAJsC;AAKtCC,EAAAA,sBALsC;AAMtCC,EAAAA,OANsC;AAOtCC,EAAAA,gBAPsC;AAQtCC,EAAAA,QARsC;AAStCC,EAAAA,KATsC;AAUtCC,EAAAA,QAVsC;AAWtCC,EAAAA,iBAXsC;AAYtCC,EAAAA,eAZsC;AAatCC,EAAAA,IAbsC;AActCC,EAAAA;AAdsC,CAAxB,EAeX;AACH,QAAMC,OAAO,GAAG,qBAAQ,IAAR,CAAhB;AACA,QAAM,CAAEC,SAAF,EAAa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Ha,KAHf;AAQC,IAAA,sBAAsB,MARvB;AASC,IAAA,yBAAyB,EAAGtC;AAT7B,KAWG,CAAE;AAAEwC,IAAAA;AAAF,GAAF,KACD,4BAAC,qBAAD,QACC,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAG,YAAY;AACrB,UAAK3B,YAAY,CAAC4B,MAAlB,EAA2B;AAC1B;AACA;AACA,aAAM,MAAMC,MAAZ,IAAsB7B,YAAtB,EAAqC;AACpC,gBAAMK,iBAAiB,CACtBwB,MADsB,CAAvB;AAGA;AACD,OARD,MAQO;AACN;AACA;AACA,cAAMxB,iBAAiB,CAAE,IAAF,CAAvB;AACA;;AACD,YAAMA,iBAAiB,CAAEN,QAAF,CAAvB;AACA4B,MAAAA,OAAO;AACP;AAjBF,KAmBG,cAAI,aAAJ,CAnBH,CADD,CAZF,CAFF,CArEF,CADD;AAkHA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n\tMenuGroup,\n\tMenuItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { moreVertical } from '@wordpress/icons';\nimport { useState, useRef, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport ListViewLeaf from './leaf';\nimport {\n\tBlockMoverUpButton,\n\tBlockMoverDownButton,\n} from '../block-mover/button';\nimport ListViewBlockContents from './block-contents';\nimport BlockSettingsDropdown from '../block-settings-menu/block-settings-dropdown';\nimport { useListViewContext } from './context';\nimport { store as blockEditorStore } from '../../store';\n\nexport default function ListViewBlock( {\n\tblock,\n\tisSelected,\n\tisDragged,\n\tisBranchSelected,\n\tisLastOfSelectedBranch,\n\tonClick,\n\tonToggleExpanded,\n\tposition,\n\tlevel,\n\trowCount,\n\tsiblingBlockCount,\n\tshowBlockMovers,\n\tpath,\n\tisExpanded,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst { clientId } = block;\n\tconst blockParents = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( blockEditorStore ).getBlockParents( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst {\n\t\tselectBlock: selectEditorBlock,\n\t\ttoggleBlockHighlight,\n\t} = useDispatch( blockEditorStore );\n\n\tconst hasSiblings = siblingBlockCount > 0;\n\tconst hasRenderedMovers = showBlockMovers && hasSiblings;\n\tconst moverCellClassName = classnames(\n\t\t'block-editor-list-view-block__mover-cell',\n\t\t{ 'is-visible': isHovered }\n\t);\n\tconst {\n\t\t__experimentalFeatures: withExperimentalFeatures,\n\t\t__experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,\n\t\tisTreeGridMounted,\n\t} = useListViewContext();\n\tconst listViewBlockSettingsClassName = classnames(\n\t\t'block-editor-list-view-block__menu-cell',\n\t\t{ 'is-visible': isHovered }\n\t);\n\n\t// If ListView has experimental features related to the Persistent List View,\n\t// only focus the selected list item on mount; otherwise the list would always\n\t// try to steal the focus from the editor canvas.\n\tuseEffect( () => {\n\t\tif (\n\t\t\twithExperimentalPersistentListViewFeatures &&\n\t\t\t! isTreeGridMounted &&\n\t\t\tisSelected\n\t\t) {\n\t\t\tcellRef.current.focus();\n\t\t}\n\t}, [] );\n\n\t// If ListView has experimental features (such as drag and drop) enabled,\n\t// leave the focus handling as it was before, to avoid accidental regressions.\n\tuseEffect( () => {\n\t\tif ( withExperimentalFeatures && isSelected ) {\n\t\t\tcellRef.current.focus();\n\t\t}\n\t}, [ withExperimentalFeatures, isSelected ] );\n\n\tconst highlightBlock = withExperimentalPersistentListViewFeatures\n\t\t? toggleBlockHighlight\n\t\t: () => {};\n\n\tconst onMouseEnter = () => {\n\t\tsetIsHovered( true );\n\t\thighlightBlock( clientId, true );\n\t};\n\tconst onMouseLeave = () => {\n\t\tsetIsHovered( false );\n\t\thighlightBlock( clientId, false );\n\t};\n\n\tconst classes = classnames( {\n\t\t'is-selected': isSelected,\n\t\t'is-branch-selected':\n\t\t\twithExperimentalPersistentListViewFeatures && isBranchSelected,\n\t\t'is-last-of-selected-branch':\n\t\t\twithExperimentalPersistentListViewFeatures &&\n\t\t\tisLastOfSelectedBranch,\n\t\t'is-dragging': isDragged,\n\t} );\n\n\treturn (\n\t\t<ListViewLeaf\n\t\t\tclassName={ classes }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onMouseEnter }\n\t\t\tonBlur={ onMouseLeave }\n\t\t\tlevel={ level }\n\t\t\tposition={ position }\n\t\t\trowCount={ rowCount }\n\t\t\tpath={ path }\n\t\t\tid={ `list-view-block-${ clientId }` }\n\t\t\tdata-block={ clientId }\n\t\t\tisExpanded={ isExpanded }\n\t\t>\n\t\t\t<TreeGridCell\n\t\t\t\tclassName=\"block-editor-list-view-block__contents-cell\"\n\t\t\t\tcolSpan={ hasRenderedMovers ? undefined : 2 }\n\t\t\t\tref={ cellRef }\n\t\t\t>\n\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t<div className=\"block-editor-list-view-block__contents-container\">\n\t\t\t\t\t\t<ListViewBlockContents\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\t\tonToggleExpanded={ onToggleExpanded }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</TreeGridCell>\n\t\t\t{ hasRenderedMovers && (\n\t\t\t\t<>\n\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\tclassName={ moverCellClassName }\n\t\t\t\t\t\twithoutGridItem\n\t\t\t\t\t>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ withExperimentalFeatures && (\n\t\t\t\t<TreeGridCell className={ listViewBlockSettingsClassName }>\n\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t<BlockSettingsDropdown\n\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\ttabIndex,\n\t\t\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tdisableOpenOnArrowDown\n\t\t\t\t\t\t\t__experimentalSelectBlock={ onClick }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\t\t\t\t\tif ( blockParents.length ) {\n\t\t\t\t\t\t\t\t\t\t\t\t// If the block to select is inside a dropdown, we need to open the dropdown.\n\t\t\t\t\t\t\t\t\t\t\t\t// Otherwise focus won't transfer to the block.\n\t\t\t\t\t\t\t\t\t\t\t\tfor ( const parent of blockParents ) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tawait selectEditorBlock(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tparent\n\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\t// If clientId is already selected, it won't be focused (see block-wrapper.js)\n\t\t\t\t\t\t\t\t\t\t\t\t// This removes the selection first to ensure the focus will always switch.\n\t\t\t\t\t\t\t\t\t\t\t\tawait selectEditorBlock( null );\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tawait selectEditorBlock( clientId );\n\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Go to block' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BlockSettingsDropdown>\n\t\t\t\t\t) }\n\t\t\t\t</TreeGridCell>\n\t\t\t) }\n\t\t</ListViewLeaf>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block.js"],"names":["ListViewBlock","block","isSelected","isDragged","isBranchSelected","isLastOfSelectedBranch","onClick","onToggleExpanded","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","cellRef","isHovered","setIsHovered","clientId","toggleBlockHighlight","blockEditorStore","hasSiblings","hasRenderedMovers","moverCellClassName","__experimentalFeatures","withExperimentalFeatures","__experimentalPersistentListViewFeatures","withExperimentalPersistentListViewFeatures","isTreeGridMounted","listViewBlockSettingsClassName","current","focus","highlightBlock","onMouseEnter","onMouseLeave","classes","undefined","ref","tabIndex","onFocus","moreVertical","className"],"mappings":";;;;;;;;;AAaA;;AAVA;;AAKA;;AAIA;;AAEA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AA3BA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;AAWe,SAASA,aAAT,CAAwB;AACtCC,EAAAA,KADsC;AAEtCC,EAAAA,UAFsC;AAGtCC,EAAAA,SAHsC;AAItCC,EAAAA,gBAJsC;AAKtCC,EAAAA,sBALsC;AAMtCC,EAAAA,OANsC;AAOtCC,EAAAA,gBAPsC;AAQtCC,EAAAA,QARsC;AAStCC,EAAAA,KATsC;AAUtCC,EAAAA,QAVsC;AAWtCC,EAAAA,iBAXsC;AAYtCC,EAAAA,eAZsC;AAatCC,EAAAA,IAbsC;AActCC,EAAAA;AAdsC,CAAxB,EAeX;AACH,QAAMC,OAAO,GAAG,qBAAQ,IAAR,CAAhB;AACA,QAAM,CAAEC,SAAF,EAAaC,YAAb,IAA8B,uBAAU,KAAV,CAApC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAejB,KAArB;AAEA,QAAM;AAAEkB,IAAAA;AAAF,MAA2B,uBAAaC,YAAb,CAAjC;AAEA,QAAMC,WAAW,GAAGV,iBAAiB,GAAG,CAAxC;AACA,QAAMW,iBAAiB,GAAGV,eAAe,IAAIS,WAA7C;AACA,QAAME,kBAAkB,GAAG,yBAC1B,0CAD0B,EAE1B;AAAE,kBA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C,IAAAA;AAAjB,GAAF,KACD,4BAAC,4BAAD;AACC,IAAA,WAAW,EAAC,UADb;AAEC,IAAA,SAAS,EAAG,CAAErB,QAAF,CAFb;AAGC,IAAA,GAAG,EAAGmB,GAHP;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,OAAO,EAAGC;AALX,IAFF,CAfD,CADD,CArCF,EAoEGd,wBAAwB,IACzB,4BAAC,sCAAD;AAAc,IAAA,SAAS,EAAGI;AAA1B,KACG,CAAE;AAAEQ,IAAAA,GAAF;AAAOC,IAAAA,QAAP;AAAiBC,IAAAA;AAAjB,GAAF,KACD,4BAAC,8BAAD;AACC,IAAA,SAAS,EAAG,CAAErB,QAAF,CADb;AAEC,IAAA,IAAI,EAAGsB,mBAFR;AAGC,IAAA,WAAW,EAAG;AACbH,MAAAA,GADa;AAEbI,MAAAA,SAAS,EAAE,oCAFE;AAGbH,MAAAA,QAHa;AAIbC,MAAAA;AAJa,KAHf;AASC,IAAA,sBAAsB,MATvB;AAUC,IAAA,yBAAyB,EAAGjC;AAV7B,IAFF,CArEF,CADD;AAyFA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { useState, useRef, useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport ListViewLeaf from './leaf';\nimport {\n\tBlockMoverUpButton,\n\tBlockMoverDownButton,\n} from '../block-mover/button';\nimport ListViewBlockContents from './block-contents';\nimport BlockSettingsDropdown from '../block-settings-menu/block-settings-dropdown';\nimport { useListViewContext } from './context';\nimport { store as blockEditorStore } from '../../store';\n\nexport default function ListViewBlock( {\n\tblock,\n\tisSelected,\n\tisDragged,\n\tisBranchSelected,\n\tisLastOfSelectedBranch,\n\tonClick,\n\tonToggleExpanded,\n\tposition,\n\tlevel,\n\trowCount,\n\tsiblingBlockCount,\n\tshowBlockMovers,\n\tpath,\n\tisExpanded,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst { clientId } = block;\n\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\n\n\tconst hasSiblings = siblingBlockCount > 0;\n\tconst hasRenderedMovers = showBlockMovers && hasSiblings;\n\tconst moverCellClassName = classnames(\n\t\t'block-editor-list-view-block__mover-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\n\t);\n\tconst {\n\t\t__experimentalFeatures: withExperimentalFeatures,\n\t\t__experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,\n\t\tisTreeGridMounted,\n\t} = useListViewContext();\n\tconst listViewBlockSettingsClassName = classnames(\n\t\t'block-editor-list-view-block__menu-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\n\t);\n\n\t// If ListView has experimental features related to the Persistent List View,\n\t// only focus the selected list item on mount; otherwise the list would always\n\t// try to steal the focus from the editor canvas.\n\tuseEffect( () => {\n\t\tif (\n\t\t\twithExperimentalPersistentListViewFeatures &&\n\t\t\t! isTreeGridMounted &&\n\t\t\tisSelected\n\t\t) {\n\t\t\tcellRef.current.focus();\n\t\t}\n\t}, [] );\n\n\tconst highlightBlock = withExperimentalPersistentListViewFeatures\n\t\t? toggleBlockHighlight\n\t\t: () => {};\n\n\tconst onMouseEnter = () => {\n\t\tsetIsHovered( true );\n\t\thighlightBlock( clientId, true );\n\t};\n\tconst onMouseLeave = () => {\n\t\tsetIsHovered( false );\n\t\thighlightBlock( clientId, false );\n\t};\n\n\tconst classes = classnames( {\n\t\t'is-selected': isSelected,\n\t\t'is-branch-selected':\n\t\t\twithExperimentalPersistentListViewFeatures && isBranchSelected,\n\t\t'is-last-of-selected-branch':\n\t\t\twithExperimentalPersistentListViewFeatures &&\n\t\t\tisLastOfSelectedBranch,\n\t\t'is-dragging': isDragged,\n\t} );\n\n\treturn (\n\t\t<ListViewLeaf\n\t\t\tclassName={ classes }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onMouseEnter }\n\t\t\tonBlur={ onMouseLeave }\n\t\t\tlevel={ level }\n\t\t\tposition={ position }\n\t\t\trowCount={ rowCount }\n\t\t\tpath={ path }\n\t\t\tid={ `list-view-block-${ clientId }` }\n\t\t\tdata-block={ clientId }\n\t\t\tisExpanded={ isExpanded }\n\t\t>\n\t\t\t<TreeGridCell\n\t\t\t\tclassName=\"block-editor-list-view-block__contents-cell\"\n\t\t\t\tcolSpan={ hasRenderedMovers ? undefined : 2 }\n\t\t\t\tref={ cellRef }\n\t\t\t>\n\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t<div className=\"block-editor-list-view-block__contents-container\">\n\t\t\t\t\t\t<ListViewBlockContents\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\t\tonToggleExpanded={ onToggleExpanded }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</TreeGridCell>\n\t\t\t{ hasRenderedMovers && (\n\t\t\t\t<>\n\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\tclassName={ moverCellClassName }\n\t\t\t\t\t\twithoutGridItem\n\t\t\t\t\t>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ withExperimentalFeatures && (\n\t\t\t\t<TreeGridCell className={ listViewBlockSettingsClassName }>\n\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t<BlockSettingsDropdown\n\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\tclassName: 'block-editor-list-view-block__menu',\n\t\t\t\t\t\t\t\ttabIndex,\n\t\t\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tdisableOpenOnArrowDown\n\t\t\t\t\t\t\t__experimentalSelectBlock={ onClick }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TreeGridCell>\n\t\t\t) }\n\t\t</ListViewLeaf>\n\t);\n}\n"]}
|
|
@@ -38,6 +38,7 @@ function ListViewListItem({
|
|
|
38
38
|
children
|
|
39
39
|
}) {
|
|
40
40
|
const blockType = (0, _blocks.getBlockType)(block.name);
|
|
41
|
+
const blockLabel = blockType ? (0, _blocks.__experimentalGetBlockLabel)(blockType, block.attributes) : null;
|
|
41
42
|
return (0, _element.createElement)("div", {
|
|
42
43
|
className: "block-editor-list-view__list-item"
|
|
43
44
|
}, (0, _element.createElement)(WrapperComponent, {
|
|
@@ -46,9 +47,9 @@ function ListViewListItem({
|
|
|
46
47
|
}),
|
|
47
48
|
onClick: onClick
|
|
48
49
|
}, (0, _element.createElement)(_blockIcon.default, {
|
|
49
|
-
icon: blockType.icon,
|
|
50
|
+
icon: blockType === null || blockType === void 0 ? void 0 : blockType.icon,
|
|
50
51
|
showColors: true
|
|
51
|
-
}), children ? children :
|
|
52
|
+
}), children ? children : blockLabel, isSelected && (0, _element.createElement)(_components.VisuallyHidden, {
|
|
52
53
|
as: "span"
|
|
53
54
|
}, (0, _i18n.__)('(selected block)'))));
|
|
54
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/list-item.js"],"names":["ListViewListItem","block","onClick","isSelected","wrapperComponent","WrapperComponent","children","blockType","name","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/list-item.js"],"names":["ListViewListItem","block","onClick","isSelected","wrapperComponent","WrapperComponent","children","blockType","name","blockLabel","attributes","icon","defaultProps","props"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAIA;;AAKA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AAGe,SAASA,gBAAT,CAA2B;AACzCC,EAAAA,KADyC;AAEzCC,EAAAA,OAFyC;AAGzCC,EAAAA,UAHyC;AAIzCC,EAAAA,gBAAgB,EAAEC,gBAJuB;AAKzCC,EAAAA;AALyC,CAA3B,EAMX;AACH,QAAMC,SAAS,GAAG,0BAAcN,KAAK,CAACO,IAApB,CAAlB;AACA,QAAMC,UAAU,GAAGF,SAAS,GACzB,yCAAeA,SAAf,EAA0BN,KAAK,CAACS,UAAhC,CADyB,GAEzB,IAFH;AAIA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAG,yBACX,0CADW,EAEX;AACC,qBAAeP;AADhB,KAFW,CADb;AAOC,IAAA,OAAO,EAAGD;AAPX,KASC,4BAAC,kBAAD;AAAW,IAAA,IAAI,EAAGK,SAAH,aAAGA,SAAH,uBAAGA,SAAS,CAAEI,IAA7B;AAAoC,IAAA,UAAU;AAA9C,IATD,EAUGL,QAAQ,GAAGA,QAAH,GAAcG,UAVzB,EAWGN,UAAU,IACX,4BAAC,0BAAD;AAAgB,IAAA,EAAE,EAAC;AAAnB,KACG,cAAI,kBAAJ,CADH,CAZF,CADD,CADD;AAqBA;;AAEDH,gBAAgB,CAACY,YAAjB,GAAgC;AAC/BV,EAAAA,OAAO,EAAE,MAAM,CAAE,CADc;AAE/BE,EAAAA,gBAAgB,EAAIS,KAAF,IAAa,4BAAC,kBAAD,EAAaA,KAAb;AAFA,CAAhC","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, VisuallyHidden } from '@wordpress/components';\nimport {\n\t__experimentalGetBlockLabel as getBlockLabel,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\n\nexport default function ListViewListItem( {\n\tblock,\n\tonClick,\n\tisSelected,\n\twrapperComponent: WrapperComponent,\n\tchildren,\n} ) {\n\tconst blockType = getBlockType( block.name );\n\tconst blockLabel = blockType\n\t\t? getBlockLabel( blockType, block.attributes )\n\t\t: null;\n\n\treturn (\n\t\t<div className=\"block-editor-list-view__list-item\">\n\t\t\t<WrapperComponent\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view__list-item-button',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-selected': isSelected,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\tonClick={ onClick }\n\t\t\t>\n\t\t\t\t<BlockIcon icon={ blockType?.icon } showColors />\n\t\t\t\t{ children ? children : blockLabel }\n\t\t\t\t{ isSelected && (\n\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t{ __( '(selected block)' ) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t</WrapperComponent>\n\t\t</div>\n\t);\n}\n\nListViewListItem.defaultProps = {\n\tonClick: () => {},\n\twrapperComponent: ( props ) => <Button { ...props } />,\n};\n"]}
|
|
@@ -90,7 +90,10 @@ function MediaPlaceholder({
|
|
|
90
90
|
onDoubleClick,
|
|
91
91
|
onFilesPreUpload = _lodash.noop,
|
|
92
92
|
onHTMLDrop = _lodash.noop,
|
|
93
|
-
children
|
|
93
|
+
children,
|
|
94
|
+
mediaLibraryButton,
|
|
95
|
+
placeholder,
|
|
96
|
+
style
|
|
94
97
|
}) {
|
|
95
98
|
const mediaUpload = (0, _data.useSelect)(select => {
|
|
96
99
|
const {
|
|
@@ -202,7 +205,7 @@ function MediaPlaceholder({
|
|
|
202
205
|
onFilesUpload(event.target.files);
|
|
203
206
|
};
|
|
204
207
|
|
|
205
|
-
const
|
|
208
|
+
const defaultRenderPlaceholder = content => {
|
|
206
209
|
let {
|
|
207
210
|
instructions,
|
|
208
211
|
title
|
|
@@ -255,10 +258,13 @@ function MediaPlaceholder({
|
|
|
255
258
|
className: placeholderClassName,
|
|
256
259
|
notices: notices,
|
|
257
260
|
onDoubleClick: onDoubleClick,
|
|
258
|
-
preview: mediaPreview
|
|
261
|
+
preview: mediaPreview,
|
|
262
|
+
style: style
|
|
259
263
|
}, content, children);
|
|
260
264
|
};
|
|
261
265
|
|
|
266
|
+
const renderPlaceholder = placeholder !== null && placeholder !== void 0 ? placeholder : defaultRenderPlaceholder;
|
|
267
|
+
|
|
262
268
|
const renderDropZone = () => {
|
|
263
269
|
if (disableDropZone) {
|
|
264
270
|
return null;
|
|
@@ -296,7 +302,19 @@ function MediaPlaceholder({
|
|
|
296
302
|
};
|
|
297
303
|
|
|
298
304
|
const renderMediaUploadChecked = () => {
|
|
299
|
-
const
|
|
305
|
+
const defaultButton = ({
|
|
306
|
+
open
|
|
307
|
+
}) => {
|
|
308
|
+
return (0, _element.createElement)(_components.Button, {
|
|
309
|
+
variant: "tertiary",
|
|
310
|
+
onClick: () => {
|
|
311
|
+
open();
|
|
312
|
+
}
|
|
313
|
+
}, (0, _i18n.__)('Media Library'));
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const libraryButton = mediaLibraryButton !== null && mediaLibraryButton !== void 0 ? mediaLibraryButton : defaultButton;
|
|
317
|
+
const uploadMediaLibraryButton = (0, _element.createElement)(_mediaUpload.default, {
|
|
300
318
|
addToGallery: addToGallery,
|
|
301
319
|
gallery: multiple && onlyAllowsImages(),
|
|
302
320
|
multiple: multiple,
|
|
@@ -305,16 +323,7 @@ function MediaPlaceholder({
|
|
|
305
323
|
value: Array.isArray(value) ? value.map(({
|
|
306
324
|
id
|
|
307
325
|
}) => id) : value.id,
|
|
308
|
-
render:
|
|
309
|
-
open
|
|
310
|
-
}) => {
|
|
311
|
-
return (0, _element.createElement)(_components.Button, {
|
|
312
|
-
variant: "tertiary",
|
|
313
|
-
onClick: () => {
|
|
314
|
-
open();
|
|
315
|
-
}
|
|
316
|
-
}, (0, _i18n.__)('Media Library'));
|
|
317
|
-
}
|
|
326
|
+
render: libraryButton
|
|
318
327
|
});
|
|
319
328
|
|
|
320
329
|
if (mediaUpload && isAppender) {
|
|
@@ -329,7 +338,7 @@ function MediaPlaceholder({
|
|
|
329
338
|
variant: "primary",
|
|
330
339
|
className: (0, _classnames.default)('block-editor-media-placeholder__button', 'block-editor-media-placeholder__upload-button'),
|
|
331
340
|
onClick: openFileDialog
|
|
332
|
-
}, (0, _i18n.__)('Upload')),
|
|
341
|
+
}, (0, _i18n.__)('Upload')), uploadMediaLibraryButton, renderUrlSelectionUI(), renderCancelLink());
|
|
333
342
|
return renderPlaceholder(content);
|
|
334
343
|
}
|
|
335
344
|
}));
|
|
@@ -342,11 +351,11 @@ function MediaPlaceholder({
|
|
|
342
351
|
onChange: onUpload,
|
|
343
352
|
accept: accept,
|
|
344
353
|
multiple: multiple
|
|
345
|
-
}, (0, _i18n.__)('Upload')),
|
|
354
|
+
}, (0, _i18n.__)('Upload')), uploadMediaLibraryButton, renderUrlSelectionUI(), renderCancelLink());
|
|
346
355
|
return renderPlaceholder(content);
|
|
347
356
|
}
|
|
348
357
|
|
|
349
|
-
return renderPlaceholder(
|
|
358
|
+
return renderPlaceholder(uploadMediaLibraryButton);
|
|
350
359
|
};
|
|
351
360
|
|
|
352
361
|
if (dropZoneUIOnly || disableMediaButtons) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/media-placeholder/index.js"],"names":["InsertFromURLPopover","src","onChange","onSubmit","onClose","keyboardReturn","MediaPlaceholder","value","allowedTypes","className","icon","labels","mediaPreview","notices","isAppender","accept","addToGallery","multiple","handleUpload","dropZoneUIOnly","disableDropZone","disableMediaButtons","onError","onSelect","onCancel","onSelectURL","onDoubleClick","onFilesPreUpload","noop","onHTMLDrop","children","mediaUpload","select","getSettings","blockEditorStore","setSrc","isURLInputVisible","setIsURLInputVisible","onlyAllowsImages","length","every","allowedType","startsWith","onChangeSrc","event","target","openURLInput","closeURLInput","onSubmitSrc","preventDefault","onFilesUpload","files","setMedia","lastMediaPassed","newMedia","filteredMedia","filter","item","id","some","Number","urlSlug","url","includes","concat","map","media","cutOffIndex","lastIndexOf","slice","filesList","onFileChange","onUpload","renderPlaceholder","content","instructions","title","undefined","typesAllowed","firstAllowedType","isOneType","isAudio","isImage","isVideo","placeholderClassName","renderDropZone","renderCancelLink","renderUrlSelectionUI","renderMediaU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MAAM,EAAGzD,MAPV;AAQC,QAAA,QAAQ,EAAGE;AARZ,SAUG,cAAI,QAAJ,CAVH,CAFD,EAcGwE,kBAdH,EAeGF,oBAAoB,EAfvB,EAgBGD,gBAAgB,EAhBnB,CADD;AAoBA,aAAOb,iBAAiB,CAAEC,OAAF,CAAxB;AACA;;AAED,WAAOD,iBAAiB,CAAEgB,kBAAF,CAAxB;AACA,GAtFD;;AAwFA,MAAKtE,cAAc,IAAIE,mBAAvB,EAA6C;AAC5C,QAAKF,cAAL,EAAsB;AACrB,+BAAY,qDAAZ,EAAmE;AAClE2E,QAAAA,KAAK,EAAE,KAD2D;AAElEC,QAAAA,WAAW,EAAE;AAFqD,OAAnE;AAIA;;AAED,WAAO,4BAAC,cAAD,QAAoBV,cAAc,EAAlC,CAAP;AACA;;AAED,SACC,4BAAC,cAAD;AACC,IAAA,QAAQ,EAAGZ,iBAAiB,CAAEc,oBAAoB,EAAtB;AAD7B,KAGGC,wBAAwB,EAH3B,CADD;AAOA;AAED;AACA;AACA;;;eACe,6BAAa,yBAAb,EAA0ClF,gBAA1C,C","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tFormFileUpload,\n\tPlaceholder,\n\tDropZone,\n\twithFilters,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { keyboardReturn } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport URLPopover from '../url-popover';\nimport { store as blockEditorStore } from '../../store';\n\nconst InsertFromURLPopover = ( { src, onChange, onSubmit, onClose } ) => (\n\t<URLPopover onClose={ onClose }>\n\t\t<form\n\t\t\tclassName=\"block-editor-media-placeholder__url-input-form\"\n\t\t\tonSubmit={ onSubmit }\n\t\t>\n\t\t\t<input\n\t\t\t\tclassName=\"block-editor-media-placeholder__url-input-field\"\n\t\t\t\ttype=\"text\"\n\t\t\t\taria-label={ __( 'URL' ) }\n\t\t\t\tplaceholder={ __( 'Paste or type URL' ) }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ src }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tclassName=\"block-editor-media-placeholder__url-input-submit-button\"\n\t\t\t\ticon={ keyboardReturn }\n\t\t\t\tlabel={ __( 'Apply' ) }\n\t\t\t\ttype=\"submit\"\n\t\t\t/>\n\t\t</form>\n\t</URLPopover>\n);\n\nexport function MediaPlaceholder( {\n\tvalue = {},\n\tallowedTypes,\n\tclassName,\n\ticon,\n\tlabels = {},\n\tmediaPreview,\n\tnotices,\n\tisAppender,\n\taccept,\n\taddToGallery,\n\tmultiple = false,\n\thandleUpload = true,\n\tdropZoneUIOnly,\n\tdisableDropZone,\n\tdisableMediaButtons,\n\tonError,\n\tonSelect,\n\tonCancel,\n\tonSelectURL,\n\tonDoubleClick,\n\tonFilesPreUpload = noop,\n\tonHTMLDrop = noop,\n\tchildren,\n} ) {\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().mediaUpload;\n\t}, [] );\n\tconst [ src, setSrc ] = useState( '' );\n\tconst [ isURLInputVisible, setIsURLInputVisible ] = useState( false );\n\n\tuseEffect( () => {\n\t\tsetSrc( value?.src ?? '' );\n\t}, [ value?.src ] );\n\n\tconst onlyAllowsImages = () => {\n\t\tif ( ! allowedTypes || allowedTypes.length === 0 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn allowedTypes.every(\n\t\t\t( allowedType ) =>\n\t\t\t\tallowedType === 'image' || allowedType.startsWith( 'image/' )\n\t\t);\n\t};\n\n\tconst onChangeSrc = ( event ) => {\n\t\tsetSrc( event.target.value );\n\t};\n\n\tconst openURLInput = () => {\n\t\tsetIsURLInputVisible( true );\n\t};\n\tconst closeURLInput = () => {\n\t\tsetIsURLInputVisible( false );\n\t};\n\n\tconst onSubmitSrc = ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( src && onSelectURL ) {\n\t\t\tonSelectURL( src );\n\t\t\tcloseURLInput();\n\t\t}\n\t};\n\n\tconst onFilesUpload = ( files ) => {\n\t\tif ( ! handleUpload ) {\n\t\t\treturn onSelect( files );\n\t\t}\n\t\tonFilesPreUpload( files );\n\t\tlet setMedia;\n\t\tif ( multiple ) {\n\t\t\tif ( addToGallery ) {\n\t\t\t\t// Since the setMedia function runs multiple times per upload group\n\t\t\t\t// and is passed newMedia containing every item in its group each time, we must\n\t\t\t\t// filter out whatever this upload group had previously returned to the\n\t\t\t\t// gallery before adding and returning the image array with replacement newMedia\n\t\t\t\t// values.\n\n\t\t\t\t// Define an array to store urls from newMedia between subsequent function calls.\n\t\t\t\tlet lastMediaPassed = [];\n\t\t\t\tsetMedia = ( newMedia ) => {\n\t\t\t\t\t// Remove any images this upload group is responsible for (lastMediaPassed).\n\t\t\t\t\t// Their replacements are contained in newMedia.\n\t\t\t\t\tconst filteredMedia = ( value ?? [] ).filter( ( item ) => {\n\t\t\t\t\t\t// If Item has id, only remove it if lastMediaPassed has an item with that id.\n\t\t\t\t\t\tif ( item.id ) {\n\t\t\t\t\t\t\treturn ! lastMediaPassed.some(\n\t\t\t\t\t\t\t\t// Be sure to convert to number for comparison.\n\t\t\t\t\t\t\t\t( { id } ) => Number( id ) === Number( item.id )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Compare transient images via .includes since gallery may append extra info onto the url.\n\t\t\t\t\t\treturn ! lastMediaPassed.some( ( { urlSlug } ) =>\n\t\t\t\t\t\t\titem.url.includes( urlSlug )\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\t\t\t\t\t// Return the filtered media array along with newMedia.\n\t\t\t\t\tonSelect( filteredMedia.concat( newMedia ) );\n\t\t\t\t\t// Reset lastMediaPassed and set it with ids and urls from newMedia.\n\t\t\t\t\tlastMediaPassed = newMedia.map( ( media ) => {\n\t\t\t\t\t\t// Add everything up to '.fileType' to compare via .includes.\n\t\t\t\t\t\tconst cutOffIndex = media.url.lastIndexOf( '.' );\n\t\t\t\t\t\tconst urlSlug = media.url.slice( 0, cutOffIndex );\n\t\t\t\t\t\treturn { id: media.id, urlSlug };\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tsetMedia = onSelect;\n\t\t\t}\n\t\t} else {\n\t\t\tsetMedia = ( [ media ] ) => onSelect( media );\n\t\t}\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: setMedia,\n\t\t\tonError,\n\t\t} );\n\t};\n\n\tconst onUpload = ( event ) => {\n\t\tonFilesUpload( event.target.files );\n\t};\n\n\tconst renderPlaceholder = ( content ) => {\n\t\tlet { instructions, title } = labels;\n\n\t\tif ( ! mediaUpload && ! onSelectURL ) {\n\t\t\tinstructions = __(\n\t\t\t\t'To edit this block, you need permission to upload media.'\n\t\t\t);\n\t\t}\n\n\t\tif ( instructions === undefined || title === undefined ) {\n\t\t\tconst typesAllowed = allowedTypes ?? [];\n\n\t\t\tconst [ firstAllowedType ] = typesAllowed;\n\t\t\tconst isOneType = 1 === typesAllowed.length;\n\t\t\tconst isAudio = isOneType && 'audio' === firstAllowedType;\n\t\t\tconst isImage = isOneType && 'image' === firstAllowedType;\n\t\t\tconst isVideo = isOneType && 'video' === firstAllowedType;\n\n\t\t\tif ( instructions === undefined && mediaUpload ) {\n\t\t\t\tinstructions = __(\n\t\t\t\t\t'Upload a media file or pick one from your media library.'\n\t\t\t\t);\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload an audio file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload an image file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload a video file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( title === undefined ) {\n\t\t\t\ttitle = __( 'Media' );\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\ttitle = __( 'Audio' );\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\ttitle = __( 'Image' );\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\ttitle = __( 'Video' );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst placeholderClassName = classnames(\n\t\t\t'block-editor-media-placeholder',\n\t\t\tclassName,\n\t\t\t{\n\t\t\t\t'is-appender': isAppender,\n\t\t\t}\n\t\t);\n\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ title }\n\t\t\t\tinstructions={ instructions }\n\t\t\t\tclassName={ placeholderClassName }\n\t\t\t\tnotices={ notices }\n\t\t\t\tonDoubleClick={ onDoubleClick }\n\t\t\t\tpreview={ mediaPreview }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t\t{ children }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst renderDropZone = () => {\n\t\tif ( disableDropZone ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<DropZone onFilesDrop={ onFilesUpload } onHTMLDrop={ onHTMLDrop } />\n\t\t);\n\t};\n\n\tconst renderCancelLink = () => {\n\t\treturn (\n\t\t\tonCancel && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"block-editor-media-placeholder__cancel-button\"\n\t\t\t\t\ttitle={ __( 'Cancel' ) }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\tonClick={ onCancel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</Button>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderUrlSelectionUI = () => {\n\t\treturn (\n\t\t\tonSelectURL && (\n\t\t\t\t<div className=\"block-editor-media-placeholder__url-input-container\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-media-placeholder__button\"\n\t\t\t\t\t\tonClick={ openURLInput }\n\t\t\t\t\t\tisPressed={ isURLInputVisible }\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Insert from URL' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t{ isURLInputVisible && (\n\t\t\t\t\t\t<InsertFromURLPopover\n\t\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\t\tonChange={ onChangeSrc }\n\t\t\t\t\t\t\tonSubmit={ onSubmitSrc }\n\t\t\t\t\t\t\tonClose={ closeURLInput }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderMediaUploadChecked = () => {\n\t\tconst mediaLibraryButton = (\n\t\t\t<MediaUpload\n\t\t\t\taddToGallery={ addToGallery }\n\t\t\t\tgallery={ multiple && onlyAllowsImages() }\n\t\t\t\tmultiple={ multiple }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\tvalue={\n\t\t\t\t\tArray.isArray( value )\n\t\t\t\t\t\t? value.map( ( { id } ) => id )\n\t\t\t\t\t\t: value.id\n\t\t\t\t}\n\t\t\t\trender={ ( { open } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Media Library' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\n\t\tif ( mediaUpload && isAppender ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\tconst content = (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tonClick={ openFileDialog }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t{ mediaLibraryButton }\n\t\t\t\t\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn renderPlaceholder( content );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\tif ( mediaUpload ) {\n\t\t\tconst content = (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t</FormFileUpload>\n\t\t\t\t\t{ mediaLibraryButton }\n\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t</>\n\t\t\t);\n\t\t\treturn renderPlaceholder( content );\n\t\t}\n\n\t\treturn renderPlaceholder( mediaLibraryButton );\n\t};\n\n\tif ( dropZoneUIOnly || disableMediaButtons ) {\n\t\tif ( dropZoneUIOnly ) {\n\t\t\tdeprecated( 'wp.blockEditor.MediaPlaceholder dropZoneUIOnly prop', {\n\t\t\t\tsince: '5.4',\n\t\t\t\talternative: 'disableMediaButtons',\n\t\t\t} );\n\t\t}\n\n\t\treturn <MediaUploadCheck>{ renderDropZone() }</MediaUploadCheck>;\n\t}\n\n\treturn (\n\t\t<MediaUploadCheck\n\t\t\tfallback={ renderPlaceholder( renderUrlSelectionUI() ) }\n\t\t>\n\t\t\t{ renderMediaUploadChecked() }\n\t\t</MediaUploadCheck>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-placeholder/README.md\n */\nexport default withFilters( 'editor.MediaPlaceholder' )( MediaPlaceholder );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/media-placeholder/index.js"],"names":["InsertFromURLPopover","src","onChange","onSubmit","onClose","keyboardReturn","MediaPlaceholder","value","allowedTypes","className","icon","labels","mediaPreview","notices","isAppender","accept","addToGallery","multiple","handleUpload","dropZoneUIOnly","disableDropZone","disableMediaButtons","onError","onSelect","onCancel","onSelectURL","onDoubleClick","onFilesPreUpload","noop","onHTMLDrop","children","mediaLibraryButton","placeholder","style","mediaUpload","select","getSettings","blockEditorStore","setSrc","isURLInputVisible","setIsURLInputVisible","onlyAllowsImages","length","every","allowedType","startsWith","onChangeSrc","event","target","openURLInput","closeURLInput","onSubmitSrc","preventDefault","onFilesUpload","files","setMedia","lastMediaPassed","newMedia","filteredMedia","filter","item","id","some","Number","urlSlug","url","includes","concat","map","media","cutOffIndex","lastIndexOf","slice","filesList","onFileChange","onUpload","defaultRenderPlaceholder","content","instructions","title","undefined","typesAllowed","firstAllowedType","isOneType","isAudio","isImage","isVideo","placeholderClassName","renderPlaceholder","renderDropZone","renderCancelLink","renderUrlSelectionUI","renderMediaUploadChecked","defaultButton","open","libraryButton","uploadMediaLibraryButton","Array","isArray","openFileDialog","since","alternative"],"mappings":";;;;;;;;;;AAiBA;;AAdA;;AACA;;AAKA;;AAOA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA5BA;AACA;AACA;;AAIA;AACA;AACA;;AAcA;AACA;AACA;AAMA,MAAMA,oBAAoB,GAAG,CAAE;AAAEC,EAAAA,GAAF;AAAOC,EAAAA,QAAP;AAAiBC,EAAAA,QAAjB;AAA2BC,EAAAA;AAA3B,CAAF,KAC5B,4BAAC,mBAAD;AAAY,EAAA,OAAO,EAAGA;AAAtB,GACC;AACC,EAAA,SAAS,EAAC,gDADX;AAEC,EAAA,QAAQ,EAAGD;AAFZ,GAIC;AACC,EAAA,SAAS,EAAC,iDADX;AAEC,EAAA,IAAI,EAAC,MAFN;AAGC,gBAAa,cAAI,KAAJ,CAHd;AAIC,EAAA,WAAW,EAAG,cAAI,mBAAJ,CAJf;AAKC,EAAA,QAAQ,EAAGD,QALZ;AAMC,EAAA,KAAK,EAAGD;AANT,EAJD,EAYC,4BAAC,kBAAD;AACC,EAAA,SAAS,EAAC,yDADX;AAEC,EAAA,IAAI,EAAGI,qBAFR;AAGC,EAAA,KAAK,EAAG,cAAI,OAAJ,CAHT;AAIC,EAAA,IAAI,EAAC;AAJN,EAZD,CADD,CADD;;AAwBO,SAASC,gBAAT,CAA2B;AACjCC,EAAAA,KAAK,GAAG,EADyB;AAEjCC,EAAAA,YAFiC;AAGjCC,EAAAA,SAHiC;AAIjCC,EA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,6BAAa,yBAAb,EAA0CtF,gBAA1C,C","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tFormFileUpload,\n\tPlaceholder,\n\tDropZone,\n\twithFilters,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { keyboardReturn } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport URLPopover from '../url-popover';\nimport { store as blockEditorStore } from '../../store';\n\nconst InsertFromURLPopover = ( { src, onChange, onSubmit, onClose } ) => (\n\t<URLPopover onClose={ onClose }>\n\t\t<form\n\t\t\tclassName=\"block-editor-media-placeholder__url-input-form\"\n\t\t\tonSubmit={ onSubmit }\n\t\t>\n\t\t\t<input\n\t\t\t\tclassName=\"block-editor-media-placeholder__url-input-field\"\n\t\t\t\ttype=\"text\"\n\t\t\t\taria-label={ __( 'URL' ) }\n\t\t\t\tplaceholder={ __( 'Paste or type URL' ) }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ src }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tclassName=\"block-editor-media-placeholder__url-input-submit-button\"\n\t\t\t\ticon={ keyboardReturn }\n\t\t\t\tlabel={ __( 'Apply' ) }\n\t\t\t\ttype=\"submit\"\n\t\t\t/>\n\t\t</form>\n\t</URLPopover>\n);\n\nexport function MediaPlaceholder( {\n\tvalue = {},\n\tallowedTypes,\n\tclassName,\n\ticon,\n\tlabels = {},\n\tmediaPreview,\n\tnotices,\n\tisAppender,\n\taccept,\n\taddToGallery,\n\tmultiple = false,\n\thandleUpload = true,\n\tdropZoneUIOnly,\n\tdisableDropZone,\n\tdisableMediaButtons,\n\tonError,\n\tonSelect,\n\tonCancel,\n\tonSelectURL,\n\tonDoubleClick,\n\tonFilesPreUpload = noop,\n\tonHTMLDrop = noop,\n\tchildren,\n\tmediaLibraryButton,\n\tplaceholder,\n\tstyle,\n} ) {\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().mediaUpload;\n\t}, [] );\n\tconst [ src, setSrc ] = useState( '' );\n\tconst [ isURLInputVisible, setIsURLInputVisible ] = useState( false );\n\n\tuseEffect( () => {\n\t\tsetSrc( value?.src ?? '' );\n\t}, [ value?.src ] );\n\n\tconst onlyAllowsImages = () => {\n\t\tif ( ! allowedTypes || allowedTypes.length === 0 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn allowedTypes.every(\n\t\t\t( allowedType ) =>\n\t\t\t\tallowedType === 'image' || allowedType.startsWith( 'image/' )\n\t\t);\n\t};\n\n\tconst onChangeSrc = ( event ) => {\n\t\tsetSrc( event.target.value );\n\t};\n\n\tconst openURLInput = () => {\n\t\tsetIsURLInputVisible( true );\n\t};\n\tconst closeURLInput = () => {\n\t\tsetIsURLInputVisible( false );\n\t};\n\n\tconst onSubmitSrc = ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( src && onSelectURL ) {\n\t\t\tonSelectURL( src );\n\t\t\tcloseURLInput();\n\t\t}\n\t};\n\n\tconst onFilesUpload = ( files ) => {\n\t\tif ( ! handleUpload ) {\n\t\t\treturn onSelect( files );\n\t\t}\n\t\tonFilesPreUpload( files );\n\t\tlet setMedia;\n\t\tif ( multiple ) {\n\t\t\tif ( addToGallery ) {\n\t\t\t\t// Since the setMedia function runs multiple times per upload group\n\t\t\t\t// and is passed newMedia containing every item in its group each time, we must\n\t\t\t\t// filter out whatever this upload group had previously returned to the\n\t\t\t\t// gallery before adding and returning the image array with replacement newMedia\n\t\t\t\t// values.\n\n\t\t\t\t// Define an array to store urls from newMedia between subsequent function calls.\n\t\t\t\tlet lastMediaPassed = [];\n\t\t\t\tsetMedia = ( newMedia ) => {\n\t\t\t\t\t// Remove any images this upload group is responsible for (lastMediaPassed).\n\t\t\t\t\t// Their replacements are contained in newMedia.\n\t\t\t\t\tconst filteredMedia = ( value ?? [] ).filter( ( item ) => {\n\t\t\t\t\t\t// If Item has id, only remove it if lastMediaPassed has an item with that id.\n\t\t\t\t\t\tif ( item.id ) {\n\t\t\t\t\t\t\treturn ! lastMediaPassed.some(\n\t\t\t\t\t\t\t\t// Be sure to convert to number for comparison.\n\t\t\t\t\t\t\t\t( { id } ) => Number( id ) === Number( item.id )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Compare transient images via .includes since gallery may append extra info onto the url.\n\t\t\t\t\t\treturn ! lastMediaPassed.some( ( { urlSlug } ) =>\n\t\t\t\t\t\t\titem.url.includes( urlSlug )\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\t\t\t\t\t// Return the filtered media array along with newMedia.\n\t\t\t\t\tonSelect( filteredMedia.concat( newMedia ) );\n\t\t\t\t\t// Reset lastMediaPassed and set it with ids and urls from newMedia.\n\t\t\t\t\tlastMediaPassed = newMedia.map( ( media ) => {\n\t\t\t\t\t\t// Add everything up to '.fileType' to compare via .includes.\n\t\t\t\t\t\tconst cutOffIndex = media.url.lastIndexOf( '.' );\n\t\t\t\t\t\tconst urlSlug = media.url.slice( 0, cutOffIndex );\n\t\t\t\t\t\treturn { id: media.id, urlSlug };\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tsetMedia = onSelect;\n\t\t\t}\n\t\t} else {\n\t\t\tsetMedia = ( [ media ] ) => onSelect( media );\n\t\t}\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: setMedia,\n\t\t\tonError,\n\t\t} );\n\t};\n\n\tconst onUpload = ( event ) => {\n\t\tonFilesUpload( event.target.files );\n\t};\n\n\tconst defaultRenderPlaceholder = ( content ) => {\n\t\tlet { instructions, title } = labels;\n\n\t\tif ( ! mediaUpload && ! onSelectURL ) {\n\t\t\tinstructions = __(\n\t\t\t\t'To edit this block, you need permission to upload media.'\n\t\t\t);\n\t\t}\n\n\t\tif ( instructions === undefined || title === undefined ) {\n\t\t\tconst typesAllowed = allowedTypes ?? [];\n\n\t\t\tconst [ firstAllowedType ] = typesAllowed;\n\t\t\tconst isOneType = 1 === typesAllowed.length;\n\t\t\tconst isAudio = isOneType && 'audio' === firstAllowedType;\n\t\t\tconst isImage = isOneType && 'image' === firstAllowedType;\n\t\t\tconst isVideo = isOneType && 'video' === firstAllowedType;\n\n\t\t\tif ( instructions === undefined && mediaUpload ) {\n\t\t\t\tinstructions = __(\n\t\t\t\t\t'Upload a media file or pick one from your media library.'\n\t\t\t\t);\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload an audio file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload an image file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Upload a video file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( title === undefined ) {\n\t\t\t\ttitle = __( 'Media' );\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\ttitle = __( 'Audio' );\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\ttitle = __( 'Image' );\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\ttitle = __( 'Video' );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst placeholderClassName = classnames(\n\t\t\t'block-editor-media-placeholder',\n\t\t\tclassName,\n\t\t\t{\n\t\t\t\t'is-appender': isAppender,\n\t\t\t}\n\t\t);\n\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ title }\n\t\t\t\tinstructions={ instructions }\n\t\t\t\tclassName={ placeholderClassName }\n\t\t\t\tnotices={ notices }\n\t\t\t\tonDoubleClick={ onDoubleClick }\n\t\t\t\tpreview={ mediaPreview }\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t\t{ children }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\tconst renderPlaceholder = placeholder ?? defaultRenderPlaceholder;\n\n\tconst renderDropZone = () => {\n\t\tif ( disableDropZone ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<DropZone onFilesDrop={ onFilesUpload } onHTMLDrop={ onHTMLDrop } />\n\t\t);\n\t};\n\n\tconst renderCancelLink = () => {\n\t\treturn (\n\t\t\tonCancel && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"block-editor-media-placeholder__cancel-button\"\n\t\t\t\t\ttitle={ __( 'Cancel' ) }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\tonClick={ onCancel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</Button>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderUrlSelectionUI = () => {\n\t\treturn (\n\t\t\tonSelectURL && (\n\t\t\t\t<div className=\"block-editor-media-placeholder__url-input-container\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-media-placeholder__button\"\n\t\t\t\t\t\tonClick={ openURLInput }\n\t\t\t\t\t\tisPressed={ isURLInputVisible }\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Insert from URL' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t{ isURLInputVisible && (\n\t\t\t\t\t\t<InsertFromURLPopover\n\t\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\t\tonChange={ onChangeSrc }\n\t\t\t\t\t\t\tonSubmit={ onSubmitSrc }\n\t\t\t\t\t\t\tonClose={ closeURLInput }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderMediaUploadChecked = () => {\n\t\tconst defaultButton = ( { open } ) => {\n\t\t\treturn (\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\topen();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Media Library' ) }\n\t\t\t\t</Button>\n\t\t\t);\n\t\t};\n\t\tconst libraryButton = mediaLibraryButton ?? defaultButton;\n\t\tconst uploadMediaLibraryButton = (\n\t\t\t<MediaUpload\n\t\t\t\taddToGallery={ addToGallery }\n\t\t\t\tgallery={ multiple && onlyAllowsImages() }\n\t\t\t\tmultiple={ multiple }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\tvalue={\n\t\t\t\t\tArray.isArray( value )\n\t\t\t\t\t\t? value.map( ( { id } ) => id )\n\t\t\t\t\t\t: value.id\n\t\t\t\t}\n\t\t\t\trender={ libraryButton }\n\t\t\t/>\n\t\t);\n\n\t\tif ( mediaUpload && isAppender ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\tconst content = (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tonClick={ openFileDialog }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t{ uploadMediaLibraryButton }\n\t\t\t\t\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn renderPlaceholder( content );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\tif ( mediaUpload ) {\n\t\t\tconst content = (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t</FormFileUpload>\n\t\t\t\t\t{ uploadMediaLibraryButton }\n\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t</>\n\t\t\t);\n\t\t\treturn renderPlaceholder( content );\n\t\t}\n\n\t\treturn renderPlaceholder( uploadMediaLibraryButton );\n\t};\n\n\tif ( dropZoneUIOnly || disableMediaButtons ) {\n\t\tif ( dropZoneUIOnly ) {\n\t\t\tdeprecated( 'wp.blockEditor.MediaPlaceholder dropZoneUIOnly prop', {\n\t\t\t\tsince: '5.4',\n\t\t\t\talternative: 'disableMediaButtons',\n\t\t\t} );\n\t\t}\n\n\t\treturn <MediaUploadCheck>{ renderDropZone() }</MediaUploadCheck>;\n\t}\n\n\treturn (\n\t\t<MediaUploadCheck\n\t\t\tfallback={ renderPlaceholder( renderUrlSelectionUI() ) }\n\t\t>\n\t\t\t{ renderMediaUploadChecked() }\n\t\t</MediaUploadCheck>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-placeholder/README.md\n */\nexport default withFilters( 'editor.MediaPlaceholder' )( MediaPlaceholder );\n"]}
|
|
@@ -56,7 +56,8 @@ const MediaReplaceFlow = ({
|
|
|
56
56
|
onFilesUpload = _lodash.noop,
|
|
57
57
|
name = (0, _i18n.__)('Replace'),
|
|
58
58
|
createNotice,
|
|
59
|
-
removeNotice
|
|
59
|
+
removeNotice,
|
|
60
|
+
children
|
|
60
61
|
}) => {
|
|
61
62
|
const [mediaURLValue, setMediaURLValue] = (0, _element.useState)(mediaURL);
|
|
62
63
|
const mediaUpload = (0, _data.useSelect)(select => {
|
|
@@ -168,7 +169,7 @@ const MediaReplaceFlow = ({
|
|
|
168
169
|
}
|
|
169
170
|
}, (0, _i18n.__)('Upload'));
|
|
170
171
|
}
|
|
171
|
-
}))), onSelectURL && // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
172
|
+
})), children), onSelectURL && // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
172
173
|
(0, _element.createElement)("form", {
|
|
173
174
|
className: "block-editor-media-flow__url-input"
|
|
174
175
|
}, (0, _element.createElement)("span", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/media-replace-flow/index.js"],"names":["MediaReplaceFlow","mediaURL","mediaId","allowedTypes","accept","onSelect","onSelectURL","onFilesUpload","noop","name","createNotice","removeNotice","mediaURLValue","setMediaURLValue","mediaUpload","select","blockEditorStore","getSettings","editMediaButtonRef","errorNoticeID","onError","message","errorElement","document","createElement","innerHTML","renderMsg","textContent","innerText","setTimeout","speak","id","isDismissible","selectMedia","media","url","selectURL","newURL","uploadFiles","event","files","target","setMedia","filesList","onFileChange","openOnArrowDown","keyCode","DOWN","preventDefault","click","POPOVER_PROPS","isAlternate","isOpen","onToggle","onClose","open","mediaIcon","openFileDialog","upload","current","focus","dispatch","noticesStore"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAkBA;AACA;AACA;AAMA,MAAMA,gBAAgB,GAAG,CAAE;AAC1BC,EAAAA,QAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA,YAH0B;AAI1BC,EAAAA,MAJ0B;AAK1BC,EAAAA,QAL0B;AAM1BC,EAAAA,WAN0B;AAO1BC,EAAAA,aAAa,GAAGC,YAPU;AAQ1BC,EAAAA,IAAI,GAAG,cAAI,SAAJ,CARmB;AAS1BC,EAAAA,YAT0B;AAU1BC,EAAAA;AAV0B,CAAF,KAWlB;AACN,QAAM,CAAEC,aAAF,EAAiBC,gBAAjB,IAAsC,uBAAUZ,QAAV,CAA5C;AACA,QAAMa,WAAW,GAAG,qBAAaC,MAAF,IAAc;AAC5C,WAAOA,MAAM,CAAEC,YAAF,CAAN,CAA2BC,WAA3B,GAAyCH,WAAhD;AACA,GAFmB,EAEjB,EAFiB,CAApB;AAGA,QAAMI,kBAAkB,GAAG,yBAA3B;AACA,QAAMC,aAAa,GAAG,sBACrB,+CADqB,CAAtB;;AAIA,QAAMC,OAAO,GAAKC,OAAF,IAAe;AAC9B,UAAMC,YAAY,GAAGC,QAAQ,CAACC,aAAT,CAAwB,KAAxB,CAArB;AACAF,IAAAA,YAAY,CAACG,SAAb,GAAyB,6BAAgBJ,OAAhB,CAAzB,CAF8B,CAG9B;AACA;AACA;AACA;;AACA,UAAMK,SAAS,GACdJ,YAAY,CAACK,WAAb,IAA4BL,YAAY,CAACM,SAAzC,IAAsD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hBF,MADD,CAXD,CADD,EAiCGnD,WAAW,IACZ;AACA;AAAM,MAAA,SAAS,EAAC;AAAhB,OACC;AAAM,MAAA,SAAS,EAAC;AAAhB,OACG,cAAI,oBAAJ,CADH,CADD,EAIC,4BAAC,oBAAD;AACC,MAAA,KAAK,EAAG;AAAE6B,QAAAA,GAAG,EAAEvB;AAAP,OADT;AAEC,MAAA,QAAQ,EAAG,EAFZ;AAGC,MAAA,eAAe,EAAG,KAHnB;AAIC,MAAA,QAAQ,EAAG,CAAE;AAAEuB,QAAAA;AAAF,OAAF,KAAe;AACzBtB,QAAAA,gBAAgB,CAAEsB,GAAF,CAAhB;AACAC,QAAAA,SAAS,CAAED,GAAF,CAAT;AACAjB,QAAAA,kBAAkB,CAACyC,OAAnB,CAA2BC,KAA3B;AACA;AARF,MAJD,CAnCF;AAfF,IADD;AAuEA,CAzJD;;eA2Je,sBAAS,CACvB,wBAAgBC,QAAF,IAAgB;AAC7B,QAAM;AAAEnD,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAiCkD,QAAQ,CAAEC,cAAF,CAA/C;AACA,SAAO;AACNpD,IAAAA,YADM;AAENC,IAAAA;AAFM,GAAP;AAIA,CAND,CADuB,EAQvB,6BAAa,yBAAb,CARuB,CAAT,EASVX,gBATU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { uniqueId, noop } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useState, createRef, renderToString } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport {\n\tFormFileUpload,\n\tNavigableMenu,\n\tMenuItem,\n\tToolbarButton,\n\tDropdown,\n\twithFilters,\n} from '@wordpress/components';\nimport { withDispatch, useSelect } from '@wordpress/data';\nimport { DOWN } from '@wordpress/keycodes';\nimport { compose } from '@wordpress/compose';\nimport { upload, media as mediaIcon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport LinkControl from '../link-control';\nimport { store as blockEditorStore } from '../../store';\n\nconst MediaReplaceFlow = ( {\n\tmediaURL,\n\tmediaId,\n\tallowedTypes,\n\taccept,\n\tonSelect,\n\tonSelectURL,\n\tonFilesUpload = noop,\n\tname = __( 'Replace' ),\n\tcreateNotice,\n\tremoveNotice,\n} ) => {\n\tconst [ mediaURLValue, setMediaURLValue ] = useState( mediaURL );\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).getSettings().mediaUpload;\n\t}, [] );\n\tconst editMediaButtonRef = createRef();\n\tconst errorNoticeID = uniqueId(\n\t\t'block-editor/media-replace-flow/error-notice/'\n\t);\n\n\tconst onError = ( message ) => {\n\t\tconst errorElement = document.createElement( 'div' );\n\t\terrorElement.innerHTML = renderToString( message );\n\t\t// The default error contains some HTML that,\n\t\t// for example, makes the filename bold.\n\t\t// The notice, by default, accepts strings only and so\n\t\t// we need to remove the html from the error.\n\t\tconst renderMsg =\n\t\t\terrorElement.textContent || errorElement.innerText || '';\n\t\t// We need to set a timeout for showing the notice\n\t\t// so that VoiceOver and possibly other screen readers\n\t\t// can announce the error afer the toolbar button\n\t\t// regains focus once the upload dialog closes.\n\t\t// Otherwise VO simply skips over the notice and announces\n\t\t// the focused element and the open menu.\n\t\tsetTimeout( () => {\n\t\t\tcreateNotice( 'error', renderMsg, {\n\t\t\t\tspeak: true,\n\t\t\t\tid: errorNoticeID,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}, 1000 );\n\t};\n\n\tconst selectMedia = ( media ) => {\n\t\tsetMediaURLValue( media.url );\n\t\t// Calling `onSelect` after the state update since it might unmount the component.\n\t\tonSelect( media );\n\t\tspeak( __( 'The media file has been replaced' ) );\n\t\tremoveNotice( errorNoticeID );\n\t};\n\n\tconst selectURL = ( newURL ) => {\n\t\tonSelectURL( newURL );\n\t};\n\n\tconst uploadFiles = ( event ) => {\n\t\tconst files = event.target.files;\n\t\tonFilesUpload( files );\n\t\tconst setMedia = ( [ media ] ) => {\n\t\t\tselectMedia( media );\n\t\t};\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: setMedia,\n\t\t\tonError,\n\t\t} );\n\t};\n\n\tconst openOnArrowDown = ( event ) => {\n\t\tif ( event.keyCode === DOWN ) {\n\t\t\tevent.preventDefault();\n\t\t\tevent.target.click();\n\t\t}\n\t};\n\n\tconst POPOVER_PROPS = {\n\t\tisAlternate: true,\n\t};\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tcontentClassName=\"block-editor-media-replace-flow__options\"\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tref={ editMediaButtonRef }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t>\n\t\t\t\t\t{ name }\n\t\t\t\t</ToolbarButton>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<NavigableMenu className=\"block-editor-media-replace-flow__media-upload-menu\">\n\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\tvalue={ mediaId }\n\t\t\t\t\t\t\tonSelect={ ( media ) => selectMedia( media ) }\n\t\t\t\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t<MenuItem icon={ mediaIcon } onClick={ open }>\n\t\t\t\t\t\t\t\t\t{ __( 'Open Media Library' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\t\t\tonChange={ ( event ) => {\n\t\t\t\t\t\t\t\t\tuploadFiles( event, onClose );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\topenFileDialog();\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\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</MediaUploadCheck>\n\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t{ onSelectURL && (\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t\t\t\t\t<form className=\"block-editor-media-flow__url-input\">\n\t\t\t\t\t\t\t<span className=\"block-editor-media-replace-flow__image-url-label\">\n\t\t\t\t\t\t\t\t{ __( 'Current media URL:' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<LinkControl\n\t\t\t\t\t\t\t\tvalue={ { url: mediaURLValue } }\n\t\t\t\t\t\t\t\tsettings={ [] }\n\t\t\t\t\t\t\t\tshowSuggestions={ false }\n\t\t\t\t\t\t\t\tonChange={ ( { url } ) => {\n\t\t\t\t\t\t\t\t\tsetMediaURLValue( url );\n\t\t\t\t\t\t\t\t\tselectURL( url );\n\t\t\t\t\t\t\t\t\teditMediaButtonRef.current.focus();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n};\n\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { createNotice, removeNotice } = dispatch( noticesStore );\n\t\treturn {\n\t\t\tcreateNotice,\n\t\t\tremoveNotice,\n\t\t};\n\t} ),\n\twithFilters( 'editor.MediaReplaceFlow' ),\n] )( MediaReplaceFlow );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/media-replace-flow/index.js"],"names":["MediaReplaceFlow","mediaURL","mediaId","allowedTypes","accept","onSelect","onSelectURL","onFilesUpload","noop","name","createNotice","removeNotice","children","mediaURLValue","setMediaURLValue","mediaUpload","select","blockEditorStore","getSettings","editMediaButtonRef","errorNoticeID","onError","message","errorElement","document","createElement","innerHTML","renderMsg","textContent","innerText","setTimeout","speak","id","isDismissible","selectMedia","media","url","selectURL","newURL","uploadFiles","event","files","target","setMedia","filesList","onFileChange","openOnArrowDown","keyCode","DOWN","preventDefault","click","POPOVER_PROPS","isAlternate","isOpen","onToggle","onClose","open","mediaIcon","openFileDialog","upload","current","focus","dispatch","noticesStore"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAkBA;AACA;AACA;AAMA,MAAMA,gBAAgB,GAAG,CAAE;AAC1BC,EAAAA,QAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA,YAH0B;AAI1BC,EAAAA,MAJ0B;AAK1BC,EAAAA,QAL0B;AAM1BC,EAAAA,WAN0B;AAO1BC,EAAAA,aAAa,GAAGC,YAPU;AAQ1BC,EAAAA,IAAI,GAAG,cAAI,SAAJ,CARmB;AAS1BC,EAAAA,YAT0B;AAU1BC,EAAAA,YAV0B;AAW1BC,EAAAA;AAX0B,CAAF,KAYlB;AACN,QAAM,CAAEC,aAAF,EAAiBC,gBAAjB,IAAsC,uBAAUb,QAAV,CAA5C;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AENC,IAAAA;AAFM,GAAP;AAIA,CAND,CADuB,EAQvB,6BAAa,yBAAb,CARuB,CAAT,EASVX,gBATU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { uniqueId, noop } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useState, createRef, renderToString } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport {\n\tFormFileUpload,\n\tNavigableMenu,\n\tMenuItem,\n\tToolbarButton,\n\tDropdown,\n\twithFilters,\n} from '@wordpress/components';\nimport { withDispatch, useSelect } from '@wordpress/data';\nimport { DOWN } from '@wordpress/keycodes';\nimport { compose } from '@wordpress/compose';\nimport { upload, media as mediaIcon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport LinkControl from '../link-control';\nimport { store as blockEditorStore } from '../../store';\n\nconst MediaReplaceFlow = ( {\n\tmediaURL,\n\tmediaId,\n\tallowedTypes,\n\taccept,\n\tonSelect,\n\tonSelectURL,\n\tonFilesUpload = noop,\n\tname = __( 'Replace' ),\n\tcreateNotice,\n\tremoveNotice,\n\tchildren,\n} ) => {\n\tconst [ mediaURLValue, setMediaURLValue ] = useState( mediaURL );\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).getSettings().mediaUpload;\n\t}, [] );\n\tconst editMediaButtonRef = createRef();\n\tconst errorNoticeID = uniqueId(\n\t\t'block-editor/media-replace-flow/error-notice/'\n\t);\n\n\tconst onError = ( message ) => {\n\t\tconst errorElement = document.createElement( 'div' );\n\t\terrorElement.innerHTML = renderToString( message );\n\t\t// The default error contains some HTML that,\n\t\t// for example, makes the filename bold.\n\t\t// The notice, by default, accepts strings only and so\n\t\t// we need to remove the html from the error.\n\t\tconst renderMsg =\n\t\t\terrorElement.textContent || errorElement.innerText || '';\n\t\t// We need to set a timeout for showing the notice\n\t\t// so that VoiceOver and possibly other screen readers\n\t\t// can announce the error afer the toolbar button\n\t\t// regains focus once the upload dialog closes.\n\t\t// Otherwise VO simply skips over the notice and announces\n\t\t// the focused element and the open menu.\n\t\tsetTimeout( () => {\n\t\t\tcreateNotice( 'error', renderMsg, {\n\t\t\t\tspeak: true,\n\t\t\t\tid: errorNoticeID,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}, 1000 );\n\t};\n\n\tconst selectMedia = ( media ) => {\n\t\tsetMediaURLValue( media.url );\n\t\t// Calling `onSelect` after the state update since it might unmount the component.\n\t\tonSelect( media );\n\t\tspeak( __( 'The media file has been replaced' ) );\n\t\tremoveNotice( errorNoticeID );\n\t};\n\n\tconst selectURL = ( newURL ) => {\n\t\tonSelectURL( newURL );\n\t};\n\n\tconst uploadFiles = ( event ) => {\n\t\tconst files = event.target.files;\n\t\tonFilesUpload( files );\n\t\tconst setMedia = ( [ media ] ) => {\n\t\t\tselectMedia( media );\n\t\t};\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: setMedia,\n\t\t\tonError,\n\t\t} );\n\t};\n\n\tconst openOnArrowDown = ( event ) => {\n\t\tif ( event.keyCode === DOWN ) {\n\t\t\tevent.preventDefault();\n\t\t\tevent.target.click();\n\t\t}\n\t};\n\n\tconst POPOVER_PROPS = {\n\t\tisAlternate: true,\n\t};\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tcontentClassName=\"block-editor-media-replace-flow__options\"\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tref={ editMediaButtonRef }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t>\n\t\t\t\t\t{ name }\n\t\t\t\t</ToolbarButton>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<NavigableMenu className=\"block-editor-media-replace-flow__media-upload-menu\">\n\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\tvalue={ mediaId }\n\t\t\t\t\t\t\tonSelect={ ( media ) => selectMedia( media ) }\n\t\t\t\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t<MenuItem icon={ mediaIcon } onClick={ open }>\n\t\t\t\t\t\t\t\t\t{ __( 'Open Media Library' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\t\t\tonChange={ ( event ) => {\n\t\t\t\t\t\t\t\t\tuploadFiles( event, onClose );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\topenFileDialog();\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\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</MediaUploadCheck>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t{ onSelectURL && (\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t\t\t\t\t<form className=\"block-editor-media-flow__url-input\">\n\t\t\t\t\t\t\t<span className=\"block-editor-media-replace-flow__image-url-label\">\n\t\t\t\t\t\t\t\t{ __( 'Current media URL:' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<LinkControl\n\t\t\t\t\t\t\t\tvalue={ { url: mediaURLValue } }\n\t\t\t\t\t\t\t\tsettings={ [] }\n\t\t\t\t\t\t\t\tshowSuggestions={ false }\n\t\t\t\t\t\t\t\tonChange={ ( { url } ) => {\n\t\t\t\t\t\t\t\t\tsetMediaURLValue( url );\n\t\t\t\t\t\t\t\t\tselectURL( url );\n\t\t\t\t\t\t\t\t\teditMediaButtonRef.current.focus();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n};\n\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { createNotice, removeNotice } = dispatch( noticesStore );\n\t\treturn {\n\t\t\tcreateNotice,\n\t\t\tremoveNotice,\n\t\t};\n\t} ),\n\twithFilters( 'editor.MediaReplaceFlow' ),\n] )( MediaReplaceFlow );\n"]}
|
|
@@ -13,6 +13,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
13
13
|
|
|
14
14
|
var _reactNative = require("react-native");
|
|
15
15
|
|
|
16
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
17
|
+
|
|
16
18
|
var _style = _interopRequireDefault(require("./style.scss"));
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -70,7 +72,34 @@ class PlainText extends _element.Component {
|
|
|
70
72
|
this._input.blur();
|
|
71
73
|
}
|
|
72
74
|
|
|
75
|
+
getFontSize() {
|
|
76
|
+
const {
|
|
77
|
+
style
|
|
78
|
+
} = this.props;
|
|
79
|
+
|
|
80
|
+
if (!(style !== null && style !== void 0 && style.fontSize)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const {
|
|
85
|
+
width,
|
|
86
|
+
height
|
|
87
|
+
} = _reactNative.Dimensions.get('window');
|
|
88
|
+
|
|
89
|
+
const cssUnitOptions = {
|
|
90
|
+
height,
|
|
91
|
+
width
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
fontSize: parseFloat((0, _blockEditor.getPxFromCssUnit)(style.fontSize, cssUnitOptions))
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
73
98
|
render() {
|
|
99
|
+
const {
|
|
100
|
+
style
|
|
101
|
+
} = this.props;
|
|
102
|
+
const textStyles = [style || _style.default['block-editor-plain-text'], this.getFontSize()];
|
|
74
103
|
return (0, _element.createElement)(_reactNative.TextInput, (0, _extends2.default)({}, this.props, {
|
|
75
104
|
ref: x => this._input = x,
|
|
76
105
|
onChange: event => {
|
|
@@ -81,7 +110,7 @@ class PlainText extends _element.Component {
|
|
|
81
110
|
onBlur: this.props.onBlur // always assign onBlur as a props
|
|
82
111
|
,
|
|
83
112
|
fontFamily: this.props.style && this.props.style.fontFamily || _style.default['block-editor-plain-text'].fontFamily,
|
|
84
|
-
style:
|
|
113
|
+
style: textStyles,
|
|
85
114
|
scrollEnabled: false
|
|
86
115
|
}));
|
|
87
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/plain-text/index.native.js"],"names":["PlainText","Component","constructor","arguments","isAndroid","Platform","OS","componentDidMount","_input","isFocused","props","isSelected","timeoutID","setTimeout","focus","componentDidUpdate","prevProps","blur","componentWillUnmount","clearTimeout","render","x","event","onChange","nativeEvent","text","onFocus","onBlur","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/plain-text/index.native.js"],"names":["PlainText","Component","constructor","arguments","isAndroid","Platform","OS","componentDidMount","_input","isFocused","props","isSelected","timeoutID","setTimeout","focus","componentDidUpdate","prevProps","blur","componentWillUnmount","clearTimeout","getFontSize","style","fontSize","width","height","Dimensions","get","cssUnitOptions","parseFloat","render","textStyles","styles","x","event","onChange","nativeEvent","text","onFocus","onBlur","fontFamily"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAMA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGe,MAAMA,SAAN,SAAwBC,kBAAxB,CAAkC;AAChDC,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV;AACA,SAAKC,SAAL,GAAiBC,sBAASC,EAAT,KAAgB,SAAjC;AACA;;AAEDC,EAAAA,iBAAiB,GAAG;AACnB;AACA,QACC,KAAKC,MAAL,IACA,KAAKA,MAAL,CAAYC,SAAZ,OAA4B,KAD5B,IAEA,KAAKC,KAAL,CAAWC,UAHZ,EAIE;AACD,UAAK,KAAKP,SAAV,EAAsB;AACrB;AACJ;AACA;AACA;AACA;AACI,aAAKQ,SAAL,GAAiBC,UAAU,CAAE,MAAM;AAClC,eAAKL,MAAL,CAAYM,KAAZ;AACA,SAF0B,EAExB,GAFwB,CAA3B;AAGA,OATD,MASO;AACN,aAAKN,MAAL,CAAYM,KAAZ;AACA;AACD;AACD;;AAEDC,EAAAA,kBAAkB,CAAEC,SAAF,EAAc;AAC/B,QAAK,CAAE,KAAKN,KAAL,CAAWC,UAAb,IAA2BK,SAAS,CAACL,UAA1C,EAAuD;AACtD,WAAKH,MAAL,CAAYS,IAAZ;AACA;AACD;;AAEDC,EAAAA,oBAAoB,GAAG;AACtB,QAAK,KAAKd,SAAV,EAAsB;AACrBe,MAAAA,YAAY,CAAE,KAAKP,SAAP,CAAZ;AACA;AACD;;AAEDE,EAAAA,KAAK,GAAG;AACP,SAAKN,MAAL,CAAYM,KAAZ;AACA;;AAEDG,EAAAA,IAAI,GAAG;AACN,SAAKT,MAAL,CAAYS,IAAZ;AACA;;AAEDG,EAAAA,WAAW,GAAG;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAY,KAAKX,KAAvB;;AAEA,QAAK,EAAEW,KAAF,aAAEA,KAAF,eAAEA,KAAK,CAAEC,QAAT,CAAL,EAAyB;AACxB;AACA;;AAED,UAAM;AAAEC,MAAAA,KAAF;AAASC,MAAAA;AAAT,QAAoBC,wBAAWC,GAAX,CAAgB,QAAhB,CAA1B;;AACA,UAAMC,cAAc,GAAG;AAAEH,MAAAA,MAAF;AAAUD,MAAAA;AAAV,KAAvB;AAEA,WAAO;AACND,MAAAA,QAAQ,EAAEM,UAAU,CACnB,mCAAkBP,KAAK,CAACC,QAAxB,EAAkCK,cAAlC,CADmB;AADd,KAAP;AAKA;;AAEDE,EAAAA,MAAM,GAAG;AACR,UAAM;AAAER,MAAAA;AAAF,QAAY,KAAKX,KAAvB;AACA,UAAMoB,UAAU,GAAG,CAClBT,KAAK,IAAIU,eAAQ,yBAAR,CADS,EAElB,KAAKX,WAAL,EAFkB,CAAnB;AAKA,WACC,4BAAC,sBAAD,6BACM,KAAKV,KADX;AAEC,MAAA,GAAG,EAAKsB,CAAF,IAAW,KAAKxB,MAAL,GAAcwB,CAFhC;AAGC,MAAA,QAAQ,EAAKC,KAAF,IAAa;AACvB,aAAKvB,KAAL,CAAWwB,QAAX,CAAqBD,KAAK,CAACE,WAAN,CAAkBC,IAAvC;AACA,OALF;AAMC,MAAA,OAAO,EAAG,KAAK1B,KAAL,CAAW2B,OANtB,CAMgC;AANhC;AAOC,MAAA,MAAM,EAAG,KAAK3B,KAAL,CAAW4B,MAPrB,CAO8B;AAP9B;AAQC,MAAA,UAAU,EACP,KAAK5B,KAAL,CAAWW,KAAX,IAAoB,KAAKX,KAAL,CAAWW,KAAX,CAAiBkB,UAAvC,IACAR,eAAQ,yBAAR,EAAoCQ,UAVtC;AAYC,MAAA,KAAK,EAAGT,UAZT;AAaC,MAAA,aAAa,EAAG;AAbjB,OADD;AAiBA;;AAzF+C","sourcesContent":["/**\n * External dependencies\n */\nimport { TextInput, Platform, Dimensions } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { getPxFromCssUnit } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nexport default class PlainText extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.isAndroid = Platform.OS === 'android';\n\t}\n\n\tcomponentDidMount() {\n\t\t// if isSelected is true, we should request the focus on this TextInput\n\t\tif (\n\t\t\tthis._input &&\n\t\t\tthis._input.isFocused() === false &&\n\t\t\tthis.props.isSelected\n\t\t) {\n\t\t\tif ( this.isAndroid ) {\n\t\t\t\t/*\n\t\t\t\t * There seems to be an issue in React Native where the keyboard doesn't show if called shortly after rendering.\n\t\t\t\t * As a common work around this delay is used.\n\t\t\t\t * https://github.com/facebook/react-native/issues/19366#issuecomment-400603928\n\t\t\t\t */\n\t\t\t\tthis.timeoutID = setTimeout( () => {\n\t\t\t\t\tthis._input.focus();\n\t\t\t\t}, 100 );\n\t\t\t} else {\n\t\t\t\tthis._input.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tif ( ! this.props.isSelected && prevProps.isSelected ) {\n\t\t\tthis._input.blur();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.isAndroid ) {\n\t\t\tclearTimeout( this.timeoutID );\n\t\t}\n\t}\n\n\tfocus() {\n\t\tthis._input.focus();\n\t}\n\n\tblur() {\n\t\tthis._input.blur();\n\t}\n\n\tgetFontSize() {\n\t\tconst { style } = this.props;\n\n\t\tif ( ! style?.fontSize ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { width, height } = Dimensions.get( 'window' );\n\t\tconst cssUnitOptions = { height, width };\n\n\t\treturn {\n\t\t\tfontSize: parseFloat(\n\t\t\t\tgetPxFromCssUnit( style.fontSize, cssUnitOptions )\n\t\t\t),\n\t\t};\n\t}\n\n\trender() {\n\t\tconst { style } = this.props;\n\t\tconst textStyles = [\n\t\t\tstyle || styles[ 'block-editor-plain-text' ],\n\t\t\tthis.getFontSize(),\n\t\t];\n\n\t\treturn (\n\t\t\t<TextInput\n\t\t\t\t{ ...this.props }\n\t\t\t\tref={ ( x ) => ( this._input = x ) }\n\t\t\t\tonChange={ ( event ) => {\n\t\t\t\t\tthis.props.onChange( event.nativeEvent.text );\n\t\t\t\t} }\n\t\t\t\tonFocus={ this.props.onFocus } // always assign onFocus as a props\n\t\t\t\tonBlur={ this.props.onBlur } // always assign onBlur as a props\n\t\t\t\tfontFamily={\n\t\t\t\t\t( this.props.style && this.props.style.fontFamily ) ||\n\t\t\t\t\tstyles[ 'block-editor-plain-text' ].fontFamily\n\t\t\t\t}\n\t\t\t\tstyle={ textStyles }\n\t\t\t\tscrollEnabled={ false }\n\t\t\t/>\n\t\t);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _lodash = require("lodash");
|
|
11
|
+
|
|
12
|
+
var _components = require("@wordpress/components");
|
|
13
|
+
|
|
14
|
+
var _i18n = require("@wordpress/i18n");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* External dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* WordPress dependencies
|
|
22
|
+
*/
|
|
23
|
+
const DEFAULT_PICKER_OPTIONS = [{
|
|
24
|
+
id: 'createEmbed',
|
|
25
|
+
label: (0, _i18n.__)('Create embed'),
|
|
26
|
+
value: 'createEmbed',
|
|
27
|
+
onSelect: _lodash.noop
|
|
28
|
+
}, {
|
|
29
|
+
id: 'createLink',
|
|
30
|
+
label: (0, _i18n.__)('Create link'),
|
|
31
|
+
value: 'createLink',
|
|
32
|
+
onSelect: _lodash.noop
|
|
33
|
+
}];
|
|
34
|
+
const EmbedHandlerPicker = (0, _element.forwardRef)(({}, ref) => {
|
|
35
|
+
const pickerRef = (0, _element.useRef)();
|
|
36
|
+
const pickerOptions = (0, _element.useRef)(DEFAULT_PICKER_OPTIONS).current;
|
|
37
|
+
const onPickerSelect = (0, _element.useCallback)(value => {
|
|
38
|
+
const selectedItem = pickerOptions.find(item => item.value === value);
|
|
39
|
+
selectedItem.onSelect();
|
|
40
|
+
}, [pickerOptions]);
|
|
41
|
+
(0, _element.useImperativeHandle)(ref, () => ({
|
|
42
|
+
presentPicker: ({
|
|
43
|
+
createEmbed,
|
|
44
|
+
createLink
|
|
45
|
+
}) => {
|
|
46
|
+
var _pickerRef$current;
|
|
47
|
+
|
|
48
|
+
pickerOptions[0].onSelect = createEmbed;
|
|
49
|
+
pickerOptions[1].onSelect = createLink;
|
|
50
|
+
(_pickerRef$current = pickerRef.current) === null || _pickerRef$current === void 0 ? void 0 : _pickerRef$current.presentPicker();
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
return (0, _element.createElement)(_components.Picker, {
|
|
54
|
+
ref: pickerRef,
|
|
55
|
+
options: pickerOptions,
|
|
56
|
+
onChange: onPickerSelect,
|
|
57
|
+
hideCancelButton: true,
|
|
58
|
+
leftAlign: true
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
var _default = (0, _element.memo)(EmbedHandlerPicker);
|
|
63
|
+
|
|
64
|
+
exports.default = _default;
|
|
65
|
+
//# sourceMappingURL=embed-handler-picker.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/embed-handler-picker.native.js"],"names":["DEFAULT_PICKER_OPTIONS","id","label","value","onSelect","noop","EmbedHandlerPicker","ref","pickerRef","pickerOptions","current","onPickerSelect","selectedItem","find","item","presentPicker","createEmbed","createLink"],"mappings":";;;;;;;AAQA;;AALA;;AAYA;;AACA;;AAhBA;AACA;AACA;;AAGA;A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AAA,SAAS;AALV,IADD;AASA,CA/B0B,CAA3B;;eAiCe,mBAAML,kBAAN,C","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tforwardRef,\n\tuseRef,\n\tuseImperativeHandle,\n\tmemo,\n\tuseCallback,\n} from '@wordpress/element';\nimport { Picker } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nconst DEFAULT_PICKER_OPTIONS = [\n\t{\n\t\tid: 'createEmbed',\n\t\tlabel: __( 'Create embed' ),\n\t\tvalue: 'createEmbed',\n\t\tonSelect: noop,\n\t},\n\t{\n\t\tid: 'createLink',\n\t\tlabel: __( 'Create link' ),\n\t\tvalue: 'createLink',\n\t\tonSelect: noop,\n\t},\n];\n\nconst EmbedHandlerPicker = forwardRef( ( {}, ref ) => {\n\tconst pickerRef = useRef();\n\tconst pickerOptions = useRef( DEFAULT_PICKER_OPTIONS ).current;\n\n\tconst onPickerSelect = useCallback(\n\t\t( value ) => {\n\t\t\tconst selectedItem = pickerOptions.find(\n\t\t\t\t( item ) => item.value === value\n\t\t\t);\n\t\t\tselectedItem.onSelect();\n\t\t},\n\t\t[ pickerOptions ]\n\t);\n\n\tuseImperativeHandle( ref, () => ( {\n\t\tpresentPicker: ( { createEmbed, createLink } ) => {\n\t\t\tpickerOptions[ 0 ].onSelect = createEmbed;\n\t\t\tpickerOptions[ 1 ].onSelect = createLink;\n\t\t\tpickerRef.current?.presentPicker();\n\t\t},\n\t} ) );\n\n\treturn (\n\t\t<Picker\n\t\t\tref={ pickerRef }\n\t\t\toptions={ pickerOptions }\n\t\t\tonChange={ onPickerSelect }\n\t\t\thideCancelButton\n\t\t\tleftAlign\n\t\t/>\n\t);\n} );\n\nexport default memo( EmbedHandlerPicker );\n"]}
|