@wordpress/editor 13.9.0 → 13.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/entities-saved-states/index.js +53 -8
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/post-featured-image/index.js +24 -29
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +0 -8
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-switch-to-draft-button/index.js +9 -4
- package/build/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +1 -1
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +54 -9
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +26 -32
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +0 -7
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-switch-to-draft-button/index.js +12 -7
- package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +1 -1
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-style/style-rtl.css +38 -16
- package/build-style/style.css +38 -16
- package/package.json +31 -31
- package/src/components/entities-saved-states/index.js +61 -16
- package/src/components/post-featured-image/index.js +26 -35
- package/src/components/post-featured-image/style.scss +38 -14
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +1 -1
- package/src/components/post-saved-state/index.js +0 -7
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +0 -9
- package/src/components/post-saved-state/test/index.js +0 -10
- package/src/components/post-switch-to-draft-button/index.js +7 -6
- package/src/components/post-taxonomies/flat-term-selector.js +1 -1
- package/src/components/post-taxonomies/style.scss +4 -4
- package/src/components/post-trash/style.scss +1 -3
- package/src/components/provider/use-block-editor-settings.js +1 -0
|
@@ -19,7 +19,6 @@ import { displayShortcut } from '@wordpress/keycodes';
|
|
|
19
19
|
* Internal dependencies
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import PostSwitchToDraftButton from '../post-switch-to-draft-button';
|
|
23
22
|
import { store as editorStore } from '../../store';
|
|
24
23
|
/**
|
|
25
24
|
* Component showing whether the post is saved or not and providing save
|
|
@@ -47,10 +46,8 @@ export default function PostSavedState(_ref) {
|
|
|
47
46
|
isDirty,
|
|
48
47
|
isNew,
|
|
49
48
|
isPending,
|
|
50
|
-
isPublished,
|
|
51
49
|
isSaveable,
|
|
52
50
|
isSaving,
|
|
53
|
-
isScheduled,
|
|
54
51
|
hasPublishAction
|
|
55
52
|
} = useSelect(select => {
|
|
56
53
|
var _getCurrentPost$_link, _getCurrentPost, _getCurrentPost$_link2;
|
|
@@ -99,10 +96,6 @@ export default function PostSavedState(_ref) {
|
|
|
99
96
|
if (!hasPublishAction && isPending) {
|
|
100
97
|
return null;
|
|
101
98
|
}
|
|
102
|
-
|
|
103
|
-
if (isPublished || isScheduled) {
|
|
104
|
-
return createElement(PostSwitchToDraftButton, null);
|
|
105
|
-
}
|
|
106
99
|
/* translators: button label text should, if possible, be under 16 characters. */
|
|
107
100
|
|
|
108
101
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-saved-state/index.js"],"names":["classnames","__unstableGetAnimateClassName","getAnimateClassName","Button","usePrevious","useViewportMatch","useDispatch","useSelect","useEffect","useState","__","Icon","check","cloud","cloudUpload","displayShortcut","PostSwitchToDraftButton","store","editorStore","PostSavedState","forceIsDirty","forceIsSaving","showIconLabels","forceSavedMessage","setForceSavedMessage","isLargeViewport","isAutosaving","isDirty","isNew","isPending","isPublished","isSaveable","isSaving","isScheduled","hasPublishAction","select","isEditedPostNew","isCurrentPostPublished","isCurrentPostScheduled","isEditedPostDirty","isSavingPost","isEditedPostSaveable","getCurrentPost","isAutosavingPost","getEditedPostAttribute","_links","savePost","wasSaving","timeoutId","setTimeout","clearTimeout","label","shortLabel","isSaved","isSavedState","isDisabled","text","type","undefined","primary"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,6BAA6B,IAAIC,mBADlC,EAECC,MAFD,QAGO,uBAHP;AAIA,SAASC,WAAT,EAAsBC,gBAAtB,QAA8C,oBAA9C;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,IAAT,EAAeC,KAAf,EAAsBC,KAAtB,EAA6BC,WAA7B,QAAgD,kBAAhD;AACA,SAASC,eAAT,QAAgC,qBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,gCAApC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,cAAT,OAIX;AAAA,MAJoC;AACvCC,IAAAA,YADuC;AAEvCC,IAAAA,aAFuC;AAGvCC,IAAAA,cAAc,GAAG;AAHsB,GAIpC;AACH,QAAM,CAAEC,iBAAF,EAAqBC,oBAArB,IAA8Cf,QAAQ,CAAE,KAAF,CAA5D;AACA,QAAMgB,eAAe,GAAGpB,gBAAgB,CAAE,OAAF,CAAxC;AAEA,QAAM;AACLqB,IAAAA,YADK;AAELC,IAAAA,OAFK;AAGLC,IAAAA,KAHK;AAILC,IAAAA,SAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA,UANK;AAOLC,IAAAA,QAPK;AAQLC,IAAAA,WAR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AiBN,YAJL;AAKZ,kBAAY2B,OALA;AAMZ,OAAEnD,mBAAmB,CAAE;AACtBuD,QAAAA,IAAI,EAAE;AADgB,OAAF,CAArB,GAEOzB;AARK,KAAF,CADb,GAWG0B,SAbL;AAeC,IAAA,OAAO,EAAGH,UAAU,GAAGG,SAAH,GAAe,MAAMZ,QAAQ;AACjD;AACH;AACA;AACA;AAnBE;AAoBC,IAAA,QAAQ,EAAGS,UAAU,GAAGG,SAAH,GAAe3C,eAAe,CAAC4C,OAAhB,CAAyB,GAAzB;AACpC;AACH;AACA;AACA;AACA;AACA;AA1BE;AA2BC,IAAA,WAAW,MA3BZ;AA4BC,IAAA,OAAO,EAAC,UA5BT;AA6BC,IAAA,IAAI,EAAGlC,eAAe,GAAGiC,SAAH,GAAe5C,WA7BtC,CA8BC;AA9BD;AA+BC,IAAA,KAAK,EAAG0C,IAAI,IAAIL,KA/BjB;AAgCC,qBAAgBI;AAhCjB,KAkCGD,YAAY,IAAI,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGD,OAAO,GAAGzC,KAAH,GAAWC;AAA/B,IAlCnB,EAmCG2C,IAnCH,CADD;AAuCA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tButton,\n} from '@wordpress/components';\nimport { usePrevious, useViewportMatch } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, check, cloud, cloudUpload } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport PostSwitchToDraftButton from '../post-switch-to-draft-button';\nimport { store as editorStore } from '../../store';\n\n/**\n * Component showing whether the post is saved or not and providing save\n * buttons.\n *\n * @param {Object} props Component props.\n * @param {?boolean} props.forceIsDirty Whether to force the post to be marked\n * as dirty.\n * @param {?boolean} props.forceIsSaving Whether to force the post to be marked\n * as being saved.\n * @param {?boolean} props.showIconLabels Whether interface buttons show labels instead of icons\n * @return {import('@wordpress/element').WPComponent} The component.\n */\nexport default function PostSavedState( {\n\tforceIsDirty,\n\tforceIsSaving,\n\tshowIconLabels = false,\n} ) {\n\tconst [ forceSavedMessage, setForceSavedMessage ] = useState( false );\n\tconst isLargeViewport = useViewportMatch( 'small' );\n\n\tconst {\n\t\tisAutosaving,\n\t\tisDirty,\n\t\tisNew,\n\t\tisPending,\n\t\tisPublished,\n\t\tisSaveable,\n\t\tisSaving,\n\t\tisScheduled,\n\t\thasPublishAction,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisEditedPostNew,\n\t\t\t\tisCurrentPostPublished,\n\t\t\t\tisCurrentPostScheduled,\n\t\t\t\tisEditedPostDirty,\n\t\t\t\tisSavingPost,\n\t\t\t\tisEditedPostSaveable,\n\t\t\t\tgetCurrentPost,\n\t\t\t\tisAutosavingPost,\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t} = select( editorStore );\n\n\t\t\treturn {\n\t\t\t\tisAutosaving: isAutosavingPost(),\n\t\t\t\tisDirty: forceIsDirty || isEditedPostDirty(),\n\t\t\t\tisNew: isEditedPostNew(),\n\t\t\t\tisPending: 'pending' === getEditedPostAttribute( 'status' ),\n\t\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\t\tisSaving: forceIsSaving || isSavingPost(),\n\t\t\t\tisSaveable: isEditedPostSaveable(),\n\t\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t\t\thasPublishAction:\n\t\t\t\t\tgetCurrentPost()?._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t};\n\t\t},\n\t\t[ forceIsDirty, forceIsSaving ]\n\t);\n\n\tconst { savePost } = useDispatch( editorStore );\n\n\tconst wasSaving = usePrevious( isSaving );\n\n\tuseEffect( () => {\n\t\tlet timeoutId;\n\n\t\tif ( wasSaving && ! isSaving ) {\n\t\t\tsetForceSavedMessage( true );\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tsetForceSavedMessage( false );\n\t\t\t}, 1000 );\n\t\t}\n\n\t\treturn () => clearTimeout( timeoutId );\n\t}, [ isSaving ] );\n\n\t// Once the post has been submitted for review this button\n\t// is not needed for the contributor role.\n\tif ( ! hasPublishAction && isPending ) {\n\t\treturn null;\n\t}\n\n\tif ( isPublished || isScheduled ) {\n\t\treturn <PostSwitchToDraftButton />;\n\t}\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst label = isPending ? __( 'Save as pending' ) : __( 'Save draft' );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst shortLabel = __( 'Save' );\n\n\tconst isSaved = forceSavedMessage || ( ! isNew && ! isDirty );\n\tconst isSavedState = isSaving || isSaved;\n\tconst isDisabled = isSaving || isSaved || ! isSaveable;\n\n\tlet text;\n\n\tif ( isSaving ) {\n\t\ttext = isAutosaving ? __( 'Autosaving' ) : __( 'Saving' );\n\t} else if ( isSaved ) {\n\t\ttext = __( 'Saved' );\n\t} else if ( isLargeViewport ) {\n\t\ttext = label;\n\t} else if ( showIconLabels ) {\n\t\ttext = shortLabel;\n\t}\n\n\t// Use common Button instance for all saved states so that focus is not\n\t// lost.\n\treturn (\n\t\t<Button\n\t\t\tclassName={\n\t\t\t\tisSaveable || isSaving\n\t\t\t\t\t? classnames( {\n\t\t\t\t\t\t\t'editor-post-save-draft': ! isSavedState,\n\t\t\t\t\t\t\t'editor-post-saved-state': isSavedState,\n\t\t\t\t\t\t\t'is-saving': isSaving,\n\t\t\t\t\t\t\t'is-autosaving': isAutosaving,\n\t\t\t\t\t\t\t'is-saved': isSaved,\n\t\t\t\t\t\t\t[ getAnimateClassName( {\n\t\t\t\t\t\t\t\ttype: 'loading',\n\t\t\t\t\t\t\t} ) ]: isSaving,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tonClick={ isDisabled ? undefined : () => savePost() }\n\t\t\t/*\n\t\t\t * We want the tooltip to show the keyboard shortcut only when the\n\t\t\t * button does something, i.e. when it's not disabled.\n\t\t\t */\n\t\t\tshortcut={ isDisabled ? undefined : displayShortcut.primary( 's' ) }\n\t\t\t/*\n\t\t\t * Displaying the keyboard shortcut conditionally makes the tooltip\n\t\t\t * itself show conditionally. This would trigger a full-rerendering\n\t\t\t * of the button that we want to avoid. By setting `showTooltip`,\n\t\t\t & the tooltip is always rendered even when there's no keyboard shortcut.\n\t\t\t */\n\t\t\tshowTooltip\n\t\t\tvariant=\"tertiary\"\n\t\t\ticon={ isLargeViewport ? undefined : cloudUpload }\n\t\t\t// Make sure the aria-label has always a value, as the default `text` is undefined on small screens.\n\t\t\tlabel={ text || label }\n\t\t\taria-disabled={ isDisabled }\n\t\t>\n\t\t\t{ isSavedState && <Icon icon={ isSaved ? check : cloud } /> }\n\t\t\t{ text }\n\t\t</Button>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-saved-state/index.js"],"names":["classnames","__unstableGetAnimateClassName","getAnimateClassName","Button","usePrevious","useViewportMatch","useDispatch","useSelect","useEffect","useState","__","Icon","check","cloud","cloudUpload","displayShortcut","store","editorStore","PostSavedState","forceIsDirty","forceIsSaving","showIconLabels","forceSavedMessage","setForceSavedMessage","isLargeViewport","isAutosaving","isDirty","isNew","isPending","isSaveable","isSaving","hasPublishAction","select","isEditedPostNew","isCurrentPostPublished","isCurrentPostScheduled","isEditedPostDirty","isSavingPost","isEditedPostSaveable","getCurrentPost","isAutosavingPost","getEditedPostAttribute","isPublished","isScheduled","_links","savePost","wasSaving","timeoutId","setTimeout","clearTimeout","label","shortLabel","isSaved","isSavedState","isDisabled","text","type","undefined","primary"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,6BAA6B,IAAIC,mBADlC,EAECC,MAFD,QAGO,uBAHP;AAIA,SAASC,WAAT,EAAsBC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AIL,KA/BjB;AAgCC,qBAAgBI;AAhCjB,KAkCGD,YAAY,IAAI,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGD,OAAO,GAAGxC,KAAH,GAAWC;AAA/B,IAlCnB,EAmCG0C,IAnCH,CADD;AAuCA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tButton,\n} from '@wordpress/components';\nimport { usePrevious, useViewportMatch } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, check, cloud, cloudUpload } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Component showing whether the post is saved or not and providing save\n * buttons.\n *\n * @param {Object} props Component props.\n * @param {?boolean} props.forceIsDirty Whether to force the post to be marked\n * as dirty.\n * @param {?boolean} props.forceIsSaving Whether to force the post to be marked\n * as being saved.\n * @param {?boolean} props.showIconLabels Whether interface buttons show labels instead of icons\n * @return {import('@wordpress/element').WPComponent} The component.\n */\nexport default function PostSavedState( {\n\tforceIsDirty,\n\tforceIsSaving,\n\tshowIconLabels = false,\n} ) {\n\tconst [ forceSavedMessage, setForceSavedMessage ] = useState( false );\n\tconst isLargeViewport = useViewportMatch( 'small' );\n\n\tconst {\n\t\tisAutosaving,\n\t\tisDirty,\n\t\tisNew,\n\t\tisPending,\n\t\tisSaveable,\n\t\tisSaving,\n\t\thasPublishAction,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisEditedPostNew,\n\t\t\t\tisCurrentPostPublished,\n\t\t\t\tisCurrentPostScheduled,\n\t\t\t\tisEditedPostDirty,\n\t\t\t\tisSavingPost,\n\t\t\t\tisEditedPostSaveable,\n\t\t\t\tgetCurrentPost,\n\t\t\t\tisAutosavingPost,\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t} = select( editorStore );\n\n\t\t\treturn {\n\t\t\t\tisAutosaving: isAutosavingPost(),\n\t\t\t\tisDirty: forceIsDirty || isEditedPostDirty(),\n\t\t\t\tisNew: isEditedPostNew(),\n\t\t\t\tisPending: 'pending' === getEditedPostAttribute( 'status' ),\n\t\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\t\tisSaving: forceIsSaving || isSavingPost(),\n\t\t\t\tisSaveable: isEditedPostSaveable(),\n\t\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t\t\thasPublishAction:\n\t\t\t\t\tgetCurrentPost()?._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t};\n\t\t},\n\t\t[ forceIsDirty, forceIsSaving ]\n\t);\n\n\tconst { savePost } = useDispatch( editorStore );\n\n\tconst wasSaving = usePrevious( isSaving );\n\n\tuseEffect( () => {\n\t\tlet timeoutId;\n\n\t\tif ( wasSaving && ! isSaving ) {\n\t\t\tsetForceSavedMessage( true );\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tsetForceSavedMessage( false );\n\t\t\t}, 1000 );\n\t\t}\n\n\t\treturn () => clearTimeout( timeoutId );\n\t}, [ isSaving ] );\n\n\t// Once the post has been submitted for review this button\n\t// is not needed for the contributor role.\n\tif ( ! hasPublishAction && isPending ) {\n\t\treturn null;\n\t}\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst label = isPending ? __( 'Save as pending' ) : __( 'Save draft' );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst shortLabel = __( 'Save' );\n\n\tconst isSaved = forceSavedMessage || ( ! isNew && ! isDirty );\n\tconst isSavedState = isSaving || isSaved;\n\tconst isDisabled = isSaving || isSaved || ! isSaveable;\n\n\tlet text;\n\n\tif ( isSaving ) {\n\t\ttext = isAutosaving ? __( 'Autosaving' ) : __( 'Saving' );\n\t} else if ( isSaved ) {\n\t\ttext = __( 'Saved' );\n\t} else if ( isLargeViewport ) {\n\t\ttext = label;\n\t} else if ( showIconLabels ) {\n\t\ttext = shortLabel;\n\t}\n\n\t// Use common Button instance for all saved states so that focus is not\n\t// lost.\n\treturn (\n\t\t<Button\n\t\t\tclassName={\n\t\t\t\tisSaveable || isSaving\n\t\t\t\t\t? classnames( {\n\t\t\t\t\t\t\t'editor-post-save-draft': ! isSavedState,\n\t\t\t\t\t\t\t'editor-post-saved-state': isSavedState,\n\t\t\t\t\t\t\t'is-saving': isSaving,\n\t\t\t\t\t\t\t'is-autosaving': isAutosaving,\n\t\t\t\t\t\t\t'is-saved': isSaved,\n\t\t\t\t\t\t\t[ getAnimateClassName( {\n\t\t\t\t\t\t\t\ttype: 'loading',\n\t\t\t\t\t\t\t} ) ]: isSaving,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tonClick={ isDisabled ? undefined : () => savePost() }\n\t\t\t/*\n\t\t\t * We want the tooltip to show the keyboard shortcut only when the\n\t\t\t * button does something, i.e. when it's not disabled.\n\t\t\t */\n\t\t\tshortcut={ isDisabled ? undefined : displayShortcut.primary( 's' ) }\n\t\t\t/*\n\t\t\t * Displaying the keyboard shortcut conditionally makes the tooltip\n\t\t\t * itself show conditionally. This would trigger a full-rerendering\n\t\t\t * of the button that we want to avoid. By setting `showTooltip`,\n\t\t\t & the tooltip is always rendered even when there's no keyboard shortcut.\n\t\t\t */\n\t\t\tshowTooltip\n\t\t\tvariant=\"tertiary\"\n\t\t\ticon={ isLargeViewport ? undefined : cloudUpload }\n\t\t\t// Make sure the aria-label has always a value, as the default `text` is undefined on small screens.\n\t\t\tlabel={ text || label }\n\t\t\taria-disabled={ isDisabled }\n\t\t>\n\t\t\t{ isSavedState && <Icon icon={ isSaved ? check : cloud } /> }\n\t\t\t{ text }\n\t\t</Button>\n\t);\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createElement
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { Button, __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';
|
|
6
|
+
import { Button, FlexItem, __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
import { withSelect, withDispatch } from '@wordpress/data';
|
|
9
|
-
import { compose
|
|
9
|
+
import { compose } from '@wordpress/compose';
|
|
10
10
|
import { useState } from '@wordpress/element';
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
@@ -21,7 +21,6 @@ function PostSwitchToDraftButton(_ref) {
|
|
|
21
21
|
isScheduled,
|
|
22
22
|
onClick
|
|
23
23
|
} = _ref;
|
|
24
|
-
const isMobileViewport = useViewportMatch('small', '<');
|
|
25
24
|
const [showConfirmDialog, setShowConfirmDialog] = useState(false);
|
|
26
25
|
|
|
27
26
|
if (!isPublished && !isScheduled) {
|
|
@@ -41,14 +40,20 @@ function PostSwitchToDraftButton(_ref) {
|
|
|
41
40
|
onClick();
|
|
42
41
|
};
|
|
43
42
|
|
|
44
|
-
return createElement(
|
|
43
|
+
return createElement(FlexItem, {
|
|
44
|
+
isBlock: true
|
|
45
|
+
}, createElement(Button, {
|
|
45
46
|
className: "editor-post-switch-to-draft",
|
|
46
47
|
onClick: () => {
|
|
47
48
|
setShowConfirmDialog(true);
|
|
48
49
|
},
|
|
49
50
|
disabled: isSaving,
|
|
50
|
-
variant: "
|
|
51
|
-
|
|
51
|
+
variant: "secondary",
|
|
52
|
+
style: {
|
|
53
|
+
width: '100%',
|
|
54
|
+
display: 'block'
|
|
55
|
+
}
|
|
56
|
+
}, __('Switch to draft')), createElement(ConfirmDialog, {
|
|
52
57
|
isOpen: showConfirmDialog,
|
|
53
58
|
onConfirm: handleConfirm,
|
|
54
59
|
onCancel: () => setShowConfirmDialog(false)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-switch-to-draft-button/index.js"],"names":["Button","__experimentalConfirmDialog","ConfirmDialog","__","withSelect","withDispatch","compose","
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-switch-to-draft-button/index.js"],"names":["Button","FlexItem","__experimentalConfirmDialog","ConfirmDialog","__","withSelect","withDispatch","compose","useState","store","editorStore","PostSwitchToDraftButton","isSaving","isPublished","isScheduled","onClick","showConfirmDialog","setShowConfirmDialog","alertMessage","handleConfirm","width","display","select","isSavingPost","isCurrentPostPublished","isCurrentPostScheduled","dispatch","editPost","savePost","status"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,MADD,EAECC,QAFD,EAGCC,2BAA2B,IAAIC,aAHhC,QAIO,uBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,aAArC;;AAEA,SAASC,uBAAT,OAKI;AAAA,MAL8B;AACjCC,IAAAA,QADiC;AAEjCC,IAAAA,WAFiC;AAGjCC,IAAAA,WAHiC;AAIjCC,IAAAA;AAJiC,GAK9B;AACH,QAAM,CAAEC,iBAAF,EAAqBC,oBAArB,IAA8CT,QAAQ,CAAE,KAAF,CAA5D;;AAEA,MAAK,CAAEK,WAAF,IAAiB,CAAEC,WAAxB,EAAsC;AACrC,WAAO,IAAP;AACA;;AAED,MAAII,YAAJ;;AACA,MAAKL,WAAL,EAAmB;AAClBK,IAAAA,YAAY,GAAGd,EAAE,CAAE,+CAAF,CAAjB;AACA,GAFD,MAEO,IAAKU,WAAL,EAAmB;AACzBI,IAAAA,YAAY,GAAGd,EAAE,CAAE,gDAAF,CAAjB;AACA;;AAED,QAAMe,aAAa,GAAG,MAAM;AAC3BF,IAAAA,oBAAoB,CAAE,KAAF,CAApB;AAC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ourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tFlexItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction PostSwitchToDraftButton( {\n\tisSaving,\n\tisPublished,\n\tisScheduled,\n\tonClick,\n} ) {\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tif ( ! isPublished && ! isScheduled ) {\n\t\treturn null;\n\t}\n\n\tlet alertMessage;\n\tif ( isPublished ) {\n\t\talertMessage = __( 'Are you sure you want to unpublish this post?' );\n\t} else if ( isScheduled ) {\n\t\talertMessage = __( 'Are you sure you want to unschedule this post?' );\n\t}\n\n\tconst handleConfirm = () => {\n\t\tsetShowConfirmDialog( false );\n\t\tonClick();\n\t};\n\n\treturn (\n\t\t<FlexItem isBlock>\n\t\t\t<Button\n\t\t\t\tclassName=\"editor-post-switch-to-draft\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t\t} }\n\t\t\t\tdisabled={ isSaving }\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tstyle={ { width: '100%', display: 'block' } }\n\t\t\t>\n\t\t\t\t{ __( 'Switch to draft' ) }\n\t\t\t</Button>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\tonConfirm={ handleConfirm }\n\t\t\t\tonCancel={ () => setShowConfirmDialog( false ) }\n\t\t\t>\n\t\t\t\t{ alertMessage }\n\t\t\t</ConfirmDialog>\n\t\t</FlexItem>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { isSavingPost, isCurrentPostPublished, isCurrentPostScheduled } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tisSaving: isSavingPost(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost, savePost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonClick: () => {\n\t\t\t\teditPost( { status: 'draft' } );\n\t\t\t\tsavePost();\n\t\t\t},\n\t\t};\n\t} ),\n] )( PostSwitchToDraftButton );\n"]}
|
|
@@ -127,7 +127,7 @@ export function FlatTermSelector(_ref) {
|
|
|
127
127
|
search
|
|
128
128
|
}) : EMPTY_ARRAY
|
|
129
129
|
};
|
|
130
|
-
}, [search]); // Update terms state only after the selectors are resolved.
|
|
130
|
+
}, [search, slug]); // Update terms state only after the selectors are resolved.
|
|
131
131
|
// We're using this to avoid terms temporarily disappearing on slow networks
|
|
132
132
|
// while core data makes REST API requests.
|
|
133
133
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/flat-term-selector.js"],"names":["escapeHtml","__","_x","sprintf","useEffect","useMemo","useState","FormTokenField","withFilters","useSelect","useDispatch","store","coreStore","useDebounce","apiFetch","speak","editorStore","unescapeString","unescapeTerm","MostUsedTerms","EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","find","term","name","id","findOrCreateTerm","restBase","namespace","escapedTermName","path","method","data","catch","error","code","Promise","reject","resolve","term_id","then","FlatTermSelector","slug","values","setValues","search","setSearch","debouncedSearch","termIds","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","getCurrentPost","getEditedPostAttribute","getEntityRecords","getTaxonomy","hasFinishedResolution","post","_taxonomy","_termIds","rest_base","query","include","join","_links","length","searchResults","newValues","suggestions","editPost","onUpdateTerms","newTermIds","onChange","termNames","availableTerms","uniqueTerms","reduce","acc","some","n","push","newTermNames","filter","rest_namespace","all","newTerms","newAvailableTerms","concat","appendTerm","newTerm","includes","defaultName","termAddedMessage","labels","singular_name","newTermLabel","add_new_item","singularName","termAddedLabel","termRemovedLabel","removeTermLabel","added","removed","remove"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,aAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,SAAT,EAAoBC,OAApB,EAA6BC,QAA7B,QAA6C,oBAA7C;AACA,SAASC,cAAT,EAAyBC,WAAzB,QAA4C,uBAA5C;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AACA,OAAOC,QAAP,MAAqB,sBAArB;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SAASJ,KAAK,IAAIK,WAAlB,QAAqC,aAArC;AACA,SAASC,cAAT,EAAyBC,YAAzB,QAA6C,mBAA7C;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,WAAW,GAAG,EAApB;AAEA;AACA;AACA;;AACA,MAAMC,qBAAqB,GAAG,EAA9B;AACA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAEF,qBADW;AAErBG,EAAAA,OAAO,EAAE,SAFY;AAGrBC,EAAAA,OAAO,EAAE;AAHY,CAAtB;;AAMA,MAAMC,cAAc,GAAG,CAAEC,KAAF,EAASC,KAAT,KACtBX,cAAc,CAAEU,KAAF,CAAd,CAAwBE,WAAxB,OACAZ,cAAc,CAAEW,KAAF,CAAd,CAAwBC,WAAxB,EAFD;;AAIA,MAAMC,cAAc,GAAG,CAAEC,KAAF,EAASC,KAAT,KAAoB;AAC1C,SAAOD,KAAK,CAACE,GAAN,CACJC,QAAF,IACCF,KAAK,CAACG,IAAN,CAAc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,EAAE,CAAE,UAAF,EAAc,MAAd,CAF2B,EAG7B8G,YAH6B,CAA9B;AAKA,QAAME,gBAAgB,GAAG/G,OAAO;AAC/B;AACAD,EAAAA,EAAE,CAAE,YAAF,EAAgB,MAAhB,CAF6B,EAG/B8G,YAH+B,CAAhC;AAKA,QAAMG,eAAe,GAAGhH,OAAO;AAC9B;AACAD,EAAAA,EAAE,CAAE,WAAF,EAAe,MAAf,CAF4B,EAG9B8G,YAH8B,CAA/B;AAMA,SACC,8BACC,cAAC,cAAD;AACC,IAAA,KAAK,EAAGxD,MADT;AAEC,IAAA,WAAW,EAAG2B,WAFf;AAGC,IAAA,QAAQ,EAAGI,QAHZ;AAIC,IAAA,aAAa,EAAG3B,eAJjB;AAKC,IAAA,cAAc,EAAGvC,qBALlB;AAMC,IAAA,KAAK,EAAGyF,YANT;AAOC,IAAA,QAAQ,EAAG;AACVM,MAAAA,KAAK,EAAEH,cADG;AAEVI,MAAAA,OAAO,EAAEH,gBAFC;AAGVI,MAAAA,MAAM,EAAEH;AAHE;AAPZ,IADD,EAcC,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAGrD,QAA1B;AAAqC,IAAA,QAAQ,EAAGyC;AAAhD,IAdD,CADD;AAkBA;AAED,eAAe/F,WAAW,CAAE,yBAAF,CAAX,CAA0C8C,gBAA1C,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport escapeHtml from 'escape-html';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, withFilters } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport apiFetch from '@wordpress/api-fetch';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Module constants\n */\nconst MAX_TERMS_SUGGESTIONS = 20;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names.map(\n\t\t( termName ) =>\n\t\t\tterms.find( ( term ) => isSameTermName( term.name, termName ) ).id\n\t);\n};\n\n// Tries to create a term or fetch it if it already exists.\nfunction findOrCreateTerm( termName, restBase, namespace ) {\n\tconst escapedTermName = escapeHtml( termName );\n\n\treturn apiFetch( {\n\t\tpath: `/${ namespace }/${ restBase }`,\n\t\tmethod: 'POST',\n\t\tdata: { name: escapedTermName },\n\t} )\n\t\t.catch( ( error ) => {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\treturn Promise.reject( error );\n\t\t\t}\n\n\t\t\treturn Promise.resolve( {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: termName,\n\t\t\t} );\n\t\t} )\n\t\t.then( unescapeTerm );\n}\n\nexport function FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecords, getTaxonomy, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! availableTerms.find( ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, availableTerms )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( termName, taxonomy.rest_base, namespace )\n\t\t\t)\n\t\t).then( ( newTerms ) => {\n\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t);\n\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst defaultName = slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' );\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\ttaxonomy?.labels?.singular_name ?? defaultName\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel =\n\t\ttaxonomy?.labels?.add_new_item ??\n\t\t( slug === 'post_tag' ? __( 'Add new tag' ) : __( 'Add new Term' ) );\n\tconst singularName =\n\t\ttaxonomy?.labels?.singular_name ??\n\t\t( slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' ) );\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<FormTokenField\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/flat-term-selector.js"],"names":["escapeHtml","__","_x","sprintf","useEffect","useMemo","useState","FormTokenField","withFilters","useSelect","useDispatch","store","coreStore","useDebounce","apiFetch","speak","editorStore","unescapeString","unescapeTerm","MostUsedTerms","EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","find","term","name","id","findOrCreateTerm","restBase","namespace","escapedTermName","path","method","data","catch","error","code","Promise","reject","resolve","term_id","then","FlatTermSelector","slug","values","setValues","search","setSearch","debouncedSearch","termIds","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","getCurrentPost","getEditedPostAttribute","getEntityRecords","getTaxonomy","hasFinishedResolution","post","_taxonomy","_termIds","rest_base","query","include","join","_links","length","searchResults","newValues","suggestions","editPost","onUpdateTerms","newTermIds","onChange","termNames","availableTerms","uniqueTerms","reduce","acc","some","n","push","newTermNames","filter","rest_namespace","all","newTerms","newAvailableTerms","concat","appendTerm","newTerm","includes","defaultName","termAddedMessage","labels","singular_name","newTermLabel","add_new_item","singularName","termAddedLabel","termRemovedLabel","removeTermLabel","added","removed","remove"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,aAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,SAAT,EAAoBC,OAApB,EAA6BC,QAA7B,QAA6C,oBAA7C;AACA,SAASC,cAAT,EAAyBC,WAAzB,QAA4C,uBAA5C;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AAC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AAQ,EAAGI,QAHZ;AAIC,IAAA,aAAa,EAAG3B,eAJjB;AAKC,IAAA,cAAc,EAAGvC,qBALlB;AAMC,IAAA,KAAK,EAAGyF,YANT;AAOC,IAAA,QAAQ,EAAG;AACVM,MAAAA,KAAK,EAAEH,cADG;AAEVI,MAAAA,OAAO,EAAEH,gBAFC;AAGVI,MAAAA,MAAM,EAAEH;AAHE;AAPZ,IADD,EAcC,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAGrD,QAA1B;AAAqC,IAAA,QAAQ,EAAGyC;AAAhD,IAdD,CADD;AAkBA;AAED,eAAe/F,WAAW,CAAE,yBAAF,CAAX,CAA0C8C,gBAA1C,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport escapeHtml from 'escape-html';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, withFilters } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport apiFetch from '@wordpress/api-fetch';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Module constants\n */\nconst MAX_TERMS_SUGGESTIONS = 20;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names.map(\n\t\t( termName ) =>\n\t\t\tterms.find( ( term ) => isSameTermName( term.name, termName ) ).id\n\t);\n};\n\n// Tries to create a term or fetch it if it already exists.\nfunction findOrCreateTerm( termName, restBase, namespace ) {\n\tconst escapedTermName = escapeHtml( termName );\n\n\treturn apiFetch( {\n\t\tpath: `/${ namespace }/${ restBase }`,\n\t\tmethod: 'POST',\n\t\tdata: { name: escapedTermName },\n\t} )\n\t\t.catch( ( error ) => {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\treturn Promise.reject( error );\n\t\t\t}\n\n\t\t\treturn Promise.resolve( {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: termName,\n\t\t\t} );\n\t\t} )\n\t\t.then( unescapeTerm );\n}\n\nexport function FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecords, getTaxonomy, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search, slug ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! availableTerms.find( ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, availableTerms )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( termName, taxonomy.rest_base, namespace )\n\t\t\t)\n\t\t).then( ( newTerms ) => {\n\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t);\n\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst defaultName = slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' );\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\ttaxonomy?.labels?.singular_name ?? defaultName\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel =\n\t\ttaxonomy?.labels?.add_new_item ??\n\t\t( slug === 'post_tag' ? __( 'Add new tag' ) : __( 'Add new Term' ) );\n\tconst singularName =\n\t\ttaxonomy?.labels?.singular_name ??\n\t\t( slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' ) );\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<FormTokenField\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"]}
|
|
@@ -13,7 +13,7 @@ import inserterMediaCategories from '../media-categories';
|
|
|
13
13
|
import { mediaUpload } from '../../utils';
|
|
14
14
|
import { store as editorStore } from '../../store';
|
|
15
15
|
const EMPTY_BLOCKS_LIST = [];
|
|
16
|
-
const BLOCK_EDITOR_SETTINGS = ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalGlobalStylesBaseStyles', '__experimentalPreferredStyleVariations', '__experimentalSetIsInserterOpened', '__unstableGalleryWithImageBlocks', 'alignWide', 'allowedBlockTypes', 'blockInspectorTabs', 'allowedMimeTypes', 'bodyPlaceholder', 'canLockBlocks', 'capabilities', 'clearBlockSelection', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomSpacingSizes', 'disableCustomGradients', 'disableLayoutStyles', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'enableOpenverseMediaCategory', 'focusMode', 'fontSizes', 'gradients', 'generateAnchors', 'hasFixedToolbar', 'hasInlineToolbar', 'isDistractionFree', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'keepCaretInsideBlock', 'locale', 'maxWidth', 'onUpdateDefaultBlockStyles', 'postContentAttributes', 'postsPerPage', 'readOnly', 'styles', 'template', 'templateLock', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableHasCustomAppender', '__unstableIsPreviewMode', '__unstableResolvedAssets', '__unstableIsBlockBasedTheme'];
|
|
16
|
+
const BLOCK_EDITOR_SETTINGS = ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalGlobalStylesBaseStyles', '__experimentalPreferredStyleVariations', '__experimentalSetIsInserterOpened', '__unstableGalleryWithImageBlocks', 'alignWide', 'allowedBlockTypes', 'blockInspectorTabs', 'allowedMimeTypes', 'bodyPlaceholder', 'canLockBlocks', 'capabilities', 'clearBlockSelection', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomSpacingSizes', 'disableCustomGradients', 'disableLayoutStyles', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'enableOpenverseMediaCategory', 'focusMode', 'fontSizes', 'gradients', 'generateAnchors', 'hasFixedToolbar', 'hasInlineToolbar', 'isDistractionFree', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'keepCaretInsideBlock', 'locale', 'maxWidth', 'onUpdateDefaultBlockStyles', 'postContentAttributes', 'postsPerPage', 'readOnly', 'styles', 'template', 'templateLock', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableHasCustomAppender', '__unstableIsPreviewMode', '__unstableResolvedAssets', '__unstableIsBlockBasedTheme', 'behaviors'];
|
|
17
17
|
/**
|
|
18
18
|
* React hook used to compute the block editor settings to use for the post editor.
|
|
19
19
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/provider/use-block-editor-settings.js"],"names":["Platform","useMemo","useDispatch","useSelect","store","coreStore","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalFetchUrlData","fetchUrlData","__","inserterMediaCategories","mediaUpload","editorStore","EMPTY_BLOCKS_LIST","BLOCK_EDITOR_SETTINGS","useBlockEditorSettings","settings","hasTemplate","reusableBlocks","hasUploadPermissions","canUseUnfilteredHTML","userCanCreatePages","pageOnFront","postType","select","canUserUseUnfilteredHTML","getCurrentPostType","isWeb","OS","canUser","getEntityRecord","siteSettings","undefined","getEntityRecords","per_page","page_on_front","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","getBlockPatterns","getBlockPatternCategories","blockPatterns","filter","x","index","arr","findIndex","y","name","postTypes","Array","isArray","includes","blockPatternCategories","undo","saveEntityRecord","createPageEntity","options","Promise","reject","message","Object","fromEntries","entries","key","__experimentalReusableBlocks","search","searchOptions","__experimentalFetchRichUrlData","__experimentalCanUserUseUnfilteredHTML","__experimentalUndo","outlineMode","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","__experimentalPreferPatternsOnRoot"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,OAAnB,QAAkC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BxD,QAAzB,CAXd;AAYPN,IAAAA,uBAZO;AAaP+D,IAAAA,8BAA8B,EAAEjE,YAbzB;AAcPkE,IAAAA,sCAAsC,EAAEtD,oBAdjC;AAePuD,IAAAA,kBAAkB,EAAEhB,IAfb;AAgBPiB,IAAAA,WAAW,EAAE3D,WAhBN;AAiBP4D,IAAAA,8BAA8B,EAAEhB,gBAjBzB;AAkBPiB,IAAAA,gCAAgC,EAAEzD,kBAlB3B;AAmBPC,IAAAA,WAnBO;AAoBPyD,IAAAA,kCAAkC,EAAE9D;AApB7B,GAAR,CADa,EAuBb,CACCD,QADD,EAECG,oBAFD,EAGCD,cAHD,EAIC4B,aAJD,EAKCY,sBALD,EAMCtC,oBAND,EAOCuC,IAPD,EAQC1C,WARD,EASCI,kBATD,EAUCC,WAVD,CAvBa,CAAd;AAoCA;;AAED,eAAeP,sBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Platform, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from '../media-categories';\nimport { mediaUpload } from '../../utils';\nimport { store as editorStore } from '../../store';\n\nconst EMPTY_BLOCKS_LIST = [];\n\nconst BLOCK_EDITOR_SETTINGS = [\n\t'__experimentalBlockDirectory',\n\t'__experimentalDiscussionSettings',\n\t'__experimentalFeatures',\n\t'__experimentalGlobalStylesBaseStyles',\n\t'__experimentalPreferredStyleVariations',\n\t'__experimentalSetIsInserterOpened',\n\t'__unstableGalleryWithImageBlocks',\n\t'alignWide',\n\t'allowedBlockTypes',\n\t'blockInspectorTabs',\n\t'allowedMimeTypes',\n\t'bodyPlaceholder',\n\t'canLockBlocks',\n\t'capabilities',\n\t'clearBlockSelection',\n\t'codeEditingEnabled',\n\t'colors',\n\t'disableCustomColors',\n\t'disableCustomFontSizes',\n\t'disableCustomSpacingSizes',\n\t'disableCustomGradients',\n\t'disableLayoutStyles',\n\t'enableCustomLineHeight',\n\t'enableCustomSpacing',\n\t'enableCustomUnits',\n\t'enableOpenverseMediaCategory',\n\t'focusMode',\n\t'fontSizes',\n\t'gradients',\n\t'generateAnchors',\n\t'hasFixedToolbar',\n\t'hasInlineToolbar',\n\t'isDistractionFree',\n\t'imageDefaultSize',\n\t'imageDimensions',\n\t'imageEditing',\n\t'imageSizes',\n\t'isRTL',\n\t'keepCaretInsideBlock',\n\t'locale',\n\t'maxWidth',\n\t'onUpdateDefaultBlockStyles',\n\t'postContentAttributes',\n\t'postsPerPage',\n\t'readOnly',\n\t'styles',\n\t'template',\n\t'templateLock',\n\t'titlePlaceholder',\n\t'supportsLayout',\n\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t'__unstableHasCustomAppender',\n\t'__unstableIsPreviewMode',\n\t'__unstableResolvedAssets',\n\t'__unstableIsBlockBasedTheme',\n];\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {boolean} hasTemplate Whether template mode is enabled.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, hasTemplate ) {\n\tconst {\n\t\treusableBlocks,\n\t\thasUploadPermissions,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpostType,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUserUseUnfilteredHTML, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst isWeb = Platform.OS === 'web';\n\t\tconst { canUser, getEntityRecord } = select( coreStore );\n\n\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanUseUnfilteredHTML: canUserUseUnfilteredHTML(),\n\t\t\treusableBlocks: isWeb\n\t\t\t\t? select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_block',\n\t\t\t\t\t\t{ per_page: -1 }\n\t\t\t\t )\n\t\t\t\t: EMPTY_BLOCKS_LIST, // Reusable blocks are fetched in the native version of this hook.\n\t\t\thasUploadPermissions: canUser( 'create', 'media' ) ?? true,\n\t\t\tuserCanCreatePages: canUser( 'create', 'pages' ),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t]\n\t\t\t\t.filter(\n\t\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t\t)\n\t\t\t\t.filter( ( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t} ),\n\t\t[ settingsBlockPatterns, restBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo } = useDispatch( editorStore );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = ( options ) => {\n\t\tif ( ! userCanCreatePages ) {\n\t\t\treturn Promise.reject( {\n\t\t\t\tmessage: __( 'You do not have permission to create Pages.' ),\n\t\t\t} );\n\t\t}\n\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t};\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( settings ).filter( ( [ key ] ) =>\n\t\t\t\t\tBLOCK_EDITOR_SETTINGS.includes( key )\n\t\t\t\t)\n\t\t\t),\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t__experimentalUndo: undo,\n\t\t\toutlineMode: hasTemplate,\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\t__experimentalPreferPatternsOnRoot: hasTemplate,\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\thasUploadPermissions,\n\t\t\treusableBlocks,\n\t\t\tblockPatterns,\n\t\t\tblockPatternCategories,\n\t\t\tcanUseUnfilteredHTML,\n\t\t\tundo,\n\t\t\thasTemplate,\n\t\t\tuserCanCreatePages,\n\t\t\tpageOnFront,\n\t\t]\n\t);\n}\n\nexport default useBlockEditorSettings;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/provider/use-block-editor-settings.js"],"names":["Platform","useMemo","useDispatch","useSelect","store","coreStore","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalFetchUrlData","fetchUrlData","__","inserterMediaCategories","mediaUpload","editorStore","EMPTY_BLOCKS_LIST","BLOCK_EDITOR_SETTINGS","useBlockEditorSettings","settings","hasTemplate","reusableBlocks","hasUploadPermissions","canUseUnfilteredHTML","userCanCreatePages","pageOnFront","postType","select","canUserUseUnfilteredHTML","getCurrentPostType","isWeb","OS","canUser","getEntityRecord","siteSettings","undefined","getEntityRecords","per_page","page_on_front","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","getBlockPatterns","getBlockPatternCategories","blockPatterns","filter","x","index","arr","findIndex","y","name","postTypes","Array","isArray","includes","blockPatternCategories","undo","saveEntityRecord","createPageEntity","options","Promise","reject","message","Object","fromEntries","entries","key","__experimentalReusableBlocks","search","searchOptions","__experimentalFetchRichUrlData","__experimentalCanUserUseUnfilteredHTML","__experimentalUndo","outlineMode","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","__experimentalPreferPatternsOnRoot"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,OAAnB,QAAkC,oBAAlC;AACA,SAASC,WAAT,EAAsBC,SAAt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N,IAAAA,uBAZO;AAaP+D,IAAAA,8BAA8B,EAAEjE,YAbzB;AAcPkE,IAAAA,sCAAsC,EAAEtD,oBAdjC;AAePuD,IAAAA,kBAAkB,EAAEhB,IAfb;AAgBPiB,IAAAA,WAAW,EAAE3D,WAhBN;AAiBP4D,IAAAA,8BAA8B,EAAEhB,gBAjBzB;AAkBPiB,IAAAA,gCAAgC,EAAEzD,kBAlB3B;AAmBPC,IAAAA,WAnBO;AAoBPyD,IAAAA,kCAAkC,EAAE9D;AApB7B,GAAR,CADa,EAuBb,CACCD,QADD,EAECG,oBAFD,EAGCD,cAHD,EAIC4B,aAJD,EAKCY,sBALD,EAMCtC,oBAND,EAOCuC,IAPD,EAQC1C,WARD,EASCI,kBATD,EAUCC,WAVD,CAvBa,CAAd;AAoCA;;AAED,eAAeP,sBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Platform, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from '../media-categories';\nimport { mediaUpload } from '../../utils';\nimport { store as editorStore } from '../../store';\n\nconst EMPTY_BLOCKS_LIST = [];\n\nconst BLOCK_EDITOR_SETTINGS = [\n\t'__experimentalBlockDirectory',\n\t'__experimentalDiscussionSettings',\n\t'__experimentalFeatures',\n\t'__experimentalGlobalStylesBaseStyles',\n\t'__experimentalPreferredStyleVariations',\n\t'__experimentalSetIsInserterOpened',\n\t'__unstableGalleryWithImageBlocks',\n\t'alignWide',\n\t'allowedBlockTypes',\n\t'blockInspectorTabs',\n\t'allowedMimeTypes',\n\t'bodyPlaceholder',\n\t'canLockBlocks',\n\t'capabilities',\n\t'clearBlockSelection',\n\t'codeEditingEnabled',\n\t'colors',\n\t'disableCustomColors',\n\t'disableCustomFontSizes',\n\t'disableCustomSpacingSizes',\n\t'disableCustomGradients',\n\t'disableLayoutStyles',\n\t'enableCustomLineHeight',\n\t'enableCustomSpacing',\n\t'enableCustomUnits',\n\t'enableOpenverseMediaCategory',\n\t'focusMode',\n\t'fontSizes',\n\t'gradients',\n\t'generateAnchors',\n\t'hasFixedToolbar',\n\t'hasInlineToolbar',\n\t'isDistractionFree',\n\t'imageDefaultSize',\n\t'imageDimensions',\n\t'imageEditing',\n\t'imageSizes',\n\t'isRTL',\n\t'keepCaretInsideBlock',\n\t'locale',\n\t'maxWidth',\n\t'onUpdateDefaultBlockStyles',\n\t'postContentAttributes',\n\t'postsPerPage',\n\t'readOnly',\n\t'styles',\n\t'template',\n\t'templateLock',\n\t'titlePlaceholder',\n\t'supportsLayout',\n\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t'__unstableHasCustomAppender',\n\t'__unstableIsPreviewMode',\n\t'__unstableResolvedAssets',\n\t'__unstableIsBlockBasedTheme',\n\t'behaviors',\n];\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {boolean} hasTemplate Whether template mode is enabled.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, hasTemplate ) {\n\tconst {\n\t\treusableBlocks,\n\t\thasUploadPermissions,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpostType,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUserUseUnfilteredHTML, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst isWeb = Platform.OS === 'web';\n\t\tconst { canUser, getEntityRecord } = select( coreStore );\n\n\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanUseUnfilteredHTML: canUserUseUnfilteredHTML(),\n\t\t\treusableBlocks: isWeb\n\t\t\t\t? select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_block',\n\t\t\t\t\t\t{ per_page: -1 }\n\t\t\t\t )\n\t\t\t\t: EMPTY_BLOCKS_LIST, // Reusable blocks are fetched in the native version of this hook.\n\t\t\thasUploadPermissions: canUser( 'create', 'media' ) ?? true,\n\t\t\tuserCanCreatePages: canUser( 'create', 'pages' ),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t]\n\t\t\t\t.filter(\n\t\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t\t)\n\t\t\t\t.filter( ( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t} ),\n\t\t[ settingsBlockPatterns, restBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo } = useDispatch( editorStore );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = ( options ) => {\n\t\tif ( ! userCanCreatePages ) {\n\t\t\treturn Promise.reject( {\n\t\t\t\tmessage: __( 'You do not have permission to create Pages.' ),\n\t\t\t} );\n\t\t}\n\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t};\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( settings ).filter( ( [ key ] ) =>\n\t\t\t\t\tBLOCK_EDITOR_SETTINGS.includes( key )\n\t\t\t\t)\n\t\t\t),\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t__experimentalUndo: undo,\n\t\t\toutlineMode: hasTemplate,\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\t__experimentalPreferPatternsOnRoot: hasTemplate,\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\thasUploadPermissions,\n\t\t\treusableBlocks,\n\t\t\tblockPatterns,\n\t\t\tblockPatternCategories,\n\t\t\tcanUseUnfilteredHTML,\n\t\t\tundo,\n\t\t\thasTemplate,\n\t\t\tuserCanCreatePages,\n\t\t\tpageOnFront,\n\t\t]\n\t);\n}\n\nexport default useBlockEditorSettings;\n"]}
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
--wp-block-synced-color: #7a00df;
|
|
99
99
|
--wp-block-synced-color--rgb: 122, 0, 223;
|
|
100
100
|
}
|
|
101
|
-
@media (
|
|
101
|
+
@media (min-resolution: 192dpi) {
|
|
102
102
|
:root {
|
|
103
103
|
--wp-admin-border-width-focus: 1.5px;
|
|
104
104
|
}
|
|
@@ -282,10 +282,6 @@
|
|
|
282
282
|
.editor-post-featured-image {
|
|
283
283
|
padding: 0;
|
|
284
284
|
}
|
|
285
|
-
.editor-post-featured-image__container {
|
|
286
|
-
margin-bottom: 1em;
|
|
287
|
-
position: relative;
|
|
288
|
-
}
|
|
289
285
|
.editor-post-featured-image .components-spinner {
|
|
290
286
|
position: absolute;
|
|
291
287
|
top: 50%;
|
|
@@ -293,22 +289,28 @@
|
|
|
293
289
|
margin-top: -9px;
|
|
294
290
|
margin-right: -9px;
|
|
295
291
|
}
|
|
296
|
-
.editor-post-featured-image .components-button + .components-button {
|
|
297
|
-
display: block;
|
|
298
|
-
margin-top: 1em;
|
|
299
|
-
}
|
|
300
292
|
.editor-post-featured-image .components-responsive-wrapper__content {
|
|
301
293
|
max-width: 100%;
|
|
302
294
|
width: auto;
|
|
303
295
|
}
|
|
304
296
|
|
|
297
|
+
.editor-post-featured-image__container {
|
|
298
|
+
position: relative;
|
|
299
|
+
}
|
|
300
|
+
.editor-post-featured-image__container:hover .editor-post-featured-image__actions, .editor-post-featured-image__container:focus .editor-post-featured-image__actions, .editor-post-featured-image__container:focus-within .editor-post-featured-image__actions {
|
|
301
|
+
opacity: 1;
|
|
302
|
+
}
|
|
303
|
+
|
|
305
304
|
.editor-post-featured-image__toggle,
|
|
306
305
|
.editor-post-featured-image__preview {
|
|
307
|
-
display: block;
|
|
308
306
|
width: 100%;
|
|
309
307
|
padding: 0;
|
|
310
308
|
transition: all 0.1s ease-out;
|
|
311
309
|
box-shadow: 0 0 0 0 var(--wp-admin-theme-color);
|
|
310
|
+
overflow: hidden;
|
|
311
|
+
display: flex;
|
|
312
|
+
justify-content: center;
|
|
313
|
+
max-height: 150px;
|
|
312
314
|
}
|
|
313
315
|
@media (prefers-reduced-motion: reduce) {
|
|
314
316
|
.editor-post-featured-image__toggle,
|
|
@@ -321,9 +323,9 @@
|
|
|
321
323
|
.editor-post-featured-image__preview {
|
|
322
324
|
height: auto;
|
|
323
325
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
326
|
+
.editor-post-featured-image__preview .components-responsive-wrapper {
|
|
327
|
+
width: 100%;
|
|
328
|
+
background: #f0f0f0;
|
|
327
329
|
}
|
|
328
330
|
|
|
329
331
|
.editor-post-featured-image__toggle {
|
|
@@ -339,6 +341,28 @@
|
|
|
339
341
|
color: #1e1e1e;
|
|
340
342
|
}
|
|
341
343
|
|
|
344
|
+
.editor-post-featured-image__actions {
|
|
345
|
+
bottom: 0;
|
|
346
|
+
opacity: 0;
|
|
347
|
+
padding: 8px;
|
|
348
|
+
position: absolute;
|
|
349
|
+
transition: opacity 50ms ease-out;
|
|
350
|
+
}
|
|
351
|
+
@media (prefers-reduced-motion: reduce) {
|
|
352
|
+
.editor-post-featured-image__actions {
|
|
353
|
+
transition-duration: 0s;
|
|
354
|
+
transition-delay: 0s;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.editor-post-featured-image__action {
|
|
359
|
+
-webkit-backdrop-filter: blur(16px) saturate(180%);
|
|
360
|
+
backdrop-filter: blur(16px) saturate(180%);
|
|
361
|
+
background: rgba(255, 255, 255, 0.75);
|
|
362
|
+
flex-grow: 1;
|
|
363
|
+
justify-content: center;
|
|
364
|
+
}
|
|
365
|
+
|
|
342
366
|
[class].editor-post-format__suggestion {
|
|
343
367
|
margin: 4px 0 0 0;
|
|
344
368
|
}
|
|
@@ -833,10 +857,8 @@
|
|
|
833
857
|
}
|
|
834
858
|
|
|
835
859
|
.editor-post-trash.components-button {
|
|
836
|
-
display: flex;
|
|
837
|
-
justify-content: center;
|
|
838
|
-
margin-top: 4px;
|
|
839
860
|
width: 100%;
|
|
861
|
+
display: block;
|
|
840
862
|
}
|
|
841
863
|
|
|
842
864
|
.table-of-contents__popover.components-popover .components-popover__content {
|
package/build-style/style.css
CHANGED
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
--wp-block-synced-color: #7a00df;
|
|
99
99
|
--wp-block-synced-color--rgb: 122, 0, 223;
|
|
100
100
|
}
|
|
101
|
-
@media (
|
|
101
|
+
@media (min-resolution: 192dpi) {
|
|
102
102
|
:root {
|
|
103
103
|
--wp-admin-border-width-focus: 1.5px;
|
|
104
104
|
}
|
|
@@ -282,10 +282,6 @@
|
|
|
282
282
|
.editor-post-featured-image {
|
|
283
283
|
padding: 0;
|
|
284
284
|
}
|
|
285
|
-
.editor-post-featured-image__container {
|
|
286
|
-
margin-bottom: 1em;
|
|
287
|
-
position: relative;
|
|
288
|
-
}
|
|
289
285
|
.editor-post-featured-image .components-spinner {
|
|
290
286
|
position: absolute;
|
|
291
287
|
top: 50%;
|
|
@@ -293,22 +289,28 @@
|
|
|
293
289
|
margin-top: -9px;
|
|
294
290
|
margin-left: -9px;
|
|
295
291
|
}
|
|
296
|
-
.editor-post-featured-image .components-button + .components-button {
|
|
297
|
-
display: block;
|
|
298
|
-
margin-top: 1em;
|
|
299
|
-
}
|
|
300
292
|
.editor-post-featured-image .components-responsive-wrapper__content {
|
|
301
293
|
max-width: 100%;
|
|
302
294
|
width: auto;
|
|
303
295
|
}
|
|
304
296
|
|
|
297
|
+
.editor-post-featured-image__container {
|
|
298
|
+
position: relative;
|
|
299
|
+
}
|
|
300
|
+
.editor-post-featured-image__container:hover .editor-post-featured-image__actions, .editor-post-featured-image__container:focus .editor-post-featured-image__actions, .editor-post-featured-image__container:focus-within .editor-post-featured-image__actions {
|
|
301
|
+
opacity: 1;
|
|
302
|
+
}
|
|
303
|
+
|
|
305
304
|
.editor-post-featured-image__toggle,
|
|
306
305
|
.editor-post-featured-image__preview {
|
|
307
|
-
display: block;
|
|
308
306
|
width: 100%;
|
|
309
307
|
padding: 0;
|
|
310
308
|
transition: all 0.1s ease-out;
|
|
311
309
|
box-shadow: 0 0 0 0 var(--wp-admin-theme-color);
|
|
310
|
+
overflow: hidden;
|
|
311
|
+
display: flex;
|
|
312
|
+
justify-content: center;
|
|
313
|
+
max-height: 150px;
|
|
312
314
|
}
|
|
313
315
|
@media (prefers-reduced-motion: reduce) {
|
|
314
316
|
.editor-post-featured-image__toggle,
|
|
@@ -321,9 +323,9 @@
|
|
|
321
323
|
.editor-post-featured-image__preview {
|
|
322
324
|
height: auto;
|
|
323
325
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
326
|
+
.editor-post-featured-image__preview .components-responsive-wrapper {
|
|
327
|
+
width: 100%;
|
|
328
|
+
background: #f0f0f0;
|
|
327
329
|
}
|
|
328
330
|
|
|
329
331
|
.editor-post-featured-image__toggle {
|
|
@@ -339,6 +341,28 @@
|
|
|
339
341
|
color: #1e1e1e;
|
|
340
342
|
}
|
|
341
343
|
|
|
344
|
+
.editor-post-featured-image__actions {
|
|
345
|
+
bottom: 0;
|
|
346
|
+
opacity: 0;
|
|
347
|
+
padding: 8px;
|
|
348
|
+
position: absolute;
|
|
349
|
+
transition: opacity 50ms ease-out;
|
|
350
|
+
}
|
|
351
|
+
@media (prefers-reduced-motion: reduce) {
|
|
352
|
+
.editor-post-featured-image__actions {
|
|
353
|
+
transition-duration: 0s;
|
|
354
|
+
transition-delay: 0s;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.editor-post-featured-image__action {
|
|
359
|
+
-webkit-backdrop-filter: blur(16px) saturate(180%);
|
|
360
|
+
backdrop-filter: blur(16px) saturate(180%);
|
|
361
|
+
background: rgba(255, 255, 255, 0.75);
|
|
362
|
+
flex-grow: 1;
|
|
363
|
+
justify-content: center;
|
|
364
|
+
}
|
|
365
|
+
|
|
342
366
|
[class].editor-post-format__suggestion {
|
|
343
367
|
margin: 4px 0 0 0;
|
|
344
368
|
}
|
|
@@ -837,10 +861,8 @@
|
|
|
837
861
|
}
|
|
838
862
|
|
|
839
863
|
.editor-post-trash.components-button {
|
|
840
|
-
display: flex;
|
|
841
|
-
justify-content: center;
|
|
842
|
-
margin-top: 4px;
|
|
843
864
|
width: 100%;
|
|
865
|
+
display: block;
|
|
844
866
|
}
|
|
845
867
|
|
|
846
868
|
.table-of-contents__popover.components-popover .components-popover__content {
|