@wordpress/editor 12.4.0-next.e230fbab09.0 → 12.4.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 CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- ## 12.3.0-next.0 (2022-03-09)
5
+ ## 12.4.0 (2022-03-23)
6
+
7
+ ## 12.3.0 (2022-03-11)
6
8
 
7
9
  ### Deprecations
8
10
 
@@ -54,11 +54,11 @@ function EntityTypeList(_ref) {
54
54
  closePanel
55
55
  } = _ref;
56
56
  const firstRecord = list[0];
57
- const entity = (0, _data.useSelect)(select => select(_coreData.store).getEntity(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]);
57
+ const entityConfig = (0, _data.useSelect)(select => select(_coreData.store).getEntityConfig(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]);
58
58
  const {
59
59
  name
60
60
  } = firstRecord;
61
- const entityLabel = name === 'wp_template_part' ? (0, _i18n._n)('Template Part', 'Template Parts', list.length) : entity.label; // Set description based on type of entity.
61
+ const entityLabel = name === 'wp_template_part' ? (0, _i18n._n)('Template Part', 'Template Parts', list.length) : entityConfig.label; // Set description based on type of entity.
62
62
 
63
63
  const description = getEntityDescription(name, list.length);
64
64
  return (0, _element.createElement)(_components.PanelBody, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/entities-saved-states/entity-type-list.js"],"names":["getEntityDescription","entity","length","EntityTypeList","list","unselectedEntities","setUnselectedEntities","closePanel","firstRecord","select","coreStore","getEntity","kind","name","entityLabel","label","description","map","record","key","property","elt","value"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAGA,SAASA,oBAAT,CAA+BC,MAA/B,EAAuCC,MAAvC,EAAgD;AAC/C,UAASD,MAAT;AACC,SAA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N,CAAE,kBACDb,kBADC,EAECgB,GAAF,IACCA,GAAG,CAACT,IAAJ,KAAaM,MAAM,CAACN,IAApB,IACAS,GAAG,CAACR,IAAJ,KAAaK,MAAM,CAACL,IADpB,IAEAQ,GAAG,CAACF,GAAJ,KAAYD,MAAM,CAACC,GAFnB,IAGAE,GAAG,CAACD,QAAJ,KAAiBF,MAAM,CAACE,QANxB,CAJJ;AAaC,MAAA,QAAQ,EAAKE,KAAF,IACVhB,qBAAqB,CAAEY,MAAF,EAAUI,KAAV,CAdvB;AAgBC,MAAA,UAAU,EAAGf;AAhBd,MADD;AAoBA,GArBC,CAFH,CADD;AA2BA","sourcesContent":["/**\n * External dependencies\n */\nimport { some } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody, PanelRow } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport EntityRecordItem from './entity-record-item';\n\nfunction getEntityDescription( entity, length ) {\n\tswitch ( entity ) {\n\t\tcase 'site':\n\t\t\treturn _n(\n\t\t\t\t'This change will affect your whole site.',\n\t\t\t\t'These changes will affect your whole site.',\n\t\t\t\tlength\n\t\t\t);\n\t\tcase 'wp_template':\n\t\t\treturn _n(\n\t\t\t\t'This change will affect pages and posts that use this template.',\n\t\t\t\t'These changes will affect pages and posts that use these templates.',\n\t\t\t\tlength\n\t\t\t);\n\t\tcase 'page':\n\t\tcase 'post':\n\t\t\treturn __( 'The following content has been modified.' );\n\t}\n}\n\nexport default function EntityTypeList( {\n\tlist,\n\tunselectedEntities,\n\tsetUnselectedEntities,\n\tclosePanel,\n} ) {\n\tconst firstRecord = list[ 0 ];\n\tconst entity = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntity( firstRecord.kind, firstRecord.name ),\n\t\t[ firstRecord.kind, firstRecord.name ]\n\t);\n\tconst { name } = firstRecord;\n\tconst entityLabel =\n\t\tname === 'wp_template_part'\n\t\t\t? _n( 'Template Part', 'Template Parts', list.length )\n\t\t\t: entity.label;\n\t// Set description based on type of entity.\n\tconst description = getEntityDescription( name, list.length );\n\n\treturn (\n\t\t<PanelBody title={ entityLabel } initialOpen={ true }>\n\t\t\t{ description && <PanelRow>{ description }</PanelRow> }\n\t\t\t{ list.map( ( record ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityRecordItem\n\t\t\t\t\t\tkey={ record.key || record.property }\n\t\t\t\t\t\trecord={ record }\n\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t! some(\n\t\t\t\t\t\t\t\tunselectedEntities,\n\t\t\t\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\t\t\t\telt.kind === record.kind &&\n\t\t\t\t\t\t\t\t\telt.name === record.name &&\n\t\t\t\t\t\t\t\t\telt.key === record.key &&\n\t\t\t\t\t\t\t\t\telt.property === record.property\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetUnselectedEntities( record, value )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclosePanel={ closePanel }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</PanelBody>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/entities-saved-states/entity-type-list.js"],"names":["getEntityDescription","entity","length","EntityTypeList","list","unselectedEntities","setUnselectedEntities","closePanel","firstRecord","entityConfig","select","coreStore","getEntityConfig","kind","name","entityLabel","label","description","map","record","key","property","elt","value"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAGA,SAASA,oBAAT,CAA+BC,MAA/B,EAAuCC,MAAvC,EAAgD;AAC/C,UAASD,MAAT;AACC,SAAK,MAAL;AACC,aAAO,cACN,0CADM,EAEN,4CAFM,EAGNC,M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,KAAaM,MAAM,CAACN,IAApB,IACAS,GAAG,CAACR,IAAJ,KAAaK,MAAM,CAACL,IADpB,IAEAQ,GAAG,CAACF,GAAJ,KAAYD,MAAM,CAACC,GAFnB,IAGAE,GAAG,CAACD,QAAJ,KAAiBF,MAAM,CAACE,QANxB,CAJJ;AAaC,MAAA,QAAQ,EAAKE,KAAF,IACVjB,qBAAqB,CAAEa,MAAF,EAAUI,KAAV,CAdvB;AAgBC,MAAA,UAAU,EAAGhB;AAhBd,MADD;AAoBA,GArBC,CAFH,CADD;AA2BA","sourcesContent":["/**\n * External dependencies\n */\nimport { some } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody, PanelRow } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport EntityRecordItem from './entity-record-item';\n\nfunction getEntityDescription( entity, length ) {\n\tswitch ( entity ) {\n\t\tcase 'site':\n\t\t\treturn _n(\n\t\t\t\t'This change will affect your whole site.',\n\t\t\t\t'These changes will affect your whole site.',\n\t\t\t\tlength\n\t\t\t);\n\t\tcase 'wp_template':\n\t\t\treturn _n(\n\t\t\t\t'This change will affect pages and posts that use this template.',\n\t\t\t\t'These changes will affect pages and posts that use these templates.',\n\t\t\t\tlength\n\t\t\t);\n\t\tcase 'page':\n\t\tcase 'post':\n\t\t\treturn __( 'The following content has been modified.' );\n\t}\n}\n\nexport default function EntityTypeList( {\n\tlist,\n\tunselectedEntities,\n\tsetUnselectedEntities,\n\tclosePanel,\n} ) {\n\tconst firstRecord = list[ 0 ];\n\tconst entityConfig = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityConfig(\n\t\t\t\tfirstRecord.kind,\n\t\t\t\tfirstRecord.name\n\t\t\t),\n\t\t[ firstRecord.kind, firstRecord.name ]\n\t);\n\tconst { name } = firstRecord;\n\tconst entityLabel =\n\t\tname === 'wp_template_part'\n\t\t\t? _n( 'Template Part', 'Template Parts', list.length )\n\t\t\t: entityConfig.label;\n\t// Set description based on type of entity.\n\tconst description = getEntityDescription( name, list.length );\n\n\treturn (\n\t\t<PanelBody title={ entityLabel } initialOpen={ true }>\n\t\t\t{ description && <PanelRow>{ description }</PanelRow> }\n\t\t\t{ list.map( ( record ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityRecordItem\n\t\t\t\t\t\tkey={ record.key || record.property }\n\t\t\t\t\t\trecord={ record }\n\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t! some(\n\t\t\t\t\t\t\t\tunselectedEntities,\n\t\t\t\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\t\t\t\telt.kind === record.kind &&\n\t\t\t\t\t\t\t\t\telt.name === record.name &&\n\t\t\t\t\t\t\t\t\telt.key === record.key &&\n\t\t\t\t\t\t\t\t\telt.property === record.property\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetUnselectedEntities( record, value )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclosePanel={ closePanel }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</PanelBody>\n\t);\n}\n"]}
@@ -194,7 +194,7 @@ function LocalAutosaveMonitor() {
194
194
  const {
195
195
  localAutosaveInterval
196
196
  } = (0, _data.useSelect)(select => ({
197
- localAutosaveInterval: select(_store.store).getEditorSettings().__experimentalLocalAutosaveInterval
197
+ localAutosaveInterval: select(_store.store).getEditorSettings().localAutosaveInterval
198
198
  }), []);
199
199
  return (0, _element.createElement)(_autosaveMonitor.default, {
200
200
  interval: localAutosaveInterval,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/local-autosave-monitor/index.js"],"names":["requestIdleCallback","window","requestAnimationFrame","hasSessionStorageSupport","sessionStorage","setItem","removeItem","error","useAutosaveNotice","postId","isEditedPostNew","hasRemoteAutosave","select","editorStore","getCurrentPostId","getEditorSettings","autosave","getEditedPostAttribute","createWarningNotice","removeNotice","noticesStore","editPost","resetEditorBlocks","localAutosave","JSON","parse","post_title","title","content","excerpt","edits","hasDifference","Object","keys","some","key","noticeId","id","actions","label","onClick","useAutosavePurge","isDirty","isAutosaving","didError","isEditedPostDirty","isAutosavingPost","didPostSaveRequestFail","lastIsDirty","lastIsAutosaving","current","wasEditedPostNew","prevPostId","LocalAutosaveMonitor","deferredAutosave","local","localAutosaveInterval","__experimentalLocalAutosaveInterval"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAIA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AAQA,MAAMA,mBAAmB,GAAGC,MAAM,CAACD,mBAAP,GACzBC,MAAM,CAACD,mBADkB,GAEzBC,MAAM,CAACC,qBAFV;AAIA;AACA;AACA;AACA;AACA;;AACA,MAAMC,wBAAwB,GAAG,kBAAM,MAAM;AAC5C,MAAI;AACH;AACA;AACA;AACAF,IAAAA,MAAM,CAACG,cAAP,CAAsBC,OAAtB,CAA+B,8BAA/B,EAA+D,EAA/D;AACAJ,IAAAA,MAAM,CAACG,cAAP,CAAsBE,UAAtB,CAAkC,8BAAlC;AACA,WAAO,IAAP;AACA,GAPD,CAOE,OAAQC,KAAR,EAAgB;AACjB,WAAO,KAAP;AACA;AACD,CAXgC,CAAjC;AAaA;AACA;AACA;AACA;;AACA,SAASC,iBAAT,GAA6B;AAC5B,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,eAAV;AAA2BC,IAAAA;AAA3B,MAAiD,qBACpDC,MAAF,KAAgB;AACfH,IAAAA,MAAM,EAAEG,MAAM,CAAEC,YAAF,CAAN,CAAsBC,gBAAtB,EADO;AAEfJ,IAAAA,eAAe,EAAEE,MAAM,CAAEC,YAAF,CAAN,CAAsBH,eAAtB,EAFF;AAGfC,IAAAA,iBAAiB,EAAE,CAAC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, omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { ifCondition, usePrevious } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { parse } from '@wordpress/blocks';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AutosaveMonitor from '../autosave-monitor';\nimport {\n\tlocalAutosaveGet,\n\tlocalAutosaveClear,\n} from '../../store/local-autosave';\nimport { store as editorStore } from '../../store';\n\nconst requestIdleCallback = window.requestIdleCallback\n\t? window.requestIdleCallback\n\t: window.requestAnimationFrame;\n\n/**\n * Function which returns true if the current environment supports browser\n * sessionStorage, or false otherwise. The result of this function is cached and\n * reused in subsequent invocations.\n */\nconst hasSessionStorageSupport = once( () => {\n\ttry {\n\t\t// Private Browsing in Safari 10 and earlier will throw an error when\n\t\t// attempting to set into sessionStorage. The test here is intentional in\n\t\t// causing a thrown error as condition bailing from local autosave.\n\t\twindow.sessionStorage.setItem( '__wpEditorTestSessionStorage', '' );\n\t\twindow.sessionStorage.removeItem( '__wpEditorTestSessionStorage' );\n\t\treturn true;\n\t} catch ( error ) {\n\t\treturn false;\n\t}\n} );\n\n/**\n * Custom hook which manages the creation of a notice prompting the user to\n * restore a local autosave, if one exists.\n */\nfunction useAutosaveNotice() {\n\tconst { postId, isEditedPostNew, hasRemoteAutosave } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\thasRemoteAutosave: !! select( editorStore ).getEditorSettings()\n\t\t\t\t.autosave,\n\t\t} ),\n\t\t[]\n\t);\n\tconst { getEditedPostAttribute } = useSelect( editorStore );\n\n\tconst { createWarningNotice, removeNotice } = useDispatch( noticesStore );\n\tconst { editPost, resetEditorBlocks } = useDispatch( editorStore );\n\n\tuseEffect( () => {\n\t\tlet localAutosave = localAutosaveGet( postId, isEditedPostNew );\n\t\tif ( ! localAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tlocalAutosave = JSON.parse( localAutosave );\n\t\t} catch ( error ) {\n\t\t\t// Not usable if it can't be parsed.\n\t\t\treturn;\n\t\t}\n\n\t\tconst { post_title: title, content, excerpt } = localAutosave;\n\t\tconst edits = { title, content, excerpt };\n\n\t\t{\n\t\t\t// Only display a notice if there is a difference between what has been\n\t\t\t// saved and that which is stored in sessionStorage.\n\t\t\tconst hasDifference = Object.keys( edits ).some( ( key ) => {\n\t\t\t\treturn edits[ key ] !== getEditedPostAttribute( key );\n\t\t\t} );\n\n\t\t\tif ( ! hasDifference ) {\n\t\t\t\t// If there is no difference, it can be safely ejected from storage.\n\t\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif ( hasRemoteAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst noticeId = uniqueId( 'wpEditorAutosaveRestore' );\n\t\tcreateWarningNotice(\n\t\t\t__(\n\t\t\t\t'The backup of this post in your browser is different from the version below.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tid: noticeId,\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Restore the backup' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\teditPost( omit( edits, [ 'content' ] ) );\n\t\t\t\t\t\t\tresetEditorBlocks( parse( edits.content ) );\n\t\t\t\t\t\t\tremoveNotice( noticeId );\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}\n\t\t);\n\t}, [ isEditedPostNew, postId ] );\n}\n\n/**\n * Custom hook which ejects a local autosave after a successful save occurs.\n */\nfunction useAutosavePurge() {\n\tconst {\n\t\tpostId,\n\t\tisEditedPostNew,\n\t\tisDirty,\n\t\tisAutosaving,\n\t\tdidError,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\tisDirty: select( editorStore ).isEditedPostDirty(),\n\t\t\tisAutosaving: select( editorStore ).isAutosavingPost(),\n\t\t\tdidError: select( editorStore ).didPostSaveRequestFail(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst lastIsDirty = useRef( isDirty );\n\tconst lastIsAutosaving = useRef( isAutosaving );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! didError &&\n\t\t\t( ( lastIsAutosaving.current && ! isAutosaving ) ||\n\t\t\t\t( lastIsDirty.current && ! isDirty ) )\n\t\t) {\n\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t}\n\n\t\tlastIsDirty.current = isDirty;\n\t\tlastIsAutosaving.current = isAutosaving;\n\t}, [ isDirty, isAutosaving, didError ] );\n\n\t// Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.\n\tconst wasEditedPostNew = usePrevious( isEditedPostNew );\n\tconst prevPostId = usePrevious( postId );\n\tuseEffect( () => {\n\t\tif ( prevPostId === postId && wasEditedPostNew && ! isEditedPostNew ) {\n\t\t\tlocalAutosaveClear( postId, true );\n\t\t}\n\t}, [ isEditedPostNew, postId ] );\n}\n\nfunction LocalAutosaveMonitor() {\n\tconst { autosave } = useDispatch( editorStore );\n\tconst deferredAutosave = useCallback( () => {\n\t\trequestIdleCallback( () => autosave( { local: true } ) );\n\t}, [] );\n\tuseAutosaveNotice();\n\tuseAutosavePurge();\n\n\tconst { localAutosaveInterval } = useSelect(\n\t\t( select ) => ( {\n\t\t\tlocalAutosaveInterval: select( editorStore ).getEditorSettings()\n\t\t\t\t.__experimentalLocalAutosaveInterval,\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<AutosaveMonitor\n\t\t\tinterval={ localAutosaveInterval }\n\t\t\tautosave={ deferredAutosave }\n\t\t/>\n\t);\n}\n\nexport default ifCondition( hasSessionStorageSupport )( LocalAutosaveMonitor );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/local-autosave-monitor/index.js"],"names":["requestIdleCallback","window","requestAnimationFrame","hasSessionStorageSupport","sessionStorage","setItem","removeItem","error","useAutosaveNotice","postId","isEditedPostNew","hasRemoteAutosave","select","editorStore","getCurrentPostId","getEditorSettings","autosave","getEditedPostAttribute","createWarningNotice","removeNotice","noticesStore","editPost","resetEditorBlocks","localAutosave","JSON","parse","post_title","title","content","excerpt","edits","hasDifference","Object","keys","some","key","noticeId","id","actions","label","onClick","useAutosavePurge","isDirty","isAutosaving","didError","isEditedPostDirty","isAutosavingPost","didPostSaveRequestFail","lastIsDirty","lastIsAutosaving","current","wasEditedPostNew","prevPostId","LocalAutosaveMonitor","deferredAutosave","local","localAutosaveInterval"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAIA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AAQA,MAAMA,mBAAmB,GAAGC,MAAM,CAACD,mBAAP,GACzBC,MAAM,CAACD,mBADkB,GAEzBC,MAAM,CAACC,qBAFV;AAIA;AACA;AACA;AACA;AACA;;AACA,MAAMC,wBAAwB,GAAG,kBAAM,MAAM;AAC5C,MAAI;AACH;AACA;AACA;AACAF,IAAAA,MAAM,CAACG,cAAP,CAAsBC,OAAtB,CAA+B,8BAA/B,EAA+D,EAA/D;AACAJ,IAAAA,MAAM,CAACG,cAAP,CAAsBE,UAAtB,CAAkC,8BAAlC;AACA,WAAO,IAAP;AACA,GAPD,CAOE,OAAQC,KAAR,EAAgB;AACjB,WAAO,KAAP;AACA;AACD,CAXgC,CAAjC;AAaA;AACA;AACA;AACA;;AACA,SAASC,iBAAT,GAA6B;AAC5B,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,eAAV;AAA2BC,IAAAA;AAA3B,MAAiD,qBACpDC,MAAF,KAAgB;AACfH,IAAAA,M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wBAAD;AACC,IAAA,QAAQ,EAAGA,qBADZ;AAEC,IAAA,QAAQ,EAAGF;AAFZ,IADD;AAMA;;eAEc,0BAAanD,wBAAb,EAAyCkD,oBAAzC,C","sourcesContent":["/**\n * External dependencies\n */\nimport { once, uniqueId, omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { ifCondition, usePrevious } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { parse } from '@wordpress/blocks';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AutosaveMonitor from '../autosave-monitor';\nimport {\n\tlocalAutosaveGet,\n\tlocalAutosaveClear,\n} from '../../store/local-autosave';\nimport { store as editorStore } from '../../store';\n\nconst requestIdleCallback = window.requestIdleCallback\n\t? window.requestIdleCallback\n\t: window.requestAnimationFrame;\n\n/**\n * Function which returns true if the current environment supports browser\n * sessionStorage, or false otherwise. The result of this function is cached and\n * reused in subsequent invocations.\n */\nconst hasSessionStorageSupport = once( () => {\n\ttry {\n\t\t// Private Browsing in Safari 10 and earlier will throw an error when\n\t\t// attempting to set into sessionStorage. The test here is intentional in\n\t\t// causing a thrown error as condition bailing from local autosave.\n\t\twindow.sessionStorage.setItem( '__wpEditorTestSessionStorage', '' );\n\t\twindow.sessionStorage.removeItem( '__wpEditorTestSessionStorage' );\n\t\treturn true;\n\t} catch ( error ) {\n\t\treturn false;\n\t}\n} );\n\n/**\n * Custom hook which manages the creation of a notice prompting the user to\n * restore a local autosave, if one exists.\n */\nfunction useAutosaveNotice() {\n\tconst { postId, isEditedPostNew, hasRemoteAutosave } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\thasRemoteAutosave: !! select( editorStore ).getEditorSettings()\n\t\t\t\t.autosave,\n\t\t} ),\n\t\t[]\n\t);\n\tconst { getEditedPostAttribute } = useSelect( editorStore );\n\n\tconst { createWarningNotice, removeNotice } = useDispatch( noticesStore );\n\tconst { editPost, resetEditorBlocks } = useDispatch( editorStore );\n\n\tuseEffect( () => {\n\t\tlet localAutosave = localAutosaveGet( postId, isEditedPostNew );\n\t\tif ( ! localAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tlocalAutosave = JSON.parse( localAutosave );\n\t\t} catch ( error ) {\n\t\t\t// Not usable if it can't be parsed.\n\t\t\treturn;\n\t\t}\n\n\t\tconst { post_title: title, content, excerpt } = localAutosave;\n\t\tconst edits = { title, content, excerpt };\n\n\t\t{\n\t\t\t// Only display a notice if there is a difference between what has been\n\t\t\t// saved and that which is stored in sessionStorage.\n\t\t\tconst hasDifference = Object.keys( edits ).some( ( key ) => {\n\t\t\t\treturn edits[ key ] !== getEditedPostAttribute( key );\n\t\t\t} );\n\n\t\t\tif ( ! hasDifference ) {\n\t\t\t\t// If there is no difference, it can be safely ejected from storage.\n\t\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif ( hasRemoteAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst noticeId = uniqueId( 'wpEditorAutosaveRestore' );\n\t\tcreateWarningNotice(\n\t\t\t__(\n\t\t\t\t'The backup of this post in your browser is different from the version below.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tid: noticeId,\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Restore the backup' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\teditPost( omit( edits, [ 'content' ] ) );\n\t\t\t\t\t\t\tresetEditorBlocks( parse( edits.content ) );\n\t\t\t\t\t\t\tremoveNotice( noticeId );\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}\n\t\t);\n\t}, [ isEditedPostNew, postId ] );\n}\n\n/**\n * Custom hook which ejects a local autosave after a successful save occurs.\n */\nfunction useAutosavePurge() {\n\tconst {\n\t\tpostId,\n\t\tisEditedPostNew,\n\t\tisDirty,\n\t\tisAutosaving,\n\t\tdidError,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\tisDirty: select( editorStore ).isEditedPostDirty(),\n\t\t\tisAutosaving: select( editorStore ).isAutosavingPost(),\n\t\t\tdidError: select( editorStore ).didPostSaveRequestFail(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst lastIsDirty = useRef( isDirty );\n\tconst lastIsAutosaving = useRef( isAutosaving );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! didError &&\n\t\t\t( ( lastIsAutosaving.current && ! isAutosaving ) ||\n\t\t\t\t( lastIsDirty.current && ! isDirty ) )\n\t\t) {\n\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t}\n\n\t\tlastIsDirty.current = isDirty;\n\t\tlastIsAutosaving.current = isAutosaving;\n\t}, [ isDirty, isAutosaving, didError ] );\n\n\t// Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.\n\tconst wasEditedPostNew = usePrevious( isEditedPostNew );\n\tconst prevPostId = usePrevious( postId );\n\tuseEffect( () => {\n\t\tif ( prevPostId === postId && wasEditedPostNew && ! isEditedPostNew ) {\n\t\t\tlocalAutosaveClear( postId, true );\n\t\t}\n\t}, [ isEditedPostNew, postId ] );\n}\n\nfunction LocalAutosaveMonitor() {\n\tconst { autosave } = useDispatch( editorStore );\n\tconst deferredAutosave = useCallback( () => {\n\t\trequestIdleCallback( () => autosave( { local: true } ) );\n\t}, [] );\n\tuseAutosaveNotice();\n\tuseAutosavePurge();\n\n\tconst { localAutosaveInterval } = useSelect(\n\t\t( select ) => ( {\n\t\t\tlocalAutosaveInterval: select( editorStore ).getEditorSettings()\n\t\t\t\t.localAutosaveInterval,\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<AutosaveMonitor\n\t\t\tinterval={ localAutosaveInterval }\n\t\t\tautosave={ deferredAutosave }\n\t\t/>\n\t);\n}\n\nexport default ifCondition( hasSessionStorageSupport )( LocalAutosaveMonitor );\n"]}
@@ -16,23 +16,22 @@ const PREFERENCES_DEFAULTS = {
16
16
  isPublishSidebarEnabled: true
17
17
  };
18
18
  /**
19
- * The default post editor settings
19
+ * The default post editor settings.
20
20
  *
21
- * allowedBlockTypes boolean|Array Allowed block types
22
- * richEditingEnabled boolean Whether rich editing is enabled or not
23
- * codeEditingEnabled boolean Whether code editing is enabled or not
24
- * enableCustomFields boolean Whether the WordPress custom fields are enabled or not.
25
- * true = the user has opted to show the Custom Fields panel at the bottom of the editor.
26
- * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
27
- * undefined = the current environment does not support Custom Fields,
28
- * so the option toggle in Preferences -> Panels to
29
- * enable the Custom Fields panel is not displayed.
30
- * autosaveInterval number Autosave Interval
31
- * availableTemplates array? The available post templates
32
- * disablePostFormats boolean Whether or not the post formats are disabled
33
- * allowedMimeTypes array? List of allowed mime types and file extensions
34
- * maxUploadFileSize number Maximum upload file size
35
- * supportsLayout boolean Whether the editor supports layouts.
21
+ * @property {boolean|Array} allowedBlockTypes Allowed block types
22
+ * @property {boolean} richEditingEnabled Whether rich editing is enabled or not
23
+ * @property {boolean} codeEditingEnabled Whether code editing is enabled or not
24
+ * @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
25
+ * true = the user has opted to show the Custom Fields panel at the bottom of the editor.
26
+ * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
27
+ * undefined = the current environment does not support Custom Fields, so the option toggle in Preferences -> Panels to enable the Custom Fields panel is not displayed.
28
+ * @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.
29
+ * @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.
30
+ * @property {Array?} availableTemplates The available post templates
31
+ * @property {boolean} disablePostFormats Whether or not the post formats are disabled
32
+ * @property {Array?} allowedMimeTypes List of allowed mime types and file extensions
33
+ * @property {number} maxUploadFileSize Maximum upload file size
34
+ * @property {boolean} supportsLayout Whether the editor supports layouts.
36
35
  */
37
36
 
38
37
  exports.PREFERENCES_DEFAULTS = PREFERENCES_DEFAULTS;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/store/defaults.js"],"names":["PREFERENCES_DEFAULTS","insertUsage","isPublishSidebarEnabled","EDITOR_SETTINGS_DEFAULTS","SETTINGS_DEFAULTS","richEditingEnabled","codeEditingEnabled","enableCustomFields","undefined","supportsLayout"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAMA,oBAAoB,GAAG;AACnCC,EAAAA,WAAW,EAAE,EADsB;AAClB;AACjBC,EAAAA,uBAAuB,EAAE;AAFU,CAA7B;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,wBAAwB,GAAG,EACvC,GAAGC,8BADoC;AAGvCC,EAAAA,kBAAkB,EAAE,IAHmB;AAIvCC,EAAAA,kBAAkB,EAAE,IAJmB;AAKvCC,EAAAA,kBAAkB,EAAEC,SALmB;AAMvCC,EAAAA,cAAc,EAAE;AANuB,CAAjC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SETTINGS_DEFAULTS } from '@wordpress/block-editor';\n\nexport const PREFERENCES_DEFAULTS = {\n\tinsertUsage: {}, // Should be kept for backward compatibility, see: https://github.com/WordPress/gutenberg/issues/14580.\n\tisPublishSidebarEnabled: true,\n};\n\n/**\n * The default post editor settings\n *\n * allowedBlockTypes boolean|Array Allowed block types\n * richEditingEnabled boolean Whether rich editing is enabled or not\n * codeEditingEnabled boolean Whether code editing is enabled or not\n * enableCustomFields boolean Whether the WordPress custom fields are enabled or not.\n * true = the user has opted to show the Custom Fields panel at the bottom of the editor.\n * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.\n * undefined = the current environment does not support Custom Fields,\n * so the option toggle in Preferences -> Panels to\n * enable the Custom Fields panel is not displayed.\n * autosaveInterval number Autosave Interval\n * availableTemplates array? The available post templates\n * disablePostFormats boolean Whether or not the post formats are disabled\n * allowedMimeTypes array? List of allowed mime types and file extensions\n * maxUploadFileSize number Maximum upload file size\n * supportsLayout boolean Whether the editor supports layouts.\n */\nexport const EDITOR_SETTINGS_DEFAULTS = {\n\t...SETTINGS_DEFAULTS,\n\n\trichEditingEnabled: true,\n\tcodeEditingEnabled: true,\n\tenableCustomFields: undefined,\n\tsupportsLayout: true,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/store/defaults.js"],"names":["PREFERENCES_DEFAULTS","insertUsage","isPublishSidebarEnabled","EDITOR_SETTINGS_DEFAULTS","SETTINGS_DEFAULTS","richEditingEnabled","codeEditingEnabled","enableCustomFields","undefined","supportsLayout"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAMA,oBAAoB,GAAG;AACnCC,EAAAA,WAAW,EAAE,EADsB;AAClB;AACjBC,EAAAA,uBAAuB,EAAE;AAFU,CAA7B;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,wBAAwB,GAAG,EACvC,GAAGC,8BADoC;AAGvCC,EAAAA,kBAAkB,EAAE,IAHmB;AAIvCC,EAAAA,kBAAkB,EAAE,IAJmB;AAKvCC,EAAAA,kBAAkB,EAAEC,SALmB;AAMvCC,EAAAA,cAAc,EAAE;AANuB,CAAjC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SETTINGS_DEFAULTS } from '@wordpress/block-editor';\n\nexport const PREFERENCES_DEFAULTS = {\n\tinsertUsage: {}, // Should be kept for backward compatibility, see: https://github.com/WordPress/gutenberg/issues/14580.\n\tisPublishSidebarEnabled: true,\n};\n\n/**\n * The default post editor settings.\n *\n * @property {boolean|Array} allowedBlockTypes Allowed block types\n * @property {boolean} richEditingEnabled Whether rich editing is enabled or not\n * @property {boolean} codeEditingEnabled Whether code editing is enabled or not\n * @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.\n * true = the user has opted to show the Custom Fields panel at the bottom of the editor.\n * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.\n * undefined = the current environment does not support Custom Fields, so the option toggle in Preferences -> Panels to enable the Custom Fields panel is not displayed.\n * @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.\n * @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.\n * @property {Array?} availableTemplates The available post templates\n * @property {boolean} disablePostFormats Whether or not the post formats are disabled\n * @property {Array?} allowedMimeTypes List of allowed mime types and file extensions\n * @property {number} maxUploadFileSize Maximum upload file size\n * @property {boolean} supportsLayout Whether the editor supports layouts.\n */\nexport const EDITOR_SETTINGS_DEFAULTS = {\n\t...SETTINGS_DEFAULTS,\n\n\trichEditingEnabled: true,\n\tcodeEditingEnabled: true,\n\tenableCustomFields: undefined,\n\tsupportsLayout: true,\n};\n"]}
@@ -53,12 +53,13 @@ function getNotificationArgumentsForSaveSuccess(data) {
53
53
  const isPublished = (0, _lodash.includes)(publishStatus, previousPost.status);
54
54
  const willPublish = (0, _lodash.includes)(publishStatus, post.status);
55
55
  let noticeMessage;
56
- let shouldShowLink = (0, _lodash.get)(postType, ['viewable'], false); // Always should a notice, which will be spoken for accessibility.
56
+ let shouldShowLink = (0, _lodash.get)(postType, ['viewable'], false);
57
+ let isDraft; // Always should a notice, which will be spoken for accessibility.
57
58
 
58
59
  if (!isPublished && !willPublish) {
59
60
  // If saving a non-published post, don't show notice.
60
- noticeMessage = (0, _i18n.__)('Draft saved');
61
- shouldShowLink = false;
61
+ noticeMessage = (0, _i18n.__)('Draft saved.');
62
+ isDraft = true;
62
63
  } else if (isPublished && !willPublish) {
63
64
  // If undoing publish status, show specific notice.
64
65
  noticeMessage = postType.labels.item_reverted_to_draft;
@@ -80,7 +81,7 @@ function getNotificationArgumentsForSaveSuccess(data) {
80
81
 
81
82
  if (shouldShowLink) {
82
83
  actions.push({
83
- label: postType.labels.view_item,
84
+ label: isDraft ? (0, _i18n.__)('View Preview') : postType.labels.view_item,
84
85
  url: post.link
85
86
  });
86
87
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/store/utils/notice-builder.js"],"names":["getNotificationArgumentsForSaveSuccess","data","previousPost","post","postType","options","status","publishStatus","isPublished","willPublish","noticeMessage","shouldShowLink","labels","item_reverted_to_draft","publish","item_published","private","item_published_privately","future","item_scheduled","item_updated","actions","push","label","view_item","url","link","id","SAVE_POST_NOTICE_ID","type","getNotificationArgumentsForSaveFail","edits","error","code","indexOf","messages","message","test","join","getNotificationArgumentsForTrashFail","TRASH_POST_NOTICE_ID"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,sCAAT,CAAiDC,IAAjD,EAAwD;AAC9D,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA,IAAhB;AAAsBC,IAAAA;AAAtB,MAAmCH,IAAzC,CAD8D,CAE9D;;AACA,MAAK,iBAAKA,IAAI,CAACI,OAAV,EAAmB,CAAE,YAAF,CAAnB,CAAL,EAA6C;AAC5C,WAAO,EAAP;AACA,GAL6D,CAO9D;;;AACA,MAAKF,IAAI,CAACG,MAAL,KAAgB,OAAhB,IAA2BJ,YAAY,CAACI,MAAb,KAAwB,OAAxD,EAAkE;AACjE,WAAO,EAAP;AACA;;AAED,QAAMC,aAAa,GAAG,CAAE,SAAF,EAAa,SAAb,EAAwB,QAAxB,CAAtB;AACA,QAAMC,WAAW,GAAG,sBAAUD,aAAV,EAAyBL,YAAY,CAACI,MAAtC,CAApB;AACA,QAAMG,WAAW,GAAG,sBAAUF,aA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AI,CAAC+B,KAAL,CAAWI,OAAX,IAAsBnC,IAAI,CAAC+B,KAAL,CAAWC,IAAX,KAAoB,eAA1C,GACGhC,IAAI,CAAC+B,KAAL,CAAWI,OADd,GAEG,cAAI,iBAAJ,CAHG,EAIN;AACCT,IAAAA,EAAE,EAAEa;AADL,GAJM,CAAP;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { SAVE_POST_NOTICE_ID, TRASH_POST_NOTICE_ID } from '../constants';\n\n/**\n * External dependencies\n */\nimport { get, includes } from 'lodash';\n\n/**\n * Builds the arguments for a success notification dispatch.\n *\n * @param {Object} data Incoming data to build the arguments from.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveSuccess( data ) {\n\tconst { previousPost, post, postType } = data;\n\t// Autosaves are neither shown a notice nor redirected.\n\tif ( get( data.options, [ 'isAutosave' ] ) ) {\n\t\treturn [];\n\t}\n\n\t// No notice is shown after trashing a post\n\tif ( post.status === 'trash' && previousPost.status !== 'trash' ) {\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = includes( publishStatus, previousPost.status );\n\tconst willPublish = includes( publishStatus, post.status );\n\n\tlet noticeMessage;\n\tlet shouldShowLink = get( postType, [ 'viewable' ], false );\n\n\t// Always should a notice, which will be spoken for accessibility.\n\tif ( ! isPublished && ! willPublish ) {\n\t\t// If saving a non-published post, don't show notice.\n\t\tnoticeMessage = __( 'Draft saved' );\n\t\tshouldShowLink = false;\n\t} else if ( isPublished && ! willPublish ) {\n\t\t// If undoing publish status, show specific notice.\n\t\tnoticeMessage = postType.labels.item_reverted_to_draft;\n\t\tshouldShowLink = false;\n\t} else if ( ! isPublished && willPublish ) {\n\t\t// If publishing or scheduling a post, show the corresponding\n\t\t// publish message.\n\t\tnoticeMessage = {\n\t\t\tpublish: postType.labels.item_published,\n\t\t\tprivate: postType.labels.item_published_privately,\n\t\t\tfuture: postType.labels.item_scheduled,\n\t\t}[ post.status ];\n\t} else {\n\t\t// Generic fallback notice.\n\t\tnoticeMessage = postType.labels.item_updated;\n\t}\n\n\tconst actions = [];\n\tif ( shouldShowLink ) {\n\t\tactions.push( {\n\t\t\tlabel: postType.labels.view_item,\n\t\t\turl: post.link,\n\t\t} );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t\ttype: 'snackbar',\n\t\t\tactions,\n\t\t},\n\t];\n}\n\n/**\n * Builds the fail notification arguments for dispatch.\n *\n * @param {Object} data Incoming data to build the arguments with.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveFail( data ) {\n\tconst { post, edits, error } = data;\n\tif ( error && 'rest_autosave_no_changes' === error.code ) {\n\t\t// Autosave requested a new autosave, but there were no changes. This shouldn't\n\t\t// result in an error notice for the user.\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = publishStatus.indexOf( post.status ) !== -1;\n\t// If the post was being published, we show the corresponding publish error message\n\t// Unless we publish an \"updating failed\" message.\n\tconst messages = {\n\t\tpublish: __( 'Publishing failed.' ),\n\t\tprivate: __( 'Publishing failed.' ),\n\t\tfuture: __( 'Scheduling failed.' ),\n\t};\n\tlet noticeMessage =\n\t\t! isPublished && publishStatus.indexOf( edits.status ) !== -1\n\t\t\t? messages[ edits.status ]\n\t\t\t: __( 'Updating failed.' );\n\n\t// Check if message string contains HTML. Notice text is currently only\n\t// supported as plaintext, and stripping the tags may muddle the meaning.\n\tif ( error.message && ! /<\\/?[^>]*>/.test( error.message ) ) {\n\t\tnoticeMessage = [ noticeMessage, error.message ].join( ' ' );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n\n/**\n * Builds the trash fail notification arguments for dispatch.\n *\n * @param {Object} data\n *\n * @return {Array} Arguments for dispatch.\n */\nexport function getNotificationArgumentsForTrashFail( data ) {\n\treturn [\n\t\tdata.error.message && data.error.code !== 'unknown_error'\n\t\t\t? data.error.message\n\t\t\t: __( 'Trashing failed' ),\n\t\t{\n\t\t\tid: TRASH_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/store/utils/notice-builder.js"],"names":["getNotificationArgumentsForSaveSuccess","data","previousPost","post","postType","options","status","publishStatus","isPublished","willPublish","noticeMessage","shouldShowLink","isDraft","labels","item_reverted_to_draft","publish","item_published","private","item_published_privately","future","item_scheduled","item_updated","actions","push","label","view_item","url","link","id","SAVE_POST_NOTICE_ID","type","getNotificationArgumentsForSaveFail","edits","error","code","indexOf","messages","message","test","join","getNotificationArgumentsForTrashFail","TRASH_POST_NOTICE_ID"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,sCAAT,CAAiDC,IAAjD,EAAwD;AAC9D,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA,IAAhB;AAAsBC,IAAAA;AAAtB,MAAmCH,IAAzC,CAD8D,CAE9D;;AACA,MAAK,iBAAKA,IAAI,CAACI,OAAV,EAAmB,CAAE,YAAF,CAAnB,CAAL,EAA6C;AAC5C,WAAO,EAAP;AACA,GAL6D,CAO9D;;;AACA,MAAKF,IAAI,CAACG,MAAL,KAAgB,OAAhB,IAA2BJ,YAAY,CAACI,MAAb,KAAwB,OAAxD,EAAkE;AACjE,WAAO,EAAP;AACA;;AAED,QAAMC,aAAa,GAAG,CAAE,SAAF,EAAa,SAAb,EAAwB,QAAxB,CAAtB;AACA,QAAMC,WAAW,GAAG,sBAAUD,aAAV,EAAyBL,YAAY,CAACI,MAAtC,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AED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASW,oCAAT,CAA+CvC,IAA/C,EAAsD;AAC5D,SAAO,CACNA,IAAI,CAACgC,KAAL,CAAWI,OAAX,IAAsBpC,IAAI,CAACgC,KAAL,CAAWC,IAAX,KAAoB,eAA1C,GACGjC,IAAI,CAACgC,KAAL,CAAWI,OADd,GAEG,cAAI,iBAAJ,CAHG,EAIN;AACCT,IAAAA,EAAE,EAAEa;AADL,GAJM,CAAP;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { SAVE_POST_NOTICE_ID, TRASH_POST_NOTICE_ID } from '../constants';\n\n/**\n * External dependencies\n */\nimport { get, includes } from 'lodash';\n\n/**\n * Builds the arguments for a success notification dispatch.\n *\n * @param {Object} data Incoming data to build the arguments from.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveSuccess( data ) {\n\tconst { previousPost, post, postType } = data;\n\t// Autosaves are neither shown a notice nor redirected.\n\tif ( get( data.options, [ 'isAutosave' ] ) ) {\n\t\treturn [];\n\t}\n\n\t// No notice is shown after trashing a post\n\tif ( post.status === 'trash' && previousPost.status !== 'trash' ) {\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = includes( publishStatus, previousPost.status );\n\tconst willPublish = includes( publishStatus, post.status );\n\n\tlet noticeMessage;\n\tlet shouldShowLink = get( postType, [ 'viewable' ], false );\n\tlet isDraft;\n\n\t// Always should a notice, which will be spoken for accessibility.\n\tif ( ! isPublished && ! willPublish ) {\n\t\t// If saving a non-published post, don't show notice.\n\t\tnoticeMessage = __( 'Draft saved.' );\n\t\tisDraft = true;\n\t} else if ( isPublished && ! willPublish ) {\n\t\t// If undoing publish status, show specific notice.\n\t\tnoticeMessage = postType.labels.item_reverted_to_draft;\n\t\tshouldShowLink = false;\n\t} else if ( ! isPublished && willPublish ) {\n\t\t// If publishing or scheduling a post, show the corresponding\n\t\t// publish message.\n\t\tnoticeMessage = {\n\t\t\tpublish: postType.labels.item_published,\n\t\t\tprivate: postType.labels.item_published_privately,\n\t\t\tfuture: postType.labels.item_scheduled,\n\t\t}[ post.status ];\n\t} else {\n\t\t// Generic fallback notice.\n\t\tnoticeMessage = postType.labels.item_updated;\n\t}\n\n\tconst actions = [];\n\tif ( shouldShowLink ) {\n\t\tactions.push( {\n\t\t\tlabel: isDraft ? __( 'View Preview' ) : postType.labels.view_item,\n\t\t\turl: post.link,\n\t\t} );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t\ttype: 'snackbar',\n\t\t\tactions,\n\t\t},\n\t];\n}\n\n/**\n * Builds the fail notification arguments for dispatch.\n *\n * @param {Object} data Incoming data to build the arguments with.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveFail( data ) {\n\tconst { post, edits, error } = data;\n\tif ( error && 'rest_autosave_no_changes' === error.code ) {\n\t\t// Autosave requested a new autosave, but there were no changes. This shouldn't\n\t\t// result in an error notice for the user.\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = publishStatus.indexOf( post.status ) !== -1;\n\t// If the post was being published, we show the corresponding publish error message\n\t// Unless we publish an \"updating failed\" message.\n\tconst messages = {\n\t\tpublish: __( 'Publishing failed.' ),\n\t\tprivate: __( 'Publishing failed.' ),\n\t\tfuture: __( 'Scheduling failed.' ),\n\t};\n\tlet noticeMessage =\n\t\t! isPublished && publishStatus.indexOf( edits.status ) !== -1\n\t\t\t? messages[ edits.status ]\n\t\t\t: __( 'Updating failed.' );\n\n\t// Check if message string contains HTML. Notice text is currently only\n\t// supported as plaintext, and stripping the tags may muddle the meaning.\n\tif ( error.message && ! /<\\/?[^>]*>/.test( error.message ) ) {\n\t\tnoticeMessage = [ noticeMessage, error.message ].join( ' ' );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n\n/**\n * Builds the trash fail notification arguments for dispatch.\n *\n * @param {Object} data\n *\n * @return {Array} Arguments for dispatch.\n */\nexport function getNotificationArgumentsForTrashFail( data ) {\n\treturn [\n\t\tdata.error.message && data.error.code !== 'unknown_error'\n\t\t\t? data.error.message\n\t\t\t: __( 'Trashing failed' ),\n\t\t{\n\t\t\tid: TRASH_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n"]}
@@ -40,11 +40,11 @@ export default function EntityTypeList(_ref) {
40
40
  closePanel
41
41
  } = _ref;
42
42
  const firstRecord = list[0];
43
- const entity = useSelect(select => select(coreStore).getEntity(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]);
43
+ const entityConfig = useSelect(select => select(coreStore).getEntityConfig(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]);
44
44
  const {
45
45
  name
46
46
  } = firstRecord;
47
- const entityLabel = name === 'wp_template_part' ? _n('Template Part', 'Template Parts', list.length) : entity.label; // Set description based on type of entity.
47
+ const entityLabel = name === 'wp_template_part' ? _n('Template Part', 'Template Parts', list.length) : entityConfig.label; // Set description based on type of entity.
48
48
 
49
49
  const description = getEntityDescription(name, list.length);
50
50
  return createElement(PanelBody, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/entities-saved-states/entity-type-list.js"],"names":["some","__","_n","useSelect","PanelBody","PanelRow","store","coreStore","EntityRecordItem","getEntityDescription","entity","length","EntityTypeList","list","unselectedEntities","setUnselectedEntities","closePanel","firstRecord","select","getEntity","kind","name","entityLabel","label","description","map","record","key","property","elt","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,SA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AAK,EAAGW,WAAnB;AAAiC,IAAA,WAAW,EAAG;AAA/C,KACGE,WAAW,IAAI,cAAC,QAAD,QAAYA,WAAZ,CADlB,EAEGX,IAAI,CAACY,GAAL,CAAYC,MAAF,IAAc;AACzB,WACC,cAAC,gBAAD;AACC,MAAA,GAAG,EAAGA,MAAM,CAACC,GAAP,IAAcD,MAAM,CAACE,QAD5B;AAEC,MAAA,MAAM,EAAGF,MAFV;AAGC,MAAA,OAAO,EACN,CAAE1B,IAAI,CACLc,kBADK,EAEHe,GAAF,IACCA,GAAG,CAACT,IAAJ,KAAaM,MAAM,CAACN,IAApB,IACAS,GAAG,CAACR,IAAJ,KAAaK,MAAM,CAACL,IADpB,IAEAQ,GAAG,CAACF,GAAJ,KAAYD,MAAM,CAACC,GAFnB,IAGAE,GAAG,CAACD,QAAJ,KAAiBF,MAAM,CAACE,QANpB,CAJR;AAaC,MAAA,QAAQ,EAAKE,KAAF,IACVf,qBAAqB,CAAEW,MAAF,EAAUI,KAAV,CAdvB;AAgBC,MAAA,UAAU,EAAGd;AAhBd,MADD;AAoBA,GArBC,CAFH,CADD;AA2BA","sourcesContent":["/**\n * External dependencies\n */\nimport { some } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody, PanelRow } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport EntityRecordItem from './entity-record-item';\n\nfunction getEntityDescription( entity, length ) {\n\tswitch ( entity ) {\n\t\tcase 'site':\n\t\t\treturn _n(\n\t\t\t\t'This change will affect your whole site.',\n\t\t\t\t'These changes will affect your whole site.',\n\t\t\t\tlength\n\t\t\t);\n\t\tcase 'wp_template':\n\t\t\treturn _n(\n\t\t\t\t'This change will affect pages and posts that use this template.',\n\t\t\t\t'These changes will affect pages and posts that use these templates.',\n\t\t\t\tlength\n\t\t\t);\n\t\tcase 'page':\n\t\tcase 'post':\n\t\t\treturn __( 'The following content has been modified.' );\n\t}\n}\n\nexport default function EntityTypeList( {\n\tlist,\n\tunselectedEntities,\n\tsetUnselectedEntities,\n\tclosePanel,\n} ) {\n\tconst firstRecord = list[ 0 ];\n\tconst entity = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntity( firstRecord.kind, firstRecord.name ),\n\t\t[ firstRecord.kind, firstRecord.name ]\n\t);\n\tconst { name } = firstRecord;\n\tconst entityLabel =\n\t\tname === 'wp_template_part'\n\t\t\t? _n( 'Template Part', 'Template Parts', list.length )\n\t\t\t: entity.label;\n\t// Set description based on type of entity.\n\tconst description = getEntityDescription( name, list.length );\n\n\treturn (\n\t\t<PanelBody title={ entityLabel } initialOpen={ true }>\n\t\t\t{ description && <PanelRow>{ description }</PanelRow> }\n\t\t\t{ list.map( ( record ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityRecordItem\n\t\t\t\t\t\tkey={ record.key || record.property }\n\t\t\t\t\t\trecord={ record }\n\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t! some(\n\t\t\t\t\t\t\t\tunselectedEntities,\n\t\t\t\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\t\t\t\telt.kind === record.kind &&\n\t\t\t\t\t\t\t\t\telt.name === record.name &&\n\t\t\t\t\t\t\t\t\telt.key === record.key &&\n\t\t\t\t\t\t\t\t\telt.property === record.property\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetUnselectedEntities( record, value )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclosePanel={ closePanel }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</PanelBody>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/entities-saved-states/entity-type-list.js"],"names":["some","__","_n","useSelect","PanelBody","PanelRow","store","coreStore","EntityRecordItem","getEntityDescription","entity","length","EntityTypeList","list","unselectedEntities","setUnselectedEntities","closePanel","firstRecord","entityConfig","select","getEntityConfig","kind","name","entityLabel","label","description","map","record","key","property","elt","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,uBAApC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;;AAEA,SAASC,oBAAT,CAA+BC,MAA/B,EAAuCC,MAAvC,EAAgD;AAC/C,UAASD,MAAT;AACC,SAAK,MAAL;AACC,aAAOR,EAAE,CACR,0CADQ,EAER,4CAFQ,EAGRS,MAHQ,CAAT;;AAKD,SAAK,aAAL;AACC,aAAOT,EAAE,CACR,iEADQ,EAER,qEAFQ,EAGRS,MAHQ,CAAT;;AAKD,SAAK,MAAL;AACA,SAAK,MAAL;AACC,aAAOV,EAAE,CAAE,0CAAF,CAAT;AAfF;AAiBA;;AAED,eAAe,SAASW,cAAT,OAKX;AAAA,MALoC;AACvCC,IAAAA,IADuC;AAEvCC,IAAAA,kBAFuC;AAGvCC,IAAAA,qBAHuC;AAIvCC,IAAAA;AAJuC,GAKpC;AACH,QAAMC,WAAW,GAAGJ,IAAI,CAAE,CAAF,CAAxB;AACA,QAAMK,YAAY,GAAGf,SAAS,CAC3BgB,MAAF,IACCA,MAAM,CAAEZ,SAAF,CAAN,CAAoBa,eAApB,CACCH,WAAW,CAACI,IADb,EAECJ,WAAW,CAACK,IAFb,CAF4B,EAM7B,CAAEL,WAAW,CAACI,IAAd,EAAoBJ,WAAW,CAACK,IAAhC,CAN6B,CAA9B;AAQA,QAAM;AAAEA,IAAAA;AAAF,MAAWL,WAAjB;AACA,QAAMM,WAAW,GAChBD,IAAI,KAAK,kBAAT,GACGpB,EAAE,CAAE,eAAF,EAAmB,gBAAnB,EAAqCW,IAAI,CAACF,MAA1C,CADL,GAEGO,YAAY,CAACM,KAHjB,CAXG,CAeH;;AACA,QAAMC,WAAW,GAAGhB,oBAAoB,CAAEa,IAAF,EAAQT,IAAI,CAACF,MAAb,CAAxC;AAEA,SACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGY,WAAnB;AAAiC,IAAA,WAAW,EAAG;AAA/C,KACGE,WAAW,IAAI,cAAC,QAAD,QAAYA,WAAZ,CADlB,EAEGZ,IAAI,CAACa,GAAL,CAAYC,MAAF,IAAc;AACzB,WACC,cAAC,gBAAD;AACC,MAAA,GAAG,EAAGA,MAAM,CAACC,GAAP,IAAcD,MAAM,CAACE,QAD5B;AAEC,MAAA,MAAM,EAAGF,MAFV;AAGC,MAAA,OAAO,EACN,CAAE3B,IAAI,CACLc,kBADK,EAEHgB,GAAF,IACCA,GAAG,CAACT,IAAJ,KAAaM,MAAM,CAACN,IAApB,IACAS,GAAG,CAACR,IAAJ,KAAaK,MAAM,CAACL,IADpB,IAEAQ,GAAG,CAACF,GAAJ,KAAYD,MAAM,CAACC,GAFnB,IAGAE,GAAG,CAACD,QAAJ,KAAiBF,MAAM,CAACE,QANpB,CAJR;AAaC,MAAA,QAAQ,EAAKE,KAAF,IACVhB,qBAAqB,CAAEY,MAAF,EAAUI,KAAV,CAdvB;AAgBC,MAAA,UAAU,EAAGf;AAhBd,MADD;AAoBA,GArBC,CAFH,CADD;AA2BA","sourcesContent":["/**\n * External dependencies\n */\nimport { some } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody, PanelRow } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport EntityRecordItem from './entity-record-item';\n\nfunction getEntityDescription( entity, length ) {\n\tswitch ( entity ) {\n\t\tcase 'site':\n\t\t\treturn _n(\n\t\t\t\t'This change will affect your whole site.',\n\t\t\t\t'These changes will affect your whole site.',\n\t\t\t\tlength\n\t\t\t);\n\t\tcase 'wp_template':\n\t\t\treturn _n(\n\t\t\t\t'This change will affect pages and posts that use this template.',\n\t\t\t\t'These changes will affect pages and posts that use these templates.',\n\t\t\t\tlength\n\t\t\t);\n\t\tcase 'page':\n\t\tcase 'post':\n\t\t\treturn __( 'The following content has been modified.' );\n\t}\n}\n\nexport default function EntityTypeList( {\n\tlist,\n\tunselectedEntities,\n\tsetUnselectedEntities,\n\tclosePanel,\n} ) {\n\tconst firstRecord = list[ 0 ];\n\tconst entityConfig = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityConfig(\n\t\t\t\tfirstRecord.kind,\n\t\t\t\tfirstRecord.name\n\t\t\t),\n\t\t[ firstRecord.kind, firstRecord.name ]\n\t);\n\tconst { name } = firstRecord;\n\tconst entityLabel =\n\t\tname === 'wp_template_part'\n\t\t\t? _n( 'Template Part', 'Template Parts', list.length )\n\t\t\t: entityConfig.label;\n\t// Set description based on type of entity.\n\tconst description = getEntityDescription( name, list.length );\n\n\treturn (\n\t\t<PanelBody title={ entityLabel } initialOpen={ true }>\n\t\t\t{ description && <PanelRow>{ description }</PanelRow> }\n\t\t\t{ list.map( ( record ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityRecordItem\n\t\t\t\t\t\tkey={ record.key || record.property }\n\t\t\t\t\t\trecord={ record }\n\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t! some(\n\t\t\t\t\t\t\t\tunselectedEntities,\n\t\t\t\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\t\t\t\telt.kind === record.kind &&\n\t\t\t\t\t\t\t\t\telt.name === record.name &&\n\t\t\t\t\t\t\t\t\telt.key === record.key &&\n\t\t\t\t\t\t\t\t\telt.property === record.property\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetUnselectedEntities( record, value )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclosePanel={ closePanel }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</PanelBody>\n\t);\n}\n"]}
@@ -177,7 +177,7 @@ function LocalAutosaveMonitor() {
177
177
  const {
178
178
  localAutosaveInterval
179
179
  } = useSelect(select => ({
180
- localAutosaveInterval: select(editorStore).getEditorSettings().__experimentalLocalAutosaveInterval
180
+ localAutosaveInterval: select(editorStore).getEditorSettings().localAutosaveInterval
181
181
  }), []);
182
182
  return createElement(AutosaveMonitor, {
183
183
  interval: localAutosaveInterval,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/local-autosave-monitor/index.js"],"names":["once","uniqueId","omit","useCallback","useEffect","useRef","ifCondition","usePrevious","useSelect","useDispatch","__","parse","store","noticesStore","AutosaveMonitor","localAutosaveGet","localAutosaveClear","editorStore","requestIdleCallback","window","requestAnimationFrame","hasSessionStorageSupport","sessionStorage","setItem","removeItem","error","useAutosaveNotice","postId","isEditedPostNew","hasRemoteAutosave","select","getCurrentPostId","getEditorSettings","autosave","getEditedPostAttribute","createWarningNotice","removeNotice","editPost","resetEditorBlocks","localAutosave","JSON","post_title","title","content","excerpt","edits","hasDifference","Object","keys","some","key","noticeId","id","actions","label","onClick","useAutosavePurge","isDirty","isAutosaving","didError","isEditedPostDirty","isAutosavingPost","didPostSaveRequestFail","lastIsDirty","lastIsAutosaving","current","wasEditedPostNew","prevPostId","LocalAutosaveMonitor","deferredAutosave","local","localAutosaveInterval","__experimentalLocalAutosaveInterval"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,QAAf,EAAyBC,IAAzB,QAAqC,QAArC;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,oBAA/C;AACA,SAASC,WAAT,EAAsBC,WAAtB,QAAyC,oBAAzC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAu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D,WAAW,CAAEe,wBAAF,CAAX,CAAyC+C,oBAAzC,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { once, uniqueId, omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { ifCondition, usePrevious } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { parse } from '@wordpress/blocks';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AutosaveMonitor from '../autosave-monitor';\nimport {\n\tlocalAutosaveGet,\n\tlocalAutosaveClear,\n} from '../../store/local-autosave';\nimport { store as editorStore } from '../../store';\n\nconst requestIdleCallback = window.requestIdleCallback\n\t? window.requestIdleCallback\n\t: window.requestAnimationFrame;\n\n/**\n * Function which returns true if the current environment supports browser\n * sessionStorage, or false otherwise. The result of this function is cached and\n * reused in subsequent invocations.\n */\nconst hasSessionStorageSupport = once( () => {\n\ttry {\n\t\t// Private Browsing in Safari 10 and earlier will throw an error when\n\t\t// attempting to set into sessionStorage. The test here is intentional in\n\t\t// causing a thrown error as condition bailing from local autosave.\n\t\twindow.sessionStorage.setItem( '__wpEditorTestSessionStorage', '' );\n\t\twindow.sessionStorage.removeItem( '__wpEditorTestSessionStorage' );\n\t\treturn true;\n\t} catch ( error ) {\n\t\treturn false;\n\t}\n} );\n\n/**\n * Custom hook which manages the creation of a notice prompting the user to\n * restore a local autosave, if one exists.\n */\nfunction useAutosaveNotice() {\n\tconst { postId, isEditedPostNew, hasRemoteAutosave } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\thasRemoteAutosave: !! select( editorStore ).getEditorSettings()\n\t\t\t\t.autosave,\n\t\t} ),\n\t\t[]\n\t);\n\tconst { getEditedPostAttribute } = useSelect( editorStore );\n\n\tconst { createWarningNotice, removeNotice } = useDispatch( noticesStore );\n\tconst { editPost, resetEditorBlocks } = useDispatch( editorStore );\n\n\tuseEffect( () => {\n\t\tlet localAutosave = localAutosaveGet( postId, isEditedPostNew );\n\t\tif ( ! localAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tlocalAutosave = JSON.parse( localAutosave );\n\t\t} catch ( error ) {\n\t\t\t// Not usable if it can't be parsed.\n\t\t\treturn;\n\t\t}\n\n\t\tconst { post_title: title, content, excerpt } = localAutosave;\n\t\tconst edits = { title, content, excerpt };\n\n\t\t{\n\t\t\t// Only display a notice if there is a difference between what has been\n\t\t\t// saved and that which is stored in sessionStorage.\n\t\t\tconst hasDifference = Object.keys( edits ).some( ( key ) => {\n\t\t\t\treturn edits[ key ] !== getEditedPostAttribute( key );\n\t\t\t} );\n\n\t\t\tif ( ! hasDifference ) {\n\t\t\t\t// If there is no difference, it can be safely ejected from storage.\n\t\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif ( hasRemoteAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst noticeId = uniqueId( 'wpEditorAutosaveRestore' );\n\t\tcreateWarningNotice(\n\t\t\t__(\n\t\t\t\t'The backup of this post in your browser is different from the version below.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tid: noticeId,\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Restore the backup' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\teditPost( omit( edits, [ 'content' ] ) );\n\t\t\t\t\t\t\tresetEditorBlocks( parse( edits.content ) );\n\t\t\t\t\t\t\tremoveNotice( noticeId );\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}\n\t\t);\n\t}, [ isEditedPostNew, postId ] );\n}\n\n/**\n * Custom hook which ejects a local autosave after a successful save occurs.\n */\nfunction useAutosavePurge() {\n\tconst {\n\t\tpostId,\n\t\tisEditedPostNew,\n\t\tisDirty,\n\t\tisAutosaving,\n\t\tdidError,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\tisDirty: select( editorStore ).isEditedPostDirty(),\n\t\t\tisAutosaving: select( editorStore ).isAutosavingPost(),\n\t\t\tdidError: select( editorStore ).didPostSaveRequestFail(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst lastIsDirty = useRef( isDirty );\n\tconst lastIsAutosaving = useRef( isAutosaving );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! didError &&\n\t\t\t( ( lastIsAutosaving.current && ! isAutosaving ) ||\n\t\t\t\t( lastIsDirty.current && ! isDirty ) )\n\t\t) {\n\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t}\n\n\t\tlastIsDirty.current = isDirty;\n\t\tlastIsAutosaving.current = isAutosaving;\n\t}, [ isDirty, isAutosaving, didError ] );\n\n\t// Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.\n\tconst wasEditedPostNew = usePrevious( isEditedPostNew );\n\tconst prevPostId = usePrevious( postId );\n\tuseEffect( () => {\n\t\tif ( prevPostId === postId && wasEditedPostNew && ! isEditedPostNew ) {\n\t\t\tlocalAutosaveClear( postId, true );\n\t\t}\n\t}, [ isEditedPostNew, postId ] );\n}\n\nfunction LocalAutosaveMonitor() {\n\tconst { autosave } = useDispatch( editorStore );\n\tconst deferredAutosave = useCallback( () => {\n\t\trequestIdleCallback( () => autosave( { local: true } ) );\n\t}, [] );\n\tuseAutosaveNotice();\n\tuseAutosavePurge();\n\n\tconst { localAutosaveInterval } = useSelect(\n\t\t( select ) => ( {\n\t\t\tlocalAutosaveInterval: select( editorStore ).getEditorSettings()\n\t\t\t\t.__experimentalLocalAutosaveInterval,\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<AutosaveMonitor\n\t\t\tinterval={ localAutosaveInterval }\n\t\t\tautosave={ deferredAutosave }\n\t\t/>\n\t);\n}\n\nexport default ifCondition( hasSessionStorageSupport )( LocalAutosaveMonitor );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/local-autosave-monitor/index.js"],"names":["once","uniqueId","omit","useCallback","useEffect","useRef","ifCondition","usePrevious","useSelect","useDispatch","__","parse","store","noticesStore","AutosaveMonitor","localAutosaveGet","localAutosaveClear","editorStore","requestIdleCallback","window","requestAnimationFrame","hasSessionStorageSupport","sessionStorage","setItem","removeItem","error","useAutosaveNotice","postId","isEditedPostNew","hasRemoteAutosave","select","getCurrentPostId","getEditorSettings","autosave","getEditedPostAttribute","createWarningNotice","removeNotice","editPost","resetEditorBlocks","localAutosave","JSON","post_title","title","content","excerpt","edits","hasDifference","Object","keys","some","key","noticeId","id","actions","label","onClick","useAutosavePurge","isDirty","isAutosaving","didError","isEditedPostDirty","isAutosavingPost","didPostSaveRequestFail","lastIsDirty","lastIsAutosaving","current","wasEditedPostNew","prevPostId","LocalAutosaveMonitor","deferredAutosave","local","localAutosaveInterval"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,QAAf,EAAyBC,IAAzB,QAAqC,QAArC;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,oBAA/C;AACA,SAASC,WAAT,EAAsBC,WAAtB,QAAyC,oBAAzC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,QAAsB,mBAAtB;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,SACCC,gBADD,EAECC,kBAFD,QAGO,4BAHP;AAIA,SAASJ,KAAK,IAAIK,WAAlB,QAAqC,aAArC;AAEA,MAAMC,mBAAmB,GAAGC,MAA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;AACA,QAAMuC,UAAU,GAAG5D,WAAW,CAAEoB,MAAF,CAA9B;AACAvB,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAK+D,UAAU,KAAKxC,MAAf,IAAyBuC,gBAAzB,IAA6C,CAAEtC,eAApD,EAAsE;AACrEZ,MAAAA,kBAAkB,CAAEW,MAAF,EAAU,IAAV,CAAlB;AACA;AACD,GAJQ,EAIN,CAAEC,eAAF,EAAmBD,MAAnB,CAJM,CAAT;AAKA;;AAED,SAASyC,oBAAT,GAAgC;AAC/B,QAAM;AAAEnC,IAAAA;AAAF,MAAexB,WAAW,CAAEQ,WAAF,CAAhC;AACA,QAAMoD,gBAAgB,GAAGlE,WAAW,CAAE,MAAM;AAC3Ce,IAAAA,mBAAmB,CAAE,MAAMe,QAAQ,CAAE;AAAEqC,MAAAA,KAAK,EAAE;AAAT,KAAF,CAAhB,CAAnB;AACA,GAFmC,EAEjC,EAFiC,CAApC;AAGA5C,EAAAA,iBAAiB;AACjB8B,EAAAA,gBAAgB;AAEhB,QAAM;AAAEe,IAAAA;AAAF,MAA4B/D,SAAS,CACxCsB,MAAF,KAAgB;AACfyC,IAAAA,qBAAqB,EAAEzC,MAAM,CAAEb,WAAF,CAAN,CAAsBe,iBAAtB,GACrBuC;AAFa,GAAhB,CAD0C,EAK1C,EAL0C,CAA3C;AAQA,SACC,cAAC,eAAD;AACC,IAAA,QAAQ,EAAGA,qBADZ;AAEC,IAAA,QAAQ,EAAGF;AAFZ,IADD;AAMA;;AAED,eAAe/D,WAAW,CAAEe,wBAAF,CAAX,CAAyC+C,oBAAzC,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { once, uniqueId, omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { ifCondition, usePrevious } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { parse } from '@wordpress/blocks';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AutosaveMonitor from '../autosave-monitor';\nimport {\n\tlocalAutosaveGet,\n\tlocalAutosaveClear,\n} from '../../store/local-autosave';\nimport { store as editorStore } from '../../store';\n\nconst requestIdleCallback = window.requestIdleCallback\n\t? window.requestIdleCallback\n\t: window.requestAnimationFrame;\n\n/**\n * Function which returns true if the current environment supports browser\n * sessionStorage, or false otherwise. The result of this function is cached and\n * reused in subsequent invocations.\n */\nconst hasSessionStorageSupport = once( () => {\n\ttry {\n\t\t// Private Browsing in Safari 10 and earlier will throw an error when\n\t\t// attempting to set into sessionStorage. The test here is intentional in\n\t\t// causing a thrown error as condition bailing from local autosave.\n\t\twindow.sessionStorage.setItem( '__wpEditorTestSessionStorage', '' );\n\t\twindow.sessionStorage.removeItem( '__wpEditorTestSessionStorage' );\n\t\treturn true;\n\t} catch ( error ) {\n\t\treturn false;\n\t}\n} );\n\n/**\n * Custom hook which manages the creation of a notice prompting the user to\n * restore a local autosave, if one exists.\n */\nfunction useAutosaveNotice() {\n\tconst { postId, isEditedPostNew, hasRemoteAutosave } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\thasRemoteAutosave: !! select( editorStore ).getEditorSettings()\n\t\t\t\t.autosave,\n\t\t} ),\n\t\t[]\n\t);\n\tconst { getEditedPostAttribute } = useSelect( editorStore );\n\n\tconst { createWarningNotice, removeNotice } = useDispatch( noticesStore );\n\tconst { editPost, resetEditorBlocks } = useDispatch( editorStore );\n\n\tuseEffect( () => {\n\t\tlet localAutosave = localAutosaveGet( postId, isEditedPostNew );\n\t\tif ( ! localAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tlocalAutosave = JSON.parse( localAutosave );\n\t\t} catch ( error ) {\n\t\t\t// Not usable if it can't be parsed.\n\t\t\treturn;\n\t\t}\n\n\t\tconst { post_title: title, content, excerpt } = localAutosave;\n\t\tconst edits = { title, content, excerpt };\n\n\t\t{\n\t\t\t// Only display a notice if there is a difference between what has been\n\t\t\t// saved and that which is stored in sessionStorage.\n\t\t\tconst hasDifference = Object.keys( edits ).some( ( key ) => {\n\t\t\t\treturn edits[ key ] !== getEditedPostAttribute( key );\n\t\t\t} );\n\n\t\t\tif ( ! hasDifference ) {\n\t\t\t\t// If there is no difference, it can be safely ejected from storage.\n\t\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif ( hasRemoteAutosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst noticeId = uniqueId( 'wpEditorAutosaveRestore' );\n\t\tcreateWarningNotice(\n\t\t\t__(\n\t\t\t\t'The backup of this post in your browser is different from the version below.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tid: noticeId,\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Restore the backup' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\teditPost( omit( edits, [ 'content' ] ) );\n\t\t\t\t\t\t\tresetEditorBlocks( parse( edits.content ) );\n\t\t\t\t\t\t\tremoveNotice( noticeId );\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}\n\t\t);\n\t}, [ isEditedPostNew, postId ] );\n}\n\n/**\n * Custom hook which ejects a local autosave after a successful save occurs.\n */\nfunction useAutosavePurge() {\n\tconst {\n\t\tpostId,\n\t\tisEditedPostNew,\n\t\tisDirty,\n\t\tisAutosaving,\n\t\tdidError,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t\tisEditedPostNew: select( editorStore ).isEditedPostNew(),\n\t\t\tisDirty: select( editorStore ).isEditedPostDirty(),\n\t\t\tisAutosaving: select( editorStore ).isAutosavingPost(),\n\t\t\tdidError: select( editorStore ).didPostSaveRequestFail(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst lastIsDirty = useRef( isDirty );\n\tconst lastIsAutosaving = useRef( isAutosaving );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! didError &&\n\t\t\t( ( lastIsAutosaving.current && ! isAutosaving ) ||\n\t\t\t\t( lastIsDirty.current && ! isDirty ) )\n\t\t) {\n\t\t\tlocalAutosaveClear( postId, isEditedPostNew );\n\t\t}\n\n\t\tlastIsDirty.current = isDirty;\n\t\tlastIsAutosaving.current = isAutosaving;\n\t}, [ isDirty, isAutosaving, didError ] );\n\n\t// Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.\n\tconst wasEditedPostNew = usePrevious( isEditedPostNew );\n\tconst prevPostId = usePrevious( postId );\n\tuseEffect( () => {\n\t\tif ( prevPostId === postId && wasEditedPostNew && ! isEditedPostNew ) {\n\t\t\tlocalAutosaveClear( postId, true );\n\t\t}\n\t}, [ isEditedPostNew, postId ] );\n}\n\nfunction LocalAutosaveMonitor() {\n\tconst { autosave } = useDispatch( editorStore );\n\tconst deferredAutosave = useCallback( () => {\n\t\trequestIdleCallback( () => autosave( { local: true } ) );\n\t}, [] );\n\tuseAutosaveNotice();\n\tuseAutosavePurge();\n\n\tconst { localAutosaveInterval } = useSelect(\n\t\t( select ) => ( {\n\t\t\tlocalAutosaveInterval: select( editorStore ).getEditorSettings()\n\t\t\t\t.localAutosaveInterval,\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<AutosaveMonitor\n\t\t\tinterval={ localAutosaveInterval }\n\t\t\tautosave={ deferredAutosave }\n\t\t/>\n\t);\n}\n\nexport default ifCondition( hasSessionStorageSupport )( LocalAutosaveMonitor );\n"]}
@@ -8,23 +8,22 @@ export const PREFERENCES_DEFAULTS = {
8
8
  isPublishSidebarEnabled: true
9
9
  };
10
10
  /**
11
- * The default post editor settings
11
+ * The default post editor settings.
12
12
  *
13
- * allowedBlockTypes boolean|Array Allowed block types
14
- * richEditingEnabled boolean Whether rich editing is enabled or not
15
- * codeEditingEnabled boolean Whether code editing is enabled or not
16
- * enableCustomFields boolean Whether the WordPress custom fields are enabled or not.
17
- * true = the user has opted to show the Custom Fields panel at the bottom of the editor.
18
- * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
19
- * undefined = the current environment does not support Custom Fields,
20
- * so the option toggle in Preferences -> Panels to
21
- * enable the Custom Fields panel is not displayed.
22
- * autosaveInterval number Autosave Interval
23
- * availableTemplates array? The available post templates
24
- * disablePostFormats boolean Whether or not the post formats are disabled
25
- * allowedMimeTypes array? List of allowed mime types and file extensions
26
- * maxUploadFileSize number Maximum upload file size
27
- * supportsLayout boolean Whether the editor supports layouts.
13
+ * @property {boolean|Array} allowedBlockTypes Allowed block types
14
+ * @property {boolean} richEditingEnabled Whether rich editing is enabled or not
15
+ * @property {boolean} codeEditingEnabled Whether code editing is enabled or not
16
+ * @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
17
+ * true = the user has opted to show the Custom Fields panel at the bottom of the editor.
18
+ * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
19
+ * undefined = the current environment does not support Custom Fields, so the option toggle in Preferences -> Panels to enable the Custom Fields panel is not displayed.
20
+ * @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.
21
+ * @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.
22
+ * @property {Array?} availableTemplates The available post templates
23
+ * @property {boolean} disablePostFormats Whether or not the post formats are disabled
24
+ * @property {Array?} allowedMimeTypes List of allowed mime types and file extensions
25
+ * @property {number} maxUploadFileSize Maximum upload file size
26
+ * @property {boolean} supportsLayout Whether the editor supports layouts.
28
27
  */
29
28
 
30
29
  export const EDITOR_SETTINGS_DEFAULTS = { ...SETTINGS_DEFAULTS,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/store/defaults.js"],"names":["SETTINGS_DEFAULTS","PREFERENCES_DEFAULTS","insertUsage","isPublishSidebarEnabled","EDITOR_SETTINGS_DEFAULTS","richEditingEnabled","codeEditingEnabled","enableCustomFields","undefined","supportsLayout"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,iBAAT,QAAkC,yBAAlC;AAEA,OAAO,MAAMC,oBAAoB,GAAG;AACnCC,EAAAA,WAAW,EAAE,EADsB;AAClB;AACjBC,EAAAA,uBAAuB,EAAE;AAFU,CAA7B;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,wBAAwB,GAAG,EACvC,GAAGJ,iBADoC;AAGvCK,EAAAA,kBAAkB,EAAE,IAHmB;AAIvCC,EAAAA,kBAAkB,EAAE,IAJmB;AAKvCC,EAAAA,kBAAkB,EAAEC,SALmB;AAMvCC,EAAAA,cAAc,EAAE;AANuB,CAAjC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SETTINGS_DEFAULTS } from '@wordpress/block-editor';\n\nexport const PREFERENCES_DEFAULTS = {\n\tinsertUsage: {}, // Should be kept for backward compatibility, see: https://github.com/WordPress/gutenberg/issues/14580.\n\tisPublishSidebarEnabled: true,\n};\n\n/**\n * The default post editor settings\n *\n * allowedBlockTypes boolean|Array Allowed block types\n * richEditingEnabled boolean Whether rich editing is enabled or not\n * codeEditingEnabled boolean Whether code editing is enabled or not\n * enableCustomFields boolean Whether the WordPress custom fields are enabled or not.\n * true = the user has opted to show the Custom Fields panel at the bottom of the editor.\n * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.\n * undefined = the current environment does not support Custom Fields,\n * so the option toggle in Preferences -> Panels to\n * enable the Custom Fields panel is not displayed.\n * autosaveInterval number Autosave Interval\n * availableTemplates array? The available post templates\n * disablePostFormats boolean Whether or not the post formats are disabled\n * allowedMimeTypes array? List of allowed mime types and file extensions\n * maxUploadFileSize number Maximum upload file size\n * supportsLayout boolean Whether the editor supports layouts.\n */\nexport const EDITOR_SETTINGS_DEFAULTS = {\n\t...SETTINGS_DEFAULTS,\n\n\trichEditingEnabled: true,\n\tcodeEditingEnabled: true,\n\tenableCustomFields: undefined,\n\tsupportsLayout: true,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/store/defaults.js"],"names":["SETTINGS_DEFAULTS","PREFERENCES_DEFAULTS","insertUsage","isPublishSidebarEnabled","EDITOR_SETTINGS_DEFAULTS","richEditingEnabled","codeEditingEnabled","enableCustomFields","undefined","supportsLayout"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,iBAAT,QAAkC,yBAAlC;AAEA,OAAO,MAAMC,oBAAoB,GAAG;AACnCC,EAAAA,WAAW,EAAE,EADsB;AAClB;AACjBC,EAAAA,uBAAuB,EAAE;AAFU,CAA7B;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,wBAAwB,GAAG,EACvC,GAAGJ,iBADoC;AAGvCK,EAAAA,kBAAkB,EAAE,IAHmB;AAIvCC,EAAAA,kBAAkB,EAAE,IAJmB;AAKvCC,EAAAA,kBAAkB,EAAEC,SALmB;AAMvCC,EAAAA,cAAc,EAAE;AANuB,CAAjC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SETTINGS_DEFAULTS } from '@wordpress/block-editor';\n\nexport const PREFERENCES_DEFAULTS = {\n\tinsertUsage: {}, // Should be kept for backward compatibility, see: https://github.com/WordPress/gutenberg/issues/14580.\n\tisPublishSidebarEnabled: true,\n};\n\n/**\n * The default post editor settings.\n *\n * @property {boolean|Array} allowedBlockTypes Allowed block types\n * @property {boolean} richEditingEnabled Whether rich editing is enabled or not\n * @property {boolean} codeEditingEnabled Whether code editing is enabled or not\n * @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.\n * true = the user has opted to show the Custom Fields panel at the bottom of the editor.\n * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.\n * undefined = the current environment does not support Custom Fields, so the option toggle in Preferences -> Panels to enable the Custom Fields panel is not displayed.\n * @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.\n * @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.\n * @property {Array?} availableTemplates The available post templates\n * @property {boolean} disablePostFormats Whether or not the post formats are disabled\n * @property {Array?} allowedMimeTypes List of allowed mime types and file extensions\n * @property {number} maxUploadFileSize Maximum upload file size\n * @property {boolean} supportsLayout Whether the editor supports layouts.\n */\nexport const EDITOR_SETTINGS_DEFAULTS = {\n\t...SETTINGS_DEFAULTS,\n\n\trichEditingEnabled: true,\n\tcodeEditingEnabled: true,\n\tenableCustomFields: undefined,\n\tsupportsLayout: true,\n};\n"]}
@@ -41,12 +41,13 @@ export function getNotificationArgumentsForSaveSuccess(data) {
41
41
  const isPublished = includes(publishStatus, previousPost.status);
42
42
  const willPublish = includes(publishStatus, post.status);
43
43
  let noticeMessage;
44
- let shouldShowLink = get(postType, ['viewable'], false); // Always should a notice, which will be spoken for accessibility.
44
+ let shouldShowLink = get(postType, ['viewable'], false);
45
+ let isDraft; // Always should a notice, which will be spoken for accessibility.
45
46
 
46
47
  if (!isPublished && !willPublish) {
47
48
  // If saving a non-published post, don't show notice.
48
- noticeMessage = __('Draft saved');
49
- shouldShowLink = false;
49
+ noticeMessage = __('Draft saved.');
50
+ isDraft = true;
50
51
  } else if (isPublished && !willPublish) {
51
52
  // If undoing publish status, show specific notice.
52
53
  noticeMessage = postType.labels.item_reverted_to_draft;
@@ -68,7 +69,7 @@ export function getNotificationArgumentsForSaveSuccess(data) {
68
69
 
69
70
  if (shouldShowLink) {
70
71
  actions.push({
71
- label: postType.labels.view_item,
72
+ label: isDraft ? __('View Preview') : postType.labels.view_item,
72
73
  url: post.link
73
74
  });
74
75
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/store/utils/notice-builder.js"],"names":["__","SAVE_POST_NOTICE_ID","TRASH_POST_NOTICE_ID","get","includes","getNotificationArgumentsForSaveSuccess","data","previousPost","post","postType","options","status","publishStatus","isPublished","willPublish","noticeMessage","shouldShowLink","labels","item_reverted_to_draft","publish","item_published","private","item_published_privately","future","item_scheduled","item_updated","actions","push","label","view_item","url","link","id","type","getNotificationArgumentsForSaveFail","edits","error","code","indexOf","messages","message","test","join","getNotificationArgumentsForTrashFail"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,mBAAT,EAA8BC,oBAA9B,QAA0D,cAA1D;AAEA;AACA;AACA;;AACA,SAASC,GAAT,EAAcC,QAAd,QAA8B,QAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sCAAT,CAAiDC,IAAjD,EAAwD;AAC9D,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA,IAAhB;AAAsBC,IAAAA;AAAtB,MAAmCH,IAAzC,CAD8D,CAE9D;;AACA,MAAKH,GAAG,CAAEG,IAAI,CAACI,OAAP,EAAgB,CAAE,YAAF,CAAhB,CAAR,EAA6C;AAC5C,WAAO,EAAP;AACA,GAL6D,CAO9D;;;AACA,MAAKF,IAAI,CAACG,MAAL,KAAgB,OAAhB,IAA2BJ,YAAY,CAACI,MAAb,KAAwB,OAAxD,EAAkE;AACjE,WAAO,EAAP;AACA;;AAED,QAAMC,aAAa,GAAG,CAAE,SAAF,EAAa,SAAb,EAAwB,QAAxB,CAAtB;AACA,QAAMC,WAAW,GAAGT,QAAQ,CAAEQ,aAAF,EAAiBL,YAAY,CAACI,MAA9B,CAA5B;AACA,QAAMG,WAAW,GAAGV,QAAQ,CAAEQ,aAAF,EAAiBJ,IAAI,CAACG,MAAtB,CAA5B;AAEA,MAAII,aAAJ;AACA,MAAIC,cAAc,GAAGb,GAAG,CAAEM,QAAF,EAAY,CAAE,UAAF,CAAZ,EAA4B,KAA5B,CAAxB,CAjB8D,CAmB9D;;AACA,MAAK,CAAEI,WAAF,IAAiB,CAAEC,WAAxB,EAAsC;AACrC;AACAC,IAAAA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AA,EAAE,EAAE9B;AADL,GAJM,CAAP;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { SAVE_POST_NOTICE_ID, TRASH_POST_NOTICE_ID } from '../constants';\n\n/**\n * External dependencies\n */\nimport { get, includes } from 'lodash';\n\n/**\n * Builds the arguments for a success notification dispatch.\n *\n * @param {Object} data Incoming data to build the arguments from.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveSuccess( data ) {\n\tconst { previousPost, post, postType } = data;\n\t// Autosaves are neither shown a notice nor redirected.\n\tif ( get( data.options, [ 'isAutosave' ] ) ) {\n\t\treturn [];\n\t}\n\n\t// No notice is shown after trashing a post\n\tif ( post.status === 'trash' && previousPost.status !== 'trash' ) {\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = includes( publishStatus, previousPost.status );\n\tconst willPublish = includes( publishStatus, post.status );\n\n\tlet noticeMessage;\n\tlet shouldShowLink = get( postType, [ 'viewable' ], false );\n\n\t// Always should a notice, which will be spoken for accessibility.\n\tif ( ! isPublished && ! willPublish ) {\n\t\t// If saving a non-published post, don't show notice.\n\t\tnoticeMessage = __( 'Draft saved' );\n\t\tshouldShowLink = false;\n\t} else if ( isPublished && ! willPublish ) {\n\t\t// If undoing publish status, show specific notice.\n\t\tnoticeMessage = postType.labels.item_reverted_to_draft;\n\t\tshouldShowLink = false;\n\t} else if ( ! isPublished && willPublish ) {\n\t\t// If publishing or scheduling a post, show the corresponding\n\t\t// publish message.\n\t\tnoticeMessage = {\n\t\t\tpublish: postType.labels.item_published,\n\t\t\tprivate: postType.labels.item_published_privately,\n\t\t\tfuture: postType.labels.item_scheduled,\n\t\t}[ post.status ];\n\t} else {\n\t\t// Generic fallback notice.\n\t\tnoticeMessage = postType.labels.item_updated;\n\t}\n\n\tconst actions = [];\n\tif ( shouldShowLink ) {\n\t\tactions.push( {\n\t\t\tlabel: postType.labels.view_item,\n\t\t\turl: post.link,\n\t\t} );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t\ttype: 'snackbar',\n\t\t\tactions,\n\t\t},\n\t];\n}\n\n/**\n * Builds the fail notification arguments for dispatch.\n *\n * @param {Object} data Incoming data to build the arguments with.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveFail( data ) {\n\tconst { post, edits, error } = data;\n\tif ( error && 'rest_autosave_no_changes' === error.code ) {\n\t\t// Autosave requested a new autosave, but there were no changes. This shouldn't\n\t\t// result in an error notice for the user.\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = publishStatus.indexOf( post.status ) !== -1;\n\t// If the post was being published, we show the corresponding publish error message\n\t// Unless we publish an \"updating failed\" message.\n\tconst messages = {\n\t\tpublish: __( 'Publishing failed.' ),\n\t\tprivate: __( 'Publishing failed.' ),\n\t\tfuture: __( 'Scheduling failed.' ),\n\t};\n\tlet noticeMessage =\n\t\t! isPublished && publishStatus.indexOf( edits.status ) !== -1\n\t\t\t? messages[ edits.status ]\n\t\t\t: __( 'Updating failed.' );\n\n\t// Check if message string contains HTML. Notice text is currently only\n\t// supported as plaintext, and stripping the tags may muddle the meaning.\n\tif ( error.message && ! /<\\/?[^>]*>/.test( error.message ) ) {\n\t\tnoticeMessage = [ noticeMessage, error.message ].join( ' ' );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n\n/**\n * Builds the trash fail notification arguments for dispatch.\n *\n * @param {Object} data\n *\n * @return {Array} Arguments for dispatch.\n */\nexport function getNotificationArgumentsForTrashFail( data ) {\n\treturn [\n\t\tdata.error.message && data.error.code !== 'unknown_error'\n\t\t\t? data.error.message\n\t\t\t: __( 'Trashing failed' ),\n\t\t{\n\t\t\tid: TRASH_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/store/utils/notice-builder.js"],"names":["__","SAVE_POST_NOTICE_ID","TRASH_POST_NOTICE_ID","get","includes","getNotificationArgumentsForSaveSuccess","data","previousPost","post","postType","options","status","publishStatus","isPublished","willPublish","noticeMessage","shouldShowLink","isDraft","labels","item_reverted_to_draft","publish","item_published","private","item_published_privately","future","item_scheduled","item_updated","actions","push","label","view_item","url","link","id","type","getNotificationArgumentsForSaveFail","edits","error","code","indexOf","messages","message","test","join","getNotificationArgumentsForTrashFail"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,mBAAT,EAA8BC,oBAA9B,QAA0D,cAA1D;AAEA;AACA;AACA;;AACA,SAASC,GAAT,EAAcC,QAAd,QAA8B,QAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sCAAT,CAAiDC,IAAjD,EAAwD;AAC9D,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA,IAAhB;AAAsBC,IAAAA;AAAtB,MAAmCH,IAAzC,CAD8D,CAE9D;;AACA,MAAKH,GAAG,CAAEG,IAAI,CAACI,OAAP,EAAgB,CAAE,YAAF,CAAhB,CAAR,EAA6C;AAC5C,WAAO,EAAP;AACA,GAL6D,CAO9D;;;AACA,MAAKF,IAAI,CAACG,MAAL,KAAgB,OAAhB,IAA2BJ,YAAY,CAACI,MAAb,KAAwB,OAAxD,EAAkE;AACjE,WAAO,EAAP;AACA;;AAED,QAAMC,aAAa,GAAG,CAAE,SAAF,EAAa,SAAb,EAAwB,QAAxB,CAAtB;AACA,QAAMC,WAAW,GAAGT,QAAQ,CAAEQ,aAAF,EAAiBL,YAAY,CAACI,MAA9B,CAA5B;AACA,QAAMG,WAAW,GAAGV,QAAQ,CAAEQ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L,GAFM,CAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAAS2C,oCAAT,CAA+CtC,IAA/C,EAAsD;AAC5D,SAAO,CACNA,IAAI,CAAC+B,KAAL,CAAWI,OAAX,IAAsBnC,IAAI,CAAC+B,KAAL,CAAWC,IAAX,KAAoB,eAA1C,GACGhC,IAAI,CAAC+B,KAAL,CAAWI,OADd,GAEGzC,EAAE,CAAE,iBAAF,CAHC,EAIN;AACCiC,IAAAA,EAAE,EAAE/B;AADL,GAJM,CAAP;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { SAVE_POST_NOTICE_ID, TRASH_POST_NOTICE_ID } from '../constants';\n\n/**\n * External dependencies\n */\nimport { get, includes } from 'lodash';\n\n/**\n * Builds the arguments for a success notification dispatch.\n *\n * @param {Object} data Incoming data to build the arguments from.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveSuccess( data ) {\n\tconst { previousPost, post, postType } = data;\n\t// Autosaves are neither shown a notice nor redirected.\n\tif ( get( data.options, [ 'isAutosave' ] ) ) {\n\t\treturn [];\n\t}\n\n\t// No notice is shown after trashing a post\n\tif ( post.status === 'trash' && previousPost.status !== 'trash' ) {\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = includes( publishStatus, previousPost.status );\n\tconst willPublish = includes( publishStatus, post.status );\n\n\tlet noticeMessage;\n\tlet shouldShowLink = get( postType, [ 'viewable' ], false );\n\tlet isDraft;\n\n\t// Always should a notice, which will be spoken for accessibility.\n\tif ( ! isPublished && ! willPublish ) {\n\t\t// If saving a non-published post, don't show notice.\n\t\tnoticeMessage = __( 'Draft saved.' );\n\t\tisDraft = true;\n\t} else if ( isPublished && ! willPublish ) {\n\t\t// If undoing publish status, show specific notice.\n\t\tnoticeMessage = postType.labels.item_reverted_to_draft;\n\t\tshouldShowLink = false;\n\t} else if ( ! isPublished && willPublish ) {\n\t\t// If publishing or scheduling a post, show the corresponding\n\t\t// publish message.\n\t\tnoticeMessage = {\n\t\t\tpublish: postType.labels.item_published,\n\t\t\tprivate: postType.labels.item_published_privately,\n\t\t\tfuture: postType.labels.item_scheduled,\n\t\t}[ post.status ];\n\t} else {\n\t\t// Generic fallback notice.\n\t\tnoticeMessage = postType.labels.item_updated;\n\t}\n\n\tconst actions = [];\n\tif ( shouldShowLink ) {\n\t\tactions.push( {\n\t\t\tlabel: isDraft ? __( 'View Preview' ) : postType.labels.view_item,\n\t\t\turl: post.link,\n\t\t} );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t\ttype: 'snackbar',\n\t\t\tactions,\n\t\t},\n\t];\n}\n\n/**\n * Builds the fail notification arguments for dispatch.\n *\n * @param {Object} data Incoming data to build the arguments with.\n *\n * @return {Array} Arguments for dispatch. An empty array signals no\n * notification should be sent.\n */\nexport function getNotificationArgumentsForSaveFail( data ) {\n\tconst { post, edits, error } = data;\n\tif ( error && 'rest_autosave_no_changes' === error.code ) {\n\t\t// Autosave requested a new autosave, but there were no changes. This shouldn't\n\t\t// result in an error notice for the user.\n\t\treturn [];\n\t}\n\n\tconst publishStatus = [ 'publish', 'private', 'future' ];\n\tconst isPublished = publishStatus.indexOf( post.status ) !== -1;\n\t// If the post was being published, we show the corresponding publish error message\n\t// Unless we publish an \"updating failed\" message.\n\tconst messages = {\n\t\tpublish: __( 'Publishing failed.' ),\n\t\tprivate: __( 'Publishing failed.' ),\n\t\tfuture: __( 'Scheduling failed.' ),\n\t};\n\tlet noticeMessage =\n\t\t! isPublished && publishStatus.indexOf( edits.status ) !== -1\n\t\t\t? messages[ edits.status ]\n\t\t\t: __( 'Updating failed.' );\n\n\t// Check if message string contains HTML. Notice text is currently only\n\t// supported as plaintext, and stripping the tags may muddle the meaning.\n\tif ( error.message && ! /<\\/?[^>]*>/.test( error.message ) ) {\n\t\tnoticeMessage = [ noticeMessage, error.message ].join( ' ' );\n\t}\n\treturn [\n\t\tnoticeMessage,\n\t\t{\n\t\t\tid: SAVE_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n\n/**\n * Builds the trash fail notification arguments for dispatch.\n *\n * @param {Object} data\n *\n * @return {Array} Arguments for dispatch.\n */\nexport function getNotificationArgumentsForTrashFail( data ) {\n\treturn [\n\t\tdata.error.message && data.error.code !== 'unknown_error'\n\t\t\t? data.error.message\n\t\t\t: __( 'Trashing failed' ),\n\t\t{\n\t\t\tid: TRASH_POST_NOTICE_ID,\n\t\t},\n\t];\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "12.4.0-next.e230fbab09.0",
3
+ "version": "12.4.0",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,30 +31,30 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.4.0-next.e230fbab09.0",
35
- "@wordpress/api-fetch": "^6.1.0-next.e230fbab09.0",
36
- "@wordpress/block-editor": "^8.3.0-next.e230fbab09.0",
37
- "@wordpress/blocks": "^11.3.0-next.e230fbab09.0",
38
- "@wordpress/components": "^19.7.0-next.e230fbab09.0",
39
- "@wordpress/compose": "^5.2.0-next.e230fbab09.0",
40
- "@wordpress/core-data": "^4.2.0-next.e230fbab09.0",
41
- "@wordpress/data": "^6.4.0-next.e230fbab09.0",
42
- "@wordpress/date": "^4.4.0-next.e230fbab09.0",
43
- "@wordpress/deprecated": "^3.4.0-next.e230fbab09.0",
44
- "@wordpress/element": "^4.3.0-next.e230fbab09.0",
45
- "@wordpress/hooks": "^3.4.0-next.e230fbab09.0",
46
- "@wordpress/html-entities": "^3.4.0-next.e230fbab09.0",
47
- "@wordpress/i18n": "^4.4.0-next.e230fbab09.0",
48
- "@wordpress/icons": "^7.1.0-next.e230fbab09.0",
49
- "@wordpress/keyboard-shortcuts": "^3.2.0-next.e230fbab09.0",
50
- "@wordpress/keycodes": "^3.4.0-next.e230fbab09.0",
51
- "@wordpress/media-utils": "^3.2.0-next.e230fbab09.0",
52
- "@wordpress/notices": "^3.4.0-next.e230fbab09.0",
53
- "@wordpress/reusable-blocks": "^3.2.0-next.e230fbab09.0",
54
- "@wordpress/rich-text": "^5.2.0-next.e230fbab09.0",
55
- "@wordpress/server-side-render": "^3.2.0-next.e230fbab09.0",
56
- "@wordpress/url": "^3.5.0-next.e230fbab09.0",
57
- "@wordpress/wordcount": "^3.4.0-next.e230fbab09.0",
34
+ "@wordpress/a11y": "^3.5.0",
35
+ "@wordpress/api-fetch": "^6.2.0",
36
+ "@wordpress/block-editor": "^8.4.0",
37
+ "@wordpress/blocks": "^11.4.0",
38
+ "@wordpress/components": "^19.7.0",
39
+ "@wordpress/compose": "^5.3.0",
40
+ "@wordpress/core-data": "^4.3.0",
41
+ "@wordpress/data": "^6.5.0",
42
+ "@wordpress/date": "^4.5.0",
43
+ "@wordpress/deprecated": "^3.5.0",
44
+ "@wordpress/element": "^4.3.0",
45
+ "@wordpress/hooks": "^3.5.0",
46
+ "@wordpress/html-entities": "^3.5.0",
47
+ "@wordpress/i18n": "^4.5.0",
48
+ "@wordpress/icons": "^8.1.0",
49
+ "@wordpress/keyboard-shortcuts": "^3.3.0",
50
+ "@wordpress/keycodes": "^3.5.0",
51
+ "@wordpress/media-utils": "^3.3.0",
52
+ "@wordpress/notices": "^3.5.0",
53
+ "@wordpress/reusable-blocks": "^3.3.0",
54
+ "@wordpress/rich-text": "^5.3.0",
55
+ "@wordpress/server-side-render": "^3.3.0",
56
+ "@wordpress/url": "^3.6.0",
57
+ "@wordpress/wordcount": "^3.5.0",
58
58
  "classnames": "^2.3.1",
59
59
  "lodash": "^4.17.21",
60
60
  "memize": "^1.1.0",
@@ -68,5 +68,5 @@
68
68
  "publishConfig": {
69
69
  "access": "public"
70
70
  },
71
- "gitHead": "308df03e6a96ded732f9c4e32471b1b4f8dea54a"
71
+ "gitHead": "aa003c3634016cc4ab6348b2106907e371c648e1"
72
72
  }
@@ -43,16 +43,19 @@ export default function EntityTypeList( {
43
43
  closePanel,
44
44
  } ) {
45
45
  const firstRecord = list[ 0 ];
46
- const entity = useSelect(
46
+ const entityConfig = useSelect(
47
47
  ( select ) =>
48
- select( coreStore ).getEntity( firstRecord.kind, firstRecord.name ),
48
+ select( coreStore ).getEntityConfig(
49
+ firstRecord.kind,
50
+ firstRecord.name
51
+ ),
49
52
  [ firstRecord.kind, firstRecord.name ]
50
53
  );
51
54
  const { name } = firstRecord;
52
55
  const entityLabel =
53
56
  name === 'wp_template_part'
54
57
  ? _n( 'Template Part', 'Template Parts', list.length )
55
- : entity.label;
58
+ : entityConfig.label;
56
59
  // Set description based on type of entity.
57
60
  const description = getEntityDescription( name, list.length );
58
61
 
@@ -6,7 +6,14 @@
6
6
  - warn the user upon loading a post that there is a local copy that can be loaded;
7
7
  - defer to remote autosaves, if any is available.
8
8
 
9
- `LocalAutosaveMonitor` observes a saving interval defined specifically for local autosaves, in contrast with remote (server-side) autosaving. See editor setting `__experimentalLocalAutosaveInterval` and setter `__experimentalUpdateLocalAutosaveInterval`.
9
+ `LocalAutosaveMonitor` observes a saving interval defined specifically for local autosaves, in contrast with remote (server-side) autosaving.
10
+
11
+ The interval used for the local autosave can be modified by updating the editor settings
12
+ ```js
13
+ wp.data.dispatch( 'core/editor' ).updateEditorSettings( {
14
+ localAutosaveInterval: 100000000000,
15
+ } );
16
+ ```
10
17
 
11
18
  ## Example
12
19
 
@@ -178,7 +178,7 @@ function LocalAutosaveMonitor() {
178
178
  const { localAutosaveInterval } = useSelect(
179
179
  ( select ) => ( {
180
180
  localAutosaveInterval: select( editorStore ).getEditorSettings()
181
- .__experimentalLocalAutosaveInterval,
181
+ .localAutosaveInterval,
182
182
  } ),
183
183
  []
184
184
  );
@@ -9,23 +9,22 @@ export const PREFERENCES_DEFAULTS = {
9
9
  };
10
10
 
11
11
  /**
12
- * The default post editor settings
12
+ * The default post editor settings.
13
13
  *
14
- * allowedBlockTypes boolean|Array Allowed block types
15
- * richEditingEnabled boolean Whether rich editing is enabled or not
16
- * codeEditingEnabled boolean Whether code editing is enabled or not
17
- * enableCustomFields boolean Whether the WordPress custom fields are enabled or not.
18
- * true = the user has opted to show the Custom Fields panel at the bottom of the editor.
19
- * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
20
- * undefined = the current environment does not support Custom Fields,
21
- * so the option toggle in Preferences -> Panels to
22
- * enable the Custom Fields panel is not displayed.
23
- * autosaveInterval number Autosave Interval
24
- * availableTemplates array? The available post templates
25
- * disablePostFormats boolean Whether or not the post formats are disabled
26
- * allowedMimeTypes array? List of allowed mime types and file extensions
27
- * maxUploadFileSize number Maximum upload file size
28
- * supportsLayout boolean Whether the editor supports layouts.
14
+ * @property {boolean|Array} allowedBlockTypes Allowed block types
15
+ * @property {boolean} richEditingEnabled Whether rich editing is enabled or not
16
+ * @property {boolean} codeEditingEnabled Whether code editing is enabled or not
17
+ * @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
18
+ * true = the user has opted to show the Custom Fields panel at the bottom of the editor.
19
+ * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
20
+ * undefined = the current environment does not support Custom Fields, so the option toggle in Preferences -> Panels to enable the Custom Fields panel is not displayed.
21
+ * @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.
22
+ * @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.
23
+ * @property {Array?} availableTemplates The available post templates
24
+ * @property {boolean} disablePostFormats Whether or not the post formats are disabled
25
+ * @property {Array?} allowedMimeTypes List of allowed mime types and file extensions
26
+ * @property {number} maxUploadFileSize Maximum upload file size
27
+ * @property {boolean} supportsLayout Whether the editor supports layouts.
29
28
  */
30
29
  export const EDITOR_SETTINGS_DEFAULTS = {
31
30
  ...SETTINGS_DEFAULTS,
@@ -83,6 +83,13 @@ describe( 'Post actions', () => {
83
83
  path.startsWith( `/wp/v2/posts/${ postId }` )
84
84
  ) {
85
85
  return { ...post, ...data };
86
+ } else if (
87
+ // This URL is requested by the actions dispatched in this test.
88
+ // They are safe to ignore and are only listed here to avoid triggeringan error.
89
+ method === 'GET' &&
90
+ path.startsWith( '/wp/v2/types/post' )
91
+ ) {
92
+ return {};
86
93
  }
87
94
 
88
95
  throw {
@@ -128,7 +135,7 @@ describe( 'Post actions', () => {
128
135
  expect( notices ).toMatchObject( [
129
136
  {
130
137
  status: 'success',
131
- content: 'Draft saved',
138
+ content: 'Draft saved.',
132
139
  },
133
140
  ] );
134
141
  } );
@@ -163,6 +170,15 @@ describe( 'Post actions', () => {
163
170
  } else if ( method === 'GET' ) {
164
171
  return [];
165
172
  }
173
+ } else if ( method === 'GET' ) {
174
+ // These URLs are requested by the actions dispatched in this test.
175
+ // They are safe to ignore and are only listed here to avoid triggeringan error.
176
+ if (
177
+ path.startsWith( '/wp/v2/types/post' ) ||
178
+ path.startsWith( `/wp/v2/posts/${ postId }` )
179
+ ) {
180
+ return {};
181
+ }
166
182
  }
167
183
 
168
184
  throw {
@@ -239,6 +255,13 @@ describe( 'Post actions', () => {
239
255
  ...data,
240
256
  };
241
257
  }
258
+ // This URL is requested by the actions dispatched in this test.
259
+ // They are safe to ignore and are only listed here to avoid triggeringan error.
260
+ } else if (
261
+ method === 'GET' &&
262
+ path.startsWith( '/wp/v2/types/post' )
263
+ ) {
264
+ return {};
242
265
  }
243
266
 
244
267
  throw {
@@ -39,12 +39,13 @@ export function getNotificationArgumentsForSaveSuccess( data ) {
39
39
 
40
40
  let noticeMessage;
41
41
  let shouldShowLink = get( postType, [ 'viewable' ], false );
42
+ let isDraft;
42
43
 
43
44
  // Always should a notice, which will be spoken for accessibility.
44
45
  if ( ! isPublished && ! willPublish ) {
45
46
  // If saving a non-published post, don't show notice.
46
- noticeMessage = __( 'Draft saved' );
47
- shouldShowLink = false;
47
+ noticeMessage = __( 'Draft saved.' );
48
+ isDraft = true;
48
49
  } else if ( isPublished && ! willPublish ) {
49
50
  // If undoing publish status, show specific notice.
50
51
  noticeMessage = postType.labels.item_reverted_to_draft;
@@ -65,7 +66,7 @@ export function getNotificationArgumentsForSaveSuccess( data ) {
65
66
  const actions = [];
66
67
  if ( shouldShowLink ) {
67
68
  actions.push( {
68
- label: postType.labels.view_item,
69
+ label: isDraft ? __( 'View Preview' ) : postType.labels.view_item,
69
70
  url: post.link,
70
71
  } );
71
72
  }
@@ -34,7 +34,7 @@ describe( 'getNotificationArgumentsForSaveSuccess()', () => {
34
34
  [
35
35
  'when previous post is not published and post will not be published',
36
36
  [ 'draft', 'draft', false ],
37
- [ 'Draft saved', defaultExpectedAction ],
37
+ [ 'Draft saved.', defaultExpectedAction ],
38
38
  ],
39
39
  [
40
40
  'when previous post is published and post will be unpublished',