@wordpress/block-library 9.29.1-next.e256d081a.0 → 9.29.1-next.f34ab90e9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/audio/edit.js +1 -3
- package/build/audio/edit.js.map +1 -1
- package/build/image/image.js +1 -1
- package/build/image/image.js.map +1 -1
- package/build/query/edit/index.js.map +1 -1
- package/build/query/edit/query-content.js +6 -7
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +9 -30
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/edit/query-toolbar.js +2 -4
- package/build/query/edit/query-toolbar.js.map +1 -1
- package/build/template-part/edit/placeholder.js +1 -2
- package/build/template-part/edit/placeholder.js.map +1 -1
- package/build/video/edit.js +1 -3
- package/build/video/edit.js.map +1 -1
- package/build-module/audio/edit.js +2 -4
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/image/image.js +1 -1
- package/build-module/image/image.js.map +1 -1
- package/build-module/query/edit/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +7 -8
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +10 -30
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/edit/query-toolbar.js +2 -4
- package/build-module/query/edit/query-toolbar.js.map +1 -1
- package/build-module/template-part/edit/placeholder.js +1 -2
- package/build-module/template-part/edit/placeholder.js.map +1 -1
- package/build-module/video/edit.js +2 -4
- package/build-module/video/edit.js.map +1 -1
- package/build-style/editor-rtl.css +0 -4
- package/build-style/editor.css +0 -4
- package/build-style/query/editor-rtl.css +0 -4
- package/build-style/query/editor.css +0 -4
- package/package.json +35 -35
- package/src/audio/edit.js +1 -6
- package/src/image/image.js +1 -2
- package/src/query/edit/index.js +0 -1
- package/src/query/edit/query-content.js +4 -8
- package/src/query/edit/query-placeholder.js +17 -47
- package/src/query/edit/query-toolbar.js +2 -10
- package/src/query/editor.scss +1 -6
- package/src/template-part/edit/placeholder.js +1 -2
- package/src/video/edit.js +1 -6
|
@@ -11,14 +11,12 @@ import PatternSelection, { useBlockPatterns } from './pattern-selection';
|
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
export default function QueryToolbar({
|
|
13
13
|
clientId,
|
|
14
|
-
attributes
|
|
15
|
-
hasInnerBlocks
|
|
14
|
+
attributes
|
|
16
15
|
}) {
|
|
17
16
|
const hasPatterns = useBlockPatterns(clientId, attributes).length;
|
|
18
17
|
if (!hasPatterns) {
|
|
19
18
|
return null;
|
|
20
19
|
}
|
|
21
|
-
const buttonLabel = hasInnerBlocks ? __('Change design') : __('Choose pattern');
|
|
22
20
|
return /*#__PURE__*/_jsx(ToolbarGroup, {
|
|
23
21
|
className: "wp-block-template-part__block-control-group",
|
|
24
22
|
children: /*#__PURE__*/_jsx(DropdownContentWrapper, {
|
|
@@ -33,7 +31,7 @@ export default function QueryToolbar({
|
|
|
33
31
|
"aria-haspopup": "true",
|
|
34
32
|
"aria-expanded": isOpen,
|
|
35
33
|
onClick: onToggle,
|
|
36
|
-
children:
|
|
34
|
+
children: __('Change design')
|
|
37
35
|
}),
|
|
38
36
|
renderContent: () => /*#__PURE__*/_jsx(PatternSelection, {
|
|
39
37
|
clientId: clientId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ToolbarGroup","ToolbarButton","Dropdown","__experimentalDropdownContentWrapper","DropdownContentWrapper","__","PatternSelection","useBlockPatterns","jsx","_jsx","QueryToolbar","clientId","attributes","
|
|
1
|
+
{"version":3,"names":["ToolbarGroup","ToolbarButton","Dropdown","__experimentalDropdownContentWrapper","DropdownContentWrapper","__","PatternSelection","useBlockPatterns","jsx","_jsx","QueryToolbar","clientId","attributes","hasPatterns","length","className","children","contentClassName","focusOnMount","expandOnMobile","renderToggle","isOpen","onToggle","onClick","renderContent","showSearch","showTitlesAsTooltip"],"sources":["@wordpress/block-library/src/query/edit/query-toolbar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tDropdown,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PatternSelection, { useBlockPatterns } from './pattern-selection';\n\nexport default function QueryToolbar( { clientId, attributes } ) {\n\tconst hasPatterns = useBlockPatterns( clientId, attributes ).length;\n\tif ( ! hasPatterns ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ToolbarGroup className=\"wp-block-template-part__block-control-group\">\n\t\t\t<DropdownContentWrapper>\n\t\t\t\t<Dropdown\n\t\t\t\t\tcontentClassName=\"block-editor-block-settings-menu__popover\"\n\t\t\t\t\tfocusOnMount=\"firstElement\"\n\t\t\t\t\texpandOnMobile\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Change design' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ () => (\n\t\t\t\t\t\t<PatternSelection\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\t\tshowSearch={ false }\n\t\t\t\t\t\t\tshowTitlesAsTooltip\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</DropdownContentWrapper>\n\t\t</ToolbarGroup>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,YAAY,EACZC,aAAa,EACbC,QAAQ,EACRC,oCAAoC,IAAIC,sBAAsB,QACxD,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,gBAAgB,IAAIC,gBAAgB,QAAQ,qBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEzE,eAAe,SAASC,YAAYA,CAAE;EAAEC,QAAQ;EAAEC;AAAW,CAAC,EAAG;EAChE,MAAMC,WAAW,GAAGN,gBAAgB,CAAEI,QAAQ,EAAEC,UAAW,CAAC,CAACE,MAAM;EACnE,IAAK,CAAED,WAAW,EAAG;IACpB,OAAO,IAAI;EACZ;EAEA,oBACCJ,IAAA,CAACT,YAAY;IAACe,SAAS,EAAC,6CAA6C;IAAAC,QAAA,eACpEP,IAAA,CAACL,sBAAsB;MAAAY,QAAA,eACtBP,IAAA,CAACP,QAAQ;QACRe,gBAAgB,EAAC,2CAA2C;QAC5DC,YAAY,EAAC,cAAc;QAC3BC,cAAc;QACdC,YAAY,EAAGA,CAAE;UAAEC,MAAM;UAAEC;QAAS,CAAC,kBACpCb,IAAA,CAACR,aAAa;UACb,iBAAc,MAAM;UACpB,iBAAgBoB,MAAQ;UACxBE,OAAO,EAAGD,QAAU;UAAAN,QAAA,EAElBX,EAAE,CAAE,eAAgB;QAAC,CACT,CACb;QACHmB,aAAa,EAAGA,CAAA,kBACff,IAAA,CAACH,gBAAgB;UAChBK,QAAQ,EAAGA,QAAU;UACrBC,UAAU,EAAGA,UAAY;UACzBa,UAAU,EAAG,KAAO;UACpBC,mBAAmB;QAAA,CACnB;MACC,CACH;IAAC,CACqB;EAAC,CACZ,CAAC;AAEjB","ignoreList":[]}
|
|
@@ -12,7 +12,6 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
12
12
|
*/
|
|
13
13
|
import { useAlternativeBlockPatterns, useAlternativeTemplateParts, useCreateTemplatePartFromBlocks, useTemplatePartArea } from './utils/hooks';
|
|
14
14
|
import TitleModal from './title-modal';
|
|
15
|
-
import { getTemplatePartIcon } from './utils/get-template-part-icon';
|
|
16
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
16
|
export default function TemplatePartPlaceholder({
|
|
18
17
|
area,
|
|
@@ -46,7 +45,7 @@ export default function TemplatePartPlaceholder({
|
|
|
46
45
|
const areaObject = useTemplatePartArea(area);
|
|
47
46
|
const createFromBlocks = useCreateTemplatePartFromBlocks(area, setAttributes);
|
|
48
47
|
return /*#__PURE__*/_jsxs(Placeholder, {
|
|
49
|
-
icon:
|
|
48
|
+
icon: areaObject.icon,
|
|
50
49
|
label: areaObject.label,
|
|
51
50
|
instructions: isBlockBasedTheme ? sprintf(
|
|
52
51
|
// Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","sprintf","Placeholder","Button","Spinner","useState","useSelect","store","coreStore","useAlternativeBlockPatterns","useAlternativeTemplateParts","useCreateTemplatePartFromBlocks","useTemplatePartArea","TitleModal","
|
|
1
|
+
{"version":3,"names":["__","sprintf","Placeholder","Button","Spinner","useState","useSelect","store","coreStore","useAlternativeBlockPatterns","useAlternativeTemplateParts","useCreateTemplatePartFromBlocks","useTemplatePartArea","TitleModal","jsx","_jsx","jsxs","_jsxs","TemplatePartPlaceholder","area","clientId","templatePartId","onOpenSelectionModal","setAttributes","templateParts","isResolving","blockPatterns","isBlockBasedTheme","canCreateTemplatePart","select","getCurrentTheme","canUser","is_block_theme","kind","name","showTitleModal","setShowTitleModal","areaObject","createFromBlocks","icon","label","instructions","toLowerCase","children","length","__next40pxDefaultSize","variant","onClick","areaLabel","onClose","onSubmit","title"],"sources":["@wordpress/block-library/src/template-part/edit/placeholder.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Placeholder, Button, Spinner } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseCreateTemplatePartFromBlocks,\n\tuseTemplatePartArea,\n} from './utils/hooks';\nimport TitleModal from './title-modal';\n\nexport default function TemplatePartPlaceholder( {\n\tarea,\n\tclientId,\n\ttemplatePartId,\n\tonOpenSelectionModal,\n\tsetAttributes,\n} ) {\n\tconst { templateParts, isResolving } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\n\tconst { isBlockBasedTheme, canCreateTemplatePart } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentTheme, canUser } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tisBlockBasedTheme: getCurrentTheme()?.is_block_theme,\n\t\t\t\tcanCreateTemplatePart: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template_part',\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst [ showTitleModal, setShowTitleModal ] = useState( false );\n\tconst areaObject = useTemplatePartArea( area );\n\tconst createFromBlocks = useCreateTemplatePartFromBlocks(\n\t\tarea,\n\t\tsetAttributes\n\t);\n\n\treturn (\n\t\t<Placeholder\n\t\t\ticon={ areaObject.icon }\n\t\t\tlabel={ areaObject.label }\n\t\t\tinstructions={\n\t\t\t\tisBlockBasedTheme\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t\t__( 'Choose an existing %s or create a new one.' ),\n\t\t\t\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t\t__( 'Choose an existing %s.' ),\n\t\t\t\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t\t\t )\n\t\t\t}\n\t\t>\n\t\t\t{ isResolving && <Spinner /> }\n\n\t\t\t{ ! isResolving &&\n\t\t\t\t!! ( templateParts.length || blockPatterns.length ) && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ onOpenSelectionModal }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t{ ! isResolving && isBlockBasedTheme && canCreateTemplatePart && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowTitleModal( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ showTitleModal && (\n\t\t\t\t<TitleModal\n\t\t\t\t\tareaLabel={ areaObject.label }\n\t\t\t\t\tonClose={ () => setShowTitleModal( false ) }\n\t\t\t\t\tonSubmit={ ( title ) => {\n\t\t\t\t\t\tcreateFromBlocks( [], title );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Placeholder>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,EAAEC,MAAM,EAAEC,OAAO,QAAQ,uBAAuB;AACpE,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SACCC,2BAA2B,EAC3BC,2BAA2B,EAC3BC,+BAA+B,EAC/BC,mBAAmB,QACb,eAAe;AACtB,OAAOC,UAAU,MAAM,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEvC,eAAe,SAASC,uBAAuBA,CAAE;EAChDC,IAAI;EACJC,QAAQ;EACRC,c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ID,aAAa,CAACoB,MAAM,IAAIlB,aAAa,CAACkB,MAAM,CAAE,iBAClD7B,IAAA,CAACZ,MAAM;MACN0C,qBAAqB;MACrBC,OAAO,EAAC,SAAS;MACjBC,OAAO,EAAGzB,oBAAsB;MAAAqB,QAAA,EAE9B3C,EAAE,CAAE,QAAS;IAAC,CACT,CACR,EAEA,CAAEyB,WAAW,IAAIE,iBAAiB,IAAIC,qBAAqB,iBAC5Db,IAAA,CAACZ,MAAM;MACN0C,qBAAqB;MACrBC,OAAO,EAAC,WAAW;MACnBC,OAAO,EAAGA,CAAA,KAAM;QACfX,iBAAiB,CAAE,IAAK,CAAC;MAC1B,CAAG;MAAAO,QAAA,EAED3C,EAAE,CAAE,aAAc;IAAC,CACd,CACR,EACCmC,cAAc,iBACfpB,IAAA,CAACF,UAAU;MACVmC,SAAS,EAAGX,UAAU,CAACG,KAAO;MAC9BS,OAAO,EAAGA,CAAA,KAAMb,iBAAiB,CAAE,KAAM,CAAG;MAC5Cc,QAAQ,EAAKC,KAAK,IAAM;QACvBb,gBAAgB,CAAE,EAAE,EAAEa,KAAM,CAAC;MAC9B;IAAG,CACH,CACD;EAAA,CACW,CAAC;AAEhB","ignoreList":[]}
|
|
@@ -8,7 +8,7 @@ import clsx from 'clsx';
|
|
|
8
8
|
*/
|
|
9
9
|
import { isBlobURL } from '@wordpress/blob';
|
|
10
10
|
import { Disabled, Spinner, Placeholder, __experimentalToolsPanel as ToolsPanel } from '@wordpress/components';
|
|
11
|
-
import { BlockControls, BlockIcon, InspectorControls, MediaPlaceholder, MediaReplaceFlow, useBlockProps
|
|
11
|
+
import { BlockControls, BlockIcon, InspectorControls, MediaPlaceholder, MediaReplaceFlow, useBlockProps } from '@wordpress/block-editor';
|
|
12
12
|
import { useRef, useEffect, useState } from '@wordpress/element';
|
|
13
13
|
import { __ } from '@wordpress/i18n';
|
|
14
14
|
import { useDispatch } from '@wordpress/data';
|
|
@@ -45,8 +45,6 @@ function VideoEdit({
|
|
|
45
45
|
} = attributes;
|
|
46
46
|
const [temporaryURL, setTemporaryURL] = useState(attributes.blob);
|
|
47
47
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
48
|
-
const blockEditingMode = useBlockEditingMode();
|
|
49
|
-
const hasNonContentControls = blockEditingMode === 'default';
|
|
50
48
|
useUploadMediaFromBlobURL({
|
|
51
49
|
url: temporaryURL,
|
|
52
50
|
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
@@ -224,7 +222,7 @@ function VideoEdit({
|
|
|
224
222
|
isSelected: isSingleSelected,
|
|
225
223
|
insertBlocksAfter: insertBlocksAfter,
|
|
226
224
|
label: __('Video caption text'),
|
|
227
|
-
showToolbarButton: isSingleSelected
|
|
225
|
+
showToolbarButton: isSingleSelected
|
|
228
226
|
})]
|
|
229
227
|
})]
|
|
230
228
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","isBlobURL","Disabled","Spinner","Placeholder","__experimentalToolsPanel","ToolsPanel","BlockControls","BlockIcon","InspectorControls","MediaPlaceholder","MediaReplaceFlow","useBlockProps","useBlockEditingMode","useRef","useEffect","useState","__","useDispatch","video","icon","store","noticesStore","createUpgradedEmbedBlock","useUploadMediaFromBlobURL","useToolsPanelDropdownMenuProps","VideoCommonSettings","TracksEditor","Tracks","Caption","PosterImage","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ALLOWED_MEDIA_TYPES","VideoEdit","isSelected","isSingleSelected","attributes","className","setAttributes","insertBlocksAfter","onReplace","videoPlayer","id","controls","poster","src","tracks","temporaryURL","setTemporaryURL","blob","dropdownMenuProps","blockEditingMode","hasNonContentControls","url","allowedTypes","onChange","onSelectVideo","onError","onUploadError","current","load","media","undefined","caption","image","onSelectURL","newSrc","embedBlock","createErrorNotice","message","type","placeholder","content","withIllustration","label","instructions","children","classes","blockProps","onSelect","accept","value","newTracks","group","mediaId","mediaURL","onReset","resetAll","autoplay","loop","muted","playsInline","preload","posterImage","isDisabled","ref","showToolbarButton"],"sources":["@wordpress/block-library/src/video/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tDisabled,\n\tSpinner,\n\tPlaceholder,\n\t__experimentalToolsPanel as ToolsPanel,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { video as icon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport {\n\tuseUploadMediaFromBlobURL,\n\tuseToolsPanelDropdownMenuProps,\n} from '../utils/hooks';\nimport VideoCommonSettings from './edit-common-settings';\nimport TracksEditor from './tracks-editor';\nimport Tracks from './tracks';\nimport { Caption } from '../utils/caption';\nimport PosterImage from '../utils/poster-image';\n\nconst ALLOWED_MEDIA_TYPES = [ 'video' ];\n\nfunction VideoEdit( {\n\tisSelected: isSingleSelected,\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tonReplace,\n} ) {\n\tconst videoPlayer = useRef();\n\tconst { id, controls, poster, src, tracks } = attributes;\n\tconst [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\n\tuseUploadMediaFromBlobURL( {\n\t\turl: temporaryURL,\n\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\tonChange: onSelectVideo,\n\t\tonError: onUploadError,\n\t} );\n\n\tuseEffect( () => {\n\t\t// Placeholder may be rendered.\n\t\tif ( videoPlayer.current ) {\n\t\t\tvideoPlayer.current.load();\n\t\t}\n\t}, [ poster ] );\n\n\t// TODO: Whether the video was obtained from the media library or was provided by URL, obtain the `videoWidth` and `videoHeight` of the video once its metadata has loaded and persist in the block attributes.\n\tfunction onSelectVideo( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error\n\t\t\t// previous attributes should be removed\n\t\t\t// because they may be temporary blob urls.\n\t\t\tsetAttributes( {\n\t\t\t\tsrc: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t\tblob: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media.\n\t\tsetAttributes( {\n\t\t\tblob: undefined,\n\t\t\tsrc: media.url,\n\t\t\tid: media.id,\n\t\t\tposter:\n\t\t\t\tmedia.image?.src !== media.icon ? media.image?.src : undefined,\n\t\t\tcaption: media.caption,\n\t\t} );\n\t\tsetTemporaryURL();\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock && onReplace ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( {\n\t\t\t\tblob: undefined,\n\t\t\t\tsrc: newSrc,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t}\n\t}\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\t// Much of this description is duplicated from MediaPlaceholder.\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName=\"block-editor-media-placeholder\"\n\t\t\t\twithIllustration={ ! isSingleSelected }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ __( 'Video' ) }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Drag and drop a video, upload, or choose from your library.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst classes = clsx( className, {\n\t\t'is-transient': !! temporaryURL,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src && ! temporaryURL ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<TracksEditor\n\t\t\t\t\t\t\ttracks={ tracks }\n\t\t\t\t\t\t\tonChange={ ( newTracks ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { tracks: newTracks } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\t\tonReset={ () => onSelectVideo( undefined ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tautoplay: false,\n\t\t\t\t\t\t\tcontrols: true,\n\t\t\t\t\t\t\tloop: false,\n\t\t\t\t\t\t\tmuted: false,\n\t\t\t\t\t\t\tplaysInline: false,\n\t\t\t\t\t\t\tpreload: 'metadata',\n\t\t\t\t\t\t\tposter: undefined,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<VideoCommonSettings\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t/>\n\t\t\t\t\t<PosterImage\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tonChange={ ( posterImage ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tposter: posterImage?.url,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n Disable the video tag if the block is not selected\n so the user clicking on it won't play the\n video when the controls are enabled.\n */ }\n\t\t\t\t<Disabled isDisabled={ ! isSingleSelected }>\n\t\t\t\t\t<video\n\t\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tsrc={ src || temporaryURL }\n\t\t\t\t\t\tref={ videoPlayer }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Tracks tracks={ tracks } />\n\t\t\t\t\t</video>\n\t\t\t\t</Disabled>\n\t\t\t\t{ !! temporaryURL && <Spinner /> }\n\t\t\t\t<Caption\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSingleSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tlabel={ __( 'Video caption text' ) }\n\t\t\t\t\tshowToolbarButton={\n\t\t\t\t\t\tisSingleSelected && hasNonContentControls\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n\nexport default VideoEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,QAAQ,EACRC,OAAO,EACPC,WAAW,EACXC,wBAAwB,IAAIC,UAAU,QAChC,uBAAuB;AAC9B,SACCC,aAAa,EACbC,SAAS,EACTC,iBAAiB,EACjBC,gBAAgB,EAChBC,gBAAgB,EAChBC,aAAa,EACbC,mBAAmB,QACb,yBAAyB;AAChC,SAASC,MAAM,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AAChE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,IAAI,QAAQ,kBAAkB;AAChD,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,SAASC,wBAAwB,QAAQ,eAAe;AACxD,SACCC,yBAAyB,EACzBC,8BAA8B,QACxB,gBAAgB;AACvB,OAAOC,mBAAmB,MAAM,wBAA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AAA,CACS;IAAC,CACK,CAAC,eACpBtB,KAAA;MAAA,GAAa+C,UAAU;MAAAF,QAAA,gBAMtBjD,IAAA,CAAC9B,QAAQ;QAACiG,UAAU,EAAG,CAAE3D,gBAAkB;QAAAyC,QAAA,eAC1CjD,IAAA;UACCgB,QAAQ,EAAGA,QAAU;UACrBC,MAAM,EAAGA,MAAQ;UACjBC,GAAG,EAAGA,GAAG,IAAIE,YAAc;UAC3BgD,GAAG,EAAGtD,WAAa;UAAAmC,QAAA,eAEnBjD,IAAA,CAACJ,MAAM;YAACuB,MAAM,EAAGA;UAAQ,CAAE;QAAC,CACtB;MAAC,CACC,CAAC,EACT,CAAC,CAAEC,YAAY,iBAAIpB,IAAA,CAAC7B,OAAO,IAAE,CAAC,eAChC6B,IAAA,CAACH,OAAO;QACPY,UAAU,EAAGA,UAAY;QACzBE,aAAa,EAAGA,aAAe;QAC/BJ,UAAU,EAAGC,gBAAkB;QAC/BI,iBAAiB,EAAGA,iBAAmB;QACvCmC,KAAK,EAAG9D,EAAE,CAAE,oBAAqB,CAAG;QACpCoF,iBAAiB,EAChB7D,gBAAgB,IAAIiB;MACpB,CACD,CAAC;IAAA,CACK,CAAC;EAAA,CACR,CAAC;AAEL;AAEA,eAAenB,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","isBlobURL","Disabled","Spinner","Placeholder","__experimentalToolsPanel","ToolsPanel","BlockControls","BlockIcon","InspectorControls","MediaPlaceholder","MediaReplaceFlow","useBlockProps","useRef","useEffect","useState","__","useDispatch","video","icon","store","noticesStore","createUpgradedEmbedBlock","useUploadMediaFromBlobURL","useToolsPanelDropdownMenuProps","VideoCommonSettings","TracksEditor","Tracks","Caption","PosterImage","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ALLOWED_MEDIA_TYPES","VideoEdit","isSelected","isSingleSelected","attributes","className","setAttributes","insertBlocksAfter","onReplace","videoPlayer","id","controls","poster","src","tracks","temporaryURL","setTemporaryURL","blob","dropdownMenuProps","url","allowedTypes","onChange","onSelectVideo","onError","onUploadError","current","load","media","undefined","caption","image","onSelectURL","newSrc","embedBlock","createErrorNotice","message","type","placeholder","content","withIllustration","label","instructions","children","classes","blockProps","onSelect","accept","value","newTracks","group","mediaId","mediaURL","onReset","resetAll","autoplay","loop","muted","playsInline","preload","posterImage","isDisabled","ref","showToolbarButton"],"sources":["@wordpress/block-library/src/video/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tDisabled,\n\tSpinner,\n\tPlaceholder,\n\t__experimentalToolsPanel as ToolsPanel,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { video as icon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport {\n\tuseUploadMediaFromBlobURL,\n\tuseToolsPanelDropdownMenuProps,\n} from '../utils/hooks';\nimport VideoCommonSettings from './edit-common-settings';\nimport TracksEditor from './tracks-editor';\nimport Tracks from './tracks';\nimport { Caption } from '../utils/caption';\nimport PosterImage from '../utils/poster-image';\n\nconst ALLOWED_MEDIA_TYPES = [ 'video' ];\n\nfunction VideoEdit( {\n\tisSelected: isSingleSelected,\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tonReplace,\n} ) {\n\tconst videoPlayer = useRef();\n\tconst { id, controls, poster, src, tracks } = attributes;\n\tconst [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tuseUploadMediaFromBlobURL( {\n\t\turl: temporaryURL,\n\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\tonChange: onSelectVideo,\n\t\tonError: onUploadError,\n\t} );\n\n\tuseEffect( () => {\n\t\t// Placeholder may be rendered.\n\t\tif ( videoPlayer.current ) {\n\t\t\tvideoPlayer.current.load();\n\t\t}\n\t}, [ poster ] );\n\n\t// TODO: Whether the video was obtained from the media library or was provided by URL, obtain the `videoWidth` and `videoHeight` of the video once its metadata has loaded and persist in the block attributes.\n\tfunction onSelectVideo( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error\n\t\t\t// previous attributes should be removed\n\t\t\t// because they may be temporary blob urls.\n\t\t\tsetAttributes( {\n\t\t\t\tsrc: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t\tblob: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media.\n\t\tsetAttributes( {\n\t\t\tblob: undefined,\n\t\t\tsrc: media.url,\n\t\t\tid: media.id,\n\t\t\tposter:\n\t\t\t\tmedia.image?.src !== media.icon ? media.image?.src : undefined,\n\t\t\tcaption: media.caption,\n\t\t} );\n\t\tsetTemporaryURL();\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock && onReplace ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( {\n\t\t\t\tblob: undefined,\n\t\t\t\tsrc: newSrc,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t}\n\t}\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\t// Much of this description is duplicated from MediaPlaceholder.\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName=\"block-editor-media-placeholder\"\n\t\t\t\twithIllustration={ ! isSingleSelected }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ __( 'Video' ) }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Drag and drop a video, upload, or choose from your library.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst classes = clsx( className, {\n\t\t'is-transient': !! temporaryURL,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src && ! temporaryURL ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<TracksEditor\n\t\t\t\t\t\t\ttracks={ tracks }\n\t\t\t\t\t\t\tonChange={ ( newTracks ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { tracks: newTracks } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\t\tonReset={ () => onSelectVideo( undefined ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tautoplay: false,\n\t\t\t\t\t\t\tcontrols: true,\n\t\t\t\t\t\t\tloop: false,\n\t\t\t\t\t\t\tmuted: false,\n\t\t\t\t\t\t\tplaysInline: false,\n\t\t\t\t\t\t\tpreload: 'metadata',\n\t\t\t\t\t\t\tposter: undefined,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<VideoCommonSettings\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t/>\n\t\t\t\t\t<PosterImage\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tonChange={ ( posterImage ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tposter: posterImage?.url,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n Disable the video tag if the block is not selected\n so the user clicking on it won't play the\n video when the controls are enabled.\n */ }\n\t\t\t\t<Disabled isDisabled={ ! isSingleSelected }>\n\t\t\t\t\t<video\n\t\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tsrc={ src || temporaryURL }\n\t\t\t\t\t\tref={ videoPlayer }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Tracks tracks={ tracks } />\n\t\t\t\t\t</video>\n\t\t\t\t</Disabled>\n\t\t\t\t{ !! temporaryURL && <Spinner /> }\n\t\t\t\t<Caption\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSingleSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tlabel={ __( 'Video caption text' ) }\n\t\t\t\t\tshowToolbarButton={ isSingleSelected }\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n\nexport default VideoEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,QAAQ,EACRC,OAAO,EACPC,WAAW,EACXC,wBAAwB,IAAIC,UAAU,QAChC,uBAAuB;AAC9B,SACCC,aAAa,EACbC,SAAS,EACTC,iBAAiB,EACjBC,gBAAgB,EAChBC,gBAAgB,EAChBC,aAAa,QACP,yBAAyB;AAChC,SAASC,MAAM,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AAChE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,IAAI,QAAQ,kBAAkB;AAChD,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,SAASC,wBAAwB,QAAQ,eAAe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BpB,KAAA;MAAA,GAAa6C,UAAU;MAAAF,QAAA,gBAMtB/C,IAAA,CAAC7B,QAAQ;QAAC8F,UAAU,EAAG,CAAEzD,gBAAkB;QAAAuC,QAAA,eAC1C/C,IAAA;UACCgB,QAAQ,EAAGA,QAAU;UACrBC,MAAM,EAAGA,MAAQ;UACjBC,GAAG,EAAGA,GAAG,IAAIE,YAAc;UAC3B8C,GAAG,EAAGpD,WAAa;UAAAiC,QAAA,eAEnB/C,IAAA,CAACJ,MAAM;YAACuB,MAAM,EAAGA;UAAQ,CAAE;QAAC,CACtB;MAAC,CACC,CAAC,EACT,CAAC,CAAEC,YAAY,iBAAIpB,IAAA,CAAC5B,OAAO,IAAE,CAAC,eAChC4B,IAAA,CAACH,OAAO;QACPY,UAAU,EAAGA,UAAY;QACzBE,aAAa,EAAGA,aAAe;QAC/BJ,UAAU,EAAGC,gBAAkB;QAC/BI,iBAAiB,EAAGA,iBAAmB;QACvCiC,KAAK,EAAG5D,EAAE,CAAE,oBAAqB,CAAG;QACpCkF,iBAAiB,EAAG3D;MAAkB,CACtC,CAAC;IAAA,CACK,CAAC;EAAA,CACR,CAAC;AAEL;AAEA,eAAeF,SAAS","ignoreList":[]}
|
|
@@ -2660,10 +2660,6 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
2660
2660
|
margin-bottom: 0;
|
|
2661
2661
|
}
|
|
2662
2662
|
|
|
2663
|
-
.wp-block-query > .block-editor-media-placeholder.is-small {
|
|
2664
|
-
min-height: 60px;
|
|
2665
|
-
}
|
|
2666
|
-
|
|
2667
2663
|
.wp-block[data-align=center] > .wp-block-query-pagination {
|
|
2668
2664
|
justify-content: center;
|
|
2669
2665
|
}
|
package/build-style/editor.css
CHANGED
|
@@ -2667,10 +2667,6 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
2667
2667
|
margin-bottom: 0;
|
|
2668
2668
|
}
|
|
2669
2669
|
|
|
2670
|
-
.wp-block-query > .block-editor-media-placeholder.is-small {
|
|
2671
|
-
min-height: 60px;
|
|
2672
|
-
}
|
|
2673
|
-
|
|
2674
2670
|
.wp-block[data-align=center] > .wp-block-query-pagination {
|
|
2675
2671
|
justify-content: center;
|
|
2676
2672
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-library",
|
|
3
|
-
"version": "9.29.1-next.
|
|
3
|
+
"version": "9.29.1-next.f34ab90e9.0",
|
|
4
4
|
"description": "Block library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -42,39 +42,39 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/runtime": "7.25.7",
|
|
45
|
-
"@wordpress/a11y": "^4.29.1-next.
|
|
46
|
-
"@wordpress/api-fetch": "^7.29.1-next.
|
|
47
|
-
"@wordpress/autop": "^4.29.1-next.
|
|
48
|
-
"@wordpress/blob": "^4.29.1-next.
|
|
49
|
-
"@wordpress/block-editor": "^15.2.1-next.
|
|
50
|
-
"@wordpress/blocks": "^15.2.1-next.
|
|
51
|
-
"@wordpress/components": "^30.2.
|
|
52
|
-
"@wordpress/compose": "^7.29.1-next.
|
|
53
|
-
"@wordpress/core-data": "^7.29.1-next.
|
|
54
|
-
"@wordpress/data": "^10.29.1-next.
|
|
55
|
-
"@wordpress/date": "^5.
|
|
56
|
-
"@wordpress/deprecated": "^4.29.1-next.
|
|
57
|
-
"@wordpress/dom": "^4.29.1-next.
|
|
58
|
-
"@wordpress/element": "^6.29.1-next.
|
|
59
|
-
"@wordpress/escape-html": "^3.29.1-next.
|
|
60
|
-
"@wordpress/hooks": "^4.29.1-next.
|
|
61
|
-
"@wordpress/html-entities": "^4.29.1-next.
|
|
62
|
-
"@wordpress/i18n": "^6.2.1-next.
|
|
63
|
-
"@wordpress/icons": "^10.29.1-next.
|
|
64
|
-
"@wordpress/interactivity": "^6.29.1-next.
|
|
65
|
-
"@wordpress/interactivity-router": "^2.29.1-next.
|
|
66
|
-
"@wordpress/keyboard-shortcuts": "^5.29.1-next.
|
|
67
|
-
"@wordpress/keycodes": "^4.29.1-next.
|
|
68
|
-
"@wordpress/notices": "^5.29.1-next.
|
|
69
|
-
"@wordpress/patterns": "^2.29.1-next.
|
|
70
|
-
"@wordpress/primitives": "^4.29.1-next.
|
|
71
|
-
"@wordpress/private-apis": "^1.29.1-next.
|
|
72
|
-
"@wordpress/reusable-blocks": "^5.29.1-next.
|
|
73
|
-
"@wordpress/rich-text": "^7.29.1-next.
|
|
74
|
-
"@wordpress/server-side-render": "^6.5.1-next.
|
|
75
|
-
"@wordpress/url": "^4.29.1-next.
|
|
76
|
-
"@wordpress/viewport": "^6.29.1-next.
|
|
77
|
-
"@wordpress/wordcount": "^4.29.1-next.
|
|
45
|
+
"@wordpress/a11y": "^4.29.1-next.f34ab90e9.0",
|
|
46
|
+
"@wordpress/api-fetch": "^7.29.1-next.f34ab90e9.0",
|
|
47
|
+
"@wordpress/autop": "^4.29.1-next.f34ab90e9.0",
|
|
48
|
+
"@wordpress/blob": "^4.29.1-next.f34ab90e9.0",
|
|
49
|
+
"@wordpress/block-editor": "^15.2.1-next.f34ab90e9.0",
|
|
50
|
+
"@wordpress/blocks": "^15.2.1-next.f34ab90e9.0",
|
|
51
|
+
"@wordpress/components": "^30.2.1-next.f34ab90e9.0",
|
|
52
|
+
"@wordpress/compose": "^7.29.1-next.f34ab90e9.0",
|
|
53
|
+
"@wordpress/core-data": "^7.29.1-next.f34ab90e9.0",
|
|
54
|
+
"@wordpress/data": "^10.29.1-next.f34ab90e9.0",
|
|
55
|
+
"@wordpress/date": "^5.29.1-next.f34ab90e9.0",
|
|
56
|
+
"@wordpress/deprecated": "^4.29.1-next.f34ab90e9.0",
|
|
57
|
+
"@wordpress/dom": "^4.29.1-next.f34ab90e9.0",
|
|
58
|
+
"@wordpress/element": "^6.29.1-next.f34ab90e9.0",
|
|
59
|
+
"@wordpress/escape-html": "^3.29.1-next.f34ab90e9.0",
|
|
60
|
+
"@wordpress/hooks": "^4.29.1-next.f34ab90e9.0",
|
|
61
|
+
"@wordpress/html-entities": "^4.29.1-next.f34ab90e9.0",
|
|
62
|
+
"@wordpress/i18n": "^6.2.1-next.f34ab90e9.0",
|
|
63
|
+
"@wordpress/icons": "^10.29.1-next.f34ab90e9.0",
|
|
64
|
+
"@wordpress/interactivity": "^6.29.1-next.f34ab90e9.0",
|
|
65
|
+
"@wordpress/interactivity-router": "^2.29.1-next.f34ab90e9.0",
|
|
66
|
+
"@wordpress/keyboard-shortcuts": "^5.29.1-next.f34ab90e9.0",
|
|
67
|
+
"@wordpress/keycodes": "^4.29.1-next.f34ab90e9.0",
|
|
68
|
+
"@wordpress/notices": "^5.29.1-next.f34ab90e9.0",
|
|
69
|
+
"@wordpress/patterns": "^2.29.1-next.f34ab90e9.0",
|
|
70
|
+
"@wordpress/primitives": "^4.29.1-next.f34ab90e9.0",
|
|
71
|
+
"@wordpress/private-apis": "^1.29.1-next.f34ab90e9.0",
|
|
72
|
+
"@wordpress/reusable-blocks": "^5.29.1-next.f34ab90e9.0",
|
|
73
|
+
"@wordpress/rich-text": "^7.29.1-next.f34ab90e9.0",
|
|
74
|
+
"@wordpress/server-side-render": "^6.5.1-next.f34ab90e9.0",
|
|
75
|
+
"@wordpress/url": "^4.29.1-next.f34ab90e9.0",
|
|
76
|
+
"@wordpress/viewport": "^6.29.1-next.f34ab90e9.0",
|
|
77
|
+
"@wordpress/wordcount": "^4.29.1-next.f34ab90e9.0",
|
|
78
78
|
"change-case": "^4.1.2",
|
|
79
79
|
"clsx": "^2.1.1",
|
|
80
80
|
"colord": "^2.7.0",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "91f58004986ec6faf118825f925ac7873d171986"
|
|
96
96
|
}
|
package/src/audio/edit.js
CHANGED
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
MediaPlaceholder,
|
|
23
23
|
MediaReplaceFlow,
|
|
24
24
|
useBlockProps,
|
|
25
|
-
useBlockEditingMode,
|
|
26
25
|
} from '@wordpress/block-editor';
|
|
27
26
|
import { __, _x } from '@wordpress/i18n';
|
|
28
27
|
import { useDispatch } from '@wordpress/data';
|
|
@@ -52,8 +51,6 @@ function AudioEdit( {
|
|
|
52
51
|
} ) {
|
|
53
52
|
const { id, autoplay, loop, preload, src } = attributes;
|
|
54
53
|
const [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );
|
|
55
|
-
const blockEditingMode = useBlockEditingMode();
|
|
56
|
-
const hasNonContentControls = blockEditingMode === 'default';
|
|
57
54
|
|
|
58
55
|
useUploadMediaFromBlobURL( {
|
|
59
56
|
url: temporaryURL,
|
|
@@ -267,9 +264,7 @@ function AudioEdit( {
|
|
|
267
264
|
isSelected={ isSingleSelected }
|
|
268
265
|
insertBlocksAfter={ insertBlocksAfter }
|
|
269
266
|
label={ __( 'Audio caption text' ) }
|
|
270
|
-
showToolbarButton={
|
|
271
|
-
isSingleSelected && hasNonContentControls
|
|
272
|
-
}
|
|
267
|
+
showToolbarButton={ isSingleSelected }
|
|
273
268
|
/>
|
|
274
269
|
</figure>
|
|
275
270
|
</>
|
package/src/image/image.js
CHANGED
|
@@ -706,8 +706,7 @@ export default function Image( {
|
|
|
706
706
|
! lockHrefControls &&
|
|
707
707
|
! lockUrlControls;
|
|
708
708
|
|
|
709
|
-
const showCoverControls =
|
|
710
|
-
isSingleSelected && canInsertCover && ! isContentOnlyMode;
|
|
709
|
+
const showCoverControls = isSingleSelected && canInsertCover;
|
|
711
710
|
|
|
712
711
|
const showBlockControls = showUrlInput || allowCrop || showCoverControls;
|
|
713
712
|
|
package/src/query/edit/index.js
CHANGED
|
@@ -5,12 +5,12 @@ import { useSelect, useDispatch } from '@wordpress/data';
|
|
|
5
5
|
import { useInstanceId } from '@wordpress/compose';
|
|
6
6
|
import { useEffect, useCallback } from '@wordpress/element';
|
|
7
7
|
import {
|
|
8
|
+
BlockControls,
|
|
8
9
|
InspectorControls,
|
|
9
10
|
useBlockProps,
|
|
10
11
|
store as blockEditorStore,
|
|
11
12
|
useInnerBlocksProps,
|
|
12
13
|
privateApis as blockEditorPrivateApis,
|
|
13
|
-
BlockControls,
|
|
14
14
|
} from '@wordpress/block-editor';
|
|
15
15
|
import { __ } from '@wordpress/i18n';
|
|
16
16
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -130,13 +130,6 @@ export default function QueryContent( {
|
|
|
130
130
|
|
|
131
131
|
return (
|
|
132
132
|
<>
|
|
133
|
-
<BlockControls>
|
|
134
|
-
<QueryToolbar
|
|
135
|
-
clientId={ clientId }
|
|
136
|
-
attributes={ attributes }
|
|
137
|
-
hasInnerBlocks
|
|
138
|
-
/>
|
|
139
|
-
</BlockControls>
|
|
140
133
|
<EnhancedPaginationModal
|
|
141
134
|
attributes={ attributes }
|
|
142
135
|
setAttributes={ setAttributes }
|
|
@@ -152,6 +145,9 @@ export default function QueryContent( {
|
|
|
152
145
|
isSingular={ isSingular }
|
|
153
146
|
/>
|
|
154
147
|
</InspectorControls>
|
|
148
|
+
<BlockControls>
|
|
149
|
+
<QueryToolbar attributes={ attributes } clientId={ clientId } />
|
|
150
|
+
</BlockControls>
|
|
155
151
|
<InspectorControls group="advanced">
|
|
156
152
|
<HTMLElementControl
|
|
157
153
|
tagName={ TagName }
|
|
@@ -8,21 +8,18 @@ import {
|
|
|
8
8
|
} from '@wordpress/blocks';
|
|
9
9
|
import { useState } from '@wordpress/element';
|
|
10
10
|
import {
|
|
11
|
+
useBlockProps,
|
|
11
12
|
store as blockEditorStore,
|
|
12
13
|
__experimentalBlockVariationPicker,
|
|
13
|
-
BlockControls,
|
|
14
|
-
useBlockProps,
|
|
15
14
|
} from '@wordpress/block-editor';
|
|
16
15
|
import { Button, Placeholder } from '@wordpress/components';
|
|
17
16
|
import { __ } from '@wordpress/i18n';
|
|
18
|
-
import { useResizeObserver } from '@wordpress/compose';
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
19
|
* Internal dependencies
|
|
22
20
|
*/
|
|
23
21
|
import { useScopedBlockVariations } from '../utils';
|
|
24
22
|
import { useBlockPatterns } from './pattern-selection';
|
|
25
|
-
import QueryToolbar from './query-toolbar';
|
|
26
23
|
|
|
27
24
|
export default function QueryPlaceholder( {
|
|
28
25
|
attributes,
|
|
@@ -31,18 +28,7 @@ export default function QueryPlaceholder( {
|
|
|
31
28
|
openPatternSelectionModal,
|
|
32
29
|
} ) {
|
|
33
30
|
const [ isStartingBlank, setIsStartingBlank ] = useState( false );
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
// Use ResizeObserver to monitor container width.
|
|
37
|
-
const resizeObserverRef = useResizeObserver( ( [ entry ] ) => {
|
|
38
|
-
setContainerWidth( entry.contentRect.width );
|
|
39
|
-
} );
|
|
40
|
-
|
|
41
|
-
const SMALL_CONTAINER_BREAKPOINT = 160;
|
|
42
|
-
|
|
43
|
-
const isSmallContainer =
|
|
44
|
-
containerWidth > 0 && containerWidth < SMALL_CONTAINER_BREAKPOINT;
|
|
45
|
-
|
|
31
|
+
const blockProps = useBlockProps();
|
|
46
32
|
const { blockType, activeBlockVariation } = useSelect(
|
|
47
33
|
( select ) => {
|
|
48
34
|
const { getActiveBlockVariation, getBlockType } =
|
|
@@ -63,10 +49,6 @@ export default function QueryPlaceholder( {
|
|
|
63
49
|
activeBlockVariation?.icon ||
|
|
64
50
|
blockType?.icon?.src;
|
|
65
51
|
const label = activeBlockVariation?.title || blockType?.title;
|
|
66
|
-
const blockProps = useBlockProps( {
|
|
67
|
-
ref: resizeObserverRef,
|
|
68
|
-
} );
|
|
69
|
-
|
|
70
52
|
if ( isStartingBlank ) {
|
|
71
53
|
return (
|
|
72
54
|
<QueryVariationPicker
|
|
@@ -79,24 +61,14 @@ export default function QueryPlaceholder( {
|
|
|
79
61
|
}
|
|
80
62
|
return (
|
|
81
63
|
<div { ...blockProps }>
|
|
82
|
-
<BlockControls>
|
|
83
|
-
<QueryToolbar
|
|
84
|
-
clientId={ clientId }
|
|
85
|
-
attributes={ attributes }
|
|
86
|
-
hasInnerBlocks={ false }
|
|
87
|
-
/>
|
|
88
|
-
</BlockControls>
|
|
89
64
|
<Placeholder
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
__( 'Choose a pattern for the query loop or start blank.' )
|
|
96
|
-
}
|
|
97
|
-
withIllustration={ isSmallContainer }
|
|
65
|
+
icon={ icon }
|
|
66
|
+
label={ label }
|
|
67
|
+
instructions={ __(
|
|
68
|
+
'Choose a pattern for the query loop or start blank.'
|
|
69
|
+
) }
|
|
98
70
|
>
|
|
99
|
-
{ !! hasPatterns &&
|
|
71
|
+
{ !! hasPatterns && (
|
|
100
72
|
<Button
|
|
101
73
|
__next40pxDefaultSize
|
|
102
74
|
variant="primary"
|
|
@@ -106,17 +78,15 @@ export default function QueryPlaceholder( {
|
|
|
106
78
|
</Button>
|
|
107
79
|
) }
|
|
108
80
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
</Button>
|
|
119
|
-
) }
|
|
81
|
+
<Button
|
|
82
|
+
__next40pxDefaultSize
|
|
83
|
+
variant="secondary"
|
|
84
|
+
onClick={ () => {
|
|
85
|
+
setIsStartingBlank( true );
|
|
86
|
+
} }
|
|
87
|
+
>
|
|
88
|
+
{ __( 'Start blank' ) }
|
|
89
|
+
</Button>
|
|
120
90
|
</Placeholder>
|
|
121
91
|
</div>
|
|
122
92
|
);
|
|
@@ -14,20 +14,12 @@ import { __ } from '@wordpress/i18n';
|
|
|
14
14
|
*/
|
|
15
15
|
import PatternSelection, { useBlockPatterns } from './pattern-selection';
|
|
16
16
|
|
|
17
|
-
export default function QueryToolbar( {
|
|
18
|
-
clientId,
|
|
19
|
-
attributes,
|
|
20
|
-
hasInnerBlocks,
|
|
21
|
-
} ) {
|
|
17
|
+
export default function QueryToolbar( { clientId, attributes } ) {
|
|
22
18
|
const hasPatterns = useBlockPatterns( clientId, attributes ).length;
|
|
23
19
|
if ( ! hasPatterns ) {
|
|
24
20
|
return null;
|
|
25
21
|
}
|
|
26
22
|
|
|
27
|
-
const buttonLabel = hasInnerBlocks
|
|
28
|
-
? __( 'Change design' )
|
|
29
|
-
: __( 'Choose pattern' );
|
|
30
|
-
|
|
31
23
|
return (
|
|
32
24
|
<ToolbarGroup className="wp-block-template-part__block-control-group">
|
|
33
25
|
<DropdownContentWrapper>
|
|
@@ -41,7 +33,7 @@ export default function QueryToolbar( {
|
|
|
41
33
|
aria-expanded={ isOpen }
|
|
42
34
|
onClick={ onToggle }
|
|
43
35
|
>
|
|
44
|
-
{
|
|
36
|
+
{ __( 'Change design' ) }
|
|
45
37
|
</ToolbarButton>
|
|
46
38
|
) }
|
|
47
39
|
renderContent={ () => (
|
package/src/query/editor.scss
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
.block-library-query-pattern__selection-modal {
|
|
2
|
+
|
|
2
3
|
.block-editor-block-patterns-list {
|
|
3
4
|
column-count: 2;
|
|
4
5
|
column-gap: $grid-unit-30;
|
|
@@ -52,9 +53,3 @@
|
|
|
52
53
|
margin-bottom: 0;
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
-
// Provide special styling for the placeholder.
|
|
57
|
-
// @todo this particular minimal style of placeholder could be componentized further.
|
|
58
|
-
.wp-block-query > .block-editor-media-placeholder.is-small {
|
|
59
|
-
min-height: 60px;
|
|
60
|
-
}
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
useTemplatePartArea,
|
|
18
18
|
} from './utils/hooks';
|
|
19
19
|
import TitleModal from './title-modal';
|
|
20
|
-
import { getTemplatePartIcon } from './utils/get-template-part-icon';
|
|
21
20
|
|
|
22
21
|
export default function TemplatePartPlaceholder( {
|
|
23
22
|
area,
|
|
@@ -55,7 +54,7 @@ export default function TemplatePartPlaceholder( {
|
|
|
55
54
|
|
|
56
55
|
return (
|
|
57
56
|
<Placeholder
|
|
58
|
-
icon={
|
|
57
|
+
icon={ areaObject.icon }
|
|
59
58
|
label={ areaObject.label }
|
|
60
59
|
instructions={
|
|
61
60
|
isBlockBasedTheme
|
package/src/video/edit.js
CHANGED
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
MediaPlaceholder,
|
|
21
21
|
MediaReplaceFlow,
|
|
22
22
|
useBlockProps,
|
|
23
|
-
useBlockEditingMode,
|
|
24
23
|
} from '@wordpress/block-editor';
|
|
25
24
|
import { useRef, useEffect, useState } from '@wordpress/element';
|
|
26
25
|
import { __ } from '@wordpress/i18n';
|
|
@@ -56,8 +55,6 @@ function VideoEdit( {
|
|
|
56
55
|
const { id, controls, poster, src, tracks } = attributes;
|
|
57
56
|
const [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );
|
|
58
57
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
59
|
-
const blockEditingMode = useBlockEditingMode();
|
|
60
|
-
const hasNonContentControls = blockEditingMode === 'default';
|
|
61
58
|
|
|
62
59
|
useUploadMediaFromBlobURL( {
|
|
63
60
|
url: temporaryURL,
|
|
@@ -254,9 +251,7 @@ function VideoEdit( {
|
|
|
254
251
|
isSelected={ isSingleSelected }
|
|
255
252
|
insertBlocksAfter={ insertBlocksAfter }
|
|
256
253
|
label={ __( 'Video caption text' ) }
|
|
257
|
-
showToolbarButton={
|
|
258
|
-
isSingleSelected && hasNonContentControls
|
|
259
|
-
}
|
|
254
|
+
showToolbarButton={ isSingleSelected }
|
|
260
255
|
/>
|
|
261
256
|
</figure>
|
|
262
257
|
</>
|