@wordpress/editor 12.19.0 → 12.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/entities-saved-states/entity-record-item.js +1 -0
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js +1 -7
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/index.js +1 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/index.js +18 -0
- package/build/components/index.js.map +1 -1
- package/build/components/post-comments/index.js +1 -0
- package/build/components/post-comments/index.js.map +1 -1
- package/build/components/post-format/index.js +1 -1
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-pending-status/index.js +1 -0
- package/build/components/post-pending-status/index.js.map +1 -1
- package/build/components/post-pingbacks/index.js +1 -0
- package/build/components/post-pingbacks/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +11 -2
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-panel/index.js +1 -0
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-category-panel.js +1 -7
- package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-post-format-panel.js +1 -1
- package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build/components/post-publish-panel/maybe-tags-panel.js +1 -7
- package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build/components/post-saved-state/index.js +19 -5
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/index.js +13 -16
- package/build/components/post-schedule/index.js.map +1 -1
- package/build/components/post-sticky/index.js +1 -0
- package/build/components/post-sticky/index.js.map +1 -1
- package/build/components/post-taxonomies/check.js +1 -7
- package/build/components/post-taxonomies/check.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +3 -1
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +3 -2
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/index.js +1 -1
- package/build/components/post-taxonomies/index.js.map +1 -1
- package/build/components/post-title/index.js +4 -2
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-type-support-check/index.js +1 -7
- package/build/components/post-type-support-check/index.js.map +1 -1
- package/build/components/theme-support-check/index.js +2 -2
- package/build/components/theme-support-check/index.js.map +1 -1
- package/build/components/time-to-read/index.js +2 -6
- package/build/components/time-to-read/index.js.map +1 -1
- package/build/store/selectors.js +1 -6
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils/notice-builder.js +2 -2
- package/build/store/utils/notice-builder.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js +1 -0
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js +1 -6
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +2 -2
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/index.js +3 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/post-comments/index.js +1 -0
- package/build-module/components/post-comments/index.js.map +1 -1
- package/build-module/components/post-format/index.js +2 -2
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-pending-status/index.js +1 -0
- package/build-module/components/post-pending-status/index.js.map +1 -1
- package/build-module/components/post-pingbacks/index.js +1 -0
- package/build-module/components/post-pingbacks/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +12 -3
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +1 -0
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-category-panel.js +1 -6
- package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js +2 -2
- package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-tags-panel.js +1 -6
- package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +19 -5
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/index.js +12 -17
- package/build-module/components/post-schedule/index.js.map +1 -1
- package/build-module/components/post-sticky/index.js +1 -0
- package/build-module/components/post-sticky/index.js.map +1 -1
- package/build-module/components/post-taxonomies/check.js +1 -6
- package/build-module/components/post-taxonomies/check.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +3 -2
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +4 -3
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/index.js +2 -2
- package/build-module/components/post-taxonomies/index.js.map +1 -1
- package/build-module/components/post-title/index.js +3 -2
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-type-support-check/index.js +1 -6
- package/build-module/components/post-type-support-check/index.js.map +1 -1
- package/build-module/components/theme-support-check/index.js +3 -3
- package/build-module/components/theme-support-check/index.js.map +1 -1
- package/build-module/components/time-to-read/index.js +2 -6
- package/build-module/components/time-to-read/index.js.map +1 -1
- package/build-module/store/selectors.js +1 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils/notice-builder.js +3 -3
- package/build-module/store/utils/notice-builder.js.map +1 -1
- package/build-style/style-rtl.css +0 -4
- package/build-style/style.css +0 -4
- package/package.json +31 -28
- package/src/components/editor-help/test/index.native.js +2 -2
- package/src/components/entities-saved-states/entity-record-item.js +1 -0
- package/src/components/entities-saved-states/entity-type-list.js +1 -7
- package/src/components/entities-saved-states/index.js +2 -3
- package/src/components/index.js +2 -0
- package/src/components/post-comments/index.js +1 -0
- package/src/components/post-format/index.js +2 -2
- package/src/components/post-pending-status/index.js +1 -0
- package/src/components/post-pingbacks/index.js +1 -0
- package/src/components/post-publish-button/index.js +13 -4
- package/src/components/post-publish-panel/index.js +1 -0
- package/src/components/post-publish-panel/maybe-category-panel.js +1 -6
- package/src/components/post-publish-panel/maybe-post-format-panel.js +2 -2
- package/src/components/post-publish-panel/maybe-tags-panel.js +1 -6
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +11 -15
- package/src/components/post-saved-state/index.js +15 -3
- package/src/components/post-saved-state/style.scss +0 -4
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +1 -1
- package/src/components/post-schedule/index.js +16 -20
- package/src/components/post-sticky/index.js +1 -0
- package/src/components/post-taxonomies/check.js +2 -7
- package/src/components/post-taxonomies/flat-term-selector.js +3 -2
- package/src/components/post-taxonomies/hierarchical-term-selector.js +4 -3
- package/src/components/post-taxonomies/index.js +2 -2
- package/src/components/post-text-editor/test/index.js +7 -3
- package/src/components/post-title/index.js +6 -2
- package/src/components/post-type-support-check/index.js +3 -9
- package/src/components/theme-support-check/index.js +5 -3
- package/src/components/time-to-read/index.js +2 -2
- package/src/store/selectors.js +1 -10
- package/src/store/test/selectors.js +2 -56
- package/src/store/utils/notice-builder.js +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-category-panel.js"],"names":["MaybeCategoryPanel","hasNoCategory","select","postType","editorStore","getCurrentPostType","categoriesTaxonomy","coreStore","getTaxonomy","defaultCategoryId","getEntityRecord","default_category","defaultCategory","postTypeSupportsCategories","types","type","categories","getEditedPostAttribute","rest_base","length","id","shouldShowPanel","setShouldShowPanel","panelBodyTitle"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-category-panel.js"],"names":["MaybeCategoryPanel","hasNoCategory","select","postType","editorStore","getCurrentPostType","categoriesTaxonomy","coreStore","getTaxonomy","defaultCategoryId","getEntityRecord","default_category","defaultCategory","postTypeSupportsCategories","types","some","type","categories","getEditedPostAttribute","rest_base","length","id","shouldShowPanel","setShouldShowPanel","panelBodyTitle"],"mappings":";;;;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIA,SAASA,kBAAT,GAA8B;AAC7B,QAAMC,aAAa,GAAG,qBAAaC,MAAF,IAAc;AAAA;;AAC9C,UAAMC,QAAQ,GAAGD,MAAM,CAAEE,YAAF,CAAN,CAAsBC,kBAAtB,EAAjB;AACA,UAAMC,kBAAkB,GACvBJ,MAAM,CAAEK,eAAF,CAAN,CAAoBC,WAApB,CAAiC,UAAjC,CADD;AAEA,UAAMC,iBAAiB,4BAAGP,MAAM,CAAEK,eAAF,CAAN,CAAoBG,eAApB,CACzB,MADyB,EAEzB,MAFyB,CAAH,0DAAG,sBAGvBC,gBAHH;AAIA,UAAMC,eAAe,GAAGV,MAAM,CAAEK,eAAF,CAAN,CAAoBG,eAApB,CACvB,UADuB,EAEvB,UAFuB,EAGvBD,iBAHuB,CAAxB;AAKA,UAAMI,0BAA0B,GAC/BP,kBAAkB,IAClBA,kBAAkB,CAACQ,KAAnB,CAAyBC,IAAzB,CAAiCC,IAAF,IAAYA,IAAI,KAAKb,QAApD,CAFD;AAGA,UAAMc,UAAU,GACfX,kBAAkB,IAClBJ,MAAM,CAAEE,YAAF,CAAN,CAAsBc,sBAAtB,CACCZ,kBAAkB,CAACa,SADpB,CAFD,CAhB8C,CAsB9C;AACA;AACA;;AACA,WACC,CAAC,CAAEb,kBAAH,IACA,CAAC,CAAEM,eADH,IAEAC,0BAFA,KAGE,CAAAI,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEG,MAAZ,MAAuB,CAAvB,IACC,CAAAH,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEG,MAAZ,MAAuB,CAAvB,IACDR,eAAe,CAACS,EAAhB,KAAuBJ,UAAU,CAAE,CAAF,CALnC,CADD;AAQA,GAjCqB,EAiCnB,EAjCmB,CAAtB;AAkCA,QAAM,CAAEK,eAAF,EAAmBC,kBAAnB,IAA0C,uBAAU,KAAV,CAAhD;AACA,0BAAW,MAAM;AAChB;AACA;AACA,QAAKtB,aAAL,EAAqB;AACpBsB,MAAAA,kBAAkB,CAAE,IAAF,CAAlB;AACA;AACD,GAND,EAMG,CAAEtB,aAAF,CANH;;AAQA,MAAK,CAAEqB,eAAP,EAAyB;AACxB,WAAO,IAAP;AACA;;AAED,QAAME,cAAc,GAAG,CACtB,cAAI,aAAJ,CADsB,EAEtB;AAAM,IAAA,SAAS,EAAC,iCAAhB;AAAkD,IAAA,GAAG,EAAC;AAAtD,KACG,cAAI,mBAAJ,CADH,CAFsB,CAAvB;AAOA,SACC,4BAAC,qBAAD;AAAW,IAAA,WAAW,EAAG,KAAzB;AAAiC,IAAA,KAAK,EAAGA;AAAzC,KACC,uCACG,cACD,oHADC,CADH,CADD,EAMC,4BAAC,iCAAD;AAA0B,IAAA,IAAI,EAAC;AAA/B,IAND,CADD;AAUA;;eAEcxB,kB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from '../post-taxonomies/hierarchical-term-selector';\nimport { store as editorStore } from '../../store';\n\nfunction MaybeCategoryPanel() {\n\tconst hasNoCategory = useSelect( ( select ) => {\n\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\tconst categoriesTaxonomy =\n\t\t\tselect( coreStore ).getTaxonomy( 'category' );\n\t\tconst defaultCategoryId = select( coreStore ).getEntityRecord(\n\t\t\t'root',\n\t\t\t'site'\n\t\t)?.default_category;\n\t\tconst defaultCategory = select( coreStore ).getEntityRecord(\n\t\t\t'taxonomy',\n\t\t\t'category',\n\t\t\tdefaultCategoryId\n\t\t);\n\t\tconst postTypeSupportsCategories =\n\t\t\tcategoriesTaxonomy &&\n\t\t\tcategoriesTaxonomy.types.some( ( type ) => type === postType );\n\t\tconst categories =\n\t\t\tcategoriesTaxonomy &&\n\t\t\tselect( editorStore ).getEditedPostAttribute(\n\t\t\t\tcategoriesTaxonomy.rest_base\n\t\t\t);\n\n\t\t// This boolean should return true if everything is loaded\n\t\t// ( categoriesTaxonomy, defaultCategory )\n\t\t// and the post has not been assigned a category different than \"uncategorized\".\n\t\treturn (\n\t\t\t!! categoriesTaxonomy &&\n\t\t\t!! defaultCategory &&\n\t\t\tpostTypeSupportsCategories &&\n\t\t\t( categories?.length === 0 ||\n\t\t\t\t( categories?.length === 1 &&\n\t\t\t\t\tdefaultCategory.id === categories[ 0 ] ) )\n\t\t);\n\t}, [] );\n\tconst [ shouldShowPanel, setShouldShowPanel ] = useState( false );\n\tuseEffect( () => {\n\t\t// We use state to avoid hiding the panel if the user edits the categories\n\t\t// and adds one within the panel itself (while visible).\n\t\tif ( hasNoCategory ) {\n\t\t\tsetShouldShowPanel( true );\n\t\t}\n\t}, [ hasNoCategory ] );\n\n\tif ( ! shouldShowPanel ) {\n\t\treturn null;\n\t}\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Assign a category' ) }\n\t\t</span>,\n\t];\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<HierarchicalTermSelector slug=\"category\" />\n\t\t</PanelBody>\n\t);\n}\n\nexport default MaybeCategoryPanel;\n"]}
|
|
@@ -33,7 +33,7 @@ var _store = require("../../store");
|
|
|
33
33
|
* Internal dependencies
|
|
34
34
|
*/
|
|
35
35
|
const getSuggestion = (supportedFormats, suggestedPostFormat) => {
|
|
36
|
-
const formats = _postFormat.POST_FORMATS.filter(format =>
|
|
36
|
+
const formats = _postFormat.POST_FORMATS.filter(format => supportedFormats === null || supportedFormats === void 0 ? void 0 : supportedFormats.includes(format.id));
|
|
37
37
|
|
|
38
38
|
return (0, _lodash.find)(formats, format => format.id === suggestedPostFormat);
|
|
39
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-post-format-panel.js"],"names":["getSuggestion","supportedFormats","suggestedPostFormat","formats","POST_FORMATS","filter","format","id","PostFormatSuggestion","suggestionText","onUpdatePostFormat","PostFormatPanel","currentPostFormat","suggestion","select","getEditedPostAttribute","getSuggestedPostFormat","editorStore","coreStore","getThemeSupports","editPost","panelBodyTitle","caption"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAIA,MAAMA,aAAa,GAAG,CAAEC,gBAAF,EAAoBC,mBAApB,KAA6C;AAClE,QAAMC,OAAO,GAAGC,yBAAaC,MAAb,CAAuBC,MAAF,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-post-format-panel.js"],"names":["getSuggestion","supportedFormats","suggestedPostFormat","formats","POST_FORMATS","filter","format","includes","id","PostFormatSuggestion","suggestionText","onUpdatePostFormat","PostFormatPanel","currentPostFormat","suggestion","select","getEditedPostAttribute","getSuggestedPostFormat","editorStore","coreStore","getThemeSupports","editPost","panelBodyTitle","caption"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAIA,MAAMA,aAAa,GAAG,CAAEC,gBAAF,EAAoBC,mBAApB,KAA6C;AAClE,QAAMC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M,IAAA,SAAS,EAAC,iCAAhB;AAAkD,IAAA,GAAG,EAAC;AAAtD,KACG,cAAI,mBAAJ,CADH,CAFsB,CAAvB;;AAOA,MAAK,CAAER,UAAF,IAAgBA,UAAU,CAACN,EAAX,KAAkBK,iBAAvC,EAA2D;AAC1D,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,qBAAD;AAAW,IAAA,WAAW,EAAG,KAAzB;AAAiC,IAAA,KAAK,EAAGS;AAAzC,KACC,uCACG,cACD,+IADC,CADH,CADD,EAMC,uCACC,4BAAC,oBAAD;AACC,IAAA,kBAAkB,EAAGX,kBADtB;AAEC,IAAA,mBAAmB,EAAGG,UAAU,CAACN,EAFlC;AAGC,IAAA,cAAc,EAAG;AAChB;AACA,kBAAI,0BAAJ,CAFgB,EAGhBM,UAAU,CAACS,OAHK;AAHlB,IADD,CAND,CADD;AAoBA","sourcesContent":["/**\n * External dependencies\n */\nimport { find, get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Button, PanelBody } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { POST_FORMATS } from '../post-format';\nimport { store as editorStore } from '../../store';\n\nconst getSuggestion = ( supportedFormats, suggestedPostFormat ) => {\n\tconst formats = POST_FORMATS.filter( ( format ) =>\n\t\tsupportedFormats?.includes( format.id )\n\t);\n\treturn find( formats, ( format ) => format.id === suggestedPostFormat );\n};\n\nconst PostFormatSuggestion = ( {\n\tsuggestedPostFormat,\n\tsuggestionText,\n\tonUpdatePostFormat,\n} ) => (\n\t<Button\n\t\tvariant=\"link\"\n\t\tonClick={ () => onUpdatePostFormat( suggestedPostFormat ) }\n\t>\n\t\t{ suggestionText }\n\t</Button>\n);\n\nexport default function PostFormatPanel() {\n\tconst { currentPostFormat, suggestion } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute, getSuggestedPostFormat } =\n\t\t\tselect( editorStore );\n\t\tconst supportedFormats = get(\n\t\t\tselect( coreStore ).getThemeSupports(),\n\t\t\t[ 'formats' ],\n\t\t\t[]\n\t\t);\n\t\treturn {\n\t\t\tcurrentPostFormat: getEditedPostAttribute( 'format' ),\n\t\t\tsuggestion: getSuggestion(\n\t\t\t\tsupportedFormats,\n\t\t\t\tgetSuggestedPostFormat()\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tconst onUpdatePostFormat = ( format ) => editPost( { format } );\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Use a post format' ) }\n\t\t</span>,\n\t];\n\n\tif ( ! suggestion || suggestion.id === currentPostFormat ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Your theme uses post formats to highlight different kinds of content, like images or videos. Apply a post format to see this special styling.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t<PostFormatSuggestion\n\t\t\t\t\tonUpdatePostFormat={ onUpdatePostFormat }\n\t\t\t\t\tsuggestedPostFormat={ suggestion.id }\n\t\t\t\t\tsuggestionText={ sprintf(\n\t\t\t\t\t\t/* translators: %s: post format */\n\t\t\t\t\t\t__( 'Apply the \"%1$s\" format.' ),\n\t\t\t\t\t\tsuggestion.caption\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</p>\n\t\t</PanelBody>\n\t);\n}\n"]}
|
|
@@ -9,8 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
12
|
var _i18n = require("@wordpress/i18n");
|
|
15
13
|
|
|
16
14
|
var _compose = require("@wordpress/compose");
|
|
@@ -25,10 +23,6 @@ var _flatTermSelector = _interopRequireDefault(require("../post-taxonomies/flat-
|
|
|
25
23
|
|
|
26
24
|
var _store = require("../../store");
|
|
27
25
|
|
|
28
|
-
/**
|
|
29
|
-
* External dependencies
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
26
|
/**
|
|
33
27
|
* WordPress dependencies
|
|
34
28
|
*/
|
|
@@ -84,7 +78,7 @@ var _default = (0, _compose.compose)((0, _data.withSelect)(select => {
|
|
|
84
78
|
const tags = tagsTaxonomy && select(_store.store).getEditedPostAttribute(tagsTaxonomy.rest_base);
|
|
85
79
|
return {
|
|
86
80
|
areTagsFetched: tagsTaxonomy !== undefined,
|
|
87
|
-
isPostTypeSupported: tagsTaxonomy &&
|
|
81
|
+
isPostTypeSupported: tagsTaxonomy && tagsTaxonomy.types.some(type => type === postType),
|
|
88
82
|
hasTags: tags && tags.length
|
|
89
83
|
};
|
|
90
84
|
}), (0, _compose.ifCondition)(_ref => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-tags-panel.js"],"names":["TagsPanel","panelBodyTitle","MaybeTagsPanel","Component","constructor","props","state","hadTagsWhenOpeningThePanel","hasTags","render","select","postType","editorStore","getCurrentPostType","tagsTaxonomy","coreStore","getTaxonomy","tags","getEditedPostAttribute","rest_base","areTagsFetched","undefined","isPostTypeSupported","types","type","length"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-tags-panel.js"],"names":["TagsPanel","panelBodyTitle","MaybeTagsPanel","Component","constructor","props","state","hadTagsWhenOpeningThePanel","hasTags","render","select","postType","editorStore","getCurrentPostType","tagsTaxonomy","coreStore","getTaxonomy","tags","getEditedPostAttribute","rest_base","areTagsFetched","undefined","isPostTypeSupported","types","some","type","length"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AACA;;AAKA;;AACA;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Ab,CAAmBC,IAAnB,CAA2BC,IAAF,IAAYA,IAAI,KAAKd,QAA9C,CAJK;AAKNH,IAAAA,OAAO,EAAES,IAAI,IAAIA,IAAI,CAACS;AALhB,GAAP;AAOA,CAfD,CADc,EAiBd,0BACC;AAAA,MAAE;AAAEN,IAAAA,cAAF;AAAkBE,IAAAA;AAAlB,GAAF;AAAA,SACCA,mBAAmB,IAAIF,cADxB;AAAA,CADD,CAjBc,EAqBZlB,cArBY,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Component } from '@wordpress/element';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { PanelBody } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport FlatTermSelector from '../post-taxonomies/flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst TagsPanel = () => {\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Add tags' ) }\n\t\t</span>,\n\t];\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Tags help users and search engines navigate your site and find your content. Add a few keywords to describe your post.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<FlatTermSelector slug={ 'post_tag' } />\n\t\t</PanelBody>\n\t);\n};\n\nclass MaybeTagsPanel extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\t\tthis.state = {\n\t\t\thadTagsWhenOpeningThePanel: props.hasTags,\n\t\t};\n\t}\n\n\t/*\n\t * We only want to show the tag panel if the post didn't have\n\t * any tags when the user hit the Publish button.\n\t *\n\t * We can't use the prop.hasTags because it'll change to true\n\t * if the user adds a new tag within the pre-publish panel.\n\t * This would force a re-render and a new prop.hasTags check,\n\t * hiding this panel and keeping the user from adding\n\t * more than one tag.\n\t */\n\trender() {\n\t\tif ( ! this.state.hadTagsWhenOpeningThePanel ) {\n\t\t\treturn <TagsPanel />;\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\nexport default compose(\n\twithSelect( ( select ) => {\n\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\tconst tagsTaxonomy = select( coreStore ).getTaxonomy( 'post_tag' );\n\t\tconst tags =\n\t\t\ttagsTaxonomy &&\n\t\t\tselect( editorStore ).getEditedPostAttribute(\n\t\t\t\ttagsTaxonomy.rest_base\n\t\t\t);\n\t\treturn {\n\t\t\tareTagsFetched: tagsTaxonomy !== undefined,\n\t\t\tisPostTypeSupported:\n\t\t\t\ttagsTaxonomy &&\n\t\t\t\ttagsTaxonomy.types.some( ( type ) => type === postType ),\n\t\t\thasTags: tags && tags.length,\n\t\t};\n\t} ),\n\tifCondition(\n\t\t( { areTagsFetched, isPostTypeSupported } ) =>\n\t\t\tisPostTypeSupported && areTagsFetched\n\t)\n)( MaybeTagsPanel );\n"]}
|
|
@@ -155,11 +155,25 @@ function PostSavedState(_ref) {
|
|
|
155
155
|
type: 'loading'
|
|
156
156
|
})]: isSaving
|
|
157
157
|
}) : undefined,
|
|
158
|
-
onClick: isDisabled ? undefined : () => savePost()
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
158
|
+
onClick: isDisabled ? undefined : () => savePost()
|
|
159
|
+
/*
|
|
160
|
+
* We want the tooltip to show the keyboard shortcut only when the
|
|
161
|
+
* button does something, i.e. when it's not disabled.
|
|
162
|
+
*/
|
|
163
|
+
,
|
|
164
|
+
shortcut: isDisabled ? undefined : _keycodes.displayShortcut.primary('s')
|
|
165
|
+
/*
|
|
166
|
+
* Displaying the keyboard shortcut conditionally makes the tooltip
|
|
167
|
+
* itself show conditionally. This would trigger a full-rerendering
|
|
168
|
+
* of the button that we want to avoid. By setting `showTooltip`,
|
|
169
|
+
& the tooltip is always rendered even when there's no keyboard shortcut.
|
|
170
|
+
*/
|
|
171
|
+
,
|
|
172
|
+
showTooltip: true,
|
|
173
|
+
variant: "tertiary",
|
|
174
|
+
icon: isLargeViewport ? undefined : _icons.cloudUpload // Make sure the aria-label has always a value, as the default `text` is undefined on small screens.
|
|
175
|
+
,
|
|
176
|
+
label: text || label,
|
|
163
177
|
"aria-disabled": isDisabled
|
|
164
178
|
}, isSavedState && (0, _element.createElement)(_icons.Icon, {
|
|
165
179
|
icon: isSaved ? _icons.check : _icons.cloud
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-saved-state/index.js"],"names":["PostSavedState","forceIsDirty","forceIsSaving","showIconLabels","forceSavedMessage","setForceSavedMessage","isLargeViewport","isAutosaving","isDirty","isNew","isPending","isPublished","isSaveable","isSaving","isScheduled","hasPublishAction","select","isEditedPostNew","isCurrentPostPublished","isCurrentPostScheduled","isEditedPostDirty","isSavingPost","isEditedPostSaveable","getCurrentPost","isAutosavingPost","getEditedPostAttribute","editorStore","_links","savePost","wasSaving","timeoutId","setTimeout","clearTimeout","label","shortLabel","isSaved","isSavedState","isDisabled","text","type","undefined","displayShortcut","primary","cloudUpload","check","cloud"],"mappings":";;;;;;;;;AAcA;;AAXA;;AAKA;;AAIA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,OAIX;AAAA,MAJoC;AACvCC,IAAAA,YADuC;AAEvCC,IAAAA,aAFuC;AAGvCC,IAAAA,cAAc,GAAG;AAHsB,GAIpC;AACH,QAAM,CAAEC,iBAAF,EAAqBC,oBAArB,IAA8C,uBAAU,KAAV,CAApD;AACA,QAAMC,eAAe,GAAG,+BAAkB,OAAlB,CAAxB;AAEA,QAAM;AACLC,IAAAA,YADK;AAELC,IAAAA,OAFK;AAGLC,IAAAA,KAHK;AAILC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BN,YAJL;AAKZ,kBAAY4B,OALA;AAMZ,OAAE,+CAAqB;AACtBI,QAAAA,IAAI,EAAE;AADgB,OAArB,CAAF,GAEO1B;AARK,KAAZ,CADH,GAWG2B,SAbL;AAeC,IAAA,OAAO,EAAGH,UAAU,GAAGG,SAAH,GAAe,MAAMZ,QAAQ
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-saved-state/index.js"],"names":["PostSavedState","forceIsDirty","forceIsSaving","showIconLabels","forceSavedMessage","setForceSavedMessage","isLargeViewport","isAutosaving","isDirty","isNew","isPending","isPublished","isSaveable","isSaving","isScheduled","hasPublishAction","select","isEditedPostNew","isCurrentPostPublished","isCurrentPostScheduled","isEditedPostDirty","isSavingPost","isEditedPostSaveable","getCurrentPost","isAutosavingPost","getEditedPostAttribute","editorStore","_links","savePost","wasSaving","timeoutId","setTimeout","clearTimeout","label","shortLabel","isSaved","isSavedState","isDisabled","text","type","undefined","displayShortcut","primary","cloudUpload","check","cloud"],"mappings":";;;;;;;;;AAcA;;AAXA;;AAKA;;AAIA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,OAIX;AAAA,MAJoC;AACvCC,IAAAA,YADuC;AAEvCC,IAAAA,aAFuC;AAGvCC,IAAAA,cAAc,GAAG;AAHsB,GAIpC;AACH,QAAM,CAAEC,iBAAF,EAAqBC,oBAArB,IAA8C,uBAAU,KAAV,CAApD;AACA,QAAMC,eAAe,GAAG,+BAAkB,OAAlB,CAAxB;AAEA,QAAM;AACLC,IAAAA,YADK;AAELC,IAAAA,OAFK;AAGLC,IAAAA,KAHK;AAILC,IAAAA,SAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA,UANK;AAOLC,IAAAA,QAPK;AAQLC,IAAAA,WARK;AASLC,IAAAA;AATK,MA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AZ,CADH,GAWG2B,SAbL;AAeC,IAAA,OAAO,EAAGH,UAAU,GAAGG,SAAH,GAAe,MAAMZ,QAAQ;AACjD;AACH;AACA;AACA;AAnBE;AAoBC,IAAA,QAAQ,EAAGS,UAAU,GAAGG,SAAH,GAAeC,0BAAgBC,OAAhB,CAAyB,GAAzB;AACpC;AACH;AACA;AACA;AACA;AACA;AA1BE;AA2BC,IAAA,WAAW,MA3BZ;AA4BC,IAAA,OAAO,EAAC,UA5BT;AA6BC,IAAA,IAAI,EAAGpC,eAAe,GAAGkC,SAAH,GAAeG,kBA7BtC,CA8BC;AA9BD;AA+BC,IAAA,KAAK,EAAGL,IAAI,IAAIL,KA/BjB;AAgCC,qBAAgBI;AAhCjB,KAkCGD,YAAY,IAAI,4BAAC,WAAD;AAAM,IAAA,IAAI,EAAGD,OAAO,GAAGS,YAAH,GAAWC;AAA/B,IAlCnB,EAmCGP,IAnCH,CADD;AAuCA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tButton,\n} from '@wordpress/components';\nimport { usePrevious, useViewportMatch } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, check, cloud, cloudUpload } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport PostSwitchToDraftButton from '../post-switch-to-draft-button';\nimport { store as editorStore } from '../../store';\n\n/**\n * Component showing whether the post is saved or not and providing save\n * buttons.\n *\n * @param {Object} props Component props.\n * @param {?boolean} props.forceIsDirty Whether to force the post to be marked\n * as dirty.\n * @param {?boolean} props.forceIsSaving Whether to force the post to be marked\n * as being saved.\n * @param {?boolean} props.showIconLabels Whether interface buttons show labels instead of icons\n * @return {import('@wordpress/element').WPComponent} The component.\n */\nexport default function PostSavedState( {\n\tforceIsDirty,\n\tforceIsSaving,\n\tshowIconLabels = false,\n} ) {\n\tconst [ forceSavedMessage, setForceSavedMessage ] = useState( false );\n\tconst isLargeViewport = useViewportMatch( 'small' );\n\n\tconst {\n\t\tisAutosaving,\n\t\tisDirty,\n\t\tisNew,\n\t\tisPending,\n\t\tisPublished,\n\t\tisSaveable,\n\t\tisSaving,\n\t\tisScheduled,\n\t\thasPublishAction,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisEditedPostNew,\n\t\t\t\tisCurrentPostPublished,\n\t\t\t\tisCurrentPostScheduled,\n\t\t\t\tisEditedPostDirty,\n\t\t\t\tisSavingPost,\n\t\t\t\tisEditedPostSaveable,\n\t\t\t\tgetCurrentPost,\n\t\t\t\tisAutosavingPost,\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t} = select( editorStore );\n\n\t\t\treturn {\n\t\t\t\tisAutosaving: isAutosavingPost(),\n\t\t\t\tisDirty: forceIsDirty || isEditedPostDirty(),\n\t\t\t\tisNew: isEditedPostNew(),\n\t\t\t\tisPending: 'pending' === getEditedPostAttribute( 'status' ),\n\t\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\t\tisSaving: forceIsSaving || isSavingPost(),\n\t\t\t\tisSaveable: isEditedPostSaveable(),\n\t\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t\t\thasPublishAction:\n\t\t\t\t\tgetCurrentPost()?._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t};\n\t\t},\n\t\t[ forceIsDirty, forceIsSaving ]\n\t);\n\n\tconst { savePost } = useDispatch( editorStore );\n\n\tconst wasSaving = usePrevious( isSaving );\n\n\tuseEffect( () => {\n\t\tlet timeoutId;\n\n\t\tif ( wasSaving && ! isSaving ) {\n\t\t\tsetForceSavedMessage( true );\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tsetForceSavedMessage( false );\n\t\t\t}, 1000 );\n\t\t}\n\n\t\treturn () => clearTimeout( timeoutId );\n\t}, [ isSaving ] );\n\n\t// Once the post has been submitted for review this button\n\t// is not needed for the contributor role.\n\tif ( ! hasPublishAction && isPending ) {\n\t\treturn null;\n\t}\n\n\tif ( isPublished || isScheduled ) {\n\t\treturn <PostSwitchToDraftButton />;\n\t}\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst label = isPending ? __( 'Save as pending' ) : __( 'Save draft' );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst shortLabel = __( 'Save' );\n\n\tconst isSaved = forceSavedMessage || ( ! isNew && ! isDirty );\n\tconst isSavedState = isSaving || isSaved;\n\tconst isDisabled = isSaving || isSaved || ! isSaveable;\n\n\tlet text;\n\n\tif ( isSaving ) {\n\t\ttext = isAutosaving ? __( 'Autosaving' ) : __( 'Saving' );\n\t} else if ( isSaved ) {\n\t\ttext = __( 'Saved' );\n\t} else if ( isLargeViewport ) {\n\t\ttext = label;\n\t} else if ( showIconLabels ) {\n\t\ttext = shortLabel;\n\t}\n\n\t// Use common Button instance for all saved states so that focus is not\n\t// lost.\n\treturn (\n\t\t<Button\n\t\t\tclassName={\n\t\t\t\tisSaveable || isSaving\n\t\t\t\t\t? classnames( {\n\t\t\t\t\t\t\t'editor-post-save-draft': ! isSavedState,\n\t\t\t\t\t\t\t'editor-post-saved-state': isSavedState,\n\t\t\t\t\t\t\t'is-saving': isSaving,\n\t\t\t\t\t\t\t'is-autosaving': isAutosaving,\n\t\t\t\t\t\t\t'is-saved': isSaved,\n\t\t\t\t\t\t\t[ getAnimateClassName( {\n\t\t\t\t\t\t\t\ttype: 'loading',\n\t\t\t\t\t\t\t} ) ]: isSaving,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tonClick={ isDisabled ? undefined : () => savePost() }\n\t\t\t/*\n\t\t\t * We want the tooltip to show the keyboard shortcut only when the\n\t\t\t * button does something, i.e. when it's not disabled.\n\t\t\t */\n\t\t\tshortcut={ isDisabled ? undefined : displayShortcut.primary( 's' ) }\n\t\t\t/*\n\t\t\t * Displaying the keyboard shortcut conditionally makes the tooltip\n\t\t\t * itself show conditionally. This would trigger a full-rerendering\n\t\t\t * of the button that we want to avoid. By setting `showTooltip`,\n\t\t\t & the tooltip is always rendered even when there's no keyboard shortcut.\n\t\t\t */\n\t\t\tshowTooltip\n\t\t\tvariant=\"tertiary\"\n\t\t\ticon={ isLargeViewport ? undefined : cloudUpload }\n\t\t\t// Make sure the aria-label has always a value, as the default `text` is undefined on small screens.\n\t\t\tlabel={ text || label }\n\t\t\taria-disabled={ isDisabled }\n\t\t>\n\t\t\t{ isSavedState && <Icon icon={ isSaved ? check : cloud } /> }\n\t\t\t{ text }\n\t\t</Button>\n\t);\n}\n"]}
|
|
@@ -7,6 +7,8 @@ exports.default = PostSchedule;
|
|
|
7
7
|
|
|
8
8
|
var _element = require("@wordpress/element");
|
|
9
9
|
|
|
10
|
+
var _dateFns = require("date-fns");
|
|
11
|
+
|
|
10
12
|
var _date = require("@wordpress/date");
|
|
11
13
|
|
|
12
14
|
var _data = require("@wordpress/data");
|
|
@@ -17,6 +19,10 @@ var _coreData = require("@wordpress/core-data");
|
|
|
17
19
|
|
|
18
20
|
var _store = require("../../store");
|
|
19
21
|
|
|
22
|
+
/**
|
|
23
|
+
* External dependencies
|
|
24
|
+
*/
|
|
25
|
+
|
|
20
26
|
/**
|
|
21
27
|
* WordPress dependencies
|
|
22
28
|
*/
|
|
@@ -24,13 +30,6 @@ var _store = require("../../store");
|
|
|
24
30
|
/**
|
|
25
31
|
* Internal dependencies
|
|
26
32
|
*/
|
|
27
|
-
function getDayOfTheMonth() {
|
|
28
|
-
let date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
|
|
29
|
-
let firstDay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
30
|
-
const d = new Date(date);
|
|
31
|
-
return new Date(d.getFullYear(), d.getMonth() + (firstDay ? 0 : 1), firstDay ? 1 : 0).toISOString();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
33
|
function PostSchedule(_ref) {
|
|
35
34
|
let {
|
|
36
35
|
onClose
|
|
@@ -50,23 +49,21 @@ function PostSchedule(_ref) {
|
|
|
50
49
|
date
|
|
51
50
|
});
|
|
52
51
|
|
|
53
|
-
const [previewedMonth, setPreviewedMonth] = (0, _element.useState)(
|
|
52
|
+
const [previewedMonth, setPreviewedMonth] = (0, _element.useState)((0, _dateFns.startOfMonth)(new Date(postDate))); // Pick up published and schduled site posts.
|
|
54
53
|
|
|
55
54
|
const eventsByPostType = (0, _data.useSelect)(select => select(_coreData.store).getEntityRecords('postType', postType, {
|
|
56
55
|
status: 'publish,future',
|
|
57
|
-
after:
|
|
58
|
-
before:
|
|
59
|
-
exclude: [select(_store.store).getCurrentPostId()]
|
|
56
|
+
after: (0, _dateFns.startOfMonth)(previewedMonth).toISOString(),
|
|
57
|
+
before: (0, _dateFns.endOfMonth)(previewedMonth).toISOString(),
|
|
58
|
+
exclude: [select(_store.store).getCurrentPostId()],
|
|
59
|
+
per_page: 100,
|
|
60
|
+
_fields: 'id,date'
|
|
60
61
|
}), [previewedMonth, postType]);
|
|
61
62
|
const events = (0, _element.useMemo)(() => (eventsByPostType || []).map(_ref2 => {
|
|
62
63
|
let {
|
|
63
|
-
title,
|
|
64
|
-
type,
|
|
65
64
|
date: eventDate
|
|
66
65
|
} = _ref2;
|
|
67
66
|
return {
|
|
68
|
-
title: title === null || title === void 0 ? void 0 : title.rendered,
|
|
69
|
-
type,
|
|
70
67
|
date: new Date(eventDate)
|
|
71
68
|
};
|
|
72
69
|
}), [eventsByPostType]);
|
|
@@ -82,7 +79,7 @@ function PostSchedule(_ref) {
|
|
|
82
79
|
onChange: onUpdateDate,
|
|
83
80
|
is12Hour: is12HourTime,
|
|
84
81
|
events: events,
|
|
85
|
-
onMonthPreviewed: setPreviewedMonth,
|
|
82
|
+
onMonthPreviewed: date => setPreviewedMonth((0, _dateFns.parseISO)(date)),
|
|
86
83
|
onClose: onClose
|
|
87
84
|
});
|
|
88
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-schedule/index.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-schedule/index.js"],"names":["PostSchedule","onClose","postDate","postType","select","editorStore","getEditedPostAttribute","getCurrentPostType","editPost","onUpdateDate","date","previewedMonth","setPreviewedMonth","Date","eventsByPostType","coreStore","getEntityRecords","status","after","toISOString","before","exclude","getCurrentPostId","per_page","_fields","events","map","eventDate","settings","is12HourTime","test","formats","time","toLowerCase","replace","split","reverse","join"],"mappings":";;;;;;;AAWA;;AARA;;AAKA;;AACA;;AACA;;AAEA;;AAKA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAGe,SAASA,YAAT,OAAqC;AAAA,MAAd;AAAEC,IAAAA;AAAF,GAAc;AACnD,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyB,qBAC5BC,MAAF,KAAgB;AACfF,IAAAA,QAAQ,EAAEE,MAAM,CAAEC,YAAF,CAAN,CAAsBC,sBAAtB,CAA8C,MAA9C,CADK;AAEfH,IAAAA,QAAQ,EAAEC,MAAM,CAAEC,YAAF,CAAN,CAAsBE,kBAAtB;AAFK,GAAhB,CAD8B,EAK9B,EAL8B,CAA/B;AAQA,QAAM;AAAEC,IAAAA;AAAF,MAAe,uBAAaH,YAAb,CAArB;;AACA,QAAMI,YAAY,GAAKC,IAAF,IAAYF,QAAQ,CAAE;AAAEE,IAAAA;AAAF,GAAF,CAAzC;;AAEA,QAAM,CAAEC,cAAF,EAAkBC,iBAAlB,IAAwC,uBAC7C,2BAAc,IAAIC,IAAJ,CAAUX,QAAV,CAAd,CAD6C,CAA9C,CAZmD,CAgBnD;;AACA,QAAMY,gBAAgB,GAAG,qBACtBV,MAAF,IACCA,MAAM,CAAEW,eAAF,CAAN,CAAoBC,gBAApB,CAAsC,UAAtC,EAAkDb,QAAlD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AO,EAAGT;AARX,IADD;AAYA","sourcesContent":["/**\n * External dependencies\n */\nimport { parseISO, endOfMonth, startOfMonth } from 'date-fns';\n\n/**\n * WordPress dependencies\n */\nimport { getSettings } from '@wordpress/date';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __experimentalPublishDateTimePicker as PublishDateTimePicker } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostSchedule( { onClose } ) {\n\tconst { postDate, postType } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostDate: select( editorStore ).getEditedPostAttribute( 'date' ),\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst onUpdateDate = ( date ) => editPost( { date } );\n\n\tconst [ previewedMonth, setPreviewedMonth ] = useState(\n\t\tstartOfMonth( new Date( postDate ) )\n\t);\n\n\t// Pick up published and schduled site posts.\n\tconst eventsByPostType = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', postType, {\n\t\t\t\tstatus: 'publish,future',\n\t\t\t\tafter: startOfMonth( previewedMonth ).toISOString(),\n\t\t\t\tbefore: endOfMonth( previewedMonth ).toISOString(),\n\t\t\t\texclude: [ select( editorStore ).getCurrentPostId() ],\n\t\t\t\tper_page: 100,\n\t\t\t\t_fields: 'id,date',\n\t\t\t} ),\n\t\t[ previewedMonth, postType ]\n\t);\n\n\tconst events = useMemo(\n\t\t() =>\n\t\t\t( eventsByPostType || [] ).map( ( { date: eventDate } ) => ( {\n\t\t\t\tdate: new Date( eventDate ),\n\t\t\t} ) ),\n\t\t[ eventsByPostType ]\n\t);\n\n\tconst settings = getSettings();\n\n\t// To know if the current timezone is a 12 hour time with look for \"a\" in the time format\n\t// We also make sure this a is not escaped by a \"/\"\n\tconst is12HourTime = /a(?!\\\\)/i.test(\n\t\tsettings.formats.time\n\t\t\t.toLowerCase() // Test only the lower case a.\n\t\t\t.replace( /\\\\\\\\/g, '' ) // Replace \"//\" with empty strings.\n\t\t\t.split( '' )\n\t\t\t.reverse()\n\t\t\t.join( '' ) // Reverse the string and test for \"a\" not followed by a slash.\n\t);\n\n\treturn (\n\t\t<PublishDateTimePicker\n\t\t\tcurrentDate={ postDate }\n\t\t\tonChange={ onUpdateDate }\n\t\t\tis12Hour={ is12HourTime }\n\t\t\tevents={ events }\n\t\t\tonMonthPreviewed={ ( date ) =>\n\t\t\t\tsetPreviewedMonth( parseISO( date ) )\n\t\t\t}\n\t\t\tonClose={ onClose }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -35,6 +35,7 @@ function PostSticky(_ref) {
|
|
|
35
35
|
postSticky = false
|
|
36
36
|
} = _ref;
|
|
37
37
|
return (0, _element.createElement)(_check.default, null, (0, _element.createElement)(_components.CheckboxControl, {
|
|
38
|
+
__nextHasNoMarginBottom: true,
|
|
38
39
|
label: (0, _i18n.__)('Stick to the top of the blog'),
|
|
39
40
|
checked: postSticky,
|
|
40
41
|
onChange: () => onUpdateSticky(!postSticky)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-sticky/index.js"],"names":["PostSticky","onUpdateSticky","postSticky","select","editorStore","getEditedPostAttribute","dispatch","editPost","sticky"],"mappings":";;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAZA;AACA;AACA;;AAMA;AACA;AACA;AAIO,SAASA,UAAT,OAA8D;AAAA,MAAzC;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,UAAU,GAAG;AAA/B,GAAyC;AACpE,SACC,4BAAC,cAAD,QACC,4BAAC,2BAAD;AACC,IAAA,KAAK,EAAG,cAAI,8BAAJ,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-sticky/index.js"],"names":["PostSticky","onUpdateSticky","postSticky","select","editorStore","getEditedPostAttribute","dispatch","editPost","sticky"],"mappings":";;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAZA;AACA;AACA;;AAMA;AACA;AACA;AAIO,SAASA,UAAT,OAA8D;AAAA,MAAzC;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,UAAU,GAAG;AAA/B,GAAyC;AACpE,SACC,4BAAC,cAAD,QACC,4BAAC,2BAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,KAAK,EAAG,cAAI,8BAAJ,CAFT;AAGC,IAAA,OAAO,EAAGA,UAHX;AAIC,IAAA,QAAQ,EAAG,MAAMD,cAAc,CAAE,CAAEC,UAAJ;AAJhC,IADD,CADD;AAUA;;eAEc,sBAAS,CACvB,sBAAcC,MAAF,IAAc;AACzB,SAAO;AACND,IAAAA,UAAU,EACTC,MAAM,CAAEC,YAAF,CAAN,CAAsBC,sBAAtB,CAA8C,QAA9C;AAFK,GAAP;AAIA,CALD,CADuB,EAOvB,wBAAgBC,QAAF,IAAgB;AAC7B,SAAO;AACNL,IAAAA,cAAc,CAAEC,UAAF,EAAe;AAC5BI,MAAAA,QAAQ,CAAEF,YAAF,CAAR,CAAwBG,QAAxB,CAAkC;AAAEC,QAAAA,MAAM,EAAEN;AAAV,OAAlC;AACA;;AAHK,GAAP;AAKA,CAND,CAPuB,CAAT,EAcVF,UAdU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { CheckboxControl } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PostStickyCheck from './check';\nimport { store as editorStore } from '../../store';\n\nexport function PostSticky( { onUpdateSticky, postSticky = false } ) {\n\treturn (\n\t\t<PostStickyCheck>\n\t\t\t<CheckboxControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Stick to the top of the blog' ) }\n\t\t\t\tchecked={ postSticky }\n\t\t\t\tonChange={ () => onUpdateSticky( ! postSticky ) }\n\t\t\t/>\n\t\t</PostStickyCheck>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostSticky:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'sticky' ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\treturn {\n\t\t\tonUpdateSticky( postSticky ) {\n\t\t\t\tdispatch( editorStore ).editPost( { sticky: postSticky } );\n\t\t\t},\n\t\t};\n\t} ),\n] )( PostSticky );\n"]}
|
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.PostTaxonomiesCheck = PostTaxonomiesCheck;
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
|
|
9
|
-
var _lodash = require("lodash");
|
|
10
|
-
|
|
11
9
|
var _compose = require("@wordpress/compose");
|
|
12
10
|
|
|
13
11
|
var _data = require("@wordpress/data");
|
|
@@ -16,10 +14,6 @@ var _coreData = require("@wordpress/core-data");
|
|
|
16
14
|
|
|
17
15
|
var _store = require("../../store");
|
|
18
16
|
|
|
19
|
-
/**
|
|
20
|
-
* External dependencies
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
17
|
/**
|
|
24
18
|
* WordPress dependencies
|
|
25
19
|
*/
|
|
@@ -33,7 +27,7 @@ function PostTaxonomiesCheck(_ref) {
|
|
|
33
27
|
taxonomies,
|
|
34
28
|
children
|
|
35
29
|
} = _ref;
|
|
36
|
-
const hasTaxonomies =
|
|
30
|
+
const hasTaxonomies = taxonomies === null || taxonomies === void 0 ? void 0 : taxonomies.some(taxonomy => taxonomy.types.includes(postType));
|
|
37
31
|
|
|
38
32
|
if (!hasTaxonomies) {
|
|
39
33
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/check.js"],"names":["PostTaxonomiesCheck","postType","taxonomies","children","hasTaxonomies","taxonomy","types","select","editorStore","getCurrentPostType","coreStore","getTaxonomies","per_page"],"mappings":";;;;;;;;AAGA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/check.js"],"names":["PostTaxonomiesCheck","postType","taxonomies","children","hasTaxonomies","some","taxonomy","types","includes","select","editorStore","getCurrentPostType","coreStore","getTaxonomies","per_page"],"mappings":";;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGO,SAASA,mBAAT,OAAmE;AAAA,MAArC;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,UAAZ;AAAwBC,IAAAA;AAAxB,GAAqC;AACzE,QAAMC,aAAa,GAAGF,UAAH,aAAGA,UAAH,uBAAGA,UAAU,CAAEG,IAAZ,CAAoBC,QAAF,IACvCA,QAAQ,CAACC,KAAT,CAAeC,QAAf,CAAyBP,QAAzB,CADqB,CAAtB;;AAGA,MAAK,CAAEG,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,SAAOD,QAAP;AACA;;eAEc,sBAAS,CACvB,sBAAcM,MAAF,IAAc;AACzB,SAAO;AACNR,IAAAA,QAAQ,EAAEQ,MAAM,CAAEC,YAAF,CAAN,CAAsBC,kBAAtB,EADJ;AAENT,IAAAA,UAAU,EAAEO,MAAM,CAAEG,eAAF,CAAN,CAAoBC,aAApB,CAAmC;AAAEC,MAAAA,QAAQ,EAAE,CAAC;AAAb,KAAnC;AAFN,GAAP;AAIA,CALD,CADuB,CAAT,EAOVd,mBAPU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function PostTaxonomiesCheck( { postType, taxonomies, children } ) {\n\tconst hasTaxonomies = taxonomies?.some( ( taxonomy ) =>\n\t\ttaxonomy.types.includes( postType )\n\t);\n\tif ( ! hasTaxonomies ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\ttaxonomies: select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t};\n\t} ),\n] )( PostTaxonomiesCheck );\n"]}
|
|
@@ -12,6 +12,8 @@ var _element = require("@wordpress/element");
|
|
|
12
12
|
|
|
13
13
|
var _lodash = require("lodash");
|
|
14
14
|
|
|
15
|
+
var _escapeHtml = _interopRequireDefault(require("escape-html"));
|
|
16
|
+
|
|
15
17
|
var _i18n = require("@wordpress/i18n");
|
|
16
18
|
|
|
17
19
|
var _components = require("@wordpress/components");
|
|
@@ -72,7 +74,7 @@ const termNamesToIds = (names, terms) => {
|
|
|
72
74
|
|
|
73
75
|
|
|
74
76
|
function findOrCreateTerm(termName, restBase, namespace) {
|
|
75
|
-
const escapedTermName = (0,
|
|
77
|
+
const escapedTermName = (0, _escapeHtml.default)(termName);
|
|
76
78
|
return (0, _apiFetch.default)({
|
|
77
79
|
path: `/${namespace}/${restBase}`,
|
|
78
80
|
method: 'POST',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/flat-term-selector.js"],"names":["EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","orderby","order","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","term","name","id","findOrCreateTerm","restBase","namespace","escapedTermName","path","method","data","catch","error","code","Promise","reject","resolve","term_id","then","unescapeTerm","FlatTermSelector","slug","values","setValues","search","setSearch","debouncedSearch","termIds","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","getCurrentPost","getEditedPostAttribute","editorStore","getEntityRecords","getTaxonomy","hasFinishedResolution","coreStore","post","_taxonomy","_termIds","rest_base","query","include","join","length","searchResults","newValues","suggestions","editPost","onUpdateTerms","newTermIds","onChange","termNames","availableTerms","uniqueTerms","reduce","acc","some","n","push","newTermNames","filter","rest_namespace","all","newTerms","newAvailableTerms","concat","appendTerm","newTerm","includes","termAddedMessage","newTermLabel","singularName","termAddedLabel","termRemovedLabel","removeTermLabel","added","removed","remove"],"mappings":";;;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAW,GAAG,EAApB;AAEA;AACA;AACA;;AACA,MAAMC,qBAAqB,GAAG,EAA9B;AACA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAEF,qBADW;AAErBG,EAAAA,OAAO,EAAE,OAFY;AAGrBC,EAAAA,KAAK,EAAE,MAHc;AAIrBC,EAAAA,OAAO,EAAE,SAJY;AAKrBC,EAAAA,OAAO,EAAE;AALY,CAAtB;;AAQA,MAAMC,cAAc,GAAG,CAAEC,KAAF,EAASC,KAAT,KACtB,2BAAgBD,KAAhB,EAAwBE,WAAxB,OACA,2BAAgBD,KAAhB,EAAwBC,WAAxB,EAFD;;AAIA,MAAMC,cAAc,GAAG,CAAEC,KAAF,EAASC,KAAT,KAAoB;AAC1C,SAAOD,KAAK,CAACE,GAAN,CACJC,QAAF,IACC,kBAAMF,KAAN,EAAeG,IAAF,IAAYT,cAAc,CAAES,IAAI,CAACC,IAAP,EAAaF,QAAb,CAAvC,EAAiEG,EAF5D,CAAP;AAIA,CALD,C,CAOA;;;AACA,SAASC,gBAAT,CAA2BJ,QAA3B,EAAqCK,QAArC,EAA+CC,SAA/C,EAA2D;AAC1D,QAAMC,eAAe,GAAG,oBAAcP,QAAd,CAAxB;AAEA,SAAO,uBAAU;AAChBQ,IAAAA,IAAI,EAAG,IAAIF,SAAW,IAAID,QAAU,EADpB;AAEhBI,IAAAA,MAAM,EAAE,MAFQ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A1B;AAAqC,IAAA,QAAQ,EAAG0C;AAAhD,IAdD,CADD;AAkBA;;eAEc,6BAAa,yBAAb,EAA0ClD,gBAA1C,C","sourcesContent":["/**\n * External dependencies\n */\nimport { escape as escapeString, find, get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, withFilters } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport apiFetch from '@wordpress/api-fetch';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Module constants\n */\nconst MAX_TERMS_SUGGESTIONS = 20;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\torderby: 'count',\n\torder: 'desc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names.map(\n\t\t( termName ) =>\n\t\t\tfind( terms, ( term ) => isSameTermName( term.name, termName ) ).id\n\t);\n};\n\n// Tries to create a term or fetch it if it already exists.\nfunction findOrCreateTerm( termName, restBase, namespace ) {\n\tconst escapedTermName = escapeString( termName );\n\n\treturn apiFetch( {\n\t\tpath: `/${ namespace }/${ restBase }`,\n\t\tmethod: 'POST',\n\t\tdata: { name: escapedTermName },\n\t} )\n\t\t.catch( ( error ) => {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\treturn Promise.reject( error );\n\t\t\t}\n\n\t\t\treturn Promise.resolve( {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: termName,\n\t\t\t} );\n\t\t} )\n\t\t.then( unescapeTerm );\n}\n\nexport function FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecords, getTaxonomy, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! find( availableTerms, ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, availableTerms )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( termName, taxonomy.rest_base, namespace )\n\t\t\t)\n\t\t).then( ( newTerms ) => {\n\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t);\n\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\tget(\n\t\t\t\ttaxonomy,\n\t\t\t\t[ 'labels', 'singular_name' ],\n\t\t\t\tslug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )\n\t\t\t)\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'add_new_item' ],\n\t\tslug === 'post_tag' ? __( 'Add new tag' ) : __( 'Add new Term' )\n\t);\n\tconst singularName = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'singular_name' ],\n\t\tslug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )\n\t);\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<FormTokenField\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/flat-term-selector.js"],"names":["EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","orderby","order","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","term","name","id","findOrCreateTerm","restBase","namespace","escapedTermName","path","method","data","catch","error","code","Promise","reject","resolve","term_id","then","unescapeTerm","FlatTermSelector","slug","values","setValues","search","setSearch","debouncedSearch","termIds","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","getCurrentPost","getEditedPostAttribute","editorStore","getEntityRecords","getTaxonomy","hasFinishedResolution","coreStore","post","_taxonomy","_termIds","rest_base","query","include","join","length","searchResults","newValues","suggestions","editPost","onUpdateTerms","newTermIds","onChange","termNames","availableTerms","uniqueTerms","reduce","acc","some","n","push","newTermNames","filter","rest_namespace","all","newTerms","newAvailableTerms","concat","appendTerm","newTerm","includes","termAddedMessage","newTermLabel","singularName","termAddedLabel","termRemovedLabel","removeTermLabel","added","removed","remove"],"mappings":";;;;;;;;;;AAUA;;AAPA;;AACA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAIA;AACA;AACA;;AAUA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAW,GAAG,EAApB;AAEA;AACA;AACA;;AACA,MAAMC,qBAAqB,GAAG,EAA9B;AACA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAEF,qBADW;AAErBG,EAAAA,OAAO,EAAE,OAFY;AAGrBC,EAAAA,KAAK,EAAE,MAHc;AAIrBC,EAAAA,OAAO,EAAE,SAJY;AAKrBC,EAAAA,OAAO,EAAE;AALY,CAAtB;;AAQA,MAAMC,cAAc,GAAG,CAAEC,KAAF,EAASC,KAAT,KACtB,2BAAgBD,KAAhB,EAAwBE,WAAxB,OACA,2BAAgBD,KAAhB,EAAwBC,WAAxB,EAFD;;AAIA,MAAMC,cAAc,GAAG,CAAEC,KAAF,EAASC,KAAT,KAAoB;AAC1C,SAAOD,KAAK,CAACE,GAAN,CACJC,QAAF,IACC,kBAAMF,KAAN,EAAeG,IAAF,IAAYT,cAAc,CAAES,IAAI,CAACC,IAAP,EAAaF,QAAb,CAAvC,EAAiEG,EAF5D,CAAP;AAIA,CALD,C,CAOA;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EAAGzC,qBALlB;AAMC,IAAA,KAAK,EAAGyF,YANT;AAOC,IAAA,QAAQ,EAAG;AACVK,MAAAA,KAAK,EAAEH,cADG;AAEVI,MAAAA,OAAO,EAAEH,gBAFC;AAGVI,MAAAA,MAAM,EAAEH;AAHE;AAPZ,IADD,EAcC,4BAAC,sBAAD;AAAe,IAAA,QAAQ,EAAGlD,QAA1B;AAAqC,IAAA,QAAQ,EAAG0C;AAAhD,IAdD,CADD;AAkBA;;eAEc,6BAAa,yBAAb,EAA0ClD,gBAA1C,C","sourcesContent":["/**\n * External dependencies\n */\nimport { find, get } from 'lodash';\nimport escapeHtml from 'escape-html';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, withFilters } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport apiFetch from '@wordpress/api-fetch';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Module constants\n */\nconst MAX_TERMS_SUGGESTIONS = 20;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\torderby: 'count',\n\torder: 'desc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names.map(\n\t\t( termName ) =>\n\t\t\tfind( terms, ( term ) => isSameTermName( term.name, termName ) ).id\n\t);\n};\n\n// Tries to create a term or fetch it if it already exists.\nfunction findOrCreateTerm( termName, restBase, namespace ) {\n\tconst escapedTermName = escapeHtml( termName );\n\n\treturn apiFetch( {\n\t\tpath: `/${ namespace }/${ restBase }`,\n\t\tmethod: 'POST',\n\t\tdata: { name: escapedTermName },\n\t} )\n\t\t.catch( ( error ) => {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\treturn Promise.reject( error );\n\t\t\t}\n\n\t\t\treturn Promise.resolve( {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: termName,\n\t\t\t} );\n\t\t} )\n\t\t.then( unescapeTerm );\n}\n\nexport function FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecords, getTaxonomy, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! find( availableTerms, ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, availableTerms )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( termName, taxonomy.rest_base, namespace )\n\t\t\t)\n\t\t).then( ( newTerms ) => {\n\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t);\n\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\tget(\n\t\t\t\ttaxonomy,\n\t\t\t\t[ 'labels', 'singular_name' ],\n\t\t\t\tslug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )\n\t\t\t)\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'add_new_item' ],\n\t\tslug === 'post_tag' ? __( 'Add new tag' ) : __( 'Add new Term' )\n\t);\n\tconst singularName = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'singular_name' ],\n\t\tslug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )\n\t);\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<FormTokenField\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"]}
|
|
@@ -248,7 +248,7 @@ function HierarchicalTermSelector(_ref) {
|
|
|
248
248
|
|
|
249
249
|
const onChange = termId => {
|
|
250
250
|
const hasTerm = terms.includes(termId);
|
|
251
|
-
const newTerms = hasTerm ?
|
|
251
|
+
const newTerms = hasTerm ? terms.filter(id => id !== termId) : [...terms, termId];
|
|
252
252
|
onUpdateTerms(newTerms);
|
|
253
253
|
};
|
|
254
254
|
|
|
@@ -282,7 +282,7 @@ function HierarchicalTermSelector(_ref) {
|
|
|
282
282
|
|
|
283
283
|
if (existingTerm) {
|
|
284
284
|
// If the term we are adding exists but is not selected select it.
|
|
285
|
-
if (!
|
|
285
|
+
if (!terms.some(term => term === existingTerm.id)) {
|
|
286
286
|
onUpdateTerms([...terms, existingTerm.id]);
|
|
287
287
|
}
|
|
288
288
|
|
|
@@ -338,6 +338,7 @@ function HierarchicalTermSelector(_ref) {
|
|
|
338
338
|
key: term.id,
|
|
339
339
|
className: "editor-post-taxonomies__hierarchical-terms-choice"
|
|
340
340
|
}, (0, _element.createElement)(_components.CheckboxControl, {
|
|
341
|
+
__nextHasNoMarginBottom: true,
|
|
341
342
|
checked: terms.indexOf(term.id) !== -1,
|
|
342
343
|
onChange: () => {
|
|
343
344
|
const termId = parseInt(term.id, 10);
|