@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
|
@@ -15,8 +15,6 @@ import { forwardRef } from '@wordpress/element';
|
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { useListViewContext } from './context';
|
|
19
|
-
import ListViewBlockSlot from './block-slot';
|
|
20
18
|
import ListViewBlockSelectButton from './block-select-button';
|
|
21
19
|
import BlockDraggable from '../block-draggable';
|
|
22
20
|
import { store as blockEditorStore } from '../../store';
|
|
@@ -30,9 +28,6 @@ const ListViewBlockContents = forwardRef(({
|
|
|
30
28
|
level,
|
|
31
29
|
...props
|
|
32
30
|
}, ref) => {
|
|
33
|
-
const {
|
|
34
|
-
__experimentalFeatures
|
|
35
|
-
} = useListViewContext();
|
|
36
31
|
const {
|
|
37
32
|
clientId
|
|
38
33
|
} = block;
|
|
@@ -61,19 +56,7 @@ const ListViewBlockContents = forwardRef(({
|
|
|
61
56
|
draggable,
|
|
62
57
|
onDragStart,
|
|
63
58
|
onDragEnd
|
|
64
|
-
}) =>
|
|
65
|
-
ref: ref,
|
|
66
|
-
className: className,
|
|
67
|
-
block: block,
|
|
68
|
-
onToggleExpanded: onToggleExpanded,
|
|
69
|
-
isSelected: isSelected,
|
|
70
|
-
position: position,
|
|
71
|
-
siblingBlockCount: siblingBlockCount,
|
|
72
|
-
level: level,
|
|
73
|
-
draggable: draggable && __experimentalFeatures,
|
|
74
|
-
onDragStart: onDragStart,
|
|
75
|
-
onDragEnd: onDragEnd
|
|
76
|
-
}, props)) : createElement(ListViewBlockSelectButton, _extends({
|
|
59
|
+
}) => createElement(ListViewBlockSelectButton, _extends({
|
|
77
60
|
ref: ref,
|
|
78
61
|
className: className,
|
|
79
62
|
block: block,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-contents.js"],"names":["classnames","useSelect","forwardRef","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-contents.js"],"names":["classnames","useSelect","forwardRef","ListViewBlockSelectButton","BlockDraggable","store","blockEditorStore","ListViewBlockContents","onClick","onToggleExpanded","block","isSelected","position","siblingBlockCount","level","props","ref","clientId","blockMovingClientId","selectedBlockInBlockEditor","select","getBlockRootClientId","hasBlockMovingClientId","getSelectedBlockClientId","rootClientId","isBlockMoveTarget","className","draggable","onDragStart","onDragEnd"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,uBAAtC;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,MAAMC,qBAAqB,GAAGL,UAAU,CACvC,CACC;AACCM,EAAAA,OADD;AAECC,EAAAA,gBAFD;AAGCC,EAAAA,KAHD;AAICC,EAAAA,UAJD;AAKCC,EAAAA,QALD;AAMCC,EAAAA,iBAND;AAOCC,EAAAA,KAPD;AAQC,KAAGC;AARJ,CADD,EAWCC,GAXD,KAYK;AACJ,QAAM;AAAEC,IAAAA;AAAF,MAAeP,KAArB;AAEA,QAAM;AAAEQ,IAAAA,mBAAF;AAAuBC,IAAAA;AAAvB,MAAsDlB,SAAS,CAClEmB,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,oBADK;AAELC,MAAAA,sBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEd,gBAAF,CAJV;AAKA,WAAO;AACNkB,MAAAA,YAAY,EAAEH,oBAAoB,CAAEJ,QAAF,CAApB,IAAoC,EAD5C;AAENC,MAAAA,mBAAmB,EAAEI,sBAAsB,EAFrC;AAGNH,MAAAA,0BAA0B,EAAEI,wBAAwB;AAH9C,KAAP;AAKA,GAZmE,EAapE,CAAEN,QAAF,CAboE,CAArE;AAgBA,QAAMQ,iBAAiB,GACtBP,mBAAmB,IAAIC,0BAA0B,KAAKF,QADvD;AAGA,QAAMS,SAAS,GAAG1B,UAAU,CAAE,uCAAF,EAA2C;AACtE,0BAAsByB;AADgD,GAA3C,CAA5B;AAIA,SACC,cAAC,cAAD;AAAgB,IAAA,SAAS,EAAG,CAAEf,KAAK,CAACO,QAAR;AAA5B,KACG,CAAE;AAAEU,IAAAA,SAAF;AAAaC,IAAAA,WAAb;AAA0BC,IAAAA;AAA1B,GAAF,KACD,cAAC,yBAAD;AACC,IAAA,GAAG,EAAGb,GADP;AAEC,IAAA,SAAS,EAAGU,SAFb;AAGC,IAAA,KAAK,EAAGhB,KAHT;AAIC,IAAA,OAAO,EAAGF,OAJX;AAKC,IAAA,gBAAgB,EAAGC,gBALpB;AAMC,IAAA,UAAU,EAAGE,UANd;AAOC,IAAA,QAAQ,EAAGC,QAPZ;AAQC,IAAA,iBAAiB,EAAGC,iBARrB;AASC,IAAA,KAAK,EAAGC,KATT;AAUC,IAAA,SAAS,EAAGa,SAVb;AAWC,IAAA,WAAW,EAAGC,WAXf;AAYC,IAAA,SAAS,EAAGC;AAZb,KAaMd,KAbN,EAFF,CADD;AAqBA,CA5DsC,CAAxC;AA+DA,eAAeR,qBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ListViewBlockSelectButton from './block-select-button';\nimport BlockDraggable from '../block-draggable';\nimport { store as blockEditorStore } from '../../store';\n\nconst ListViewBlockContents = forwardRef(\n\t(\n\t\t{\n\t\t\tonClick,\n\t\t\tonToggleExpanded,\n\t\t\tblock,\n\t\t\tisSelected,\n\t\t\tposition,\n\t\t\tsiblingBlockCount,\n\t\t\tlevel,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tconst { clientId } = block;\n\n\t\tconst { blockMovingClientId, selectedBlockInBlockEditor } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\thasBlockMovingClientId,\n\t\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\treturn {\n\t\t\t\t\trootClientId: getBlockRootClientId( clientId ) || '',\n\t\t\t\t\tblockMovingClientId: hasBlockMovingClientId(),\n\t\t\t\t\tselectedBlockInBlockEditor: getSelectedBlockClientId(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId ]\n\t\t);\n\n\t\tconst isBlockMoveTarget =\n\t\t\tblockMovingClientId && selectedBlockInBlockEditor === clientId;\n\n\t\tconst className = classnames( 'block-editor-list-view-block-contents', {\n\t\t\t'is-dropping-before': isBlockMoveTarget,\n\t\t} );\n\n\t\treturn (\n\t\t\t<BlockDraggable clientIds={ [ block.clientId ] }>\n\t\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t\t<ListViewBlockSelectButton\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\tonToggleExpanded={ onToggleExpanded }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\t\tonDragStart={ onDragStart }\n\t\t\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockDraggable>\n\t\t);\n\t}\n);\n\nexport default ListViewBlockContents;\n"]}
|
|
@@ -8,11 +8,10 @@ import classnames from 'classnames';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { __experimentalTreeGridCell as TreeGridCell, __experimentalTreeGridItem as TreeGridItem
|
|
12
|
-
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { __experimentalTreeGridCell as TreeGridCell, __experimentalTreeGridItem as TreeGridItem } from '@wordpress/components';
|
|
13
12
|
import { moreVertical } from '@wordpress/icons';
|
|
14
13
|
import { useState, useRef, useEffect } from '@wordpress/element';
|
|
15
|
-
import { useDispatch
|
|
14
|
+
import { useDispatch } from '@wordpress/data';
|
|
16
15
|
/**
|
|
17
16
|
* Internal dependencies
|
|
18
17
|
*/
|
|
@@ -44,17 +43,13 @@ export default function ListViewBlock({
|
|
|
44
43
|
const {
|
|
45
44
|
clientId
|
|
46
45
|
} = block;
|
|
47
|
-
const blockParents = useSelect(select => {
|
|
48
|
-
return select(blockEditorStore).getBlockParents(clientId);
|
|
49
|
-
}, [clientId]);
|
|
50
46
|
const {
|
|
51
|
-
selectBlock: selectEditorBlock,
|
|
52
47
|
toggleBlockHighlight
|
|
53
48
|
} = useDispatch(blockEditorStore);
|
|
54
49
|
const hasSiblings = siblingBlockCount > 0;
|
|
55
50
|
const hasRenderedMovers = showBlockMovers && hasSiblings;
|
|
56
51
|
const moverCellClassName = classnames('block-editor-list-view-block__mover-cell', {
|
|
57
|
-
'is-visible': isHovered
|
|
52
|
+
'is-visible': isHovered || isSelected
|
|
58
53
|
});
|
|
59
54
|
const {
|
|
60
55
|
__experimentalFeatures: withExperimentalFeatures,
|
|
@@ -62,7 +57,7 @@ export default function ListViewBlock({
|
|
|
62
57
|
isTreeGridMounted
|
|
63
58
|
} = useListViewContext();
|
|
64
59
|
const listViewBlockSettingsClassName = classnames('block-editor-list-view-block__menu-cell', {
|
|
65
|
-
'is-visible': isHovered
|
|
60
|
+
'is-visible': isHovered || isSelected
|
|
66
61
|
}); // If ListView has experimental features related to the Persistent List View,
|
|
67
62
|
// only focus the selected list item on mount; otherwise the list would always
|
|
68
63
|
// try to steal the focus from the editor canvas.
|
|
@@ -71,14 +66,7 @@ export default function ListViewBlock({
|
|
|
71
66
|
if (withExperimentalPersistentListViewFeatures && !isTreeGridMounted && isSelected) {
|
|
72
67
|
cellRef.current.focus();
|
|
73
68
|
}
|
|
74
|
-
}, []);
|
|
75
|
-
// leave the focus handling as it was before, to avoid accidental regressions.
|
|
76
|
-
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
if (withExperimentalFeatures && isSelected) {
|
|
79
|
-
cellRef.current.focus();
|
|
80
|
-
}
|
|
81
|
-
}, [withExperimentalFeatures, isSelected]);
|
|
69
|
+
}, []);
|
|
82
70
|
const highlightBlock = withExperimentalPersistentListViewFeatures ? toggleBlockHighlight : () => {};
|
|
83
71
|
|
|
84
72
|
const onMouseEnter = () => {
|
|
@@ -165,30 +153,12 @@ export default function ListViewBlock({
|
|
|
165
153
|
icon: moreVertical,
|
|
166
154
|
toggleProps: {
|
|
167
155
|
ref,
|
|
156
|
+
className: 'block-editor-list-view-block__menu',
|
|
168
157
|
tabIndex,
|
|
169
158
|
onFocus
|
|
170
159
|
},
|
|
171
160
|
disableOpenOnArrowDown: true,
|
|
172
161
|
__experimentalSelectBlock: onClick
|
|
173
|
-
}
|
|
174
|
-
onClose
|
|
175
|
-
}) => createElement(MenuGroup, null, createElement(MenuItem, {
|
|
176
|
-
onClick: async () => {
|
|
177
|
-
if (blockParents.length) {
|
|
178
|
-
// If the block to select is inside a dropdown, we need to open the dropdown.
|
|
179
|
-
// Otherwise focus won't transfer to the block.
|
|
180
|
-
for (const parent of blockParents) {
|
|
181
|
-
await selectEditorBlock(parent);
|
|
182
|
-
}
|
|
183
|
-
} else {
|
|
184
|
-
// If clientId is already selected, it won't be focused (see block-wrapper.js)
|
|
185
|
-
// This removes the selection first to ensure the focus will always switch.
|
|
186
|
-
await selectEditorBlock(null);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
await selectEditorBlock(clientId);
|
|
190
|
-
onClose();
|
|
191
|
-
}
|
|
192
|
-
}, __('Go to block'))))));
|
|
162
|
+
})));
|
|
193
163
|
}
|
|
194
164
|
//# sourceMappingURL=block.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block.js"],"names":["classnames","__experimentalTreeGridCell","TreeGridCell","__experimentalTreeGridItem","TreeGridItem","MenuGroup","MenuItem","__","moreVertical","useState","useRef","useEffect","useDispatch","useSelect","ListViewLeaf","BlockMoverUpButton","BlockMoverDownButton","ListViewBlockContents","BlockSettingsDropdown","useListViewContext","store","blockEditorStore","ListViewBlock","block","isSelected","isDragged","isBranchSelected","isLastOfSelectedBranch","onClick","onToggleExpanded","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","cellRef","isHovered","setIsHovered","clientId","blockParents","select","getBlockParents","selectBlock","selectEditorBlock","toggleBlockHighlight","hasSiblings","hasRenderedMovers","moverCellClassName","__experimentalFeatures","withExperimentalFeatures","__experimentalPersistentListViewFeatures","withExperimentalPersistentListViewFeatures","isTreeGridMounted","listViewBlockSettingsClassName","current","focus","highlightBlock","onMouseEnter","onMouseLeave","classes","undefined","ref","tabIndex","onFocus","onClose","length","parent"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,0BAA0B,IAAIC,YAD/B,EAECC,0BAA0B,IAAIC,YAF/B,EAGCC,SAHD,EAICC,QAJD,QAKO,uBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASC,QAAT,EAAmBC,MAAnB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,SACCC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EF,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":["classnames","__experimentalTreeGridCell","TreeGridCell","__experimentalTreeGridItem","TreeGridItem","moreVertical","useState","useRef","useEffect","useDispatch","ListViewLeaf","BlockMoverUpButton","BlockMoverDownButton","ListViewBlockContents","BlockSettingsDropdown","useListViewContext","store","blockEditorStore","ListViewBlock","block","isSelected","isDragged","isBranchSelected","isLastOfSelectedBranch","onClick","onToggleExpanded","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","cellRef","isHovered","setIsHovered","clientId","toggleBlockHighlight","hasSiblings","hasRenderedMovers","moverCellClassName","__experimentalFeatures","withExperimentalFeatures","__experimentalPersistentListViewFeatures","withExperimentalPersistentListViewFeatures","isTreeGridMounted","listViewBlockSettingsClassName","current","focus","highlightBlock","onMouseEnter","onMouseLeave","classes","undefined","ref","tabIndex","onFocus","className"],"mappings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D,EAeC,cAAC,YAAD,QACG,CAAE;AAAEF,IAAAA,GAAF;AAAOC,IAAAA,QAAP;AAAiBC,IAAAA;AAAjB,GAAF,KACD,cAAC,oBAAD;AACC,IAAA,WAAW,EAAC,UADb;AAEC,IAAA,SAAS,EAAG,CAAEpB,QAAF,CAFb;AAGC,IAAA,GAAG,EAAGkB,GAHP;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,OAAO,EAAGC;AALX,IAFF,CAfD,CADD,CArCF,EAoEGd,wBAAwB,IACzB,cAAC,YAAD;AAAc,IAAA,SAAS,EAAGI;AAA1B,KACG,CAAE;AAAEQ,IAAAA,GAAF;AAAOC,IAAAA,QAAP;AAAiBC,IAAAA;AAAjB,GAAF,KACD,cAAC,qBAAD;AACC,IAAA,SAAS,EAAG,CAAEpB,QAAF,CADb;AAEC,IAAA,IAAI,EAAG/B,YAFR;AAGC,IAAA,WAAW,EAAG;AACbiD,MAAAA,GADa;AAEbG,MAAAA,SAAS,EAAE,oCAFE;AAGbF,MAAAA,QAHa;AAIbC,MAAAA;AAJa,KAHf;AASC,IAAA,sBAAsB,MATvB;AAUC,IAAA,yBAAyB,EAAGhC;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"]}
|
|
@@ -24,6 +24,7 @@ export default function ListViewListItem({
|
|
|
24
24
|
children
|
|
25
25
|
}) {
|
|
26
26
|
const blockType = getBlockType(block.name);
|
|
27
|
+
const blockLabel = blockType ? getBlockLabel(blockType, block.attributes) : null;
|
|
27
28
|
return createElement("div", {
|
|
28
29
|
className: "block-editor-list-view__list-item"
|
|
29
30
|
}, createElement(WrapperComponent, {
|
|
@@ -32,9 +33,9 @@ export default function ListViewListItem({
|
|
|
32
33
|
}),
|
|
33
34
|
onClick: onClick
|
|
34
35
|
}, createElement(BlockIcon, {
|
|
35
|
-
icon: blockType.icon,
|
|
36
|
+
icon: blockType === null || blockType === void 0 ? void 0 : blockType.icon,
|
|
36
37
|
showColors: true
|
|
37
|
-
}), children ? children :
|
|
38
|
+
}), children ? children : blockLabel, isSelected && createElement(VisuallyHidden, {
|
|
38
39
|
as: "span"
|
|
39
40
|
}, __('(selected block)'))));
|
|
40
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/list-item.js"],"names":["classnames","Button","VisuallyHidden","__experimentalGetBlockLabel","getBlockLabel","getBlockType","__","BlockIcon","ListViewListItem","block","onClick","isSelected","wrapperComponent","WrapperComponent","children","blockType","name","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/list-view/list-item.js"],"names":["classnames","Button","VisuallyHidden","__experimentalGetBlockLabel","getBlockLabel","getBlockType","__","BlockIcon","ListViewListItem","block","onClick","isSelected","wrapperComponent","WrapperComponent","children","blockType","name","blockLabel","attributes","icon","defaultProps","props"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,cAAjB,QAAuC,uBAAvC;AACA,SACCC,2BAA2B,IAAIC,aADhC,EAECC,YAFD,QAGO,mBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AAEA,eAAe,SAASC,gBAAT,CAA2B;AACzCC,EAAAA,KADyC;AAEzCC,EAAAA,OAFyC;AAGzCC,EAAAA,UAHyC;AAIzCC,EAAAA,gBAAgB,EAAEC,gBAJuB;AAKzCC,EAAAA;AALyC,CAA3B,EAMX;AACH,QAAMC,SAAS,GAAGV,YAAY,CAAEI,KAAK,CAACO,IAAR,CAA9B;AACA,QAAMC,UAAU,GAAGF,SAAS,GACzBX,aAAa,CAAEW,SAAF,EAAaN,KAAK,CAACS,UAAnB,CADY,GAEzB,IAFH;AAIA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,gBAAD;AACC,IAAA,SAAS,EAAGlB,UAAU,CACrB,0CADqB,EAErB;AACC,qBAAeW;AADhB,KAFqB,CADvB;AAOC,IAAA,OAAO,EAAGD;AAPX,KASC,cAAC,SAAD;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,cAAC,cAAD;AAAgB,IAAA,EAAE,EAAC;AAAnB,KACGL,EAAE,CAAE,kBAAF,CADL,CAZF,CADD,CADD;AAqBA;AAEDE,gBAAgB,CAACY,YAAjB,GAAgC;AAC/BV,EAAAA,OAAO,EAAE,MAAM,CAAE,CADc;AAE/BE,EAAAA,gBAAgB,EAAIS,KAAF,IAAa,cAAC,MAAD,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"]}
|
|
@@ -71,7 +71,10 @@ export function MediaPlaceholder({
|
|
|
71
71
|
onDoubleClick,
|
|
72
72
|
onFilesPreUpload = noop,
|
|
73
73
|
onHTMLDrop = noop,
|
|
74
|
-
children
|
|
74
|
+
children,
|
|
75
|
+
mediaLibraryButton,
|
|
76
|
+
placeholder,
|
|
77
|
+
style
|
|
75
78
|
}) {
|
|
76
79
|
const mediaUpload = useSelect(select => {
|
|
77
80
|
const {
|
|
@@ -183,7 +186,7 @@ export function MediaPlaceholder({
|
|
|
183
186
|
onFilesUpload(event.target.files);
|
|
184
187
|
};
|
|
185
188
|
|
|
186
|
-
const
|
|
189
|
+
const defaultRenderPlaceholder = content => {
|
|
187
190
|
let {
|
|
188
191
|
instructions,
|
|
189
192
|
title
|
|
@@ -236,10 +239,13 @@ export function MediaPlaceholder({
|
|
|
236
239
|
className: placeholderClassName,
|
|
237
240
|
notices: notices,
|
|
238
241
|
onDoubleClick: onDoubleClick,
|
|
239
|
-
preview: mediaPreview
|
|
242
|
+
preview: mediaPreview,
|
|
243
|
+
style: style
|
|
240
244
|
}, content, children);
|
|
241
245
|
};
|
|
242
246
|
|
|
247
|
+
const renderPlaceholder = placeholder !== null && placeholder !== void 0 ? placeholder : defaultRenderPlaceholder;
|
|
248
|
+
|
|
243
249
|
const renderDropZone = () => {
|
|
244
250
|
if (disableDropZone) {
|
|
245
251
|
return null;
|
|
@@ -277,7 +283,19 @@ export function MediaPlaceholder({
|
|
|
277
283
|
};
|
|
278
284
|
|
|
279
285
|
const renderMediaUploadChecked = () => {
|
|
280
|
-
const
|
|
286
|
+
const defaultButton = ({
|
|
287
|
+
open
|
|
288
|
+
}) => {
|
|
289
|
+
return createElement(Button, {
|
|
290
|
+
variant: "tertiary",
|
|
291
|
+
onClick: () => {
|
|
292
|
+
open();
|
|
293
|
+
}
|
|
294
|
+
}, __('Media Library'));
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const libraryButton = mediaLibraryButton !== null && mediaLibraryButton !== void 0 ? mediaLibraryButton : defaultButton;
|
|
298
|
+
const uploadMediaLibraryButton = createElement(MediaUpload, {
|
|
281
299
|
addToGallery: addToGallery,
|
|
282
300
|
gallery: multiple && onlyAllowsImages(),
|
|
283
301
|
multiple: multiple,
|
|
@@ -286,16 +304,7 @@ export function MediaPlaceholder({
|
|
|
286
304
|
value: Array.isArray(value) ? value.map(({
|
|
287
305
|
id
|
|
288
306
|
}) => id) : value.id,
|
|
289
|
-
render:
|
|
290
|
-
open
|
|
291
|
-
}) => {
|
|
292
|
-
return createElement(Button, {
|
|
293
|
-
variant: "tertiary",
|
|
294
|
-
onClick: () => {
|
|
295
|
-
open();
|
|
296
|
-
}
|
|
297
|
-
}, __('Media Library'));
|
|
298
|
-
}
|
|
307
|
+
render: libraryButton
|
|
299
308
|
});
|
|
300
309
|
|
|
301
310
|
if (mediaUpload && isAppender) {
|
|
@@ -310,7 +319,7 @@ export function MediaPlaceholder({
|
|
|
310
319
|
variant: "primary",
|
|
311
320
|
className: classnames('block-editor-media-placeholder__button', 'block-editor-media-placeholder__upload-button'),
|
|
312
321
|
onClick: openFileDialog
|
|
313
|
-
}, __('Upload')),
|
|
322
|
+
}, __('Upload')), uploadMediaLibraryButton, renderUrlSelectionUI(), renderCancelLink());
|
|
314
323
|
return renderPlaceholder(content);
|
|
315
324
|
}
|
|
316
325
|
}));
|
|
@@ -323,11 +332,11 @@ export function MediaPlaceholder({
|
|
|
323
332
|
onChange: onUpload,
|
|
324
333
|
accept: accept,
|
|
325
334
|
multiple: multiple
|
|
326
|
-
}, __('Upload')),
|
|
335
|
+
}, __('Upload')), uploadMediaLibraryButton, renderUrlSelectionUI(), renderCancelLink());
|
|
327
336
|
return renderPlaceholder(content);
|
|
328
337
|
}
|
|
329
338
|
|
|
330
|
-
return renderPlaceholder(
|
|
339
|
+
return renderPlaceholder(uploadMediaLibraryButton);
|
|
331
340
|
};
|
|
332
341
|
|
|
333
342
|
if (dropZoneUIOnly || disableMediaButtons) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/media-placeholder/index.js"],"names":["noop","classnames","Button","FormFileUpload","Placeholder","DropZone","withFilters","__","useState","useEffect","useSelect","deprecated","keyboardReturn","MediaUpload","MediaUploadCheck","URLPopover","store","blockEditorStore","InsertFromURLPopover","src","onChange","onSubmit","onClose","MediaPlaceholder","value","allowedTypes","className","icon","labels","mediaPreview","notices","isAppender","accept","addToGallery","multiple","handleUpload","dropZoneUIOnly","disableDropZone","disableMediaButtons","onError","onSelect","onCancel","onSelectURL","onDoubleClick","onFilesPreUpload","onHTMLDrop","children","mediaUpload","select","getSettings","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","renderMediaUploadChecked","mediaLibraryButton","Array","isArray","open","openFileDialog","since","alternative"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,MADD,EAECC,cAFD,EAGCC,WAHD,EAICC,QAJD,EAKCC,WALD,QAMO,uBANP;AAOA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,cAAT,QAA+B,kBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,gBAAP,MAA6B,uBAA7B;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;;AAEA,MAAMC,oBAAoB,GAAG,CAAE;AAAEC,EAAAA,GAAF;AAAOC,EAAAA,QAAP;AAAiBC,EAAAA,QAAjB;AAA2BC,EAAAA;AAA3B,CAAF,KAC5B,cAAC,UAAD;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,gBAAad,EAAE,CAAE,KAAF,CAHhB;AAIC,EAAA,WAAW,EAAGA,EAA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AAU,CAAE,qDAAF,EAAyD;AAClEkG,QAAAA,KAAK,EAAE,KAD2D;AAElEC,QAAAA,WAAW,EAAE;AAFqD,OAAzD,CAAV;AAIA;;AAED,WAAO,cAAC,gBAAD,QAAoBV,cAAc,EAAlC,CAAP;AACA;;AAED,SACC,cAAC,gBAAD;AACC,IAAA,QAAQ,EAAGZ,iBAAiB,CAAEc,oBAAoB,EAAtB;AAD7B,KAGGC,wBAAwB,EAH3B,CADD;AAOA;AAED;AACA;AACA;;AACA,eAAejG,WAAW,CAAE,yBAAF,CAAX,CAA0CiB,gBAA1C,CAAf","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":["noop","classnames","Button","FormFileUpload","Placeholder","DropZone","withFilters","__","useState","useEffect","useSelect","deprecated","keyboardReturn","MediaUpload","MediaUploadCheck","URLPopover","store","blockEditorStore","InsertFromURLPopover","src","onChange","onSubmit","onClose","MediaPlaceholder","value","allowedTypes","className","icon","labels","mediaPreview","notices","isAppender","accept","addToGallery","multiple","handleUpload","dropZoneUIOnly","disableDropZone","disableMediaButtons","onError","onSelect","onCancel","onSelectURL","onDoubleClick","onFilesPreUpload","onHTMLDrop","children","mediaLibraryButton","placeholder","style","mediaUpload","select","getSettings","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":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,MADD,EAECC,cAFD,EAGCC,WAHD,EAICC,QAJD,EAKCC,WALD,QAMO,uBANP;AAOA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,cAAT,QAA+B,kBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,gBAAP,MAA6B,uBAA7B;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;;AAEA,MAAMC,oBAAoB,GAAG,CAAE;AAAEC,EAAAA,GAAF;AAAOC,EAAAA,QAAP;AAAiBC,EAAAA,QAAjB;AAA2BC,EAAAA;AAA3B,CAAF,KAC5B,cAAC,UAAD;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,gBAAad,EAAE,CAAE,KAAF,CAHhB;AAIC,EAAA,WAAW,EAAGA,EAAE,CAAE,mBAAF,CAJjB;AAKC,EAAA,QAAQ,EAAGa,QALZ;AAMC,EAAA,KAAK,EAAGD;AANT,EAJD,EAYC,cAAC,MAAD;AACC,EAAA,SAAS,EAAC,yDADX;AAEC,EAAA,IAAI,EAAGP,cAFR;AAGC,EAAA,KAAK,EAAGL,EAAE,CAAE,O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AxFD;;AA0FA,MAAK3E,cAAc,IAAIE,mBAAvB,EAA6C;AAC5C,QAAKF,cAAL,EAAsB;AACrBzB,MAAAA,UAAU,CAAE,qDAAF,EAAyD;AAClEwG,QAAAA,KAAK,EAAE,KAD2D;AAElEC,QAAAA,WAAW,EAAE;AAFqD,OAAzD,CAAV;AAIA;;AAED,WAAO,cAAC,gBAAD,QAAoBZ,cAAc,EAAlC,CAAP;AACA;;AAED,SACC,cAAC,gBAAD;AACC,IAAA,QAAQ,EAAGD,iBAAiB,CAAEG,oBAAoB,EAAtB;AAD7B,KAGGC,wBAAwB,EAH3B,CADD;AAOA;AAED;AACA;AACA;;AACA,eAAerG,WAAW,CAAE,yBAAF,CAAX,CAA0CiB,gBAA1C,CAAf","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"]}
|
|
@@ -36,7 +36,8 @@ const MediaReplaceFlow = ({
|
|
|
36
36
|
onFilesUpload = noop,
|
|
37
37
|
name = __('Replace'),
|
|
38
38
|
createNotice,
|
|
39
|
-
removeNotice
|
|
39
|
+
removeNotice,
|
|
40
|
+
children
|
|
40
41
|
}) => {
|
|
41
42
|
const [mediaURLValue, setMediaURLValue] = useState(mediaURL);
|
|
42
43
|
const mediaUpload = useSelect(select => {
|
|
@@ -148,7 +149,7 @@ const MediaReplaceFlow = ({
|
|
|
148
149
|
}
|
|
149
150
|
}, __('Upload'));
|
|
150
151
|
}
|
|
151
|
-
}))), onSelectURL && // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
152
|
+
})), children), onSelectURL && // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
152
153
|
createElement("form", {
|
|
153
154
|
className: "block-editor-media-flow__url-input"
|
|
154
155
|
}, createElement("span", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/media-replace-flow/index.js"],"names":["uniqueId","noop","useState","createRef","renderToString","__","speak","FormFileUpload","NavigableMenu","MenuItem","ToolbarButton","Dropdown","withFilters","withDispatch","useSelect","DOWN","compose","upload","media","mediaIcon","store","noticesStore","MediaUpload","MediaUploadCheck","LinkControl","blockEditorStore","MediaReplaceFlow","mediaURL","mediaId","allowedTypes","accept","onSelect","onSelectURL","onFilesUpload","name","createNotice","removeNotice","mediaURLValue","setMediaURLValue","mediaUpload","select","getSettings","editMediaButtonRef","errorNoticeID","onError","message","errorElement","document","createElement","innerHTML","renderMsg","textContent","innerText","setTimeout","id","isDismissible","selectMedia","url","selectURL","newURL","uploadFiles","event","files","target","setMedia","filesList","onFileChange","openOnArrowDown","keyCode","preventDefault","click","POPOVER_PROPS","isAlternate","isOpen","onToggle","onClose","open","openFileDialog","current","focus","dispatch"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,IAAnB,QAA+B,QAA/B;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,cAA9B,QAAoD,oBAApD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SACCC,cADD,EAECC,aAFD,EAGCC,QAHD,EAICC,aAJD,EAKCC,QALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SAASC,YAAT,EAAuBC,SAAvB,QAAwC,iBAAxC;AACA,SAASC,IAAT,QAAqB,qBAArB;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,MAAT,EAAiBC,KAAK,IAAIC,SAA1B,QAA2C,kBAA3C;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,OAAOC,WAAP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ACG3B,EAAE,CAAE,oBAAF,CADL,CADD,EAIC,cAAC,WAAD;AACC,MAAA,KAAK,EAAG;AAAEoD,QAAAA,GAAG,EAAEpB;AAAP,OADT;AAEC,MAAA,QAAQ,EAAG,EAFZ;AAGC,MAAA,eAAe,EAAG,KAHnB;AAIC,MAAA,QAAQ,EAAG,CAAE;AAAEoB,QAAAA;AAAF,OAAF,KAAe;AACzBnB,QAAAA,gBAAgB,CAAEmB,GAAF,CAAhB;AACAC,QAAAA,SAAS,CAAED,GAAF,CAAT;AACAf,QAAAA,kBAAkB,CAACoC,OAAnB,CAA2BC,KAA3B;AACA;AARF,MAJD,CAnCF;AAfF,IADD;AAuEA,CAzJD;;AA2JA,eAAe/D,OAAO,CAAE,CACvBH,YAAY,CAAImE,QAAF,IAAgB;AAC7B,QAAM;AAAE7C,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAiC4C,QAAQ,CAAE3D,YAAF,CAA/C;AACA,SAAO;AACNc,IAAAA,YADM;AAENC,IAAAA;AAFM,GAAP;AAIA,CANW,CADW,EAQvBxB,WAAW,CAAE,yBAAF,CARY,CAAF,CAAP,CASVc,gBATU,CAAf","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":["uniqueId","noop","useState","createRef","renderToString","__","speak","FormFileUpload","NavigableMenu","MenuItem","ToolbarButton","Dropdown","withFilters","withDispatch","useSelect","DOWN","compose","upload","media","mediaIcon","store","noticesStore","MediaUpload","MediaUploadCheck","LinkControl","blockEditorStore","MediaReplaceFlow","mediaURL","mediaId","allowedTypes","accept","onSelect","onSelectURL","onFilesUpload","name","createNotice","removeNotice","children","mediaURLValue","setMediaURLValue","mediaUpload","select","getSettings","editMediaButtonRef","errorNoticeID","onError","message","errorElement","document","createElement","innerHTML","renderMsg","textContent","innerText","setTimeout","id","isDismissible","selectMedia","url","selectURL","newURL","uploadFiles","event","files","target","setMedia","filesList","onFileChange","openOnArrowDown","keyCode","preventDefault","click","POPOVER_PROPS","isAlternate","isOpen","onToggle","onClose","open","openFileDialog","current","focus","dispatch"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,IAAnB,QAA+B,QAA/B;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,cAA9B,QAAoD,oBAApD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SACCC,cADD,EAECC,aAFD,EAGCC,QAHD,EAICC,aAJD,EAKCC,QALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SAASC,YAAT,EAAuBC,SAAvB,QAAwC,iBAAxC;AACA,SAASC,IAAT,QAAqB,qBAArB;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,MAAT,EAAiBC,KAAK,IAAIC,SAA1B,QAA2C,kBAA3C;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAA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ACZ;AACA;AAAM,MAAA,SAAS,EAAC;AAAhB,OACC;AAAM,MAAA,SAAS,EAAC;AAAhB,OACG3B,EAAE,CAAE,oBAAF,CADL,CADD,EAIC,cAAC,WAAD;AACC,MAAA,KAAK,EAAG;AAAEqD,QAAAA,GAAG,EAAEpB;AAAP,OADT;AAEC,MAAA,QAAQ,EAAG,EAFZ;AAGC,MAAA,eAAe,EAAG,KAHnB;AAIC,MAAA,QAAQ,EAAG,CAAE;AAAEoB,QAAAA;AAAF,OAAF,KAAe;AACzBnB,QAAAA,gBAAgB,CAAEmB,GAAF,CAAhB;AACAC,QAAAA,SAAS,CAAED,GAAF,CAAT;AACAf,QAAAA,kBAAkB,CAACoC,OAAnB,CAA2BC,KAA3B;AACA;AARF,MAJD,CApCF;AAfF,IADD;AAwEA,CA3JD;;AA6JA,eAAehE,OAAO,CAAE,CACvBH,YAAY,CAAIoE,QAAF,IAAgB;AAC7B,QAAM;AAAE9C,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAiC6C,QAAQ,CAAE5D,YAAF,CAA/C;AACA,SAAO;AACNc,IAAAA,YADM;AAENC,IAAAA;AAFM,GAAP;AAIA,CANW,CADW,EAQvBxB,WAAW,CAAE,yBAAF,CARY,CAAF,CAAP,CASVc,gBATU,CAAf","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"]}
|
|
@@ -4,12 +4,13 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
/**
|
|
5
5
|
* External dependencies
|
|
6
6
|
*/
|
|
7
|
-
import { TextInput, Platform } from 'react-native';
|
|
7
|
+
import { TextInput, Platform, Dimensions } from 'react-native';
|
|
8
8
|
/**
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { Component } from '@wordpress/element';
|
|
13
|
+
import { getPxFromCssUnit } from '@wordpress/block-editor';
|
|
13
14
|
/**
|
|
14
15
|
* Internal dependencies
|
|
15
16
|
*/
|
|
@@ -59,7 +60,33 @@ export default class PlainText extends Component {
|
|
|
59
60
|
this._input.blur();
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
getFontSize() {
|
|
64
|
+
const {
|
|
65
|
+
style
|
|
66
|
+
} = this.props;
|
|
67
|
+
|
|
68
|
+
if (!(style !== null && style !== void 0 && style.fontSize)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const {
|
|
73
|
+
width,
|
|
74
|
+
height
|
|
75
|
+
} = Dimensions.get('window');
|
|
76
|
+
const cssUnitOptions = {
|
|
77
|
+
height,
|
|
78
|
+
width
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
fontSize: parseFloat(getPxFromCssUnit(style.fontSize, cssUnitOptions))
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
62
85
|
render() {
|
|
86
|
+
const {
|
|
87
|
+
style
|
|
88
|
+
} = this.props;
|
|
89
|
+
const textStyles = [style || styles['block-editor-plain-text'], this.getFontSize()];
|
|
63
90
|
return createElement(TextInput, _extends({}, this.props, {
|
|
64
91
|
ref: x => this._input = x,
|
|
65
92
|
onChange: event => {
|
|
@@ -70,7 +97,7 @@ export default class PlainText extends Component {
|
|
|
70
97
|
onBlur: this.props.onBlur // always assign onBlur as a props
|
|
71
98
|
,
|
|
72
99
|
fontFamily: this.props.style && this.props.style.fontFamily || styles['block-editor-plain-text'].fontFamily,
|
|
73
|
-
style:
|
|
100
|
+
style: textStyles,
|
|
74
101
|
scrollEnabled: false
|
|
75
102
|
}));
|
|
76
103
|
}
|