@wordpress/editor 14.19.2 → 14.19.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/start-page-options/index.js +2 -1
- package/build/components/start-page-options/index.js.map +1 -1
- package/build-module/components/start-page-options/index.js +2 -1
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-types/components/start-page-options/index.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/components/start-page-options/index.js +3 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -14,6 +14,7 @@ var _coreData = require("@wordpress/core-data");
|
|
|
14
14
|
var _blocks = require("@wordpress/blocks");
|
|
15
15
|
var _preferences = require("@wordpress/preferences");
|
|
16
16
|
var _interface = require("@wordpress/interface");
|
|
17
|
+
var _constants = require("../../store/constants");
|
|
17
18
|
var _store = require("../../store");
|
|
18
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
20
|
/**
|
|
@@ -158,7 +159,7 @@ function StartPageOptions() {
|
|
|
158
159
|
const choosePatternModalEnabled = select(_preferences.store).get('core', 'enableChoosePatternModal');
|
|
159
160
|
return {
|
|
160
161
|
postId: getCurrentPostId(),
|
|
161
|
-
enabled: choosePatternModalEnabled &&
|
|
162
|
+
enabled: choosePatternModalEnabled && _constants.TEMPLATE_POST_TYPE !== getCurrentPostType()
|
|
162
163
|
};
|
|
163
164
|
}, []);
|
|
164
165
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_element","_blockEditor","_data","_coreData","_blocks","_preferences","_interface","_store","_jsxRuntime","useStartPatterns","blockPatternsWithPostContentBlockType","postType","useSelect","select","getPatternsByBlockTypes","getBlocksByName","blockEditorStore","getCurrentPostType","getRenderingMode","editorStore","rootClientId","useMemo","length","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","blockPatterns","onChoosePattern","editEntityRecord","useDispatch","coreStore","postId","getCurrentPostId","jsx","__experimentalBlockPatternsList","onClickPattern","_pattern","blocks","content","blocksForSerialization","__unstableSerializeAndClean","StartPageOptionsModal","onClose","showStartPatterns","setShowStartPatterns","useState","set","setPreference","preferencesStore","startPatterns","hasStartPattern","handleClose","jsxs","Modal","className","title","__","isFullScreen","onRequestClose","children","Flex","justify","expanded","FlexItem","ToggleControl","__nextHasNoMarginBottom","checked","label","help","onChange","newValue","StartPageOptions","isOpen","setIsOpen","isEditedPostDirty","isEditedPostEmpty","isModalActive","interfaceStore","enabled","choosePatternModalEnabled","get","useEffect","isFreshPage","isPreferencesModalActive"],"sources":["@wordpress/editor/src/components/start-page-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Flex, FlexItem, Modal, ToggleControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declared and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes, getBlocksByName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getCurrentPostType, getRenderingMode } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst rootClientId =\n\t\t\t\tgetRenderingMode() === 'post-only'\n\t\t\t\t\t? ''\n\t\t\t\t\t: getBlocksByName( 'core/post-content' )?.[ 0 ];\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType: getPatternsByBlockTypes(\n\t\t\t\t\t'core/post-content',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\tif ( ! blockPatternsWithPostContentBlockType?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t/*\n\t\t * Filter patterns without postTypes declared if the current postType is page\n\t\t * or patterns that declare the current postType in its post type array.\n\t\t */\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { blockPatterns, onChoosePattern } ) {\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { postType, postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId } = select( editorStore );\n\n\t\treturn {\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\t\t\tblocks,\n\t\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t} );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartPageOptionsModal( { onClose } ) {\n\tconst [ showStartPatterns, setShowStartPatterns ] = useState( true );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tconst startPatterns = useStartPatterns();\n\tconst hasStartPattern = startPatterns.length > 0;\n\n\tif ( ! hasStartPattern ) {\n\t\treturn null;\n\t}\n\n\tfunction handleClose() {\n\t\tonClose();\n\t\tsetPreference( 'core', 'enableChoosePatternModal', showStartPatterns );\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"editor-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen\n\t\t\tonRequestClose={ handleClose }\n\t\t>\n\t\t\t<div className=\"editor-start-page-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tblockPatterns={ startPatterns }\n\t\t\t\t\tonChoosePattern={ handleClose }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<Flex\n\t\t\t\tclassName=\"editor-start-page-options__modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tchecked={ showStartPatterns }\n\t\t\t\t\t\tlabel={ __( 'Show starter patterns' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Shows starter patterns when creating a new page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\tsetShowStartPatterns( newValue );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartPageOptions() {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\tconst { isEditedPostDirty, isEditedPostEmpty } = useSelect( editorStore );\n\tconst { isModalActive } = useSelect( interfaceStore );\n\tconst { enabled, postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst choosePatternModalEnabled = select( preferencesStore ).get(\n\t\t\t'core',\n\t\t\t'enableChoosePatternModal'\n\t\t);\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tenabled:\n\t\t\t\tchoosePatternModalEnabled && 'page' === getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\t// Note: The `postId` ensures the effect re-runs when pages are switched without remounting the component.\n\t// Examples: changing pages in the List View, creating a new page via Command Palette.\n\tuseEffect( () => {\n\t\tconst isFreshPage = ! isEditedPostDirty() && isEditedPostEmpty();\n\t\t// Prevents immediately opening when features is enabled via preferences modal.\n\t\tconst isPreferencesModalActive = isModalActive( 'editor/preferences' );\n\t\tif ( ! enabled || ! isFreshPage || isPreferencesModalActive ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Open the modal after the initial render for a new page.\n\t\tsetIsOpen( true );\n\t}, [\n\t\tenabled,\n\t\tpostId,\n\t\tisEditedPostDirty,\n\t\tisEditedPostEmpty,\n\t\tisModalActive,\n\t] );\n\n\tif ( ! isOpen ) {\n\t\treturn null;\n\t}\n\n\treturn <StartPageOptionsModal onClose={ () => setIsOpen( false ) } />;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAIA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AAAmD,IAAAU,WAAA,GAAAV,OAAA;AAnBnD;AACA;AACA;;AAcA;AACA;AACA;;AAGO,SAASW,gBAAgBA,CAAA,EAAG;EAClC;EACA;EACA;EACA,MAAM;IAAEC,qCAAqC;IAAEC;EAAS,CAAC,GAAG,IAAAC,eAAS,EAClEC,MAAM,IAAM;IACb,MAAM;MAAEC,uBAAuB;MAAEC;IAAgB,CAAC,GACjDF,MAAM,CAAEG,kBAAiB,CAAC;IAC3B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G,CAC/D,MAAM,EACN,0BACD,CAAC;IACD,OAAO;MACNjD,MAAM,EAAEC,gBAAgB,CAAC,CAAC;MAC1B8C,OAAO,EACNC,yBAAyB,IAAI,MAAM,KAAKlE,kBAAkB,CAAC;IAC7D,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;;EAEP;EACA;EACA,IAAAoE,kBAAS,EAAE,MAAM;IAChB,MAAMC,WAAW,GAAG,CAAER,iBAAiB,CAAC,CAAC,IAAIC,iBAAiB,CAAC,CAAC;IAChE;IACA,MAAMQ,wBAAwB,GAAGP,aAAa,CAAE,oBAAqB,CAAC;IACtE,IAAK,CAAEE,OAAO,IAAI,CAAEI,WAAW,IAAIC,wBAAwB,EAAG;MAC7D;IACD;;IAEA;IACAV,SAAS,CAAE,IAAK,CAAC;EAClB,CAAC,EAAE,CACFK,OAAO,EACP/C,MAAM,EACN2C,iBAAiB,EACjBC,iBAAiB,EACjBC,aAAa,CACZ,CAAC;EAEH,IAAK,CAAEJ,MAAM,EAAG;IACf,OAAO,IAAI;EACZ;EAEA,oBAAO,IAAApE,WAAA,CAAA6B,GAAA,EAACQ,qBAAqB;IAACC,OAAO,EAAGA,CAAA,KAAM+B,SAAS,CAAE,KAAM;EAAG,CAAE,CAAC;AACtE","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_element","_blockEditor","_data","_coreData","_blocks","_preferences","_interface","_constants","_store","_jsxRuntime","useStartPatterns","blockPatternsWithPostContentBlockType","postType","useSelect","select","getPatternsByBlockTypes","getBlocksByName","blockEditorStore","getCurrentPostType","getRenderingMode","editorStore","rootClientId","useMemo","length","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","blockPatterns","onChoosePattern","editEntityRecord","useDispatch","coreStore","postId","getCurrentPostId","jsx","__experimentalBlockPatternsList","onClickPattern","_pattern","blocks","content","blocksForSerialization","__unstableSerializeAndClean","StartPageOptionsModal","onClose","showStartPatterns","setShowStartPatterns","useState","set","setPreference","preferencesStore","startPatterns","hasStartPattern","handleClose","jsxs","Modal","className","title","__","isFullScreen","onRequestClose","children","Flex","justify","expanded","FlexItem","ToggleControl","__nextHasNoMarginBottom","checked","label","help","onChange","newValue","StartPageOptions","isOpen","setIsOpen","isEditedPostDirty","isEditedPostEmpty","isModalActive","interfaceStore","enabled","choosePatternModalEnabled","get","TEMPLATE_POST_TYPE","useEffect","isFreshPage","isPreferencesModalActive"],"sources":["@wordpress/editor/src/components/start-page-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Flex, FlexItem, Modal, ToggleControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPE } from '../../store/constants';\nimport { store as editorStore } from '../../store';\n\nexport function useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declared and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes, getBlocksByName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getCurrentPostType, getRenderingMode } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst rootClientId =\n\t\t\t\tgetRenderingMode() === 'post-only'\n\t\t\t\t\t? ''\n\t\t\t\t\t: getBlocksByName( 'core/post-content' )?.[ 0 ];\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType: getPatternsByBlockTypes(\n\t\t\t\t\t'core/post-content',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\tif ( ! blockPatternsWithPostContentBlockType?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t/*\n\t\t * Filter patterns without postTypes declared if the current postType is page\n\t\t * or patterns that declare the current postType in its post type array.\n\t\t */\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { blockPatterns, onChoosePattern } ) {\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { postType, postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId } = select( editorStore );\n\n\t\treturn {\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\t\t\tblocks,\n\t\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t} );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartPageOptionsModal( { onClose } ) {\n\tconst [ showStartPatterns, setShowStartPatterns ] = useState( true );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tconst startPatterns = useStartPatterns();\n\tconst hasStartPattern = startPatterns.length > 0;\n\n\tif ( ! hasStartPattern ) {\n\t\treturn null;\n\t}\n\n\tfunction handleClose() {\n\t\tonClose();\n\t\tsetPreference( 'core', 'enableChoosePatternModal', showStartPatterns );\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"editor-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen\n\t\t\tonRequestClose={ handleClose }\n\t\t>\n\t\t\t<div className=\"editor-start-page-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tblockPatterns={ startPatterns }\n\t\t\t\t\tonChoosePattern={ handleClose }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<Flex\n\t\t\t\tclassName=\"editor-start-page-options__modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tchecked={ showStartPatterns }\n\t\t\t\t\t\tlabel={ __( 'Show starter patterns' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Shows starter patterns when creating a new page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\tsetShowStartPatterns( newValue );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartPageOptions() {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\tconst { isEditedPostDirty, isEditedPostEmpty } = useSelect( editorStore );\n\tconst { isModalActive } = useSelect( interfaceStore );\n\tconst { enabled, postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst choosePatternModalEnabled = select( preferencesStore ).get(\n\t\t\t'core',\n\t\t\t'enableChoosePatternModal'\n\t\t);\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tenabled:\n\t\t\t\tchoosePatternModalEnabled &&\n\t\t\t\tTEMPLATE_POST_TYPE !== getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\t// Note: The `postId` ensures the effect re-runs when pages are switched without remounting the component.\n\t// Examples: changing pages in the List View, creating a new page via Command Palette.\n\tuseEffect( () => {\n\t\tconst isFreshPage = ! isEditedPostDirty() && isEditedPostEmpty();\n\t\t// Prevents immediately opening when features is enabled via preferences modal.\n\t\tconst isPreferencesModalActive = isModalActive( 'editor/preferences' );\n\t\tif ( ! enabled || ! isFreshPage || isPreferencesModalActive ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Open the modal after the initial render for a new page.\n\t\tsetIsOpen( true );\n\t}, [\n\t\tenabled,\n\t\tpostId,\n\t\tisEditedPostDirty,\n\t\tisEditedPostEmpty,\n\t\tisModalActive,\n\t] );\n\n\tif ( ! isOpen ) {\n\t\treturn null;\n\t}\n\n\treturn <StartPageOptionsModal onClose={ () => setIsOpen( false ) } />;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAIA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAKA,IAAAS,UAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AAAmD,IAAAW,WAAA,GAAAX,OAAA;AApBnD;AACA;AACA;;AAcA;AACA;AACA;;AAIO,SAASY,gBAAgBA,CAAA,EAAG;EAClC;EACA;EACA;EACA,MAAM;IAAEC,qCAAqC;IAAEC;EAAS,CAAC,GAAG,IAAAC,eAAS,EAClEC,MAAM,IAAM;IACb,MAAM;MAAEC,uBAAuB;MAAEC;IAAgB,CAAC,GACjDF,MAAM,CAAEG,kBAAiB,CAAC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gC,GAAG,CAC/D,MAAM,EACN,0BACD,CAAC;IACD,OAAO;MACNjD,MAAM,EAAEC,gBAAgB,CAAC,CAAC;MAC1B8C,OAAO,EACNC,yBAAyB,IACzBE,6BAAkB,KAAKpE,kBAAkB,CAAC;IAC5C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;;EAEP;EACA;EACA,IAAAqE,kBAAS,EAAE,MAAM;IAChB,MAAMC,WAAW,GAAG,CAAET,iBAAiB,CAAC,CAAC,IAAIC,iBAAiB,CAAC,CAAC;IAChE;IACA,MAAMS,wBAAwB,GAAGR,aAAa,CAAE,oBAAqB,CAAC;IACtE,IAAK,CAAEE,OAAO,IAAI,CAAEK,WAAW,IAAIC,wBAAwB,EAAG;MAC7D;IACD;;IAEA;IACAX,SAAS,CAAE,IAAK,CAAC;EAClB,CAAC,EAAE,CACFK,OAAO,EACP/C,MAAM,EACN2C,iBAAiB,EACjBC,iBAAiB,EACjBC,aAAa,CACZ,CAAC;EAEH,IAAK,CAAEJ,MAAM,EAAG;IACf,OAAO,IAAI;EACZ;EAEA,oBAAO,IAAApE,WAAA,CAAA6B,GAAA,EAACQ,qBAAqB;IAACC,OAAO,EAAGA,CAAA,KAAM+B,SAAS,CAAE,KAAM;EAAG,CAAE,CAAC;AACtE","ignoreList":[]}
|
|
@@ -14,6 +14,7 @@ import { store as interfaceStore } from '@wordpress/interface';
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
|
+
import { TEMPLATE_POST_TYPE } from '../../store/constants';
|
|
17
18
|
import { store as editorStore } from '../../store';
|
|
18
19
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
20
|
export function useStartPatterns() {
|
|
@@ -150,7 +151,7 @@ export default function StartPageOptions() {
|
|
|
150
151
|
const choosePatternModalEnabled = select(preferencesStore).get('core', 'enableChoosePatternModal');
|
|
151
152
|
return {
|
|
152
153
|
postId: getCurrentPostId(),
|
|
153
|
-
enabled: choosePatternModalEnabled &&
|
|
154
|
+
enabled: choosePatternModalEnabled && TEMPLATE_POST_TYPE !== getCurrentPostType()
|
|
154
155
|
};
|
|
155
156
|
}, []);
|
|
156
157
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Flex","FlexItem","Modal","ToggleControl","__","useState","useMemo","useEffect","store","blockEditorStore","__experimentalBlockPatternsList","BlockPatternsList","useSelect","useDispatch","coreStore","__unstableSerializeAndClean","preferencesStore","interfaceStore","editorStore","jsx","_jsx","jsxs","_jsxs","useStartPatterns","blockPatternsWithPostContentBlockType","postType","select","getPatternsByBlockTypes","getBlocksByName","getCurrentPostType","getRenderingMode","rootClientId","length","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","blockPatterns","onChoosePattern","editEntityRecord","postId","getCurrentPostId","onClickPattern","_pattern","blocks","content","blocksForSerialization","StartPageOptionsModal","onClose","showStartPatterns","setShowStartPatterns","set","setPreference","startPatterns","hasStartPattern","handleClose","className","title","isFullScreen","onRequestClose","children","justify","expanded","__nextHasNoMarginBottom","checked","label","help","onChange","newValue","StartPageOptions","isOpen","setIsOpen","isEditedPostDirty","isEditedPostEmpty","isModalActive","enabled","choosePatternModalEnabled","get","isFreshPage","isPreferencesModalActive"],"sources":["@wordpress/editor/src/components/start-page-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Flex, FlexItem, Modal, ToggleControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declared and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes, getBlocksByName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getCurrentPostType, getRenderingMode } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst rootClientId =\n\t\t\t\tgetRenderingMode() === 'post-only'\n\t\t\t\t\t? ''\n\t\t\t\t\t: getBlocksByName( 'core/post-content' )?.[ 0 ];\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType: getPatternsByBlockTypes(\n\t\t\t\t\t'core/post-content',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\tif ( ! blockPatternsWithPostContentBlockType?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t/*\n\t\t * Filter patterns without postTypes declared if the current postType is page\n\t\t * or patterns that declare the current postType in its post type array.\n\t\t */\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { blockPatterns, onChoosePattern } ) {\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { postType, postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId } = select( editorStore );\n\n\t\treturn {\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\t\t\tblocks,\n\t\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t} );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartPageOptionsModal( { onClose } ) {\n\tconst [ showStartPatterns, setShowStartPatterns ] = useState( true );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tconst startPatterns = useStartPatterns();\n\tconst hasStartPattern = startPatterns.length > 0;\n\n\tif ( ! hasStartPattern ) {\n\t\treturn null;\n\t}\n\n\tfunction handleClose() {\n\t\tonClose();\n\t\tsetPreference( 'core', 'enableChoosePatternModal', showStartPatterns );\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"editor-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen\n\t\t\tonRequestClose={ handleClose }\n\t\t>\n\t\t\t<div className=\"editor-start-page-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tblockPatterns={ startPatterns }\n\t\t\t\t\tonChoosePattern={ handleClose }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<Flex\n\t\t\t\tclassName=\"editor-start-page-options__modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tchecked={ showStartPatterns }\n\t\t\t\t\t\tlabel={ __( 'Show starter patterns' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Shows starter patterns when creating a new page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\tsetShowStartPatterns( newValue );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartPageOptions() {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\tconst { isEditedPostDirty, isEditedPostEmpty } = useSelect( editorStore );\n\tconst { isModalActive } = useSelect( interfaceStore );\n\tconst { enabled, postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst choosePatternModalEnabled = select( preferencesStore ).get(\n\t\t\t'core',\n\t\t\t'enableChoosePatternModal'\n\t\t);\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tenabled:\n\t\t\t\tchoosePatternModalEnabled && 'page' === getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\t// Note: The `postId` ensures the effect re-runs when pages are switched without remounting the component.\n\t// Examples: changing pages in the List View, creating a new page via Command Palette.\n\tuseEffect( () => {\n\t\tconst isFreshPage = ! isEditedPostDirty() && isEditedPostEmpty();\n\t\t// Prevents immediately opening when features is enabled via preferences modal.\n\t\tconst isPreferencesModalActive = isModalActive( 'editor/preferences' );\n\t\tif ( ! enabled || ! isFreshPage || isPreferencesModalActive ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Open the modal after the initial render for a new page.\n\t\tsetIsOpen( true );\n\t}, [\n\t\tenabled,\n\t\tpostId,\n\t\tisEditedPostDirty,\n\t\tisEditedPostEmpty,\n\t\tisModalActive,\n\t] );\n\n\tif ( ! isOpen ) {\n\t\treturn null;\n\t}\n\n\treturn <StartPageOptionsModal onClose={ () => setIsOpen( false ) } />;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,aAAa,QAAQ,uBAAuB;AAC5E,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,OAAO,EAAEC,SAAS,QAAQ,oBA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AM;IAAEsE,iBAAiB;IAAEC;EAAkB,CAAC,GAAGhE,SAAS,CAAEM,WAAY,CAAC;EACzE,MAAM;IAAE2D;EAAc,CAAC,GAAGjE,SAAS,CAAEK,cAAe,CAAC;EACrD,MAAM;IAAE6D,OAAO;IAAEnC;EAAO,CAAC,GAAG/B,SAAS,CAAIc,MAAM,IAAM;IACpD,MAAM;MAAEkB,gBAAgB;MAAEf;IAAmB,CAAC,GAAGH,MAAM,CAAER,WAAY,CAAC;IACtE,MAAM6D,yBAAyB,GAAGrD,MAAM,CAAEV,gBAAiB,CAAC,CAACgE,GAAG,CAC/D,MAAM,EACN,0BACD,CAAC;IACD,OAAO;MACNrC,MAAM,EAAEC,gBAAgB,CAAC,CAAC;MAC1BkC,OAAO,EACNC,yBAAyB,IAAI,MAAM,KAAKlD,kBAAkB,CAAC;IAC7D,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;;EAEP;EACA;EACAtB,SAAS,CAAE,MAAM;IAChB,MAAM0E,WAAW,GAAG,CAAEN,iBAAiB,CAAC,CAAC,IAAIC,iBAAiB,CAAC,CAAC;IAChE;IACA,MAAMM,wBAAwB,GAAGL,aAAa,CAAE,oBAAqB,CAAC;IACtE,IAAK,CAAEC,OAAO,IAAI,CAAEG,WAAW,IAAIC,wBAAwB,EAAG;MAC7D;IACD;;IAEA;IACAR,SAAS,CAAE,IAAK,CAAC;EAClB,CAAC,EAAE,CACFI,OAAO,EACPnC,MAAM,EACNgC,iBAAiB,EACjBC,iBAAiB,EACjBC,aAAa,CACZ,CAAC;EAEH,IAAK,CAAEJ,MAAM,EAAG;IACf,OAAO,IAAI;EACZ;EAEA,oBAAOrD,IAAA,CAAC8B,qBAAqB;IAACC,OAAO,EAAGA,CAAA,KAAMuB,SAAS,CAAE,KAAM;EAAG,CAAE,CAAC;AACtE","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Flex","FlexItem","Modal","ToggleControl","__","useState","useMemo","useEffect","store","blockEditorStore","__experimentalBlockPatternsList","BlockPatternsList","useSelect","useDispatch","coreStore","__unstableSerializeAndClean","preferencesStore","interfaceStore","TEMPLATE_POST_TYPE","editorStore","jsx","_jsx","jsxs","_jsxs","useStartPatterns","blockPatternsWithPostContentBlockType","postType","select","getPatternsByBlockTypes","getBlocksByName","getCurrentPostType","getRenderingMode","rootClientId","length","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","blockPatterns","onChoosePattern","editEntityRecord","postId","getCurrentPostId","onClickPattern","_pattern","blocks","content","blocksForSerialization","StartPageOptionsModal","onClose","showStartPatterns","setShowStartPatterns","set","setPreference","startPatterns","hasStartPattern","handleClose","className","title","isFullScreen","onRequestClose","children","justify","expanded","__nextHasNoMarginBottom","checked","label","help","onChange","newValue","StartPageOptions","isOpen","setIsOpen","isEditedPostDirty","isEditedPostEmpty","isModalActive","enabled","choosePatternModalEnabled","get","isFreshPage","isPreferencesModalActive"],"sources":["@wordpress/editor/src/components/start-page-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Flex, FlexItem, Modal, ToggleControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPE } from '../../store/constants';\nimport { store as editorStore } from '../../store';\n\nexport function useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declared and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes, getBlocksByName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getCurrentPostType, getRenderingMode } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst rootClientId =\n\t\t\t\tgetRenderingMode() === 'post-only'\n\t\t\t\t\t? ''\n\t\t\t\t\t: getBlocksByName( 'core/post-content' )?.[ 0 ];\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType: getPatternsByBlockTypes(\n\t\t\t\t\t'core/post-content',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\tif ( ! blockPatternsWithPostContentBlockType?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t/*\n\t\t * Filter patterns without postTypes declared if the current postType is page\n\t\t * or patterns that declare the current postType in its post type array.\n\t\t */\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { blockPatterns, onChoosePattern } ) {\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { postType, postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId } = select( editorStore );\n\n\t\treturn {\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\t\t\tblocks,\n\t\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t} );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartPageOptionsModal( { onClose } ) {\n\tconst [ showStartPatterns, setShowStartPatterns ] = useState( true );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tconst startPatterns = useStartPatterns();\n\tconst hasStartPattern = startPatterns.length > 0;\n\n\tif ( ! hasStartPattern ) {\n\t\treturn null;\n\t}\n\n\tfunction handleClose() {\n\t\tonClose();\n\t\tsetPreference( 'core', 'enableChoosePatternModal', showStartPatterns );\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"editor-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen\n\t\t\tonRequestClose={ handleClose }\n\t\t>\n\t\t\t<div className=\"editor-start-page-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tblockPatterns={ startPatterns }\n\t\t\t\t\tonChoosePattern={ handleClose }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<Flex\n\t\t\t\tclassName=\"editor-start-page-options__modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tchecked={ showStartPatterns }\n\t\t\t\t\t\tlabel={ __( 'Show starter patterns' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Shows starter patterns when creating a new page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\tsetShowStartPatterns( newValue );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartPageOptions() {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\tconst { isEditedPostDirty, isEditedPostEmpty } = useSelect( editorStore );\n\tconst { isModalActive } = useSelect( interfaceStore );\n\tconst { enabled, postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst choosePatternModalEnabled = select( preferencesStore ).get(\n\t\t\t'core',\n\t\t\t'enableChoosePatternModal'\n\t\t);\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tenabled:\n\t\t\t\tchoosePatternModalEnabled &&\n\t\t\t\tTEMPLATE_POST_TYPE !== getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\t// Note: The `postId` ensures the effect re-runs when pages are switched without remounting the component.\n\t// Examples: changing pages in the List View, creating a new page via Command Palette.\n\tuseEffect( () => {\n\t\tconst isFreshPage = ! isEditedPostDirty() && isEditedPostEmpty();\n\t\t// Prevents immediately opening when features is enabled via preferences modal.\n\t\tconst isPreferencesModalActive = isModalActive( 'editor/preferences' );\n\t\tif ( ! enabled || ! isFreshPage || isPreferencesModalActive ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Open the modal after the initial render for a new page.\n\t\tsetIsOpen( true );\n\t}, [\n\t\tenabled,\n\t\tpostId,\n\t\tisEditedPostDirty,\n\t\tisEditedPostEmpty,\n\t\tisModalActive,\n\t] );\n\n\tif ( ! isOpen ) {\n\t\treturn null;\n\t}\n\n\treturn <StartPageOptionsModal onClose={ () => setIsOpen( false ) } />;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,aAAa,QAAQ,uBAAuB;AAC5E,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,OAAO,EAAEC,SAAS,QAAQ,oBAAoB;AACjE,SACCC,KAAK,IAAIC,gBAAgB,EACzBC,+BAA+B,IAAIC,iBAAiB,QAC9C,yBAAyB;AAChC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASL,KAAK,IAAI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S,CAAEK,cAAe,CAAC;EACrD,MAAM;IAAE8D,OAAO;IAAEnC;EAAO,CAAC,GAAGhC,SAAS,CAAIe,MAAM,IAAM;IACpD,MAAM;MAAEkB,gBAAgB;MAAEf;IAAmB,CAAC,GAAGH,MAAM,CAAER,WAAY,CAAC;IACtE,MAAM6D,yBAAyB,GAAGrD,MAAM,CAAEX,gBAAiB,CAAC,CAACiE,GAAG,CAC/D,MAAM,EACN,0BACD,CAAC;IACD,OAAO;MACNrC,MAAM,EAAEC,gBAAgB,CAAC,CAAC;MAC1BkC,OAAO,EACNC,yBAAyB,IACzB9D,kBAAkB,KAAKY,kBAAkB,CAAC;IAC5C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;;EAEP;EACA;EACAvB,SAAS,CAAE,MAAM;IAChB,MAAM2E,WAAW,GAAG,CAAEN,iBAAiB,CAAC,CAAC,IAAIC,iBAAiB,CAAC,CAAC;IAChE;IACA,MAAMM,wBAAwB,GAAGL,aAAa,CAAE,oBAAqB,CAAC;IACtE,IAAK,CAAEC,OAAO,IAAI,CAAEG,WAAW,IAAIC,wBAAwB,EAAG;MAC7D;IACD;;IAEA;IACAR,SAAS,CAAE,IAAK,CAAC;EAClB,CAAC,EAAE,CACFI,OAAO,EACPnC,MAAM,EACNgC,iBAAiB,EACjBC,iBAAiB,EACjBC,aAAa,CACZ,CAAC;EAEH,IAAK,CAAEJ,MAAM,EAAG;IACf,OAAO,IAAI;EACZ;EAEA,oBAAOrD,IAAA,CAAC8B,qBAAqB;IAACC,OAAO,EAAGA,CAAA,KAAMuB,SAAS,CAAE,KAAM;EAAG,CAAE,CAAC;AACtE","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/start-page-options/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/start-page-options/index.js"],"names":[],"mappings":"AAsBA,wCA0CC;AA8ED,+EA2CC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "14.19.
|
|
3
|
+
"version": "14.19.4",
|
|
4
4
|
"description": "Enhanced block editor for WordPress posts.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -37,35 +37,35 @@
|
|
|
37
37
|
"@wordpress/a11y": "^4.19.1",
|
|
38
38
|
"@wordpress/api-fetch": "^7.19.1",
|
|
39
39
|
"@wordpress/blob": "^4.19.1",
|
|
40
|
-
"@wordpress/block-editor": "^14.14.
|
|
40
|
+
"@wordpress/block-editor": "^14.14.3",
|
|
41
41
|
"@wordpress/blocks": "^14.8.1",
|
|
42
|
-
"@wordpress/commands": "^1.19.
|
|
43
|
-
"@wordpress/components": "^29.5.
|
|
42
|
+
"@wordpress/commands": "^1.19.2",
|
|
43
|
+
"@wordpress/components": "^29.5.2",
|
|
44
44
|
"@wordpress/compose": "^7.19.1",
|
|
45
|
-
"@wordpress/core-data": "^7.19.
|
|
45
|
+
"@wordpress/core-data": "^7.19.3",
|
|
46
46
|
"@wordpress/data": "^10.19.1",
|
|
47
|
-
"@wordpress/dataviews": "^4.15.
|
|
47
|
+
"@wordpress/dataviews": "^4.15.2",
|
|
48
48
|
"@wordpress/date": "^5.19.1",
|
|
49
49
|
"@wordpress/deprecated": "^4.19.1",
|
|
50
50
|
"@wordpress/dom": "^4.19.1",
|
|
51
51
|
"@wordpress/element": "^6.19.1",
|
|
52
|
-
"@wordpress/fields": "^0.11.
|
|
52
|
+
"@wordpress/fields": "^0.11.3",
|
|
53
53
|
"@wordpress/hooks": "^4.19.1",
|
|
54
54
|
"@wordpress/html-entities": "^4.19.1",
|
|
55
55
|
"@wordpress/i18n": "^5.19.1",
|
|
56
56
|
"@wordpress/icons": "^10.19.1",
|
|
57
|
-
"@wordpress/interface": "^9.4.
|
|
57
|
+
"@wordpress/interface": "^9.4.2",
|
|
58
58
|
"@wordpress/keyboard-shortcuts": "^5.19.1",
|
|
59
59
|
"@wordpress/keycodes": "^4.19.1",
|
|
60
60
|
"@wordpress/media-utils": "^5.19.1",
|
|
61
61
|
"@wordpress/notices": "^5.19.1",
|
|
62
|
-
"@wordpress/patterns": "^2.19.
|
|
63
|
-
"@wordpress/plugins": "^7.19.
|
|
64
|
-
"@wordpress/preferences": "^4.19.
|
|
62
|
+
"@wordpress/patterns": "^2.19.3",
|
|
63
|
+
"@wordpress/plugins": "^7.19.2",
|
|
64
|
+
"@wordpress/preferences": "^4.19.2",
|
|
65
65
|
"@wordpress/private-apis": "^1.19.1",
|
|
66
|
-
"@wordpress/reusable-blocks": "^5.19.
|
|
66
|
+
"@wordpress/reusable-blocks": "^5.19.3",
|
|
67
67
|
"@wordpress/rich-text": "^7.19.1",
|
|
68
|
-
"@wordpress/server-side-render": "^5.19.
|
|
68
|
+
"@wordpress/server-side-render": "^5.19.2",
|
|
69
69
|
"@wordpress/url": "^4.19.1",
|
|
70
70
|
"@wordpress/warning": "^3.19.1",
|
|
71
71
|
"@wordpress/wordcount": "^4.19.1",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "0750912b313e3e488ec2cad0c084e548cedd6b95"
|
|
92
92
|
}
|
|
@@ -17,6 +17,7 @@ import { store as interfaceStore } from '@wordpress/interface';
|
|
|
17
17
|
/**
|
|
18
18
|
* Internal dependencies
|
|
19
19
|
*/
|
|
20
|
+
import { TEMPLATE_POST_TYPE } from '../../store/constants';
|
|
20
21
|
import { store as editorStore } from '../../store';
|
|
21
22
|
|
|
22
23
|
export function useStartPatterns() {
|
|
@@ -152,7 +153,8 @@ export default function StartPageOptions() {
|
|
|
152
153
|
return {
|
|
153
154
|
postId: getCurrentPostId(),
|
|
154
155
|
enabled:
|
|
155
|
-
choosePatternModalEnabled &&
|
|
156
|
+
choosePatternModalEnabled &&
|
|
157
|
+
TEMPLATE_POST_TYPE !== getCurrentPostType(),
|
|
156
158
|
};
|
|
157
159
|
}, [] );
|
|
158
160
|
|