@wordpress/edit-post 7.12.0 → 7.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/block-manager/index.js +20 -4
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/device-preview/index.js +2 -4
- package/build/components/device-preview/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.js +2 -2
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/index.js +7 -14
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/plugin-sidebar-more-menu-item/index.js +4 -7
- package/build/components/header/plugin-sidebar-more-menu-item/index.js.map +1 -1
- package/build/components/header/writing-menu/index.js +0 -8
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +2 -1
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/preferences-modal/meta-boxes-section.js +2 -1
- package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build/components/preferences-modal/options/enable-custom-fields.js +1 -1
- package/build/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +4 -8
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js +4 -7
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +1 -1
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/visual-editor/index.js +19 -11
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/editor.js +27 -9
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +4 -5
- package/build/editor.native.js.map +1 -1
- package/build/hooks/validate-multiple-use/index.js +6 -8
- package/build/hooks/validate-multiple-use/index.js.map +1 -1
- package/build/index.js +18 -2
- package/build/index.js.map +1 -1
- package/build/{private-apis.js → lock-unlock.js} +1 -1
- package/build/lock-unlock.js.map +1 -0
- package/build/plugins/index.js +1 -1
- package/build/plugins/index.js.map +1 -1
- package/build-module/components/block-manager/index.js +23 -7
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/device-preview/index.js +2 -4
- package/build-module/components/device-preview/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js +1 -1
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/index.js +7 -14
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js +4 -4
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +0 -8
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +2 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js +2 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-custom-fields.js +1 -1
- package/build-module/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +4 -5
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +4 -4
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +2 -2
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +14 -7
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/editor.js +24 -6
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +4 -4
- package/build-module/editor.native.js.map +1 -1
- package/build-module/hooks/validate-multiple-use/index.js +6 -5
- package/build-module/hooks/validate-multiple-use/index.js.map +1 -1
- package/build-module/index.js +18 -2
- package/build-module/index.js.map +1 -1
- package/build-module/{private-apis.js → lock-unlock.js} +1 -1
- package/build-module/lock-unlock.js.map +1 -0
- package/build-module/plugins/index.js +1 -1
- package/build-module/plugins/index.js.map +1 -1
- package/build-style/style-rtl.css +3 -1
- package/build-style/style.css +3 -1
- package/package.json +32 -32
- package/src/components/block-manager/index.js +51 -31
- package/src/components/block-manager/style.scss +3 -1
- package/src/components/device-preview/index.js +1 -2
- package/src/components/header/header-toolbar/index.js +1 -1
- package/src/components/header/index.js +3 -8
- package/src/components/header/writing-menu/index.js +0 -10
- package/src/components/keyboard-shortcuts/index.js +1 -1
- package/src/components/preferences-modal/options/enable-custom-fields.js +2 -2
- package/src/components/preferences-modal/options/test/__snapshots__/enable-custom-fields.js.snap +2 -2
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +10 -4
- package/src/components/sidebar/post-status/index.js +2 -1
- package/src/components/visual-editor/index.js +12 -11
- package/src/editor.js +22 -1
- package/src/index.js +30 -3
- package/src/plugins/index.js +1 -1
- package/src/test/editor.native.js +34 -9
- package/build/private-apis.js.map +0 -1
- package/build-module/private-apis.js.map +0 -1
- /package/src/{private-apis.js → lock-unlock.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/editor.native.js"],"names":["Editor","Component","constructor","props","arguments","galleryWithImageBlocks","window","wp","galleryBlockV2Enabled","initialHtmlModeEnabled","mode","switchEditorMode","getEditorSettings","maxSize","setTitleRef","bind","settings","hasFixedToolbar","focusMode","hiddenBlockTypes","blockTypes","isRTL","I18nManager","length","allowedBlockTypes","undefined","defaultAllowedBlockTypes","map","name","filter","type","includes","componentDidMount","editEntityRecord","postType","postId","subscriptionParentSetFocusOnTitle","postTitleRef","focus","focusTitleWhenAvailable","subscriptionParentFeaturedImageIdNativeUpdated","payload","featured_media","featuredImageId","undoIgnore","componentWillUnmount","remove","subscribeFeaturedImageIdNativeUpdated","titleRef","render","initialEdits","post","initialHtml","editorSettings","normalizedPost","id","title","raw","initialTitle","content","status","meta","flex","select","isFeatureActive","getEditorMode","__experimentalGetPreviewDeviceType","getHiddenBlockTypes","editPostStore","getBlockTypes","blocksStore","dispatch","coreStore"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AAKA;;AACA;;AA1BA;AACA;AACA;;AAKA;AACA;AACA;;AAaA;AACA;AACA;AAIA,MAAMA,MAAN,SAAqBC,kBAArB,CAA+B;AAC9BC,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAO,GAAGC,SAAV,EADoB,CAGpB;AACA;;AACA,UAAM;AAAEC,MAAAA,sBAAsB,GAAG;AAA3B,QAAoCF,KAA1C;AACAG,IAAAA,MAAM,CAACC,EAAP,CAAUC,qBAAV,GAAkCH,sBAAlC;;AAEA,QAAKF,KAAK,CAACM,sBAAN,IAAgCN,KAAK,CAACO,IAAN,KAAe,QAApD,EAA+D;AAC9D;AACA,WAAKP,KAAL,CAAWQ,gBAAX,CAA6B,MAA7B;AACA;;AAED,SAAKC,iBAAL,GAAyB,qBAAQ,KAAKA,iBAAb,EAAgC;AACxDC,MAAAA,OAAO,EAAE;AAD+C,KAAhC,CAAzB;AAIA,SAAKC,WAAL,GAAmB,KAAKA,WAAL,CAAiBC,IAAjB,CAAuB,IAAvB,CAAnB;AACA;;AAEDH,EAAAA,iBAAiB,CAChBI,QADgB,EAEhBC,eAFgB,EAGhBC,SAHgB,EAIhBC,gBAJgB,EAKhBC,UALgB,EAMf;AACDJ,IAAAA,QAAQ,GAAG,EACV,GAAGA,QADO;AAEVK,MAAAA,KAAK,EAAEC,yBAAYD,KAFT;AAGVJ,MAAAA,eAHU;AAIVC,MAAAA;AAJU,KAAX,CADC,CAQD;;AACA,QAAKC,gBAAgB,CAACI,MAAjB,GAA0B,CAA/B,EAAmC;AAClC,UAAKP,Q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GT,cADZ;AAEC,MAAA,IAAI,EAAGC,cAFR;AAGC,MAAA,YAAY,EAAGJ,YAHhB;AAIC,MAAA,cAAc,EAAG;AAJlB,OAKM/C,KALN,GAOC,4BAAC,eAAD;AAAQ,MAAA,WAAW,EAAG,KAAKW;AAA3B,MAPD,CADD,CADD,CADD;AAeA;;AAjK6B;;eAoKhB,sBAAS,CACvB,sBAAciD,MAAF,IAAc;AACzB,QAAM;AACLC,IAAAA,eADK;AAELC,IAAAA,aAFK;AAGLC,IAAAA,kCAHK;AAILC,IAAAA;AAJK,MAKFJ,MAAM,CAAEK,YAAF,CALV;AAMA,QAAM;AAAEC,IAAAA;AAAF,MAAoBN,MAAM,CAAEO,aAAF,CAAhC;AAEA,SAAO;AACNrD,IAAAA,eAAe,EACd+C,eAAe,CAAE,cAAF,CAAf,IACAE,kCAAkC,OAAO,SAHpC;AAINhD,IAAAA,SAAS,EAAE8C,eAAe,CAAE,WAAF,CAJpB;AAKNtD,IAAAA,IAAI,EAAEuD,aAAa,EALb;AAMN9C,IAAAA,gBAAgB,EAAEgD,mBAAmB,EAN/B;AAON/C,IAAAA,UAAU,EAAEiD,aAAa;AAPnB,GAAP;AASA,CAlBD,CADuB,EAoBvB,wBAAgBE,QAAF,IAAgB;AAC7B,QAAM;AAAE5D,IAAAA;AAAF,MAAuB4D,QAAQ,CAAEH,YAAF,CAArC;AACA,QAAM;AAAEnC,IAAAA;AAAF,MAAuBsC,QAAQ,CAAEC,eAAF,CAArC;AACA,SAAO;AACN7D,IAAAA,gBADM;AAENsB,IAAAA;AAFM,GAAP;AAIA,CAPD,CApBuB,CAAT,EA4BVjC,MA5BU,C","sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\nimport { I18nManager } from 'react-native';\nimport { GestureHandlerRootView } from 'react-native-gesture-handler';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { EditorProvider } from '@wordpress/editor';\nimport { parse, serialize, store as blocksStore } from '@wordpress/blocks';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport {\n\tsubscribeSetFocusOnTitle,\n\tsubscribeFeaturedImageIdNativeUpdated,\n} from '@wordpress/react-native-bridge';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport { store as editPostStore } from './store';\n\nclass Editor extends Component {\n\tconstructor( props ) {\n\t\tsuper( ...arguments );\n\n\t\t// need to set this globally to avoid race with deprecations\n\t\t// defaulting to true to avoid issues with a not-yet-cached value\n\t\tconst { galleryWithImageBlocks = true } = props;\n\t\twindow.wp.galleryBlockV2Enabled = galleryWithImageBlocks;\n\n\t\tif ( props.initialHtmlModeEnabled && props.mode === 'visual' ) {\n\t\t\t// Enable html mode if the initial mode the parent wants it but we're not already in it.\n\t\t\tthis.props.switchEditorMode( 'text' );\n\t\t}\n\n\t\tthis.getEditorSettings = memize( this.getEditorSettings, {\n\t\t\tmaxSize: 1,\n\t\t} );\n\n\t\tthis.setTitleRef = this.setTitleRef.bind( this );\n\t}\n\n\tgetEditorSettings(\n\t\tsettings,\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\thiddenBlockTypes,\n\t\tblockTypes\n\t) {\n\t\tsettings = {\n\t\t\t...settings,\n\t\t\tisRTL: I18nManager.isRTL,\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t};\n\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( hiddenBlockTypes.length > 0 ) {\n\t\t\tif ( settings.allowedBlockTypes === undefined ) {\n\t\t\t\t// If no specific flags for allowedBlockTypes are set, assume `true`\n\t\t\t\t// meaning allow all block types.\n\t\t\t\tsettings.allowedBlockTypes = true;\n\t\t\t}\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? blockTypes.map( ( { name } ) => name )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\tsettings.allowedBlockTypes = defaultAllowedBlockTypes.filter(\n\t\t\t\t( type ) => ! hiddenBlockTypes.includes( type )\n\t\t\t);\n\t\t}\n\n\t\treturn settings;\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { editEntityRecord, postType, postId } = this.props;\n\n\t\tthis.subscriptionParentSetFocusOnTitle = subscribeSetFocusOnTitle(\n\t\t\t() => {\n\t\t\t\tif ( this.postTitleRef ) {\n\t\t\t\t\tthis.postTitleRef.focus();\n\t\t\t\t} else {\n\t\t\t\t\t// If the post title ref is not available, we postpone setting focus to when it's available.\n\t\t\t\t\tthis.focusTitleWhenAvailable = true;\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentFeaturedImageIdNativeUpdated =\n\t\t\tsubscribeFeaturedImageIdNativeUpdated( ( payload ) => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\t{ featured_media: payload.featuredImageId },\n\t\t\t\t\t{\n\t\t\t\t\t\tundoIgnore: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.subscriptionParentSetFocusOnTitle ) {\n\t\t\tthis.subscriptionParentSetFocusOnTitle.remove();\n\t\t}\n\n\t\tif ( this.subscribeFeaturedImageIdNativeUpdated ) {\n\t\t\tthis.subscribeFeaturedImageIdNativeUpdated.remove();\n\t\t}\n\t}\n\n\tsetTitleRef( titleRef ) {\n\t\tif ( this.focusTitleWhenAvailable && ! this.postTitleRef ) {\n\t\t\tthis.focusTitleWhenAvailable = false;\n\t\t\ttitleRef.focus();\n\t\t}\n\n\t\tthis.postTitleRef = titleRef;\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tsettings,\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t\tinitialEdits,\n\t\t\thiddenBlockTypes,\n\t\t\tblockTypes,\n\t\t\tpost,\n\t\t\tpostId,\n\t\t\tpostType,\n\t\t\tfeaturedImageId,\n\t\t\tinitialHtml,\n\t\t\t...props\n\t\t} = this.props;\n\n\t\tconst editorSettings = this.getEditorSettings(\n\t\t\tsettings,\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t\thiddenBlockTypes,\n\t\t\tblockTypes\n\t\t);\n\n\t\tconst normalizedPost = post || {\n\t\t\tid: postId,\n\t\t\ttitle: {\n\t\t\t\traw: props.initialTitle || '',\n\t\t\t},\n\t\t\tfeatured_media: featuredImageId,\n\t\t\tcontent: {\n\t\t\t\t// Make sure the post content is in sync with gutenberg store\n\t\t\t\t// to avoid marking the post as modified when simply loaded\n\t\t\t\t// For now, let's assume: serialize( parse( html ) ) !== html.\n\t\t\t\traw: serialize( parse( initialHtml || '' ) ),\n\t\t\t},\n\t\t\ttype: postType,\n\t\t\tstatus: 'draft',\n\t\t\tmeta: [],\n\t\t};\n\n\t\treturn (\n\t\t\t<GestureHandlerRootView style={ { flex: 1 } }>\n\t\t\t\t<SlotFillProvider>\n\t\t\t\t\t<EditorProvider\n\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\tpost={ normalizedPost }\n\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Layout setTitleRef={ this.setTitleRef } />\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t</SlotFillProvider>\n\t\t\t</GestureHandlerRootView>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tisFeatureActive,\n\t\t\tgetEditorMode,\n\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\tgetHiddenBlockTypes,\n\t\t} = select( editPostStore );\n\t\tconst { getBlockTypes } = select( blocksStore );\n\n\t\treturn {\n\t\t\thasFixedToolbar:\n\t\t\t\tisFeatureActive( 'fixedToolbar' ) ||\n\t\t\t\t__experimentalGetPreviewDeviceType() !== 'Desktop',\n\t\t\tfocusMode: isFeatureActive( 'focusMode' ),\n\t\t\tmode: getEditorMode(),\n\t\t\thiddenBlockTypes: getHiddenBlockTypes(),\n\t\t\tblockTypes: getBlockTypes(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { switchEditorMode } = dispatch( editPostStore );\n\t\tconst { editEntityRecord } = dispatch( coreStore );\n\t\treturn {\n\t\t\tswitchEditorMode,\n\t\t\teditEntityRecord,\n\t\t};\n\t} ),\n] )( Editor );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/editor.native.js"],"names":["Editor","Component","constructor","props","arguments","galleryWithImageBlocks","window","wp","galleryBlockV2Enabled","initialHtmlModeEnabled","mode","switchEditorMode","getEditorSettings","maxSize","setTitleRef","bind","settings","hasFixedToolbar","focusMode","hiddenBlockTypes","blockTypes","isRTL","I18nManager","length","allowedBlockTypes","undefined","defaultAllowedBlockTypes","map","name","filter","type","includes","componentDidMount","editEntityRecord","postType","postId","subscriptionParentSetFocusOnTitle","postTitleRef","focus","focusTitleWhenAvailable","subscriptionParentFeaturedImageIdNativeUpdated","payload","featured_media","featuredImageId","undoIgnore","componentWillUnmount","remove","subscribeFeaturedImageIdNativeUpdated","titleRef","render","initialEdits","post","initialHtml","editorSettings","normalizedPost","id","title","raw","initialTitle","content","status","meta","flex","select","isFeatureActive","getEditorMode","__experimentalGetPreviewDeviceType","getHiddenBlockTypes","editPostStore","getBlockTypes","blocksStore","dispatch","coreStore"],"mappings":";;;;;;;;;AAUA;;AAPA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AAKA;;AACA;;AA1BA;AACA;AACA;;AAKA;AACA;AACA;;AAaA;AACA;AACA;AAIA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AAILC,IAAAA;AAJK,MAKFJ,MAAM,CAAEK,YAAF,CALV;AAMA,QAAM;AAAEC,IAAAA;AAAF,MAAoBN,MAAM,CAAEO,aAAF,CAAhC;AAEA,SAAO;AACNrD,IAAAA,eAAe,EACd+C,eAAe,CAAE,cAAF,CAAf,IACAE,kCAAkC,OAAO,SAHpC;AAINhD,IAAAA,SAAS,EAAE8C,eAAe,CAAE,WAAF,CAJpB;AAKNtD,IAAAA,IAAI,EAAEuD,aAAa,EALb;AAMN9C,IAAAA,gBAAgB,EAAEgD,mBAAmB,EAN/B;AAON/C,IAAAA,UAAU,EAAEiD,aAAa;AAPnB,GAAP;AASA,CAlBD,CADuB,EAoBvB,wBAAgBE,QAAF,IAAgB;AAC7B,QAAM;AAAE5D,IAAAA;AAAF,MAAuB4D,QAAQ,CAAEH,YAAF,CAArC;AACA,QAAM;AAAEnC,IAAAA;AAAF,MAAuBsC,QAAQ,CAAEC,eAAF,CAArC;AACA,SAAO;AACN7D,IAAAA,gBADM;AAENsB,IAAAA;AAFM,GAAP;AAIA,CAPD,CApBuB,CAAT,EA4BVjC,MA5BU,C","sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\nimport { I18nManager } from 'react-native';\nimport { GestureHandlerRootView } from 'react-native-gesture-handler';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { EditorProvider } from '@wordpress/editor';\nimport { parse, serialize, store as blocksStore } from '@wordpress/blocks';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport {\n\tsubscribeSetFocusOnTitle,\n\tsubscribeFeaturedImageIdNativeUpdated,\n} from '@wordpress/react-native-bridge';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport { store as editPostStore } from './store';\n\nclass Editor extends Component {\n\tconstructor( props ) {\n\t\tsuper( ...arguments );\n\n\t\t// need to set this globally to avoid race with deprecations\n\t\t// defaulting to true to avoid issues with a not-yet-cached value\n\t\tconst { galleryWithImageBlocks = true } = props;\n\t\twindow.wp.galleryBlockV2Enabled = galleryWithImageBlocks;\n\n\t\tif ( props.initialHtmlModeEnabled && props.mode === 'visual' ) {\n\t\t\t// Enable html mode if the initial mode the parent wants it but we're not already in it.\n\t\t\tthis.props.switchEditorMode( 'text' );\n\t\t}\n\n\t\tthis.getEditorSettings = memize( this.getEditorSettings, {\n\t\t\tmaxSize: 1,\n\t\t} );\n\n\t\tthis.setTitleRef = this.setTitleRef.bind( this );\n\t}\n\n\tgetEditorSettings(\n\t\tsettings,\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\thiddenBlockTypes,\n\t\tblockTypes\n\t) {\n\t\tsettings = {\n\t\t\t...settings,\n\t\t\tisRTL: I18nManager.isRTL,\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t};\n\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( hiddenBlockTypes.length > 0 ) {\n\t\t\tif ( settings.allowedBlockTypes === undefined ) {\n\t\t\t\t// If no specific flags for allowedBlockTypes are set, assume `true`\n\t\t\t\t// meaning allow all block types.\n\t\t\t\tsettings.allowedBlockTypes = true;\n\t\t\t}\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? blockTypes.map( ( { name } ) => name )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\tsettings.allowedBlockTypes = defaultAllowedBlockTypes.filter(\n\t\t\t\t( type ) => ! hiddenBlockTypes.includes( type )\n\t\t\t);\n\t\t}\n\n\t\treturn settings;\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { editEntityRecord, postType, postId } = this.props;\n\n\t\tthis.subscriptionParentSetFocusOnTitle = subscribeSetFocusOnTitle(\n\t\t\t() => {\n\t\t\t\tif ( this.postTitleRef ) {\n\t\t\t\t\tthis.postTitleRef.focus();\n\t\t\t\t} else {\n\t\t\t\t\t// If the post title ref is not available, we postpone setting focus to when it's available.\n\t\t\t\t\tthis.focusTitleWhenAvailable = true;\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentFeaturedImageIdNativeUpdated =\n\t\t\tsubscribeFeaturedImageIdNativeUpdated( ( payload ) => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\t{ featured_media: payload.featuredImageId },\n\t\t\t\t\t{\n\t\t\t\t\t\tundoIgnore: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.subscriptionParentSetFocusOnTitle ) {\n\t\t\tthis.subscriptionParentSetFocusOnTitle.remove();\n\t\t}\n\n\t\tif ( this.subscribeFeaturedImageIdNativeUpdated ) {\n\t\t\tthis.subscribeFeaturedImageIdNativeUpdated.remove();\n\t\t}\n\t}\n\n\tsetTitleRef( titleRef ) {\n\t\tif ( this.focusTitleWhenAvailable && ! this.postTitleRef ) {\n\t\t\tthis.focusTitleWhenAvailable = false;\n\t\t\ttitleRef.focus();\n\t\t}\n\n\t\tthis.postTitleRef = titleRef;\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tsettings,\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t\tinitialEdits,\n\t\t\thiddenBlockTypes,\n\t\t\tblockTypes,\n\t\t\tpost,\n\t\t\tpostId,\n\t\t\tpostType,\n\t\t\tfeaturedImageId,\n\t\t\tinitialHtml,\n\t\t\t...props\n\t\t} = this.props;\n\n\t\tconst editorSettings = this.getEditorSettings(\n\t\t\tsettings,\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t\thiddenBlockTypes,\n\t\t\tblockTypes\n\t\t);\n\n\t\tconst normalizedPost = post || {\n\t\t\tid: postId,\n\t\t\ttitle: {\n\t\t\t\traw: props.initialTitle || '',\n\t\t\t},\n\t\t\tfeatured_media: featuredImageId,\n\t\t\tcontent: {\n\t\t\t\t// Make sure the post content is in sync with gutenberg store\n\t\t\t\t// to avoid marking the post as modified when simply loaded\n\t\t\t\t// For now, let's assume: serialize( parse( html ) ) !== html.\n\t\t\t\traw: serialize( parse( initialHtml || '' ) ),\n\t\t\t},\n\t\t\ttype: postType,\n\t\t\tstatus: 'draft',\n\t\t\tmeta: [],\n\t\t};\n\n\t\treturn (\n\t\t\t<GestureHandlerRootView style={ { flex: 1 } }>\n\t\t\t\t<SlotFillProvider>\n\t\t\t\t\t<EditorProvider\n\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\tpost={ normalizedPost }\n\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Layout setTitleRef={ this.setTitleRef } />\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t</SlotFillProvider>\n\t\t\t</GestureHandlerRootView>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tisFeatureActive,\n\t\t\tgetEditorMode,\n\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\tgetHiddenBlockTypes,\n\t\t} = select( editPostStore );\n\t\tconst { getBlockTypes } = select( blocksStore );\n\n\t\treturn {\n\t\t\thasFixedToolbar:\n\t\t\t\tisFeatureActive( 'fixedToolbar' ) ||\n\t\t\t\t__experimentalGetPreviewDeviceType() !== 'Desktop',\n\t\t\tfocusMode: isFeatureActive( 'focusMode' ),\n\t\t\tmode: getEditorMode(),\n\t\t\thiddenBlockTypes: getHiddenBlockTypes(),\n\t\t\tblockTypes: getBlockTypes(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { switchEditorMode } = dispatch( editPostStore );\n\t\tconst { editEntityRecord } = dispatch( coreStore );\n\t\treturn {\n\t\t\tswitchEditorMode,\n\t\t\teditEntityRecord,\n\t\t};\n\t} ),\n] )( Editor );\n"]}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
var _element = require("@wordpress/element");
|
|
6
4
|
|
|
7
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
|
-
|
|
9
5
|
var _blocks = require("@wordpress/blocks");
|
|
10
6
|
|
|
11
7
|
var _components = require("@wordpress/components");
|
|
@@ -65,7 +61,8 @@ const withMultipleValidation = (0, _compose.createHigherOrderComponent)(BlockEdi
|
|
|
65
61
|
...props
|
|
66
62
|
}) => {
|
|
67
63
|
if (!originalBlockClientId) {
|
|
68
|
-
return (0, _element.createElement)(BlockEdit, props
|
|
64
|
+
return (0, _element.createElement)(BlockEdit, { ...props
|
|
65
|
+
});
|
|
69
66
|
}
|
|
70
67
|
|
|
71
68
|
const blockType = (0, _blocks.getBlockType)(props.name);
|
|
@@ -75,9 +72,10 @@ const withMultipleValidation = (0, _compose.createHigherOrderComponent)(BlockEdi
|
|
|
75
72
|
style: {
|
|
76
73
|
minHeight: '60px'
|
|
77
74
|
}
|
|
78
|
-
}, (0, _element.createElement)(BlockEdit,
|
|
79
|
-
key: "block-edit"
|
|
80
|
-
|
|
75
|
+
}, (0, _element.createElement)(BlockEdit, {
|
|
76
|
+
key: "block-edit",
|
|
77
|
+
...props
|
|
78
|
+
})), (0, _element.createElement)(_blockEditor.Warning, {
|
|
81
79
|
key: "multiple-use-warning",
|
|
82
80
|
actions: [(0, _element.createElement)(_components.Button, {
|
|
83
81
|
key: "find-original",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/hooks/validate-multiple-use/index.js"],"names":["enhance","select","block","multiple","name","blocks","blockEditorStore","getBlocks","firstOfSameType","find","isInvalid","clientId","originalBlockClientId","dispatch","selectFirst","selectBlock","withMultipleValidation","BlockEdit","props","blockType","outboundType","getOutboundType","minHeight","onReplace","attributes","title","blockName","transform","type","length"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/hooks/validate-multiple-use/index.js"],"names":["enhance","select","block","multiple","name","blocks","blockEditorStore","getBlocks","firstOfSameType","find","isInvalid","clientId","originalBlockClientId","dispatch","selectFirst","selectBlock","withMultipleValidation","BlockEdit","props","blockType","outboundType","getOutboundType","minHeight","onReplace","attributes","title","blockName","transform","type","length"],"mappings":";;;;AAGA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAfA;AACA;AACA;AAeA,MAAMA,OAAO,GAAG;AACf;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACC,sBAAY,CAAEC,MAAF,EAAUC,KAAV,KAAqB;AAChC,QAAMC,QAAQ,GAAG,6BAAiBD,KAAK,CAACE,IAAvB,EAA6B,UAA7B,EAAyC,IAAzC,CAAjB,CADgC,CAGhC;AACA;;AACA,MAAKD,QAAL,EAAgB;AACf,WAAO,EAAP;AACA,GAP+B,CAShC;AACA;;;AACA,QAAME,MAAM,GAAGJ,MAAM,CAAEK,kBAAF,CAAN,CAA2BC,SAA3B,EAAf;AACA,QAAMC,eAAe,GAAGH,MAAM,CAACI,IAAP,CACvB,CAAE;AAAEL,IAAAA;AAAF,GAAF,KAAgBF,KAAK,CAACE,IAAN,KAAeA,IADR,CAAxB;AAGA,QAAMM,SAAS,GACdF,eAAe,IAAIA,eAAe,CAACG,QAAhB,KAA6BT,KAAK,CAACS,QADvD;AAEA,SAAO;AACNC,IAAAA,qBAAqB,EAAEF,SAAS,IAAIF,eAAe,CAACG;AAD9C,GAAP;AAGA,CApBD,CAZe,EAiCf,wBAAc,CAAEE,QAAF,EAAY;AAAED,EAAAA;AAAF,C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,SAAN,CACC,yBACCH,YAAY,CAAChB,IADd,EAECc,KAAK,CAACM,UAFP,CADD;AAJF,SAYG,cAAI,iBAAJ,CAZH,OAY+BJ,YAAY,CAACK,KAZ5C,CAhBQ;AAFX,OAmCC,4CAAUN,SAAS,EAAEM,KAArB,OAnCD,EAoCG,cAAI,mCAAJ,CApCH,CAJM,CAAP;AA2CA,GAnDa,CAAd;AAoDA,CArD8B,EAqD5B,wBArD4B,CAA/B;AAuDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASJ,eAAT,CAA0BK,SAA1B,EAAsC;AACrC;AACA,QAAMC,SAAS,GAAG,2BACjB,gCAAoB,IAApB,EAA0BD,SAA1B,CADiB,EAEjB,CAAE;AAAEE,IAAAA,IAAF;AAAQvB,IAAAA;AAAR,GAAF,KAAwBuB,IAAI,KAAK,OAAT,IAAoBvB,MAAM,CAACwB,MAAP,KAAkB,CAF7C,CAE+C;AAF/C,GAAlB;;AAKA,MAAK,CAAEF,SAAP,EAAmB;AAClB,WAAO,IAAP;AACA;;AAED,SAAO,0BAAcA,SAAS,CAACtB,MAAV,CAAkB,CAAlB,CAAd,CAAP;AACA;;AAED,sBACC,kBADD,EAEC,+DAFD,EAGCW,sBAHD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { Button } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { Warning, store as blockEditorStore } from '@wordpress/block-editor';\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { compose, createHigherOrderComponent } from '@wordpress/compose';\n\nconst enhance = compose(\n\t/**\n\t * For blocks whose block type doesn't support `multiple`, provides the\n\t * wrapped component with `originalBlockClientId` -- a reference to the\n\t * first block of the same type in the content -- if and only if that\n\t * \"original\" block is not the current one. Thus, an inexisting\n\t * `originalBlockClientId` prop signals that the block is valid.\n\t *\n\t * @param {WPComponent} WrappedBlockEdit A filtered BlockEdit instance.\n\t *\n\t * @return {WPComponent} Enhanced component with merged state data props.\n\t */\n\twithSelect( ( select, block ) => {\n\t\tconst multiple = hasBlockSupport( block.name, 'multiple', true );\n\n\t\t// For block types with `multiple` support, there is no \"original\n\t\t// block\" to be found in the content, as the block itself is valid.\n\t\tif ( multiple ) {\n\t\t\treturn {};\n\t\t}\n\n\t\t// Otherwise, only pass `originalBlockClientId` if it refers to a different\n\t\t// block from the current one.\n\t\tconst blocks = select( blockEditorStore ).getBlocks();\n\t\tconst firstOfSameType = blocks.find(\n\t\t\t( { name } ) => block.name === name\n\t\t);\n\t\tconst isInvalid =\n\t\t\tfirstOfSameType && firstOfSameType.clientId !== block.clientId;\n\t\treturn {\n\t\t\toriginalBlockClientId: isInvalid && firstOfSameType.clientId,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, { originalBlockClientId } ) => ( {\n\t\tselectFirst: () =>\n\t\t\tdispatch( blockEditorStore ).selectBlock( originalBlockClientId ),\n\t} ) )\n);\n\nconst withMultipleValidation = createHigherOrderComponent( ( BlockEdit ) => {\n\treturn enhance( ( { originalBlockClientId, selectFirst, ...props } ) => {\n\t\tif ( ! originalBlockClientId ) {\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t}\n\n\t\tconst blockType = getBlockType( props.name );\n\t\tconst outboundType = getOutboundType( props.name );\n\n\t\treturn [\n\t\t\t<div key=\"invalid-preview\" style={ { minHeight: '60px' } }>\n\t\t\t\t<BlockEdit key=\"block-edit\" { ...props } />\n\t\t\t</div>,\n\t\t\t<Warning\n\t\t\t\tkey=\"multiple-use-warning\"\n\t\t\t\tactions={ [\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey=\"find-original\"\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tonClick={ selectFirst }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Find original' ) }\n\t\t\t\t\t</Button>,\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey=\"remove\"\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tonClick={ () => props.onReplace( [] ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t</Button>,\n\t\t\t\t\toutboundType && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey=\"transform\"\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\tprops.onReplace(\n\t\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\t\toutboundType.name,\n\t\t\t\t\t\t\t\t\t\tprops.attributes\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Transform into:' ) } { outboundType.title }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t),\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t<strong>{ blockType?.title }: </strong>\n\t\t\t\t{ __( 'This block can only be used once.' ) }\n\t\t\t</Warning>,\n\t\t];\n\t} );\n}, 'withMultipleValidation' );\n\n/**\n * Given a base block name, returns the default block type to which to offer\n * transforms.\n *\n * @param {string} blockName Base block name.\n *\n * @return {?Object} The chosen default block type.\n */\nfunction getOutboundType( blockName ) {\n\t// Grab the first outbound transform.\n\tconst transform = findTransform(\n\t\tgetBlockTransforms( 'to', blockName ),\n\t\t( { type, blocks } ) => type === 'block' && blocks.length === 1 // What about when .length > 1?\n\t);\n\n\tif ( ! transform ) {\n\t\treturn null;\n\t}\n\n\treturn getBlockType( transform.blocks[ 0 ] );\n}\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-post/validate-multiple-use/with-multiple-validation',\n\twithMultipleValidation\n);\n"]}
|
package/build/index.js
CHANGED
|
@@ -178,7 +178,7 @@ function initializeEditor(id, postType, postId, settings, initialEdits) {
|
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
/*
|
|
181
|
-
* Prevent adding template part
|
|
181
|
+
* Prevent adding template part in the post editor.
|
|
182
182
|
* Only add the filter when the post editor is initialized, not imported.
|
|
183
183
|
* Also only add the filter(s) after registerCoreBlocks()
|
|
184
184
|
* so that common filters in the block library are not overwritten.
|
|
@@ -186,10 +186,26 @@ function initializeEditor(id, postType, postId, settings, initialEdits) {
|
|
|
186
186
|
|
|
187
187
|
|
|
188
188
|
(0, _hooks.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (canInsert, blockType) => {
|
|
189
|
-
if (!(0, _data.select)(_store.store).isEditingTemplate() &&
|
|
189
|
+
if (!(0, _data.select)(_store.store).isEditingTemplate() && blockType.name === 'core/template-part') {
|
|
190
190
|
return false;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
return canInsert;
|
|
194
|
+
});
|
|
195
|
+
/*
|
|
196
|
+
* Prevent adding post content block (except in query block) in the post editor.
|
|
197
|
+
* Only add the filter when the post editor is initialized, not imported.
|
|
198
|
+
* Also only add the filter(s) after registerCoreBlocks()
|
|
199
|
+
* so that common filters in the block library are not overwritten.
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
(0, _hooks.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removePostContentFromInserter', (canInsert, blockType, rootClientId, {
|
|
203
|
+
getBlockParentsByBlockName
|
|
204
|
+
}) => {
|
|
205
|
+
if (!(0, _data.select)(_store.store).isEditingTemplate() && blockType.name === 'core/post-content') {
|
|
206
|
+
return getBlockParentsByBlockName(rootClientId, 'core/query').length > 0;
|
|
207
|
+
}
|
|
208
|
+
|
|
193
209
|
return canInsert;
|
|
194
210
|
}); // Show a console log warning if the browser is not in Standards rendering mode.
|
|
195
211
|
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/index.js"],"names":["initializeEditor","id","postType","postId","settings","initialEdits","target","document","getElementById","root","preferencesStore","setDefaults","editorMode","fixedToolbar","fullscreenMode","hiddenBlockTypes","inactivePanels","isPublishSidebarEnabled","openPanels","preferredStyleVariations","showBlockBreadcrumbs","showIconLabels","showListViewByDefault","themeStyles","welcomeGuide","welcomeGuideTemplate","blocksStore","__experimentalReapplyBlockTypeFilters","editPostStore","isFeatureActive","setIsListViewOpened","inserter","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","__unstableEnableFullSiteEditingBlocks","canInsert","blockType","isEditingTemplate","name","documentMode","compatMode","console","warn","isIphone","window","navigator","userAgent","indexOf","addEventListener","event","editorScrollContainer","getElementsByClassName","scrollY","scrollTop","scrollTo","e","preventDefault","render","reinitializeEditor","since","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AANA;;AACA;;AAIA;;AAEA;;AACA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AA+IA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAhLA;AACA;AACA;;AAgBA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CACNC,EADM,EAENC,QAFM,EAGNC,MAHM,EAINC,QAJM,EAKNC,YALM,EAML;AACD,QAAMC,MAAM,GAAGC,QAAQ,CAACC,cAAT,CAAyBP,EAAzB,CAAf;AACA,QAAMQ,IAAI,GAAG,yBAAYH,MAAZ,CAAb;AAEA,sBAAUI,kBAAV,EAA6BC,WAA7B,CAA0C,gBAA1C,EAA4D;AAC3DC,IAAAA,UAAU,EAAE,QAD+C;AAE3DC,IAAAA,YAAY,EAAE,KAF6C;AAG3DC,IAAAA,cAAc,EAAE,IAH2C;AAI3DC,IAAAA,gBAAgB,EAAE,EAJyC;AAK3DC,IAAAA,cAAc,EAAE,EAL2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AACA;;;AACO,SAASmD,kBAAT,GAA8B;AACpC,2BAAY,gCAAZ,EAA8C;AAC7CC,IAAAA,KAAK,EAAE,KADsC;AAE7CC,IAAAA,OAAO,EAAE;AAFoC,GAA9C;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot } from '@wordpress/element';\nimport { dispatch, select } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport './plugins';\nimport Editor from './editor';\nimport { store as editPostStore } from './store';\n\n/**\n * Initializes and returns an instance of Editor.\n *\n * @param {string} id Unique identifier for editor instance.\n * @param {string} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function initializeEditor(\n\tid,\n\tpostType,\n\tpostId,\n\tsettings,\n\tinitialEdits\n) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-post', {\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfullscreenMode: true,\n\t\thiddenBlockTypes: [],\n\t\tinactivePanels: [],\n\t\tisPublishSidebarEnabled: true,\n\t\topenPanels: [ 'post-status' ],\n\t\tpreferredStyleVariations: {},\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowIconLabels: false,\n\t\tshowListViewByDefault: false,\n\t\tthemeStyles: true,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\n\t// Check if the block list view should be open by default.\n\tif ( select( editPostStore ).isFeatureActive( 'showListViewByDefault' ) ) {\n\t\tdispatch( editPostStore ).setIsListViewOpened( true );\n\t}\n\n\tregisterCoreBlocks();\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks,\n\t\t} );\n\t}\n\n\t/*\n\t * Prevent adding template part and post content block in the post editor.\n\t * Only add the filter when the post editor is initialized, not imported.\n\t * Also only add the filter(s) after registerCoreBlocks()\n\t * so that common filters in the block library are not overwritten.\n\t */\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'removeTemplatePartsFromInserter',\n\t\t( canInsert, blockType ) => {\n\t\t\tif (\n\t\t\t\t! select( editPostStore ).isEditingTemplate() &&\n\t\t\t\t( blockType.name === 'core/template-part' ||\n\t\t\t\t\tblockType.name === 'core/post-content' )\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn canInsert;\n\t\t}\n\t);\n\n\t// Show a console log warning if the browser is not in Standards rendering mode.\n\tconst documentMode =\n\t\tdocument.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';\n\tif ( documentMode !== 'Standards' ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t\"Your browser is using Quirks Mode. \\nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins.\"\n\t\t);\n\t}\n\n\t// This is a temporary fix for a couple of issues specific to Webkit on iOS.\n\t// Without this hack the browser scrolls the mobile toolbar off-screen.\n\t// Once supported in Safari we can replace this in favor of preventScroll.\n\t// For details see issue #18632 and PR #18686\n\t// Specifically, we scroll `interface-interface-skeleton__body` to enable a fixed top toolbar.\n\t// But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar.\n\n\tconst isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1;\n\tif ( isIphone ) {\n\t\twindow.addEventListener( 'scroll', ( event ) => {\n\t\t\tconst editorScrollContainer = document.getElementsByClassName(\n\t\t\t\t'interface-interface-skeleton__body'\n\t\t\t)[ 0 ];\n\t\t\tif ( event.target === document ) {\n\t\t\t\t// Scroll element into view by scrolling the editor container by the same amount\n\t\t\t\t// that Mobile Safari tried to scroll the html element upwards.\n\t\t\t\tif ( window.scrollY > 100 ) {\n\t\t\t\t\teditorScrollContainer.scrollTop =\n\t\t\t\t\t\teditorScrollContainer.scrollTop + window.scrollY;\n\t\t\t\t}\n\t\t\t\t// Undo unwanted scroll on html element, but only in the visual editor.\n\t\t\t\tif (\n\t\t\t\t\tdocument.getElementsByClassName( 'is-mode-visual' )[ 0 ]\n\t\t\t\t) {\n\t\t\t\t\twindow.scrollTo( 0, 0 );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\troot.render(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t/>\n\t);\n\n\treturn root;\n}\n\n/**\n * Used to reinitialize the editor after an error. Now it's a deprecated noop function.\n */\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editPost.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';\nexport { default as PluginDocumentSettingPanel } from './components/sidebar/plugin-document-setting-panel';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\nexport { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';\nexport { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';\nexport { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close';\nexport { default as __experimentalMainDashboardButton } from './components/header/main-dashboard-button';\nexport { store } from './store';\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/index.js"],"names":["initializeEditor","id","postType","postId","settings","initialEdits","target","document","getElementById","root","preferencesStore","setDefaults","editorMode","fixedToolbar","fullscreenMode","hiddenBlockTypes","inactivePanels","isPublishSidebarEnabled","openPanels","preferredStyleVariations","showBlockBreadcrumbs","showIconLabels","showListViewByDefault","themeStyles","welcomeGuide","welcomeGuideTemplate","blocksStore","__experimentalReapplyBlockTypeFilters","editPostStore","isFeatureActive","setIsListViewOpened","inserter","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","__unstableEnableFullSiteEditingBlocks","canInsert","blockType","isEditingTemplate","name","rootClientId","getBlockParentsByBlockName","length","documentMode","compatMode","console","warn","isIphone","window","navigator","userAgent","indexOf","addEventListener","event","editorScrollContainer","getElementsByClassName","scrollY","scrollTop","scrollTo","e","preventDefault","render","reinitializeEditor","since","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AANA;;AACA;;AAIA;;AAEA;;AACA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AA0KA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA3MA;AACA;AACA;;AAgBA;AACA;AACA;;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ChC;AACA;AACA,YAAK0C,MAAM,CAACQ,OAAP,GAAiB,GAAtB,EAA4B;AAC3BF,UAAAA,qBAAqB,CAACG,SAAtB,GACCH,qBAAqB,CAACG,SAAtB,GAAkCT,MAAM,CAACQ,OAD1C;AAEA,SAN+B,CAOhC;;;AACA,YACClD,QAAQ,CAACiD,sBAAT,CAAiC,gBAAjC,EAAqD,CAArD,CADD,EAEE;AACDP,UAAAA,MAAM,CAACU,QAAP,CAAiB,CAAjB,EAAoB,CAApB;AACA;AACD;AACD,KAlBD;AAmBA,GA3HA,CA6HD;;;AACAV,EAAAA,MAAM,CAACI,gBAAP,CAAyB,UAAzB,EAAuCO,CAAF,IAASA,CAAC,CAACC,cAAF,EAA9C,EAAkE,KAAlE;AACAZ,EAAAA,MAAM,CAACI,gBAAP,CAAyB,MAAzB,EAAmCO,CAAF,IAASA,CAAC,CAACC,cAAF,EAA1C,EAA8D,KAA9D;AAEApD,EAAAA,IAAI,CAACqD,MAAL,CACC,4BAAC,eAAD;AACC,IAAA,QAAQ,EAAG1D,QADZ;AAEC,IAAA,MAAM,EAAGD,MAFV;AAGC,IAAA,QAAQ,EAAGD,QAHZ;AAIC,IAAA,YAAY,EAAGG;AAJhB,IADD;AASA,SAAOI,IAAP;AACA;AAED;AACA;AACA;;;AACO,SAASsD,kBAAT,GAA8B;AACpC,2BAAY,gCAAZ,EAA8C;AAC7CC,IAAAA,KAAK,EAAE,KADsC;AAE7CC,IAAAA,OAAO,EAAE;AAFoC,GAA9C;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot } from '@wordpress/element';\nimport { dispatch, select } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport './plugins';\nimport Editor from './editor';\nimport { store as editPostStore } from './store';\n\n/**\n * Initializes and returns an instance of Editor.\n *\n * @param {string} id Unique identifier for editor instance.\n * @param {string} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function initializeEditor(\n\tid,\n\tpostType,\n\tpostId,\n\tsettings,\n\tinitialEdits\n) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-post', {\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfullscreenMode: true,\n\t\thiddenBlockTypes: [],\n\t\tinactivePanels: [],\n\t\tisPublishSidebarEnabled: true,\n\t\topenPanels: [ 'post-status' ],\n\t\tpreferredStyleVariations: {},\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowIconLabels: false,\n\t\tshowListViewByDefault: false,\n\t\tthemeStyles: true,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\n\t// Check if the block list view should be open by default.\n\tif ( select( editPostStore ).isFeatureActive( 'showListViewByDefault' ) ) {\n\t\tdispatch( editPostStore ).setIsListViewOpened( true );\n\t}\n\n\tregisterCoreBlocks();\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks,\n\t\t} );\n\t}\n\n\t/*\n\t * Prevent adding template part in the post editor.\n\t * Only add the filter when the post editor is initialized, not imported.\n\t * Also only add the filter(s) after registerCoreBlocks()\n\t * so that common filters in the block library are not overwritten.\n\t */\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'removeTemplatePartsFromInserter',\n\t\t( canInsert, blockType ) => {\n\t\t\tif (\n\t\t\t\t! select( editPostStore ).isEditingTemplate() &&\n\t\t\t\tblockType.name === 'core/template-part'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn canInsert;\n\t\t}\n\t);\n\n\t/*\n\t * Prevent adding post content block (except in query block) in the post editor.\n\t * Only add the filter when the post editor is initialized, not imported.\n\t * Also only add the filter(s) after registerCoreBlocks()\n\t * so that common filters in the block library are not overwritten.\n\t */\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'removePostContentFromInserter',\n\t\t(\n\t\t\tcanInsert,\n\t\t\tblockType,\n\t\t\trootClientId,\n\t\t\t{ getBlockParentsByBlockName }\n\t\t) => {\n\t\t\tif (\n\t\t\t\t! select( editPostStore ).isEditingTemplate() &&\n\t\t\t\tblockType.name === 'core/post-content'\n\t\t\t) {\n\t\t\t\treturn (\n\t\t\t\t\tgetBlockParentsByBlockName( rootClientId, 'core/query' )\n\t\t\t\t\t\t.length > 0\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn canInsert;\n\t\t}\n\t);\n\n\t// Show a console log warning if the browser is not in Standards rendering mode.\n\tconst documentMode =\n\t\tdocument.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';\n\tif ( documentMode !== 'Standards' ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t\"Your browser is using Quirks Mode. \\nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins.\"\n\t\t);\n\t}\n\n\t// This is a temporary fix for a couple of issues specific to Webkit on iOS.\n\t// Without this hack the browser scrolls the mobile toolbar off-screen.\n\t// Once supported in Safari we can replace this in favor of preventScroll.\n\t// For details see issue #18632 and PR #18686\n\t// Specifically, we scroll `interface-interface-skeleton__body` to enable a fixed top toolbar.\n\t// But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar.\n\n\tconst isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1;\n\tif ( isIphone ) {\n\t\twindow.addEventListener( 'scroll', ( event ) => {\n\t\t\tconst editorScrollContainer = document.getElementsByClassName(\n\t\t\t\t'interface-interface-skeleton__body'\n\t\t\t)[ 0 ];\n\t\t\tif ( event.target === document ) {\n\t\t\t\t// Scroll element into view by scrolling the editor container by the same amount\n\t\t\t\t// that Mobile Safari tried to scroll the html element upwards.\n\t\t\t\tif ( window.scrollY > 100 ) {\n\t\t\t\t\teditorScrollContainer.scrollTop =\n\t\t\t\t\t\teditorScrollContainer.scrollTop + window.scrollY;\n\t\t\t\t}\n\t\t\t\t// Undo unwanted scroll on html element, but only in the visual editor.\n\t\t\t\tif (\n\t\t\t\t\tdocument.getElementsByClassName( 'is-mode-visual' )[ 0 ]\n\t\t\t\t) {\n\t\t\t\t\twindow.scrollTo( 0, 0 );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\troot.render(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t/>\n\t);\n\n\treturn root;\n}\n\n/**\n * Used to reinitialize the editor after an error. Now it's a deprecated noop function.\n */\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editPost.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';\nexport { default as PluginDocumentSettingPanel } from './components/sidebar/plugin-document-setting-panel';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\nexport { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';\nexport { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';\nexport { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close';\nexport { default as __experimentalMainDashboardButton } from './components/header/main-dashboard-button';\nexport { store } from './store';\n"]}
|
|
@@ -16,4 +16,4 @@ const {
|
|
|
16
16
|
} = (0, _privateApis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', '@wordpress/edit-post');
|
|
17
17
|
exports.unlock = unlock;
|
|
18
18
|
exports.lock = lock;
|
|
19
|
-
//# sourceMappingURL=
|
|
19
|
+
//# sourceMappingURL=lock-unlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/lock-unlock.js"],"names":["lock","unlock"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAM;AAAEA,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZ,mEACC,8GADD,EAEC,sBAFD,CADM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/edit-post'\n\t);\n"]}
|
package/build/plugins/index.js
CHANGED
|
@@ -38,7 +38,7 @@ var _welcomeGuideMenuItem = _interopRequireDefault(require("./welcome-guide-menu
|
|
|
38
38
|
href: (0, _url.addQueryArgs)('edit.php', {
|
|
39
39
|
post_type: 'wp_block'
|
|
40
40
|
})
|
|
41
|
-
}, (0, _i18n.__)('Manage
|
|
41
|
+
}, (0, _i18n.__)('Manage Patterns')), (0, _element.createElement)(_keyboardShortcutsHelpMenuItem.default, {
|
|
42
42
|
onSelect: onClose
|
|
43
43
|
}), (0, _element.createElement)(_welcomeGuideMenuItem.default, null), (0, _element.createElement)(_copyContentMenuItem.default, null), (0, _element.createElement)(_components.MenuItem, {
|
|
44
44
|
role: "menuitem",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/plugins/index.js"],"names":["render","onClose","post_type","external"],"mappings":";;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAfA;AACA;AACA;;AAOA;AACA;AACA;AAMA,6BAAgB,WAAhB,EAA6B;AAC5BA,EAAAA,MAAM,GAAG;AACR,WACC,qDACC,4BAAC,2BAAD,QACG,CAAE;AAAEC,MAAAA;AAAF,KAAF,KACD,qDACC,4BAAC,oBAAD;AACC,MAAA,IAAI,EAAC,UADN;AAEC,MAAA,IAAI,EAAG,uBAAc,UAAd,EAA0B;AAChCC,QAAAA,SAAS,EAAE;AADqB,OAA1B;AAFR,OAMG,cAAI,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/plugins/index.js"],"names":["render","onClose","post_type","external"],"mappings":";;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAfA;AACA;AACA;;AAOA;AACA;AACA;AAMA,6BAAgB,WAAhB,EAA6B;AAC5BA,EAAAA,MAAM,GAAG;AACR,WACC,qDACC,4BAAC,2BAAD,QACG,CAAE;AAAEC,MAAAA;AAAF,KAAF,KACD,qDACC,4BAAC,oBAAD;AACC,MAAA,IAAI,EAAC,UADN;AAEC,MAAA,IAAI,EAAG,uBAAc,UAAd,EAA0B;AAChCC,QAAAA,SAAS,EAAE;AADqB,OAA1B;AAFR,OAMG,cAAI,iBAAJ,CANH,CADD,EASC,4BAAC,sCAAD;AACC,MAAA,QAAQ,EAAGD;AADZ,MATD,EAYC,4BAAC,6BAAD,OAZD,EAaC,4BAAC,4BAAD,OAbD,EAcC,4BAAC,oBAAD;AACC,MAAA,IAAI,EAAC,UADN;AAEC,MAAA,IAAI,EAAGE,eAFR;AAGC,MAAA,IAAI,EAAG,cACN,qEADM,CAHR;AAMC,MAAA,MAAM,EAAC,QANR;AAOC,MAAA,GAAG,EAAC;AAPL,OASG,cAAI,MAAJ,CATH,EAUC,4BAAC,0BAAD;AAAgB,MAAA,EAAE,EAAC;AAAnB;AAEE;AACA,kBAAI,sBAAJ,CAHF,CAVD,CAdD,CAFF,CADD,CADD;AAwCA;;AA1C2B,CAA7B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem, VisuallyHidden } from '@wordpress/components';\nimport { external } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { registerPlugin } from '@wordpress/plugins';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport CopyContentMenuItem from './copy-content-menu-item';\nimport KeyboardShortcutsHelpMenuItem from './keyboard-shortcuts-help-menu-item';\nimport ToolsMoreMenuGroup from '../components/header/tools-more-menu-group';\nimport WelcomeGuideMenuItem from './welcome-guide-menu-item';\n\nregisterPlugin( 'edit-post', {\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<ToolsMoreMenuGroup>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\thref={ addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Manage Patterns' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<KeyboardShortcutsHelpMenuItem\n\t\t\t\t\t\t\t\tonSelect={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<WelcomeGuideMenuItem />\n\t\t\t\t\t\t\t<CopyContentMenuItem />\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/wordpress-block-editor/'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Help' ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</ToolsMoreMenuGroup>\n\t\t\t</>\n\t\t);\n\t},\n} );\n"]}
|
|
@@ -4,11 +4,11 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
6
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
7
|
-
import { withSelect } from '@wordpress/data';
|
|
8
|
-
import { SearchControl } from '@wordpress/components';
|
|
7
|
+
import { withSelect, withDispatch } from '@wordpress/data';
|
|
8
|
+
import { SearchControl, Button } from '@wordpress/components';
|
|
9
9
|
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
10
10
|
import { useEffect, useState } from '@wordpress/element';
|
|
11
|
-
import { useDebounce } from '@wordpress/compose';
|
|
11
|
+
import { useDebounce, compose } from '@wordpress/compose';
|
|
12
12
|
import { speak } from '@wordpress/a11y';
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
@@ -22,7 +22,8 @@ function BlockManager({
|
|
|
22
22
|
categories,
|
|
23
23
|
hasBlockSupport,
|
|
24
24
|
isMatchingSearchTerm,
|
|
25
|
-
numberOfHiddenBlocks
|
|
25
|
+
numberOfHiddenBlocks,
|
|
26
|
+
enableAllBlockTypes
|
|
26
27
|
}) {
|
|
27
28
|
const debouncedSpeak = useDebounce(speak, 500);
|
|
28
29
|
const [search, setSearch] = useState(''); // Filtering occurs here (as opposed to `withSelect`) to avoid
|
|
@@ -48,7 +49,10 @@ function BlockManager({
|
|
|
48
49
|
className: "edit-post-block-manager__disabled-blocks-count"
|
|
49
50
|
}, sprintf(
|
|
50
51
|
/* translators: %d: number of blocks. */
|
|
51
|
-
_n('%d block is hidden.', '%d blocks are hidden.', numberOfHiddenBlocks), numberOfHiddenBlocks)
|
|
52
|
+
_n('%d block is hidden.', '%d blocks are hidden.', numberOfHiddenBlocks), numberOfHiddenBlocks), createElement(Button, {
|
|
53
|
+
variant: "link",
|
|
54
|
+
onClick: () => enableAllBlockTypes(blockTypes)
|
|
55
|
+
}, __('Reset'))), createElement(SearchControl, {
|
|
52
56
|
__nextHasNoMarginBottom: true,
|
|
53
57
|
label: __('Search for a block'),
|
|
54
58
|
placeholder: __('Search for a block'),
|
|
@@ -74,7 +78,7 @@ function BlockManager({
|
|
|
74
78
|
})));
|
|
75
79
|
}
|
|
76
80
|
|
|
77
|
-
export default withSelect(select => {
|
|
81
|
+
export default compose([withSelect(select => {
|
|
78
82
|
const {
|
|
79
83
|
getBlockTypes,
|
|
80
84
|
getCategories,
|
|
@@ -101,5 +105,17 @@ export default withSelect(select => {
|
|
|
101
105
|
isMatchingSearchTerm,
|
|
102
106
|
numberOfHiddenBlocks
|
|
103
107
|
};
|
|
104
|
-
})(
|
|
108
|
+
}), withDispatch(dispatch => {
|
|
109
|
+
const {
|
|
110
|
+
showBlockTypes
|
|
111
|
+
} = dispatch(editPostStore);
|
|
112
|
+
return {
|
|
113
|
+
enableAllBlockTypes: blockTypes => {
|
|
114
|
+
const blockNames = blockTypes.map(({
|
|
115
|
+
name
|
|
116
|
+
}) => name);
|
|
117
|
+
showBlockTypes(blockNames);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
})])(BlockManager);
|
|
105
121
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/block-manager/index.js"],"names":["store","blocksStore","withSelect","SearchControl","__","_n","sprintf","useEffect","useState","useDebounce","speak","BlockManagerCategory","editPostStore","BlockManager","blockTypes","categories","hasBlockSupport","isMatchingSearchTerm","numberOfHiddenBlocks","debouncedSpeak","search","setSearch","filter","blockType","parent","includes","count","length","resultsFoundMessage","nextSearch","map","category","slug","title","select","getBlockTypes","getCategories","getHiddenBlockTypes","hiddenBlockTypes","hiddenBlock","some","registeredBlock","name","Array","isArray"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,UAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/block-manager/index.js"],"names":["store","blocksStore","withSelect","withDispatch","SearchControl","Button","__","_n","sprintf","useEffect","useState","useDebounce","compose","speak","BlockManagerCategory","editPostStore","BlockManager","blockTypes","categories","hasBlockSupport","isMatchingSearchTerm","numberOfHiddenBlocks","enableAllBlockTypes","debouncedSpeak","search","setSearch","filter","blockType","parent","includes","count","length","resultsFoundMessage","nextSearch","map","category","slug","title","select","getBlockTypes","getCategories","getHiddenBlockTypes","hiddenBlockTypes","hiddenBlock","some","registeredBlock","name","Array","isArray","dispatch","showBlockTypes","blockNames"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAlB,QAAqC,m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U,GAAGlC,UAAU,CAACiB,GAAX,CAAgB,CAAE;AAAEY,QAAAA;AAAF,OAAF,KAAgBA,IAAhC,CAAnB;AACAI,MAAAA,cAAc,CAAEC,UAAF,CAAd;AACA;AAJK,GAAP;AAMA,CARW,CAlCW,CAAF,CAAP,CA2CVnC,YA3CU,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { SearchControl, Button } from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport { useDebounce, compose } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockManagerCategory from './category';\nimport { store as editPostStore } from '../../store';\n\nfunction BlockManager( {\n\tblockTypes,\n\tcategories,\n\thasBlockSupport,\n\tisMatchingSearchTerm,\n\tnumberOfHiddenBlocks,\n\tenableAllBlockTypes,\n} ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ search, setSearch ] = useState( '' );\n\n\t// Filtering occurs here (as opposed to `withSelect`) to avoid\n\t// wasted renders by consequence of `Array#filter` producing\n\t// a new value reference on each call.\n\tblockTypes = blockTypes.filter(\n\t\t( blockType ) =>\n\t\t\thasBlockSupport( blockType, 'inserter', true ) &&\n\t\t\t( ! search || isMatchingSearchTerm( blockType, search ) ) &&\n\t\t\t( ! blockType.parent ||\n\t\t\t\tblockType.parent.includes( 'core/post-content' ) )\n\t);\n\n\t// Announce search results on change\n\tuseEffect( () => {\n\t\tif ( ! search ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = blockTypes.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ blockTypes.length, search, debouncedSpeak ] );\n\n\treturn (\n\t\t<div className=\"edit-post-block-manager__content\">\n\t\t\t{ !! numberOfHiddenBlocks && (\n\t\t\t\t<div className=\"edit-post-block-manager__disabled-blocks-count\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %d: number of blocks. */\n\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t'%d block is hidden.',\n\t\t\t\t\t\t\t'%d blocks are hidden.',\n\t\t\t\t\t\t\tnumberOfHiddenBlocks\n\t\t\t\t\t\t),\n\t\t\t\t\t\tnumberOfHiddenBlocks\n\t\t\t\t\t) }\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => enableAllBlockTypes( blockTypes ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<SearchControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Search for a block' ) }\n\t\t\t\tplaceholder={ __( 'Search for a block' ) }\n\t\t\t\tvalue={ search }\n\t\t\t\tonChange={ ( nextSearch ) => setSearch( nextSearch ) }\n\t\t\t\tclassName=\"edit-post-block-manager__search\"\n\t\t\t/>\n\t\t\t<div\n\t\t\t\ttabIndex=\"0\"\n\t\t\t\trole=\"region\"\n\t\t\t\taria-label={ __( 'Available block types' ) }\n\t\t\t\tclassName=\"edit-post-block-manager__results\"\n\t\t\t>\n\t\t\t\t{ blockTypes.length === 0 && (\n\t\t\t\t\t<p className=\"edit-post-block-manager__no-results\">\n\t\t\t\t\t\t{ __( 'No blocks found.' ) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t\t<BlockManagerCategory\n\t\t\t\t\t\tkey={ category.slug }\n\t\t\t\t\t\ttitle={ category.title }\n\t\t\t\t\t\tblockTypes={ blockTypes.filter(\n\t\t\t\t\t\t\t( blockType ) =>\n\t\t\t\t\t\t\t\tblockType.category === category.slug\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t\t<BlockManagerCategory\n\t\t\t\t\ttitle={ __( 'Uncategorized' ) }\n\t\t\t\t\tblockTypes={ blockTypes.filter(\n\t\t\t\t\t\t( { category } ) => ! category\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockTypes,\n\t\t\tgetCategories,\n\t\t\thasBlockSupport,\n\t\t\tisMatchingSearchTerm,\n\t\t} = select( blocksStore );\n\t\tconst { getHiddenBlockTypes } = select( editPostStore );\n\n\t\t// Some hidden blocks become unregistered\n\t\t// by removing for instance the plugin that registered them, yet\n\t\t// they're still remain as hidden by the user's action.\n\t\t// We consider \"hidden\", blocks which were hidden and\n\t\t// are still registered.\n\t\tconst blockTypes = getBlockTypes();\n\t\tconst hiddenBlockTypes = getHiddenBlockTypes().filter(\n\t\t\t( hiddenBlock ) => {\n\t\t\t\treturn blockTypes.some(\n\t\t\t\t\t( registeredBlock ) => registeredBlock.name === hiddenBlock\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t\tconst numberOfHiddenBlocks =\n\t\t\tArray.isArray( hiddenBlockTypes ) && hiddenBlockTypes.length;\n\n\t\treturn {\n\t\t\tblockTypes,\n\t\t\tcategories: getCategories(),\n\t\t\thasBlockSupport,\n\t\t\tisMatchingSearchTerm,\n\t\t\tnumberOfHiddenBlocks,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { showBlockTypes } = dispatch( editPostStore );\n\t\treturn {\n\t\t\tenableAllBlockTypes: ( blockTypes ) => {\n\t\t\t\tconst blockNames = blockTypes.map( ( { name } ) => name );\n\t\t\t\tshowBlockTypes( blockNames );\n\t\t\t},\n\t\t};\n\t} ),\n] )( BlockManager );\n"]}
|
|
@@ -47,10 +47,8 @@ export default function DevicePreview() {
|
|
|
47
47
|
isEnabled: isPostSaveable,
|
|
48
48
|
className: "edit-post-post-preview-dropdown",
|
|
49
49
|
deviceType: deviceType,
|
|
50
|
-
setDeviceType: setPreviewDeviceType
|
|
51
|
-
|
|
52
|
-
,
|
|
53
|
-
viewLabel: __('Preview')
|
|
50
|
+
setDeviceType: setPreviewDeviceType,
|
|
51
|
+
label: __('Preview')
|
|
54
52
|
}, isViewable && createElement(MenuGroup, null, createElement("div", {
|
|
55
53
|
className: "edit-post-header-preview__grouping-external"
|
|
56
54
|
}, createElement(PostPreviewButton, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/device-preview/index.js"],"names":["Icon","MenuGroup","PostPreviewButton","store","editorStore","external","__","__experimentalPreviewOptions","PreviewOptions","useDispatch","useSelect","coreStore","editPostStore","DevicePreview","hasActiveMetaboxes","isPostSaveable","isSaving","isViewable","deviceType","select","getEditedPostAttribute","getPostType","postType","hasMetaBoxes","isSavingMetaBoxes","isEditedPostSaveable","viewable","__experimentalGetPreviewDeviceType","__experimentalSetPreviewDeviceType","setPreviewDeviceType","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,SAAf,QAAgC,uBAAhC;AACA,SAASC,iBAAT,EAA4BC,KAAK,IAAIC,WAArC,QAAwD,mBAAxD;AACA,SAASC,QAAT,QAAyB,kBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,4BAA4B,IAAIC,cAAzC,QAA+D,yBAA/D;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASP,KAAK,IAAIQ,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASR,KAAK,IAAIS,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,aAAT,GAAyB;AACvC,QAAM;AACLC,IAAAA,kBADK;AAELC,IAAAA,cAFK;AAGLC,IAAAA,QAHK;AAILC,IAAAA,UAJK;AAKLC,IAAAA;AALK,MAMFR,SAAS,CAAIS,MAAF,IAAc;AAAA;;AAC5B,UAAM;AAAEC,MAAAA;AAAF,QAA6BD,MAAM,CAAEf,WAAF,CAAzC;AACA,UAAM;AAAEiB,MAAAA;AAAF,QAAkBF,MAAM,CAAER,SAAF,CAA9B;AACA,UAAMW,QAAQ,GAAGD,WAAW,CAAED,sBAAsB,CAAE,MAAF,CAAxB,CAA5B;AAEA,WAAO;AACNN,MAAAA,kBAAkB,EAAEK,MAAM,CAAEP,aAAF,CAAN,CAAwBW,YAAxB,EADd;AAENP,MAAAA,QAAQ,EAAEG,MAAM,CAAEP,aAAF,CAAN,CAAwBY,iBAAxB,EAFJ;AAGNT,MAAAA,cAAc,EAAEI,MAAM,CAAEf,WAAF,CAAN,CAAsBqB,oBAAtB,EAHV;AAINR,MAAAA,UAAU,wBAAEK,QAAQ,EAAEI,QAAZ,mEAAwB,KAJ5B;AAKNR,MAAAA,UAAU,EACTC,MAAM,CAAEP,aAAF,CAAN,CAAwBe,kCAAxB;AANK,KAAP;AAQA,GAbY,EAaV,EAbU,CANb;AAoBA,QAAM;AAAEC,IAAAA,kCAAkC,EAAEC;AAAtC,MACLpB,WAAW,CAAEG,aAAF,CADZ;AAGA,SACC,cAAC,cAAD;AACC,IAAA,SAAS,EAAGG,cADb;AAEC,IAAA,SAAS,EAAC,iCAFX;AAGC,IAAA,UAAU,EAAGG,UAHd;AAIC,IAAA,aAAa,EAAGW;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/device-preview/index.js"],"names":["Icon","MenuGroup","PostPreviewButton","store","editorStore","external","__","__experimentalPreviewOptions","PreviewOptions","useDispatch","useSelect","coreStore","editPostStore","DevicePreview","hasActiveMetaboxes","isPostSaveable","isSaving","isViewable","deviceType","select","getEditedPostAttribute","getPostType","postType","hasMetaBoxes","isSavingMetaBoxes","isEditedPostSaveable","viewable","__experimentalGetPreviewDeviceType","__experimentalSetPreviewDeviceType","setPreviewDeviceType","und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,IAAAA,kCAAkC,EAAEC;AAAtC,MACLpB,WAAW,CAAEG,aAAF,CADZ;AAGA,SACC,cAAC,cAAD;AACC,IAAA,SAAS,EAAGG,cADb;AAEC,IAAA,SAAS,EAAC,iCAFX;AAGC,IAAA,UAAU,EAAGG,UAHd;AAIC,IAAA,aAAa,EAAGW,oBAJjB;AAKC,IAAA,KAAK,EAAGvB,EAAE,CAAE,SAAF;AALX,KAOGW,UAAU,IACX,cAAC,SAAD,QACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,iBAAD;AACC,IAAA,SAAS,EACR,2CAFF;AAIC,IAAA,IAAI,EAAC,UAJN;AAKC,IAAA,mBAAmB,EAAGH,kBALvB;AAMC,IAAA,gBAAgB,EAAGE,QAAQ,GAAG,IAAH,GAAUc,SANtC;AAOC,IAAA,WAAW,EACV,8BACGxB,EAAE,CAAE,oBAAF,CADL,EAEC,cAAC,IAAD;AAAM,MAAA,IAAI,EAAGD;AAAb,MAFD;AARF,IADD,CADD,CARF,CADD;AA8BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Icon, MenuGroup } from '@wordpress/components';\nimport { PostPreviewButton, store as editorStore } from '@wordpress/editor';\nimport { external } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalPreviewOptions as PreviewOptions } from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport default function DevicePreview() {\n\tconst {\n\t\thasActiveMetaboxes,\n\t\tisPostSaveable,\n\t\tisSaving,\n\t\tisViewable,\n\t\tdeviceType,\n\t} = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\thasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),\n\t\t\tisSaving: select( editPostStore ).isSavingMetaBoxes(),\n\t\t\tisPostSaveable: select( editorStore ).isEditedPostSaveable(),\n\t\t\tisViewable: postType?.viewable ?? false,\n\t\t\tdeviceType:\n\t\t\t\tselect( editPostStore ).__experimentalGetPreviewDeviceType(),\n\t\t};\n\t}, [] );\n\tconst { __experimentalSetPreviewDeviceType: setPreviewDeviceType } =\n\t\tuseDispatch( editPostStore );\n\n\treturn (\n\t\t<PreviewOptions\n\t\t\tisEnabled={ isPostSaveable }\n\t\t\tclassName=\"edit-post-post-preview-dropdown\"\n\t\t\tdeviceType={ deviceType }\n\t\t\tsetDeviceType={ setPreviewDeviceType }\n\t\t\tlabel={ __( 'Preview' ) }\n\t\t>\n\t\t\t{ isViewable && (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t<div className=\"edit-post-header-preview__grouping-external\">\n\t\t\t\t\t\t<PostPreviewButton\n\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t'edit-post-header-preview__button-external'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\tforceIsAutosaveable={ hasActiveMetaboxes }\n\t\t\t\t\t\t\tforcePreviewLink={ isSaving ? null : undefined }\n\t\t\t\t\t\t\ttextContent={\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ __( 'Preview in new tab' ) }\n\t\t\t\t\t\t\t\t\t<Icon icon={ external } />\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</PreviewOptions>\n\t);\n}\n"]}
|
|
@@ -17,7 +17,7 @@ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { store as editPostStore } from '../../../store';
|
|
20
|
-
import { unlock } from '../../../
|
|
20
|
+
import { unlock } from '../../../lock-unlock';
|
|
21
21
|
const {
|
|
22
22
|
useShouldContextualToolbarShow
|
|
23
23
|
} = unlock(blockEditorPrivateApis);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/header/header-toolbar/index.js"],"names":["useViewportMatch","useSelect","useDispatch","__","_x","NavigableToolbar","ToolSelector","store","blockEditorStore","privateApis","blockEditorPrivateApis","EditorHistoryRedo","EditorHistoryUndo","editorStore","Button","ToolbarItem","listView","plus","useRef","useCallback","keyboardShortcutsStore","editPostStore","unlock","useShouldContextualToolbarShow","preventDefault","event","HeaderToolbar","inserterButton","setIsInserterOpened","setIsListViewOpened","isInserterEnabled","isInserterOpened","isTextModeEnabled","showIconLabels","isListViewOpen","listViewShortcut","select","hasInserterItems","getBlockRootClientId","getBlockSelectionEnd","getEditorSettings","getEditorMode","isFeatureActive","isListViewOpened","getShortcutRepresentation","richEditingEnabled","isLargeViewport","isWideViewport","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","toolbarAriaLabel","toggleListView","overflowItems","undefined","toggleInserter","current","focus","longLabel","shortLabel"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,gBAAT,QAAiC,oBAAjC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SACCC,gBADD,EAECC,YAFD,EAGCC,KAAK,IAAIC,gBAHV,EAICC,WAAW,IAAIC,sBAJhB,QAKO,yBALP;AAMA,SACCC,iBADD,EAECC,iBAFD,EAGCL,KAAK,IAAIM,WAHV,QAIO,mBAJP;AAKA,SAASC,MAAT,EAAiBC,WAAjB,QAAoC,uBAApC;AACA,SAASC,QAAT,EAAmBC,IAAnB,QAA+B,kBAA/B;AACA,SAASC,MAAT,EAAiBC,WAAjB,QAAoC,oBAApC;AACA,SAASZ,KAAK,IAAIa,sBAAlB,QAAgD,+BAAhD;AAEA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W,EAAG,CAAEqB,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgBsB;AAHzC,IAXD,EAgBC,cAAC,WAAD;AACC,IAAA,EAAE,EAAG5C,iBADN;AAEC,IAAA,WAAW,EAAG,CAAEsB,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgBsB;AAHzC,IAhBD,EAqBGD,aArBH,CAfF,CALD,CADD;AAgDA;;AAED,eAAe5B,aAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tNavigableToolbar,\n\tToolSelector,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tEditorHistoryRedo,\n\tEditorHistoryUndo,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { listView, plus } from '@wordpress/icons';\nimport { useRef, useCallback } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\nimport { unlock } from '../../../private-apis';\n\nconst { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\nconst preventDefault = ( event ) => {\n\tevent.preventDefault();\n};\n\nfunction HeaderToolbar() {\n\tconst inserterButton = useRef();\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editPostStore );\n\tconst {\n\t\tisInserterEnabled,\n\t\tisInserterOpened,\n\t\tisTextModeEnabled,\n\t\tshowIconLabels,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t} = useSelect( ( select ) => {\n\t\tconst { hasInserterItems, getBlockRootClientId, getBlockSelectionEnd } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getEditorSettings } = select( editorStore );\n\t\tconst { getEditorMode, isFeatureActive, isListViewOpened } =\n\t\t\tselect( editPostStore );\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\n\t\treturn {\n\t\t\t// This setting (richEditingEnabled) should not live in the block editor's setting.\n\t\t\tisInserterEnabled:\n\t\t\t\tgetEditorMode() === 'visual' &&\n\t\t\t\tgetEditorSettings().richEditingEnabled &&\n\t\t\t\thasInserterItems(\n\t\t\t\t\tgetBlockRootClientId( getBlockSelectionEnd() )\n\t\t\t\t),\n\t\t\tisInserterOpened: select( editPostStore ).isInserterOpened(),\n\t\t\tisTextModeEnabled: getEditorMode() === 'text',\n\t\t\tshowIconLabels: isFeatureActive( 'showIconLabels' ),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/edit-post/toggle-list-view'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\tconst {\n\t\tshouldShowContextualToolbar,\n\t\tcanFocusHiddenToolbar,\n\t\tfixedToolbarCanBeFocused,\n\t} = useShouldContextualToolbarShow();\n\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\t// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.\n\tconst blockToolbarCanBeFocused =\n\t\tshouldShowContextualToolbar ||\n\t\tcanFocusHiddenToolbar ||\n\t\tfixedToolbarCanBeFocused;\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\tconst overflowItems = (\n\t\t<>\n\t\t\t<ToolbarItem\n\t\t\t\tas={ Button }\n\t\t\t\tclassName=\"edit-post-header-toolbar__document-overview-toggle\"\n\t\t\t\ticon={ listView }\n\t\t\t\tdisabled={ isTextModeEnabled }\n\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\tlabel={ __( 'Document Overview' ) }\n\t\t\t\tonClick={ toggleListView }\n\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t/>\n\t\t</>\n\t);\n\tconst toggleInserter = useCallback( () => {\n\t\tif ( isInserterOpened ) {\n\t\t\t// Focusing the inserter button should close the inserter popover.\n\t\t\t// However, there are some cases it won't close when the focus is lost.\n\t\t\t// See https://github.com/WordPress/gutenberg/issues/43090 for more details.\n\t\t\tinserterButton.current.focus();\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tsetIsInserterOpened( true );\n\t\t}\n\t}, [ isInserterOpened, setIsInserterOpened ] );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName=\"edit-post-header-toolbar\"\n\t\t\taria-label={ toolbarAriaLabel }\n\t\t\tshouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }\n\t\t>\n\t\t\t<div className=\"edit-post-header-toolbar__left\">\n\t\t\t\t<ToolbarItem\n\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tclassName=\"edit-post-header-toolbar__inserter-toggle\"\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\tdisabled={ ! isInserterEnabled }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tlabel={ showIconLabels ? shortLabel : longLabel }\n\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t/>\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdisabled={ isTextModeEnabled }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryUndo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryRedo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ overflowItems }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default HeaderToolbar;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/header/header-toolbar/index.js"],"names":["useViewportMatch","useSelect","useDispatch","__","_x","NavigableToolbar","ToolSelector","store","blockEditorStore","privateApis","blockEditorPrivateApis","EditorHistoryRedo","EditorHistoryUndo","editorStore","Button","ToolbarItem","listView","plus","useRef","useCallback","keyboardShortcutsStore","editPostStore","unlock","useShouldContextualToolbarShow","preventDefault","event","HeaderToolbar","inserterButton","setIsInserterOpened","setIsListViewOpened","isInserterEnabled","isInserterOpened","isTextModeEnabled","showIconLabels","isListViewOpen","listViewShortcut","select","hasInserterItems","getBlockRootClientId","getBlockSelectionEnd","getEditorSettings","getEditorMode","isFeatureActive","isListViewOpened","getShortcutRepresentation","richEditingEnabled","isLargeViewport","isWideViewport","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","toolbarAriaLabel","toggleListView","overflowItems","undefined","toggleInserter","current","focus","longLabel","shortLabel"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,gBAAT,QAAiC,oBAAjC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SACCC,gBADD,EAECC,YAFD,EAGCC,KAAK,IAAIC,gBAHV,EAICC,WAAW,IAAIC,sBAJhB,QAKO,yBALP;AAMA,SACCC,iBADD,EAECC,iBAFD,EAGCL,KAAK,IAAIM,WAHV,QAIO,mBAJP;AAKA,SAASC,MAAT,EAAiBC,WAAjB,QAAoC,uBAApC;AACA,SAASC,QAAT,EAAmBC,IAAnB,QAA+B,kBAA/B;AACA,SAASC,MAAT,EAAiBC,WAAjB,QAAoC,oBAApC;AACA,SAASZ,KAAK,IAAIa,sBAAlB,QAAgD,+BAAhD;AAEA;AACA;AACA;;AACA,SAASb,KAAK,IAAIc,aAAlB,QAAuC,gBAAvC;AACA,SAASC,MAAT,QAAuB,sBAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAqCD,MAAM,CAAEZ,sBAAF,CAAjD;;AAEA,MAAMc,cAAc,GAAKC,KAAF,IAAa;AACnCA,EAAAA,KAAK,CAACD,cAAN;AACA,CAFD;;AAIA,SAASE,aAAT,GAAyB;AACxB,QAAMC,cAAc,GAAGT,MAAM,EAA7B;AACA,QAAM;AAAEU,IAAAA,mBAAF;AAAuBC,IAAAA;AAAvB,MACL3B,WAAW,CAAEmB,aAAF,CADZ;AAEA,QAAM;AACLS,IAAAA,iBADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,iBA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AAHpC,KAKC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,WAAD;AACC,IAAA,GAAG,EAAGxB,cADP;AAEC,IAAA,EAAE,EAAGb,MAFN;AAGC,IAAA,SAAS,EAAC,2CAHX;AAIC,IAAA,OAAO,EAAC,SAJT;AAKC,IAAA,SAAS,EAAGiB,gBALb;AAMC,IAAA,WAAW,EAAGP,cANf;AAOC,IAAA,OAAO,EAAGgC,cAPX;AAQC,IAAA,QAAQ,EAAG,CAAE1B,iBARd;AASC,IAAA,IAAI,EAAGb,IATR;AAUC,IAAA,KAAK,EAAGgB,cAAc,GAAG2B,UAAH,GAAgBD,SAVvC;AAWC,IAAA,WAAW,EAAG,CAAE1B;AAXjB,IADD,EAcG,CAAEc,cAAc,IAAI,CAAEd,cAAtB,KACD,8BACGa,eAAe,IAChB,cAAC,WAAD;AACC,IAAA,EAAE,EAAGxC,YADN;AAEC,IAAA,WAAW,EAAG,CAAE2B,cAFjB;AAGC,IAAA,OAAO,EACNA,cAAc,GAAG,UAAH,GAAgBsB,SAJhC;AAMC,IAAA,QAAQ,EAAGvB;AANZ,IAFF,EAWC,cAAC,WAAD;AACC,IAAA,EAAE,EAAGpB,iBADN;AAEC,IAAA,WAAW,EAAG,CAAEqB,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgBsB;AAHzC,IAXD,EAgBC,cAAC,WAAD;AACC,IAAA,EAAE,EAAG5C,iBADN;AAEC,IAAA,WAAW,EAAG,CAAEsB,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgBsB;AAHzC,IAhBD,EAqBGD,aArBH,CAfF,CALD,CADD;AAgDA;;AAED,eAAe5B,aAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tNavigableToolbar,\n\tToolSelector,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tEditorHistoryRedo,\n\tEditorHistoryUndo,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { listView, plus } from '@wordpress/icons';\nimport { useRef, useCallback } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\nconst preventDefault = ( event ) => {\n\tevent.preventDefault();\n};\n\nfunction HeaderToolbar() {\n\tconst inserterButton = useRef();\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editPostStore );\n\tconst {\n\t\tisInserterEnabled,\n\t\tisInserterOpened,\n\t\tisTextModeEnabled,\n\t\tshowIconLabels,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t} = useSelect( ( select ) => {\n\t\tconst { hasInserterItems, getBlockRootClientId, getBlockSelectionEnd } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getEditorSettings } = select( editorStore );\n\t\tconst { getEditorMode, isFeatureActive, isListViewOpened } =\n\t\t\tselect( editPostStore );\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\n\t\treturn {\n\t\t\t// This setting (richEditingEnabled) should not live in the block editor's setting.\n\t\t\tisInserterEnabled:\n\t\t\t\tgetEditorMode() === 'visual' &&\n\t\t\t\tgetEditorSettings().richEditingEnabled &&\n\t\t\t\thasInserterItems(\n\t\t\t\t\tgetBlockRootClientId( getBlockSelectionEnd() )\n\t\t\t\t),\n\t\t\tisInserterOpened: select( editPostStore ).isInserterOpened(),\n\t\t\tisTextModeEnabled: getEditorMode() === 'text',\n\t\t\tshowIconLabels: isFeatureActive( 'showIconLabels' ),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/edit-post/toggle-list-view'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\tconst {\n\t\tshouldShowContextualToolbar,\n\t\tcanFocusHiddenToolbar,\n\t\tfixedToolbarCanBeFocused,\n\t} = useShouldContextualToolbarShow();\n\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\t// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.\n\tconst blockToolbarCanBeFocused =\n\t\tshouldShowContextualToolbar ||\n\t\tcanFocusHiddenToolbar ||\n\t\tfixedToolbarCanBeFocused;\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\tconst overflowItems = (\n\t\t<>\n\t\t\t<ToolbarItem\n\t\t\t\tas={ Button }\n\t\t\t\tclassName=\"edit-post-header-toolbar__document-overview-toggle\"\n\t\t\t\ticon={ listView }\n\t\t\t\tdisabled={ isTextModeEnabled }\n\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\tlabel={ __( 'Document Overview' ) }\n\t\t\t\tonClick={ toggleListView }\n\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t/>\n\t\t</>\n\t);\n\tconst toggleInserter = useCallback( () => {\n\t\tif ( isInserterOpened ) {\n\t\t\t// Focusing the inserter button should close the inserter popover.\n\t\t\t// However, there are some cases it won't close when the focus is lost.\n\t\t\t// See https://github.com/WordPress/gutenberg/issues/43090 for more details.\n\t\t\tinserterButton.current.focus();\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tsetIsInserterOpened( true );\n\t\t}\n\t}, [ isInserterOpened, setIsInserterOpened ] );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName=\"edit-post-header-toolbar\"\n\t\t\taria-label={ toolbarAriaLabel }\n\t\t\tshouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }\n\t\t>\n\t\t\t<div className=\"edit-post-header-toolbar__left\">\n\t\t\t\t<ToolbarItem\n\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tclassName=\"edit-post-header-toolbar__inserter-toggle\"\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\tdisabled={ ! isInserterEnabled }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tlabel={ showIconLabels ? shortLabel : longLabel }\n\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t/>\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdisabled={ isTextModeEnabled }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryUndo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryRedo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ overflowItems }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default HeaderToolbar;\n"]}
|
|
@@ -30,21 +30,16 @@ function Header({
|
|
|
30
30
|
hasActiveMetaboxes,
|
|
31
31
|
isPublishSidebarOpened,
|
|
32
32
|
isSaving,
|
|
33
|
-
showIconLabels
|
|
34
|
-
isDistractionFreeMode
|
|
33
|
+
showIconLabels
|
|
35
34
|
} = useSelect(select => ({
|
|
36
35
|
hasActiveMetaboxes: select(editPostStore).hasMetaBoxes(),
|
|
37
36
|
isPublishSidebarOpened: select(editPostStore).isPublishSidebarOpened(),
|
|
38
37
|
isSaving: select(editPostStore).isSavingMetaBoxes(),
|
|
39
|
-
showIconLabels: select(editPostStore).isFeatureActive('showIconLabels')
|
|
40
|
-
isDistractionFreeMode: select(editPostStore).isFeatureActive('distractionFree')
|
|
38
|
+
showIconLabels: select(editPostStore).isFeatureActive('showIconLabels')
|
|
41
39
|
}), []);
|
|
42
|
-
const isDistractionFree = isDistractionFreeMode && isLargeViewport;
|
|
43
40
|
const slideY = {
|
|
44
|
-
hidden:
|
|
45
|
-
y: '-
|
|
46
|
-
} : {
|
|
47
|
-
y: 0
|
|
41
|
+
hidden: {
|
|
42
|
+
y: '-50px'
|
|
48
43
|
},
|
|
49
44
|
hover: {
|
|
50
45
|
y: 0,
|
|
@@ -55,10 +50,8 @@ function Header({
|
|
|
55
50
|
}
|
|
56
51
|
};
|
|
57
52
|
const slideX = {
|
|
58
|
-
hidden:
|
|
53
|
+
hidden: {
|
|
59
54
|
x: '-100%'
|
|
60
|
-
} : {
|
|
61
|
-
x: 0
|
|
62
55
|
},
|
|
63
56
|
hover: {
|
|
64
57
|
x: 0,
|
|
@@ -103,10 +96,10 @@ function Header({
|
|
|
103
96
|
forceIsDirty: hasActiveMetaboxes,
|
|
104
97
|
forceIsSaving: isSaving,
|
|
105
98
|
showIconLabels: showIconLabels
|
|
106
|
-
}), createElement(
|
|
99
|
+
}), createElement(DevicePreview, null), createElement(PostPreviewButton, {
|
|
107
100
|
forceIsAutosaveable: hasActiveMetaboxes,
|
|
108
101
|
forcePreviewLink: isSaving ? null : undefined
|
|
109
|
-
}), createElement(PostPublishButtonOrToggle, {
|
|
102
|
+
}), createElement(ViewLink, null), createElement(PostPublishButtonOrToggle, {
|
|
110
103
|
forceIsDirty: hasActiveMetaboxes,
|
|
111
104
|
forceIsSaving: isSaving,
|
|
112
105
|
setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/header/index.js"],"names":["PostSavedState","PostPreviewButton","useSelect","PinnedItems","useViewportMatch","__unstableMotion","motion","FullscreenModeClose","HeaderToolbar","MoreMenu","PostPublishButtonOrToggle","default","DevicePreview","ViewLink","MainDashboardButton","store","editPostStore","DocumentTitle","Header","setEntitiesSavedStatesCallback","isLargeViewport","hasActiveMetaboxes","isPublishSidebarOpened","isSaving","showIconLabels","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/header/index.js"],"names":["PostSavedState","PostPreviewButton","useSelect","PinnedItems","useViewportMatch","__unstableMotion","motion","FullscreenModeClose","HeaderToolbar","MoreMenu","PostPublishButtonOrToggle","default","DevicePreview","ViewLink","MainDashboardButton","store","editPostStore","DocumentTitle","Header","setEntitiesSavedStatesCallback","isLargeViewport","hasActiveMetaboxes","isPublishSidebarOpened","isSaving","showIconLabels","select","hasMetaBoxes","isSavingMetaBoxes","isFeatureActive","slideY","hidden","y","hover","transition","type","delay","slideX","x","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,EAAyBC,iBAAzB,QAAkD,mBAAlD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,WAAT,QAA4B,sBAA5B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,gBAAgB,IAAIC,MAA7B,QAA2C,uBAA3C;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AACA,SAASC,OAAO,IAAIC,aAApB,QAAyC,mBAAzC;AACA,OAAOC,QAAP,MAAqB,cAArB;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AACA,OAAOC,aAAP,MAA0B,kBAA1B;;AAEA,SAASC,MAAT,CAAiB;AAAEC,EAAAA;AAAF,CAAjB,EAAsD;AACrD,QAAMC,eAAe,GAAGhB,gBAAgB,CAAE,OAAF,CAAxC;AACA,QAAM;AACLiB,IAAAA,kBADK;AAELC,IAAAA,sBAFK;AAGLC,IAAAA,QAHK;AAILC,IAAAA;AAJK,MAKFtB,SAAS,CACVuB,MAAF,KAAgB;AACfJ,IAAAA,kBAAkB,EAAEI,MAAM,CAAET,aAAF,CAAN,CAAwBU,YAAxB,EADL;AAEfJ,IAAAA,sBAAsB,EACrBG,MAAM,CAAET,aAAF,CAAN,CAAwBM,sBAAxB,EAHc;AAIfC,IAAAA,QAAQ,EAAEE,MAAM,CAAET,aAAF,CAAN,CAAwBW,iBAAxB,EAJK;AAKfH,IAAAA,cAAc,EACbC,MAAM,CAAET,aAAF,CAAN,CAAwBY,eAAxB,CAAyC,gBAAzC;AANc,GAAhB,CADY,EASZ,EATY,CALb;AAiBA,QAAMC,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AFd;AAGC,IAAA,SAAS,EAAC;AAHX,KAKG,CAAEb,sBAAF,IACD;AACA;AACA;AACA;AACA;AACA,gBAAC,cAAD;AACC,IAAA,YAAY,EAAGD,kBADhB;AAEC,IAAA,aAAa,EAAGE,QAFjB;AAGC,IAAA,cAAc,EAAGC;AAHlB,IAXF,EAiBC,cAAC,aAAD,OAjBD,EAkBC,cAAC,iBAAD;AACC,IAAA,mBAAmB,EAAGH,kBADvB;AAEC,IAAA,gBAAgB,EAAGE,QAAQ,GAAG,IAAH,GAAUe;AAFtC,IAlBD,EAsBC,cAAC,QAAD,OAtBD,EAuBC,cAAC,yBAAD;AACC,IAAA,YAAY,EAAGjB,kBADhB;AAEC,IAAA,aAAa,EAAGE,QAFjB;AAGC,IAAA,8BAA8B,EAC7BJ;AAJF,IAvBD,EA8BG,CAAEC,eAAe,IAAI,CAAEI,cAAvB,KACD,8BACC,cAAC,WAAD,CAAa,IAAb;AAAkB,IAAA,KAAK,EAAC;AAAxB,IADD,EAEC,cAAC,QAAD;AAAU,IAAA,cAAc,EAAGA;AAA3B,IAFD,CA/BF,EAoCGA,cAAc,IAAI,CAAEJ,eAApB,IACD,cAAC,QAAD;AAAU,IAAA,cAAc,EAAGI;AAA3B,IArCF,CAnBD,CADD;AA8DA;;AAED,eAAeN,MAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PostSavedState, PostPreviewButton } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\nimport { PinnedItems } from '@wordpress/interface';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport FullscreenModeClose from './fullscreen-mode-close';\nimport HeaderToolbar from './header-toolbar';\nimport MoreMenu from './more-menu';\nimport PostPublishButtonOrToggle from './post-publish-button-or-toggle';\nimport { default as DevicePreview } from '../device-preview';\nimport ViewLink from '../view-link';\nimport MainDashboardButton from './main-dashboard-button';\nimport { store as editPostStore } from '../../store';\nimport DocumentTitle from './document-title';\n\nfunction Header( { setEntitiesSavedStatesCallback } ) {\n\tconst isLargeViewport = useViewportMatch( 'large' );\n\tconst {\n\t\thasActiveMetaboxes,\n\t\tisPublishSidebarOpened,\n\t\tisSaving,\n\t\tshowIconLabels,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\thasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),\n\t\t\tisPublishSidebarOpened:\n\t\t\t\tselect( editPostStore ).isPublishSidebarOpened(),\n\t\t\tisSaving: select( editPostStore ).isSavingMetaBoxes(),\n\t\t\tshowIconLabels:\n\t\t\t\tselect( editPostStore ).isFeatureActive( 'showIconLabels' ),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst slideY = {\n\t\thidden: { y: '-50px' },\n\t\thover: { y: 0, transition: { type: 'tween', delay: 0.2 } },\n\t};\n\n\tconst slideX = {\n\t\thidden: { x: '-100%' },\n\t\thover: { x: 0, transition: { type: 'tween', delay: 0.2 } },\n\t};\n\n\treturn (\n\t\t<div className=\"edit-post-header\">\n\t\t\t<MainDashboardButton.Slot>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ slideX }\n\t\t\t\t\ttransition={ { type: 'tween', delay: 0.8 } }\n\t\t\t\t>\n\t\t\t\t\t<FullscreenModeClose showTooltip />\n\t\t\t\t</motion.div>\n\t\t\t</MainDashboardButton.Slot>\n\t\t\t<motion.div\n\t\t\t\tvariants={ slideY }\n\t\t\t\ttransition={ { type: 'tween', delay: 0.8 } }\n\t\t\t\tclassName=\"edit-post-header__toolbar\"\n\t\t\t>\n\t\t\t\t<HeaderToolbar />\n\t\t\t\t<div className=\"edit-post-header__document-title\">\n\t\t\t\t\t<DocumentTitle />\n\t\t\t\t</div>\n\t\t\t</motion.div>\n\t\t\t<motion.div\n\t\t\t\tvariants={ slideY }\n\t\t\t\ttransition={ { type: 'tween', delay: 0.8 } }\n\t\t\t\tclassName=\"edit-post-header__settings\"\n\t\t\t>\n\t\t\t\t{ ! isPublishSidebarOpened && (\n\t\t\t\t\t// This button isn't completely hidden by the publish sidebar.\n\t\t\t\t\t// We can't hide the whole toolbar when the publish sidebar is open because\n\t\t\t\t\t// we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.\n\t\t\t\t\t// We track that DOM node to return focus to the PostPublishButtonOrToggle\n\t\t\t\t\t// when the publish sidebar has been closed.\n\t\t\t\t\t<PostSavedState\n\t\t\t\t\t\tforceIsDirty={ hasActiveMetaboxes }\n\t\t\t\t\t\tforceIsSaving={ isSaving }\n\t\t\t\t\t\tshowIconLabels={ showIconLabels }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<DevicePreview />\n\t\t\t\t<PostPreviewButton\n\t\t\t\t\tforceIsAutosaveable={ hasActiveMetaboxes }\n\t\t\t\t\tforcePreviewLink={ isSaving ? null : undefined }\n\t\t\t\t/>\n\t\t\t\t<ViewLink />\n\t\t\t\t<PostPublishButtonOrToggle\n\t\t\t\t\tforceIsDirty={ hasActiveMetaboxes }\n\t\t\t\t\tforceIsSaving={ isSaving }\n\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t{ ( isLargeViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-post\" />\n\t\t\t\t\t\t<MoreMenu showIconLabels={ showIconLabels } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t{ showIconLabels && ! isLargeViewport && (\n\t\t\t\t\t<MoreMenu showIconLabels={ showIconLabels } />\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t</div>\n\t);\n}\n\nexport default Header;\n"]}
|