@wordpress/edit-post 5.0.18-next.33ec3857e2.0 → 5.0.18

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.
Files changed (61) hide show
  1. package/build/components/block-manager/category.js +47 -42
  2. package/build/components/block-manager/category.js.map +1 -1
  3. package/build/components/edit-post-settings/index.js +16 -0
  4. package/build/components/edit-post-settings/index.js.map +1 -0
  5. package/build/components/header/mode-switcher/index.js +0 -6
  6. package/build/components/header/mode-switcher/index.js.map +1 -1
  7. package/build/components/header/template-title/edit-template-title.js +5 -0
  8. package/build/components/header/template-title/edit-template-title.js.map +1 -1
  9. package/build/components/header/template-title/index.js +10 -3
  10. package/build/components/header/template-title/index.js.map +1 -1
  11. package/build/components/header/template-title/template-description.js +14 -4
  12. package/build/components/header/template-title/template-description.js.map +1 -1
  13. package/build/components/layout/index.js +1 -3
  14. package/build/components/layout/index.js.map +1 -1
  15. package/build/components/visual-editor/index.js +6 -14
  16. package/build/components/visual-editor/index.js.map +1 -1
  17. package/build/editor.js +11 -6
  18. package/build/editor.js.map +1 -1
  19. package/build/index.js +2 -13
  20. package/build/index.js.map +1 -1
  21. package/build/prevent-event-discovery.js +24 -0
  22. package/build/prevent-event-discovery.js.map +1 -0
  23. package/build-module/components/block-manager/category.js +48 -44
  24. package/build-module/components/block-manager/category.js.map +1 -1
  25. package/build-module/components/edit-post-settings/index.js +7 -0
  26. package/build-module/components/edit-post-settings/index.js.map +1 -0
  27. package/build-module/components/header/mode-switcher/index.js +0 -6
  28. package/build-module/components/header/mode-switcher/index.js.map +1 -1
  29. package/build-module/components/header/template-title/edit-template-title.js +4 -0
  30. package/build-module/components/header/template-title/edit-template-title.js.map +1 -1
  31. package/build-module/components/header/template-title/index.js +11 -4
  32. package/build-module/components/header/template-title/index.js.map +1 -1
  33. package/build-module/components/header/template-title/template-description.js +16 -6
  34. package/build-module/components/header/template-title/template-description.js.map +1 -1
  35. package/build-module/components/layout/index.js +2 -4
  36. package/build-module/components/layout/index.js.map +1 -1
  37. package/build-module/components/visual-editor/index.js +7 -15
  38. package/build-module/components/visual-editor/index.js.map +1 -1
  39. package/build-module/editor.js +10 -7
  40. package/build-module/editor.js.map +1 -1
  41. package/build-module/index.js +1 -12
  42. package/build-module/index.js.map +1 -1
  43. package/build-module/prevent-event-discovery.js +17 -0
  44. package/build-module/prevent-event-discovery.js.map +1 -0
  45. package/build-style/style-rtl.css +8 -3
  46. package/build-style/style.css +8 -3
  47. package/package.json +27 -27
  48. package/src/components/block-manager/category.js +48 -41
  49. package/src/components/edit-post-settings/index.js +7 -0
  50. package/src/components/header/mode-switcher/index.js +0 -6
  51. package/src/components/header/template-title/edit-template-title.js +4 -0
  52. package/src/components/header/template-title/index.js +43 -26
  53. package/src/components/header/template-title/style.scss +13 -5
  54. package/src/components/header/template-title/template-description.js +21 -3
  55. package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +2 -2
  56. package/src/components/layout/index.js +1 -2
  57. package/src/components/preferences-modal/test/__snapshots__/index.js.snap +4 -4
  58. package/src/components/visual-editor/index.js +6 -16
  59. package/src/editor.js +26 -22
  60. package/src/index.js +1 -19
  61. package/src/prevent-event-discovery.js +21 -0
package/build/editor.js CHANGED
@@ -25,10 +25,14 @@ var _coreData = require("@wordpress/core-data");
25
25
 
26
26
  var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
27
27
 
28
+ var _preventEventDiscovery = _interopRequireDefault(require("./prevent-event-discovery"));
29
+
28
30
  var _layout = _interopRequireDefault(require("./components/layout"));
29
31
 
30
32
  var _editorInitialization = _interopRequireDefault(require("./components/editor-initialization"));
31
33
 
34
+ var _editPostSettings = _interopRequireDefault(require("./components/edit-post-settings"));
35
+
32
36
  var _store = require("./store");
33
37
 
34
38
  /**
@@ -132,10 +136,7 @@ function Editor(_ref) {
132
136
  __experimentalLocalAutosaveInterval,
133
137
  // This is marked as experimental to give time for the quick inserter to mature.
134
138
  __experimentalSetIsInserterOpened: setIsInserterOpened,
135
- keepCaretInsideBlock,
136
- // Keep a reference of the `allowedBlockTypes` from the server to handle use cases
137
- // where we need to differentiate if a block is disabled by the user or some plugin.
138
- defaultAllowedBlockTypes: settings.allowedBlockTypes
139
+ keepCaretInsideBlock
139
140
  }; // Omit hidden block types if exists and non-empty.
140
141
 
141
142
  if ((0, _lodash.size)(hiddenBlockTypes) > 0) {
@@ -166,7 +167,9 @@ function Editor(_ref) {
166
167
  return null;
167
168
  }
168
169
 
169
- return (0, _element.createElement)(_element.StrictMode, null, (0, _element.createElement)(_keyboardShortcuts.ShortcutProvider, null, (0, _element.createElement)(_components.SlotFillProvider, null, (0, _element.createElement)(_editor.EditorProvider, (0, _extends2.default)({
170
+ return (0, _element.createElement)(_element.StrictMode, null, (0, _element.createElement)(_keyboardShortcuts.ShortcutProvider, null, (0, _element.createElement)(_editPostSettings.default.Provider, {
171
+ value: settings
172
+ }, (0, _element.createElement)(_components.SlotFillProvider, null, (0, _element.createElement)(_editor.EditorProvider, (0, _extends2.default)({
170
173
  settings: editorSettings,
171
174
  post: post,
172
175
  initialEdits: initialEdits,
@@ -178,7 +181,9 @@ function Editor(_ref) {
178
181
  postId: postId
179
182
  }), (0, _element.createElement)(_layout.default, {
180
183
  styles: styles
181
- })), (0, _element.createElement)(_editor.PostLockedModal, null)))));
184
+ }), (0, _element.createElement)(_components.KeyboardShortcuts, {
185
+ shortcuts: _preventEventDiscovery.default
186
+ })), (0, _element.createElement)(_editor.PostLockedModal, null))))));
182
187
  }
183
188
 
184
189
  var _default = Editor;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/editor.js"],"names":["Editor","postId","postType","settings","initialEdits","onError","props","hasFixedToolbar","focusMode","hasReducedUI","hasThemeStyles","post","preferredStyleVariations","hiddenBlockTypes","blockTypes","__experimentalLocalAutosaveInterval","keepCaretInsideBlock","isTemplateMode","template","select","isFeatureActive","getPreference","__experimentalGetPreviewDeviceType","isEditingTemplate","getEditedPostTemplate","editPostStore","getEntityRecord","getPostType","getEntityRecords","coreStore","getEditorSettings","editorStore","getBlockTypes","blocksStore","isTemplate","includes","postObject","posts","wp_id","supportsTemplateMode","isViewable","viewable","updatePreferredStyleVariations","setIsInserterOpened","editorSettings","result","__experimentalPreferredStyleVariations","value","onChange","__experimentalSetIsInserterOpened","defaultAllowedBlockTypes","allowedBlockTypes","styles","themeStyles","presetStyles","forEach","style","__unstableType","push","defaultEditorStyles","length","undefined"],"mappings":";;;;;;;;;AAgBA;;;;AAbA;;AAKA;;AACA;;AACA;;AAOA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA;AACA;AAKA,SAASA,MAAT,OAOI;AAAA,MAPa;AAChBC,IAAAA,MADgB;AAEhBC,IAAAA,QAFgB;AAGhBC,IAAAA,QAHgB;AAIhBC,IAAAA,YAJgB;AAKhBC,IAAAA,OALgB;AAMhB,OAAGC;AANa,GAOb;AACH,QAAM;AACLC,IAAAA,eADK;AAELC,IAAAA,SAFK;AAGLC,IAAAA,YAHK;AAILC,IAAAA,cAJK;AAKLC,IAAAA,IALK;AAMLC,IAAAA,wBANK;AAOLC,IAAAA,gBAPK;AAQLC,IAAAA,UARK;AASLC,IAAAA,mCATK;AAULC,IAAAA,oBAVK;AAWLC,IAAAA,cAXK;AAYLC,IAAAA;AAZK,MAaF,qBACDC,MAAF,IAAc;AAAA;;AACb,UAAM;AACLC,MAAAA,eADK;AAELC,MAAAA,aAFK;AAGLC,MAAAA,kCAHK;AAILC,MAAAA,iBAJK;AAKLC,MAAAA;AALK,QAMFL,MAAM,CAAEM,YAAF,CANV;AAOA,UAAM;AAAEC,MAAAA,eAAF;AAAmBC,MAAAA,WAAnB;AAAgCC,MAAAA;AAAhC,QAAqDT,MAAM,CAChEU,eADgE,CAAjE;AAGA,UAAM;AAAEC,MAAAA;AAAF,QAAwBX,MAAM,CAAEY,aAAF,CAApC;AACA,UAAM;AAAEC,MAAAA;AAAF,QA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dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tEditorProvider,\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { StrictMode, useMemo } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport EditorInitialization from './components/editor-initialization';\nimport { store as editPostStore } from './store';\n\nfunction Editor( {\n\tpostId,\n\tpostType,\n\tsettings,\n\tinitialEdits,\n\tonError,\n\t...props\n} ) {\n\tconst {\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\thasReducedUI,\n\t\thasThemeStyles,\n\t\tpost,\n\t\tpreferredStyleVariations,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\t__experimentalLocalAutosaveInterval,\n\t\tkeepCaretInsideBlock,\n\t\tisTemplateMode,\n\t\ttemplate,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisFeatureActive,\n\t\t\t\tgetPreference,\n\t\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\t\tisEditingTemplate,\n\t\t\t\tgetEditedPostTemplate,\n\t\t\t} = select( editPostStore );\n\t\t\tconst { getEntityRecord, getPostType, getEntityRecords } = select(\n\t\t\t\tcoreStore\n\t\t\t);\n\t\t\tconst { getEditorSettings } = select( editorStore );\n\t\t\tconst { getBlockTypes } = select( blocksStore );\n\t\t\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\t\tpostType\n\t\t\t);\n\t\t\t// Ideally the initializeEditor function should be called using the ID of the REST endpoint.\n\t\t\t// to avoid the special case.\n\t\t\tlet postObject;\n\t\t\tif ( isTemplate ) {\n\t\t\t\tconst posts = getEntityRecords( 'postType', postType, {\n\t\t\t\t\twp_id: postId,\n\t\t\t\t} );\n\t\t\t\tpostObject = posts?.[ 0 ];\n\t\t\t} else {\n\t\t\t\tpostObject = getEntityRecord( 'postType', postType, postId );\n\t\t\t}\n\t\t\tconst supportsTemplateMode = getEditorSettings()\n\t\t\t\t.supportsTemplateMode;\n\t\t\tconst isViewable = getPostType( postType )?.viewable ?? false;\n\n\t\t\treturn {\n\t\t\t\thasFixedToolbar:\n\t\t\t\t\tisFeatureActive( 'fixedToolbar' ) ||\n\t\t\t\t\t__experimentalGetPreviewDeviceType() !== 'Desktop',\n\t\t\t\tfocusMode: isFeatureActive( 'focusMode' ),\n\t\t\t\thasReducedUI: isFeatureActive( 'reducedUI' ),\n\t\t\t\thasThemeStyles: isFeatureActive( 'themeStyles' ),\n\t\t\t\tpreferredStyleVariations: getPreference(\n\t\t\t\t\t'preferredStyleVariations'\n\t\t\t\t),\n\t\t\t\thiddenBlockTypes: getPreference( 'hiddenBlockTypes' ),\n\t\t\t\tblockTypes: getBlockTypes(),\n\t\t\t\t__experimentalLocalAutosaveInterval: getPreference(\n\t\t\t\t\t'localAutosaveInterval'\n\t\t\t\t),\n\t\t\t\tkeepCaretInsideBlock: isFeatureActive( 'keepCaretInsideBlock' ),\n\t\t\t\tisTemplateMode: isEditingTemplate(),\n\t\t\t\ttemplate:\n\t\t\t\t\tsupportsTemplateMode && isViewable\n\t\t\t\t\t\t? getEditedPostTemplate()\n\t\t\t\t\t\t: null,\n\t\t\t\tpost: postObject,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tconst { updatePreferredStyleVariations, setIsInserterOpened } = useDispatch(\n\t\teditPostStore\n\t);\n\n\tconst editorSettings = useMemo( () => {\n\t\tconst result = {\n\t\t\t...settings,\n\t\t\t__experimentalPreferredStyleVariations: {\n\t\t\t\tvalue: preferredStyleVariations,\n\t\t\t\tonChange: updatePreferredStyleVariations,\n\t\t\t},\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t\thasReducedUI,\n\t\t\t__experimentalLocalAutosaveInterval,\n\n\t\t\t// This is marked as experimental to give time for the quick inserter to mature.\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tkeepCaretInsideBlock,\n\t\t\t// Keep a reference of the `allowedBlockTypes` from the server to handle use cases\n\t\t\t// where we need to differentiate if a block is disabled by the user or some plugin.\n\t\t\tdefaultAllowedBlockTypes: settings.allowedBlockTypes,\n\t\t};\n\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( size( hiddenBlockTypes ) > 0 ) {\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? map( blockTypes, 'name' )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\tresult.allowedBlockTypes = without(\n\t\t\t\tdefaultAllowedBlockTypes,\n\t\t\t\t...hiddenBlockTypes\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}, [\n\t\tsettings,\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\thasReducedUI,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\tpreferredStyleVariations,\n\t\t__experimentalLocalAutosaveInterval,\n\t\tsetIsInserterOpened,\n\t\tupdatePreferredStyleVariations,\n\t\tkeepCaretInsideBlock,\n\t] );\n\n\tconst styles = useMemo( () => {\n\t\tconst themeStyles = [];\n\t\tconst presetStyles = [];\n\t\tsettings.styles.forEach( ( style ) => {\n\t\t\tif ( ! style.__unstableType || style.__unstableType === 'theme' ) {\n\t\t\t\tthemeStyles.push( style );\n\t\t\t} else {\n\t\t\t\tpresetStyles.push( style );\n\t\t\t}\n\t\t} );\n\t\tconst defaultEditorStyles = [\n\t\t\t...settings.defaultEditorStyles,\n\t\t\t...presetStyles,\n\t\t];\n\t\treturn hasThemeStyles && themeStyles.length\n\t\t\t? settings.styles\n\t\t\t: defaultEditorStyles;\n\t}, [ settings, hasThemeStyles ] );\n\n\tif ( ! post ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StrictMode>\n\t\t\t<ShortcutProvider>\n\t\t\t\t<SlotFillProvider>\n\t\t\t\t\t<EditorProvider\n\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\tpost={ post }\n\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t__unstableTemplate={\n\t\t\t\t\t\t\tisTemplateMode ? template : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ErrorBoundary onError={ onError }>\n\t\t\t\t\t\t\t<EditorInitialization postId={ postId } />\n\t\t\t\t\t\t\t<Layout styles={ styles } />\n\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t<PostLockedModal />\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t</SlotFillProvider>\n\t\t\t</ShortcutProvider>\n\t\t</StrictMode>\n\t);\n}\n\nexport default Editor;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/editor.js"],"names":["Editor","postId","postType","settings","initialEdits","onError","props","hasFixedToolbar","focusMode","hasReducedUI","hasThemeStyles","post","preferredStyleVariations","hiddenBlockTypes","blockTypes","__experimentalLocalAutosaveInterval","keepCaretInsideBlock","isTemplateMode","template","select","isFeatureActive","getPreference","__experimentalGetPreviewDeviceType","isEditingTemplate","getEditedPostTemplate","editPostStore","getEntityRecord","getPostType","getEntityRecords","coreStore","getEditorSettings","editorStore","getBlockTypes","blocksStore","isTemplate","includes","postObject","posts","wp_id","supportsTemplateMode","isViewable","viewable","updatePreferredStyleVariations","setIsInserterOpened","editorSettings","result","__experimentalPreferredStyleVariations","value","onChange","__experimentalSetIsInserterOpened","defaultAllowedBlockTypes","allowedBlockTypes","styles","themeStyles","presetStyles","forEach","style","__unstableType","push","defaultEditorStyles","length","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,KAAnB;AACA;AACD,KAND;AAOA,UAAMG,mBAAmB,GAAG,CAC3B,GAAGxD,QAAQ,CAACwD,mBADe,EAE3B,GAAGL,YAFwB,CAA5B;AAIA,WAAO5C,cAAc,IAAI2C,WAAW,CAACO,MAA9B,GACJzD,QAAQ,CAACiD,MADL,GAEJO,mBAFH;AAGA,GAjBc,EAiBZ,CAAExD,QAAF,EAAYO,cAAZ,CAjBY,CAAf;;AAmBA,MAAK,CAAEC,IAAP,EAAc;AACb,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,mBAAD,QACC,4BAAC,mCAAD,QACC,4BAAC,yBAAD,CAAkB,QAAlB;AAA2B,IAAA,KAAK,EAAGR;AAAnC,KACC,4BAAC,4BAAD,QACC,4BAAC,sBAAD;AACC,IAAA,QAAQ,EAAGyC,cADZ;AAEC,IAAA,IAAI,EAAGjC,IAFR;AAGC,IAAA,YAAY,EAAGP,YAHhB;AAIC,IAAA,cAAc,EAAG,KAJlB;AAKC,IAAA,kBAAkB,EACjBa,cAAc,GAAGC,QAAH,GAAc2C;AAN9B,KAQMvD,KARN,GAUC,4BAAC,qBAAD;AAAe,IAAA,OAAO,EAAGD;AAAzB,KACC,4BAAC,6BAAD;AAAsB,IAAA,MAAM,EAAGJ;AAA/B,IADD,EAEC,4BAAC,eAAD;AAAQ,IAAA,MAAM,EAAGmD;AAAjB,IAFD,EAGC,4BAAC,6BAAD;AACC,IAAA,SAAS,EAAGU;AADb,IAHD,CAVD,EAiBC,4BAAC,uBAAD,OAjBD,CADD,CADD,CADD,CADD,CADD;AA6BA;;eAEc9D,M","sourcesContent":["/**\n * External dependencies\n */\nimport { size, map, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tEditorProvider,\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { StrictMode, useMemo } from '@wordpress/element';\nimport { KeyboardShortcuts, SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport preventEventDiscovery from './prevent-event-discovery';\nimport Layout from './components/layout';\nimport EditorInitialization from './components/editor-initialization';\nimport EditPostSettings from './components/edit-post-settings';\nimport { store as editPostStore } from './store';\n\nfunction Editor( {\n\tpostId,\n\tpostType,\n\tsettings,\n\tinitialEdits,\n\tonError,\n\t...props\n} ) {\n\tconst {\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\thasReducedUI,\n\t\thasThemeStyles,\n\t\tpost,\n\t\tpreferredStyleVariations,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\t__experimentalLocalAutosaveInterval,\n\t\tkeepCaretInsideBlock,\n\t\tisTemplateMode,\n\t\ttemplate,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisFeatureActive,\n\t\t\t\tgetPreference,\n\t\t\t\t__experimentalGetPreviewDeviceType,\n\t\t\t\tisEditingTemplate,\n\t\t\t\tgetEditedPostTemplate,\n\t\t\t} = select( editPostStore );\n\t\t\tconst { getEntityRecord, getPostType, getEntityRecords } = select(\n\t\t\t\tcoreStore\n\t\t\t);\n\t\t\tconst { getEditorSettings } = select( editorStore );\n\t\t\tconst { getBlockTypes } = select( blocksStore );\n\t\t\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\t\tpostType\n\t\t\t);\n\t\t\t// Ideally the initializeEditor function should be called using the ID of the REST endpoint.\n\t\t\t// to avoid the special case.\n\t\t\tlet postObject;\n\t\t\tif ( isTemplate ) {\n\t\t\t\tconst posts = getEntityRecords( 'postType', postType, {\n\t\t\t\t\twp_id: postId,\n\t\t\t\t} );\n\t\t\t\tpostObject = posts?.[ 0 ];\n\t\t\t} else {\n\t\t\t\tpostObject = getEntityRecord( 'postType', postType, postId );\n\t\t\t}\n\t\t\tconst supportsTemplateMode = getEditorSettings()\n\t\t\t\t.supportsTemplateMode;\n\t\t\tconst isViewable = getPostType( postType )?.viewable ?? false;\n\n\t\t\treturn {\n\t\t\t\thasFixedToolbar:\n\t\t\t\t\tisFeatureActive( 'fixedToolbar' ) ||\n\t\t\t\t\t__experimentalGetPreviewDeviceType() !== 'Desktop',\n\t\t\t\tfocusMode: isFeatureActive( 'focusMode' ),\n\t\t\t\thasReducedUI: isFeatureActive( 'reducedUI' ),\n\t\t\t\thasThemeStyles: isFeatureActive( 'themeStyles' ),\n\t\t\t\tpreferredStyleVariations: getPreference(\n\t\t\t\t\t'preferredStyleVariations'\n\t\t\t\t),\n\t\t\t\thiddenBlockTypes: getPreference( 'hiddenBlockTypes' ),\n\t\t\t\tblockTypes: getBlockTypes(),\n\t\t\t\t__experimentalLocalAutosaveInterval: getPreference(\n\t\t\t\t\t'localAutosaveInterval'\n\t\t\t\t),\n\t\t\t\tkeepCaretInsideBlock: isFeatureActive( 'keepCaretInsideBlock' ),\n\t\t\t\tisTemplateMode: isEditingTemplate(),\n\t\t\t\ttemplate:\n\t\t\t\t\tsupportsTemplateMode && isViewable\n\t\t\t\t\t\t? getEditedPostTemplate()\n\t\t\t\t\t\t: null,\n\t\t\t\tpost: postObject,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tconst { updatePreferredStyleVariations, setIsInserterOpened } = useDispatch(\n\t\teditPostStore\n\t);\n\n\tconst editorSettings = useMemo( () => {\n\t\tconst result = {\n\t\t\t...settings,\n\t\t\t__experimentalPreferredStyleVariations: {\n\t\t\t\tvalue: preferredStyleVariations,\n\t\t\t\tonChange: updatePreferredStyleVariations,\n\t\t\t},\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t\thasReducedUI,\n\t\t\t__experimentalLocalAutosaveInterval,\n\n\t\t\t// This is marked as experimental to give time for the quick inserter to mature.\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tkeepCaretInsideBlock,\n\t\t};\n\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( size( hiddenBlockTypes ) > 0 ) {\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? map( blockTypes, 'name' )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\tresult.allowedBlockTypes = without(\n\t\t\t\tdefaultAllowedBlockTypes,\n\t\t\t\t...hiddenBlockTypes\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}, [\n\t\tsettings,\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\thasReducedUI,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\tpreferredStyleVariations,\n\t\t__experimentalLocalAutosaveInterval,\n\t\tsetIsInserterOpened,\n\t\tupdatePreferredStyleVariations,\n\t\tkeepCaretInsideBlock,\n\t] );\n\n\tconst styles = useMemo( () => {\n\t\tconst themeStyles = [];\n\t\tconst presetStyles = [];\n\t\tsettings.styles.forEach( ( style ) => {\n\t\t\tif ( ! style.__unstableType || style.__unstableType === 'theme' ) {\n\t\t\t\tthemeStyles.push( style );\n\t\t\t} else {\n\t\t\t\tpresetStyles.push( style );\n\t\t\t}\n\t\t} );\n\t\tconst defaultEditorStyles = [\n\t\t\t...settings.defaultEditorStyles,\n\t\t\t...presetStyles,\n\t\t];\n\t\treturn hasThemeStyles && themeStyles.length\n\t\t\t? settings.styles\n\t\t\t: defaultEditorStyles;\n\t}, [ settings, hasThemeStyles ] );\n\n\tif ( ! post ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StrictMode>\n\t\t\t<ShortcutProvider>\n\t\t\t\t<EditPostSettings.Provider value={ settings }>\n\t\t\t\t\t<SlotFillProvider>\n\t\t\t\t\t\t<EditorProvider\n\t\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\t\tpost={ post }\n\t\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t\t__unstableTemplate={\n\t\t\t\t\t\t\t\tisTemplateMode ? template : undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ErrorBoundary onError={ onError }>\n\t\t\t\t\t\t\t\t<EditorInitialization postId={ postId } />\n\t\t\t\t\t\t\t\t<Layout styles={ styles } />\n\t\t\t\t\t\t\t\t<KeyboardShortcuts\n\t\t\t\t\t\t\t\t\tshortcuts={ preventEventDiscovery }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ErrorBoundary>\n\t\t\t\t\t\t\t<PostLockedModal />\n\t\t\t\t\t\t</EditorProvider>\n\t\t\t\t\t</SlotFillProvider>\n\t\t\t\t</EditPostSettings.Provider>\n\t\t\t</ShortcutProvider>\n\t\t</StrictMode>\n\t);\n}\n\nexport default Editor;\n"]}
package/build/index.js CHANGED
@@ -82,8 +82,6 @@ var _blockLibrary = require("@wordpress/block-library");
82
82
 
83
83
  var _data = require("@wordpress/data");
84
84
 
85
- var _hooks = require("@wordpress/hooks");
86
-
87
85
  var _interface = require("@wordpress/interface");
88
86
 
89
87
  require("./hooks");
@@ -92,8 +90,6 @@ require("./plugins");
92
90
 
93
91
  var _editor = _interopRequireDefault(require("./editor"));
94
92
 
95
- var _store = require("./store");
96
-
97
93
  var _pluginBlockSettingsMenuItem = _interopRequireDefault(require("./components/block-settings-menu/plugin-block-settings-menu-item"));
98
94
 
99
95
  var _pluginDocumentSettingPanel = _interopRequireDefault(require("./components/sidebar/plugin-document-setting-panel"));
@@ -114,6 +110,8 @@ var _fullscreenModeClose = _interopRequireDefault(require("./components/header/f
114
110
 
115
111
  var _mainDashboardButton = _interopRequireDefault(require("./components/header/main-dashboard-button"));
116
112
 
113
+ var _store = require("./store");
114
+
117
115
  /**
118
116
  * WordPress dependencies
119
117
  */
@@ -161,15 +159,6 @@ function reinitializeEditor(postType, postId, target, settings, initialEdits) {
161
159
 
162
160
 
163
161
  function initializeEditor(id, postType, postId, settings, initialEdits) {
164
- // Prevent adding template part in the post editor.
165
- // Only add the filter when the post editor is initialized, not imported.
166
- (0, _hooks.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (can, blockType) => {
167
- if (!(0, _data.select)(_store.store).isEditingTemplate() && blockType.name === 'core/template-part') {
168
- return false;
169
- }
170
-
171
- return can;
172
- });
173
162
  const target = document.getElementById(id);
174
163
  const reboot = reinitializeEditor.bind(null, postType, postId, target, settings, initialEdits);
175
164
  (0, _data.dispatch)(_interface.store).setFeatureDefaults('core/edit-post', {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/index.js"],"names":["reinitializeEditor","postType","postId","target","settings","initialEdits","reboot","bind","initializeEditor","id","can","blockType","editPostStore","isEditingTemplate","name","document","getElementById","interfaceStore","setFeatureDefaults","fixedToolbar","welcomeGuide","mobileGalleryWarning","fullscreenMode","showIconLabels","themeStyles","showBlockBreadcrumbs","welcomeGuideTemplate","blocksStore","__experimentalReapplyBlockTypeFilters","process","env","GUTENBERG_PHASE","enableFSEBlocks","__unstableEnableFullSiteEditingBlocks","documentMode","compatMode","console","warn","isIphone","window","navigator","userAgent","indexOf","addEventListener","event","editorScrollContainer","getElementsByClassName","scrollY","scrollTop","scrollTo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;AALA;;AACA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAgKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA5LA;AACA;AACA;;AAWA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AAjB,EAAoB,CAApB;AACA;AACD;AACD,KAlBD;AAmBA;;AAED,uBACC,4BAAC,eAAD;AACC,IAAA,QAAQ,EAAG7C,QADZ;AAEC,IAAA,OAAO,EAAGE,MAFX;AAGC,IAAA,MAAM,EAAGJ,MAHV;AAIC,IAAA,QAAQ,EAAGD,QAJZ;AAKC,IAAA,YAAY,EAAGI;AALhB,IADD,EAQCF,MARD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport { dispatch, select } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport './plugins';\nimport Editor from './editor';\nimport { store as editPostStore } from './store';\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Object} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function reinitializeEditor(\n\tpostType,\n\tpostId,\n\ttarget,\n\tsettings,\n\tinitialEdits\n) {\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind(\n\t\tnull,\n\t\tpostType,\n\t\tpostId,\n\t\ttarget,\n\t\tsettings,\n\t\tinitialEdits\n\t);\n\n\trender(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tonError={ reboot }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t\trecovery\n\t\t/>,\n\t\ttarget\n\t);\n}\n\n/**\n * Initializes and returns an instance of Editor.\n *\n * @param {string} id Unique identifier for editor instance.\n * @param {string} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function initializeEditor(\n\tid,\n\tpostType,\n\tpostId,\n\tsettings,\n\tinitialEdits\n) {\n\t// Prevent adding template part in the post editor.\n\t// Only add the filter when the post editor is initialized, not imported.\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'removeTemplatePartsFromInserter',\n\t\t( can, blockType ) => {\n\t\t\tif (\n\t\t\t\t! select( editPostStore ).isEditingTemplate() &&\n\t\t\t\tblockType.name === 'core/template-part'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn can;\n\t\t}\n\t);\n\n\tconst target = document.getElementById( id );\n\tconst reboot = reinitializeEditor.bind(\n\t\tnull,\n\t\tpostType,\n\t\tpostId,\n\t\ttarget,\n\t\tsettings,\n\t\tinitialEdits\n\t);\n\n\tdispatch( interfaceStore ).setFeatureDefaults( 'core/edit-post', {\n\t\tfixedToolbar: false,\n\t\twelcomeGuide: true,\n\t\tmobileGalleryWarning: true,\n\t\tfullscreenMode: true,\n\t\tshowIconLabels: false,\n\t\tthemeStyles: true,\n\t\tshowBlockBreadcrumbs: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tregisterCoreBlocks();\n\tif ( process.env.GUTENBERG_PHASE === 2 ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks,\n\t\t} );\n\t}\n\n\t// Show a console log warning if the browser is not in Standards rendering mode.\n\tconst documentMode =\n\t\tdocument.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';\n\tif ( documentMode !== 'Standards' ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t\"Your browser is using Quirks Mode. \\nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins.\"\n\t\t);\n\t}\n\n\t// This is a temporary fix for a couple of issues specific to Webkit on iOS.\n\t// Without this hack the browser scrolls the mobile toolbar off-screen.\n\t// Once supported in Safari we can replace this in favor of preventScroll.\n\t// For details see issue #18632 and PR #18686\n\t// Specifically, we scroll `interface-interface-skeleton__body` to enable a fixed top toolbar.\n\t// But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar.\n\n\tconst isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1;\n\tif ( isIphone ) {\n\t\twindow.addEventListener( 'scroll', ( event ) => {\n\t\t\tconst editorScrollContainer = document.getElementsByClassName(\n\t\t\t\t'interface-interface-skeleton__body'\n\t\t\t)[ 0 ];\n\t\t\tif ( event.target === document ) {\n\t\t\t\t// Scroll element into view by scrolling the editor container by the same amount\n\t\t\t\t// that Mobile Safari tried to scroll the html element upwards.\n\t\t\t\tif ( window.scrollY > 100 ) {\n\t\t\t\t\teditorScrollContainer.scrollTop =\n\t\t\t\t\t\teditorScrollContainer.scrollTop + window.scrollY;\n\t\t\t\t}\n\t\t\t\t// Undo unwanted scroll on html element, but only in the visual editor.\n\t\t\t\tif (\n\t\t\t\t\tdocument.getElementsByClassName( 'is-mode-visual' )[ 0 ]\n\t\t\t\t) {\n\t\t\t\t\twindow.scrollTo( 0, 0 );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\trender(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tonError={ reboot }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t/>,\n\t\ttarget\n\t);\n}\n\nexport { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';\nexport { default as PluginDocumentSettingPanel } from './components/sidebar/plugin-document-setting-panel';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\nexport { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';\nexport { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';\nexport { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close';\nexport { default as __experimentalMainDashboardButton } from './components/header/main-dashboard-button';\nexport { store } from './store';\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/index.js"],"names":["reinitializeEditor","postType","postId","target","settings","initialEdits","reboot","bind","initializeEditor","id","document","getElementById","interfaceStore","setFeatureDefaults","fixedToolbar","welcomeGuide","mobileGalleryWarning","fullscreenMode","showIconLabels","themeStyles","showBlockBreadcrumbs","welcomeGuideTemplate","blocksStore","__experimentalReapplyBlockTypeFilters","process","env","GUTENBERG_PHASE","enableFSEBlocks","__unstableEnableFullSiteEditingBlocks","documentMode","compatMode","console","warn","isIphone","window","navigator","userAgent","indexOf","addEventListener","event","editorScrollContainer","getElementsByClassName","scrollY","scrollTop","scrollTo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;AALA;;AACA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AAgJA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA3KA;AACA;AACA;;AAUA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAT,CACNC,QADM,EAENC,MAFM,E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nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport { dispatch } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport './plugins';\nimport Editor from './editor';\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Object} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function reinitializeEditor(\n\tpostType,\n\tpostId,\n\ttarget,\n\tsettings,\n\tinitialEdits\n) {\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind(\n\t\tnull,\n\t\tpostType,\n\t\tpostId,\n\t\ttarget,\n\t\tsettings,\n\t\tinitialEdits\n\t);\n\n\trender(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tonError={ reboot }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t\trecovery\n\t\t/>,\n\t\ttarget\n\t);\n}\n\n/**\n * Initializes and returns an instance of Editor.\n *\n * @param {string} id Unique identifier for editor instance.\n * @param {string} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function initializeEditor(\n\tid,\n\tpostType,\n\tpostId,\n\tsettings,\n\tinitialEdits\n) {\n\tconst target = document.getElementById( id );\n\tconst reboot = reinitializeEditor.bind(\n\t\tnull,\n\t\tpostType,\n\t\tpostId,\n\t\ttarget,\n\t\tsettings,\n\t\tinitialEdits\n\t);\n\n\tdispatch( interfaceStore ).setFeatureDefaults( 'core/edit-post', {\n\t\tfixedToolbar: false,\n\t\twelcomeGuide: true,\n\t\tmobileGalleryWarning: true,\n\t\tfullscreenMode: true,\n\t\tshowIconLabels: false,\n\t\tthemeStyles: true,\n\t\tshowBlockBreadcrumbs: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tregisterCoreBlocks();\n\tif ( process.env.GUTENBERG_PHASE === 2 ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks,\n\t\t} );\n\t}\n\n\t// Show a console log warning if the browser is not in Standards rendering mode.\n\tconst documentMode =\n\t\tdocument.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';\n\tif ( documentMode !== 'Standards' ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t\"Your browser is using Quirks Mode. \\nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins.\"\n\t\t);\n\t}\n\n\t// This is a temporary fix for a couple of issues specific to Webkit on iOS.\n\t// Without this hack the browser scrolls the mobile toolbar off-screen.\n\t// Once supported in Safari we can replace this in favor of preventScroll.\n\t// For details see issue #18632 and PR #18686\n\t// Specifically, we scroll `interface-interface-skeleton__body` to enable a fixed top toolbar.\n\t// But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar.\n\n\tconst isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1;\n\tif ( isIphone ) {\n\t\twindow.addEventListener( 'scroll', ( event ) => {\n\t\t\tconst editorScrollContainer = document.getElementsByClassName(\n\t\t\t\t'interface-interface-skeleton__body'\n\t\t\t)[ 0 ];\n\t\t\tif ( event.target === document ) {\n\t\t\t\t// Scroll element into view by scrolling the editor container by the same amount\n\t\t\t\t// that Mobile Safari tried to scroll the html element upwards.\n\t\t\t\tif ( window.scrollY > 100 ) {\n\t\t\t\t\teditorScrollContainer.scrollTop =\n\t\t\t\t\t\teditorScrollContainer.scrollTop + window.scrollY;\n\t\t\t\t}\n\t\t\t\t// Undo unwanted scroll on html element, but only in the visual editor.\n\t\t\t\tif (\n\t\t\t\t\tdocument.getElementsByClassName( 'is-mode-visual' )[ 0 ]\n\t\t\t\t) {\n\t\t\t\t\twindow.scrollTo( 0, 0 );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\trender(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tonError={ reboot }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t/>,\n\t\ttarget\n\t);\n}\n\nexport { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';\nexport { default as PluginDocumentSettingPanel } from './components/sidebar/plugin-document-setting-panel';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\nexport { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';\nexport { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';\nexport { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close';\nexport { default as __experimentalMainDashboardButton } from './components/header/main-dashboard-button';\nexport { store } from './store';\n"]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ 't a l e s o f g u t e n b e r g': event => {
9
+ const {
10
+ ownerDocument
11
+ } = event.target;
12
+
13
+ if (!ownerDocument.activeElement.classList.contains('edit-post-visual-editor') && ownerDocument.activeElement !== ownerDocument.body) {
14
+ return;
15
+ }
16
+
17
+ event.preventDefault();
18
+ window.wp.data.dispatch('core/block-editor').insertBlock(window.wp.blocks.createBlock('core/paragraph', {
19
+ content: '🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️'
20
+ }));
21
+ }
22
+ };
23
+ exports.default = _default;
24
+ //# sourceMappingURL=prevent-event-discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-post/src/prevent-event-discovery.js"],"names":["event","ownerDocument","target","activeElement","classList","contains","body","preventDefault","window","wp","data","dispatch","insertBlock","blocks","createBlock","content"],"mappings":";;;;;;eAAe;AACd,qCAAqCA,KAAF,IAAa;AAC/C,UAAM;AAAEC,MAAAA;AAAF,QAAoBD,KAAK,CAACE,MAAhC;;AACA,QACC,CAAED,aAAa,CAACE,aAAd,CAA4BC,SAA5B,CAAsCC,QAAtC,CACD,yBADC,CAAF,IAGAJ,aAAa,CAACE,aAAd,KAAgCF,aAAa,CAACK,IAJ/C,EAKE;AACD;AACA;;AAEDN,IAAAA,KAAK,CAACO,cAAN;AACAC,IAAAA,MAAM,CAACC,EAAP,CAAUC,IAAV,CAAeC,QAAf,CAAyB,mBAAzB,EAA+CC,WAA/C,CACCJ,MAAM,CAACC,EAAP,CAAUI,MAAV,CAAiBC,WAAjB,CAA8B,gBAA9B,EAAgD;AAC/CC,MAAAA,OAAO,EACN;AAF8C,KAAhD,CADD;AAMA;AAnBa,C","sourcesContent":["export default {\n\t't a l e s o f g u t e n b e r g': ( event ) => {\n\t\tconst { ownerDocument } = event.target;\n\t\tif (\n\t\t\t! ownerDocument.activeElement.classList.contains(\n\t\t\t\t'edit-post-visual-editor'\n\t\t\t) &&\n\t\t\townerDocument.activeElement !== ownerDocument.body\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tevent.preventDefault();\n\t\twindow.wp.data.dispatch( 'core/block-editor' ).insertBlock(\n\t\t\twindow.wp.blocks.createBlock( 'core/paragraph', {\n\t\t\t\tcontent:\n\t\t\t\t\t'🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️',\n\t\t\t} )\n\t\t);\n\t},\n};\n"]}
@@ -8,41 +8,33 @@ import { includes, map, without } from 'lodash';
8
8
  * WordPress dependencies
9
9
  */
10
10
 
11
- import { useMemo, useCallback } from '@wordpress/element';
12
- import { useDispatch, useSelect } from '@wordpress/data';
13
- import { useInstanceId } from '@wordpress/compose';
11
+ import { useContext, useMemo } from '@wordpress/element';
12
+ import { withSelect, withDispatch } from '@wordpress/data';
13
+ import { compose, withInstanceId } from '@wordpress/compose';
14
14
  import { CheckboxControl } from '@wordpress/components';
15
- import { store as editorStore } from '@wordpress/editor';
16
15
  /**
17
16
  * Internal dependencies
18
17
  */
19
18
 
20
19
  import BlockTypesChecklist from './checklist';
20
+ import EditPostSettings from '../edit-post-settings';
21
21
  import { store as editPostStore } from '../../store';
22
22
 
23
23
  function BlockManagerCategory(_ref) {
24
24
  let {
25
+ instanceId,
25
26
  title,
26
- blockTypes
27
+ blockTypes,
28
+ hiddenBlockTypes,
29
+ toggleVisible,
30
+ toggleAllVisible
27
31
  } = _ref;
28
- const instanceId = useInstanceId(BlockManagerCategory);
32
+ const settings = useContext(EditPostSettings);
29
33
  const {
30
- defaultAllowedBlockTypes,
31
- hiddenBlockTypes
32
- } = useSelect(select => {
33
- const {
34
- getEditorSettings
35
- } = select(editorStore);
36
- const {
37
- getPreference
38
- } = select(editPostStore);
39
- return {
40
- defaultAllowedBlockTypes: getEditorSettings().defaultAllowedBlockTypes,
41
- hiddenBlockTypes: getPreference('hiddenBlockTypes')
42
- };
43
- }, []);
34
+ allowedBlockTypes
35
+ } = settings;
44
36
  const filteredBlockTypes = useMemo(() => {
45
- if (defaultAllowedBlockTypes === true) {
37
+ if (allowedBlockTypes === true) {
46
38
  return blockTypes;
47
39
  }
48
40
 
@@ -50,29 +42,9 @@ function BlockManagerCategory(_ref) {
50
42
  let {
51
43
  name
52
44
  } = _ref2;
53
- return includes(defaultAllowedBlockTypes || [], name);
45
+ return includes(allowedBlockTypes || [], name);
54
46
  });
55
- }, [defaultAllowedBlockTypes, blockTypes]);
56
- const {
57
- showBlockTypes,
58
- hideBlockTypes
59
- } = useDispatch(editPostStore);
60
- const toggleVisible = useCallback((blockName, nextIsChecked) => {
61
- if (nextIsChecked) {
62
- showBlockTypes(blockName);
63
- } else {
64
- hideBlockTypes(blockName);
65
- }
66
- }, []);
67
- const toggleAllVisible = useCallback(nextIsChecked => {
68
- const blockNames = map(blockTypes, 'name');
69
-
70
- if (nextIsChecked) {
71
- showBlockTypes(blockNames);
72
- } else {
73
- hideBlockTypes(blockNames);
74
- }
75
- }, [blockTypes]);
47
+ }, [allowedBlockTypes, blockTypes]);
76
48
 
77
49
  if (!filteredBlockTypes.length) {
78
50
  return null;
@@ -110,5 +82,37 @@ function BlockManagerCategory(_ref) {
110
82
  }));
111
83
  }
112
84
 
113
- export default BlockManagerCategory;
85
+ export default compose([withInstanceId, withSelect(select => {
86
+ const {
87
+ getPreference
88
+ } = select(editPostStore);
89
+ return {
90
+ hiddenBlockTypes: getPreference('hiddenBlockTypes')
91
+ };
92
+ }), withDispatch((dispatch, ownProps) => {
93
+ const {
94
+ showBlockTypes,
95
+ hideBlockTypes
96
+ } = dispatch(editPostStore);
97
+ return {
98
+ toggleVisible(blockName, nextIsChecked) {
99
+ if (nextIsChecked) {
100
+ showBlockTypes(blockName);
101
+ } else {
102
+ hideBlockTypes(blockName);
103
+ }
104
+ },
105
+
106
+ toggleAllVisible(nextIsChecked) {
107
+ const blockNames = map(ownProps.blockTypes, 'name');
108
+
109
+ if (nextIsChecked) {
110
+ showBlockTypes(blockNames);
111
+ } else {
112
+ hideBlockTypes(blockNames);
113
+ }
114
+ }
115
+
116
+ };
117
+ })])(BlockManagerCategory);
114
118
  //# sourceMappingURL=category.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/block-manager/category.js"],"names":["includes","map","without","useMemo","useCallback","useDispatch","useSelect","useInstanceId","CheckboxControl","store","editorStore","BlockTypesChecklist","editPostStore","BlockManagerCategory","title","blockTypes","instanceId","defaultAllowedBlockTypes","hiddenBlockTypes","select","getEditorSettings","getPreference","filteredBlockTypes","filter","name","showBlockTypes","hideBlockTypes","toggleVisible","blockName","nextIsChecked","toggleAllVisible","blockNames","length","checkedBlockNames","titleId","isAllChecked","ariaChecked"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,GAAnB,EAAwBC,OAAxB,QAAuC,QAAvC;AAEA;AACA;AACA;;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,eAAT,QAAgC,uBAAhC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,aAAhC;AACA,SAASF,KAAK,IAAIG,aAAlB,QAAuC,aAAvC;;AAEA,SAASC,oBAAT,OAAuD;AAAA,MAAxB;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAAwB;AACtD,QAAMC,UAAU,GAAGT,aAAa,CAAEM,oBAAF,CAAhC;AACA,QAAM;AAAEI,IAAAA,wBAAF;AAA4BC,IAAAA;AAA5B,MAAiDZ,SAAS,CAC7Da,MAAF,IAAc;AACb,UAAM;AAAEC,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CATmC,CAApC;;AAYA,MAAK,CAAEO,kBAAkB,CAACU,MAA1B,EAAmC;AAClC,WAAO,IAAP;AACA;;AAED,QAAMC,iBAAiB,GAAG/B,OAAO,CAChCD,GAAG,CAAEqB,kBAAF,EAAsB,MAAtB,CAD6B,EAEhC,GAAGJ,gBAF6B,CAAjC;AAKA,QAAMgB,OAAO,GAAG,6CAA6ClB,UAA7D;AAEA,QAAMmB,YAAY,GAAGF,iBAAiB,CAACD,MAAlB,KAA6BV,kBAAkB,CAACU,MAArE;AAEA,MAAII,WAAJ;;AACA,MAAKD,YAAL,EAAoB;AACnBC,IAAAA,WAAW,GAAG,MAAd;AACA,GAFD,MAEO,IAAKH,iBAAiB,CAACD,MAAlB,GAA2B,CAAhC,EAAoC;AAC1CI,IAAAA,WAAW,GAAG,OAAd;AACA,GAFM,MAEA;AACNA,IAAAA,WAAW,GAAG,OAAd;AACA;;AAED,SACC;AACC,IAAA,IAAI,EAAC,OADN;AAEC,uBAAkBF,OAFnB;AAGC,IAAA,SAAS,EAAC;AAHX,KAKC,cAAC,eAAD;AACC,IAAA,OAAO,EAAGC,YADX;AAEC,IAAA,QAAQ,EAAGL,gBAFZ;AAGC,IAAA,SAAS,EAAC,yCAHX;AAIC,oBAAeM,WAJhB;AAKC,IAAA,KAAK,EAAG;AAAM,MAAA,EAAE,EAAGF;AAAX,OAAuBpB,KAAvB;AALT,IALD,EAYC,cAAC,mBAAD;AACC,IAAA,UAAU,EAAGQ,kBADd;AAEC,IAAA,KAAK,EAAGW,iBAFT;AAGC,IAAA,YAAY,EAAGN;AAHhB,IAZD,CADD;AAoBA;;AAED,eAAed,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { includes, map, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { CheckboxControl } from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesChecklist from './checklist';\nimport { store as editPostStore } from '../../store';\n\nfunction BlockManagerCategory( { title, blockTypes } ) {\n\tconst instanceId = useInstanceId( BlockManagerCategory );\n\tconst { defaultAllowedBlockTypes, hiddenBlockTypes } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditorSettings } = select( editorStore );\n\t\t\tconst { getPreference } = select( editPostStore );\n\t\t\treturn {\n\t\t\t\tdefaultAllowedBlockTypes: getEditorSettings()\n\t\t\t\t\t.defaultAllowedBlockTypes,\n\t\t\t\thiddenBlockTypes: getPreference( 'hiddenBlockTypes' ),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst filteredBlockTypes = useMemo( () => {\n\t\tif ( defaultAllowedBlockTypes === true ) {\n\t\t\treturn blockTypes;\n\t\t}\n\t\treturn blockTypes.filter( ( { name } ) => {\n\t\t\treturn includes( defaultAllowedBlockTypes || [], name );\n\t\t} );\n\t}, [ defaultAllowedBlockTypes, blockTypes ] );\n\tconst { showBlockTypes, hideBlockTypes } = useDispatch( editPostStore );\n\tconst toggleVisible = useCallback( ( blockName, nextIsChecked ) => {\n\t\tif ( nextIsChecked ) {\n\t\t\tshowBlockTypes( blockName );\n\t\t} else {\n\t\t\thideBlockTypes( blockName );\n\t\t}\n\t}, [] );\n\tconst toggleAllVisible = useCallback(\n\t\t( nextIsChecked ) => {\n\t\t\tconst blockNames = map( blockTypes, 'name' );\n\t\t\tif ( nextIsChecked ) {\n\t\t\t\tshowBlockTypes( blockNames );\n\t\t\t} else {\n\t\t\t\thideBlockTypes( blockNames );\n\t\t\t}\n\t\t},\n\t\t[ blockTypes ]\n\t);\n\n\tif ( ! filteredBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\tconst checkedBlockNames = without(\n\t\tmap( filteredBlockTypes, 'name' ),\n\t\t...hiddenBlockTypes\n\t);\n\n\tconst titleId = 'edit-post-block-manager__category-title-' + instanceId;\n\n\tconst isAllChecked = checkedBlockNames.length === filteredBlockTypes.length;\n\n\tlet ariaChecked;\n\tif ( isAllChecked ) {\n\t\tariaChecked = 'true';\n\t} else if ( checkedBlockNames.length > 0 ) {\n\t\tariaChecked = 'mixed';\n\t} else {\n\t\tariaChecked = 'false';\n\t}\n\n\treturn (\n\t\t<div\n\t\t\trole=\"group\"\n\t\t\taria-labelledby={ titleId }\n\t\t\tclassName=\"edit-post-block-manager__category\"\n\t\t>\n\t\t\t<CheckboxControl\n\t\t\t\tchecked={ isAllChecked }\n\t\t\t\tonChange={ toggleAllVisible }\n\t\t\t\tclassName=\"edit-post-block-manager__category-title\"\n\t\t\t\taria-checked={ ariaChecked }\n\t\t\t\tlabel={ <span id={ titleId }>{ title }</span> }\n\t\t\t/>\n\t\t\t<BlockTypesChecklist\n\t\t\t\tblockTypes={ filteredBlockTypes }\n\t\t\t\tvalue={ checkedBlockNames }\n\t\t\t\tonItemChange={ toggleVisible }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default BlockManagerCategory;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/block-manager/category.js"],"names":["includes","map","without","useContext","useMemo","withSelect","withDispatch","compose","withInstanceId","CheckboxControl","BlockTypesChecklist","EditPostSettings","store","editPostStore","BlockManagerCategory","instanceId","title","blockTypes","hiddenBlockTypes","toggleVisible","toggleAllVisible","settings","allowedBlockTypes","filteredBlockTypes","filter","name","length","checkedBlockNames","titleId","isAllChecked","ariaChecked","select","getPreference","dispatch","ownProps","showBlockTypes","hideBlockTypes","blockName","nextIsChecked","blockNames"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,GAAnB,EAAwBC,OAAxB,QAAuC,QAAvC;AAEA;AACA;AACA;;AACA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,oBAApC;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,cAAlB,QAAwC,oBAAxC;AACA,SAASC,eAAT,QAA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MAAvB,CAAtB;;AACA,UAAKqB,aAAL,EAAqB;AACpBH,QAAAA,cAAc,CAAEI,UAAF,CAAd;AACA,OAFD,MAEO;AACNH,QAAAA,cAAc,CAAEG,UAAF,CAAd;AACA;AACD;;AAfK,GAAP;AAiBA,CApBW,CATW,CAAF,CAAP,CA8BVzB,oBA9BU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { includes, map, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useMemo } from '@wordpress/element';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose, withInstanceId } from '@wordpress/compose';\nimport { CheckboxControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesChecklist from './checklist';\nimport EditPostSettings from '../edit-post-settings';\nimport { store as editPostStore } from '../../store';\n\nfunction BlockManagerCategory( {\n\tinstanceId,\n\ttitle,\n\tblockTypes,\n\thiddenBlockTypes,\n\ttoggleVisible,\n\ttoggleAllVisible,\n} ) {\n\tconst settings = useContext( EditPostSettings );\n\tconst { allowedBlockTypes } = settings;\n\tconst filteredBlockTypes = useMemo( () => {\n\t\tif ( allowedBlockTypes === true ) {\n\t\t\treturn blockTypes;\n\t\t}\n\t\treturn blockTypes.filter( ( { name } ) => {\n\t\t\treturn includes( allowedBlockTypes || [], name );\n\t\t} );\n\t}, [ allowedBlockTypes, blockTypes ] );\n\n\tif ( ! filteredBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\tconst checkedBlockNames = without(\n\t\tmap( filteredBlockTypes, 'name' ),\n\t\t...hiddenBlockTypes\n\t);\n\n\tconst titleId = 'edit-post-block-manager__category-title-' + instanceId;\n\n\tconst isAllChecked = checkedBlockNames.length === filteredBlockTypes.length;\n\n\tlet ariaChecked;\n\tif ( isAllChecked ) {\n\t\tariaChecked = 'true';\n\t} else if ( checkedBlockNames.length > 0 ) {\n\t\tariaChecked = 'mixed';\n\t} else {\n\t\tariaChecked = 'false';\n\t}\n\n\treturn (\n\t\t<div\n\t\t\trole=\"group\"\n\t\t\taria-labelledby={ titleId }\n\t\t\tclassName=\"edit-post-block-manager__category\"\n\t\t>\n\t\t\t<CheckboxControl\n\t\t\t\tchecked={ isAllChecked }\n\t\t\t\tonChange={ toggleAllVisible }\n\t\t\t\tclassName=\"edit-post-block-manager__category-title\"\n\t\t\t\taria-checked={ ariaChecked }\n\t\t\t\tlabel={ <span id={ titleId }>{ title }</span> }\n\t\t\t/>\n\t\t\t<BlockTypesChecklist\n\t\t\t\tblockTypes={ filteredBlockTypes }\n\t\t\t\tvalue={ checkedBlockNames }\n\t\t\t\tonItemChange={ toggleVisible }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default compose( [\n\twithInstanceId,\n\twithSelect( ( select ) => {\n\t\tconst { getPreference } = select( editPostStore );\n\n\t\treturn {\n\t\t\thiddenBlockTypes: getPreference( 'hiddenBlockTypes' ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, ownProps ) => {\n\t\tconst { showBlockTypes, hideBlockTypes } = dispatch( editPostStore );\n\n\t\treturn {\n\t\t\ttoggleVisible( blockName, nextIsChecked ) {\n\t\t\t\tif ( nextIsChecked ) {\n\t\t\t\t\tshowBlockTypes( blockName );\n\t\t\t\t} else {\n\t\t\t\t\thideBlockTypes( blockName );\n\t\t\t\t}\n\t\t\t},\n\t\t\ttoggleAllVisible( nextIsChecked ) {\n\t\t\t\tconst blockNames = map( ownProps.blockTypes, 'name' );\n\t\t\t\tif ( nextIsChecked ) {\n\t\t\t\t\tshowBlockTypes( blockNames );\n\t\t\t\t} else {\n\t\t\t\t\thideBlockTypes( blockNames );\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t} ),\n] )( BlockManagerCategory );\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { createContext } from '@wordpress/element';
5
+ const EditPostSettings = createContext({});
6
+ export default EditPostSettings;
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/edit-post-settings/index.js"],"names":["createContext","EditPostSettings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,oBAA9B;AAEA,MAAMC,gBAAgB,GAAGD,aAAa,CAAE,EAAF,CAAtC;AACA,eAAeC,gBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nconst EditPostSettings = createContext( {} );\nexport default EditPostSettings;\n"]}
@@ -32,23 +32,17 @@ function ModeSwitcher() {
32
32
  shortcut,
33
33
  isRichEditingEnabled,
34
34
  isCodeEditingEnabled,
35
- isEditingTemplate,
36
35
  mode
37
36
  } = useSelect(select => ({
38
37
  shortcut: select(keyboardShortcutsStore).getShortcutRepresentation('core/edit-post/toggle-mode'),
39
38
  isRichEditingEnabled: select(editorStore).getEditorSettings().richEditingEnabled,
40
39
  isCodeEditingEnabled: select(editorStore).getEditorSettings().codeEditingEnabled,
41
- isEditingTemplate: select(editPostStore).isEditingTemplate(),
42
40
  mode: select(editPostStore).getEditorMode()
43
41
  }), []);
44
42
  const {
45
43
  switchEditorMode
46
44
  } = useDispatch(editPostStore);
47
45
 
48
- if (isEditingTemplate) {
49
- return null;
50
- }
51
-
52
46
  if (!isRichEditingEnabled || !isCodeEditingEnabled) {
53
47
  return null;
54
48
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/mode-switcher/index.js"],"names":["__","MenuItemsChoice","MenuGroup","useSelect","useDispatch","store","keyboardShortcutsStore","editorStore","editPostStore","MODES","value","label","ModeSwitcher","shortcut","isRichEditingEnabled","isCodeEditingEnabled","isEditingTemplate","mode","select","getShortcutRepresentation","getEditorSettings","richEditingEnabled","codeEditingEnabled","getEditorMode","switchEditorMode","choices","map","choice"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,EAA0BC,SAA1B,QAA2C,uBAA3C;AACA,SAASC,SAAT,EA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;AACA;;AAED,QAAMU,OAAO,GAAGhB,KAAK,CAACiB,GAAN,CAAaC,MAAF,IAAc;AACxC,QAAKA,MAAM,CAACjB,KAAP,KAAiBO,IAAtB,EAA6B;AAC5B,aAAO,EAAE,GAAGU,MAAL;AAAad,QAAAA;AAAb,OAAP;AACA;;AACD,WAAOc,MAAP;AACA,GALe,CAAhB;AAOA,SACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAG3B,EAAE,CAAE,QAAF;AAArB,KACC,cAAC,eAAD;AACC,IAAA,OAAO,EAAGyB,OADX;AAEC,IAAA,KAAK,EAAGR,IAFT;AAGC,IAAA,QAAQ,EAAGO;AAHZ,IADD,CADD;AASA;;AAED,eAAeZ,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItemsChoice, MenuGroup } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\n/**\n * Set of available mode options.\n *\n * @type {Array}\n */\nconst MODES = [\n\t{\n\t\tvalue: 'visual',\n\t\tlabel: __( 'Visual editor' ),\n\t},\n\t{\n\t\tvalue: 'text',\n\t\tlabel: __( 'Code editor' ),\n\t},\n];\n\nfunction ModeSwitcher() {\n\tconst {\n\t\tshortcut,\n\t\tisRichEditingEnabled,\n\t\tisCodeEditingEnabled,\n\t\tisEditingTemplate,\n\t\tmode,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\tshortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/edit-post/toggle-mode' ),\n\t\t\tisRichEditingEnabled: select( editorStore ).getEditorSettings()\n\t\t\t\t.richEditingEnabled,\n\t\t\tisCodeEditingEnabled: select( editorStore ).getEditorSettings()\n\t\t\t\t.codeEditingEnabled,\n\t\t\tisEditingTemplate: select( editPostStore ).isEditingTemplate(),\n\t\t\tmode: select( editPostStore ).getEditorMode(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { switchEditorMode } = useDispatch( editPostStore );\n\n\tif ( isEditingTemplate ) {\n\t\treturn null;\n\t}\n\n\tif ( ! isRichEditingEnabled || ! isCodeEditingEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst choices = MODES.map( ( choice ) => {\n\t\tif ( choice.value !== mode ) {\n\t\t\treturn { ...choice, shortcut };\n\t\t}\n\t\treturn choice;\n\t} );\n\n\treturn (\n\t\t<MenuGroup label={ __( 'Editor' ) }>\n\t\t\t<MenuItemsChoice\n\t\t\t\tchoices={ choices }\n\t\t\t\tvalue={ mode }\n\t\t\t\tonSelect={ switchEditorMode }\n\t\t\t/>\n\t\t</MenuGroup>\n\t);\n}\n\nexport default ModeSwitcher;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/header/mode-switcher/index.js"],"names":["__","MenuItemsChoice","MenuGroup","useSelect","useDispatch","store","keyboardShortcutsStore","editorStore","editPostStore","MODES","value","label","ModeSwitcher","shortcut","isRichEditingEnabled","isCodeEditingEnabled","mode","select","getShortcutRepresentation","getEditorSettings","richEditingEnabled","codeEditingEnabled","getEditorMode","switchEditorMode","choices","map","choice"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,EAA0BC,SAA1B,QAA2C,uBAA3C;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,sBAAlB,QAAgD,+BAAhD;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASF,KAAK,IAAIG,aAAlB,QAAuC,gBAAvC;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,KAAK,GAAG,CACb;AACCC,EAAAA,KAAK,EAAE,QADR;AAECC,EAAAA,KAAK,EAAEX,EAAE,CA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\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItemsChoice, MenuGroup } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\n/**\n * Set of available mode options.\n *\n * @type {Array}\n */\nconst MODES = [\n\t{\n\t\tvalue: 'visual',\n\t\tlabel: __( 'Visual editor' ),\n\t},\n\t{\n\t\tvalue: 'text',\n\t\tlabel: __( 'Code editor' ),\n\t},\n];\n\nfunction ModeSwitcher() {\n\tconst {\n\t\tshortcut,\n\t\tisRichEditingEnabled,\n\t\tisCodeEditingEnabled,\n\t\tmode,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\tshortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/edit-post/toggle-mode' ),\n\t\t\tisRichEditingEnabled: select( editorStore ).getEditorSettings()\n\t\t\t\t.richEditingEnabled,\n\t\t\tisCodeEditingEnabled: select( editorStore ).getEditorSettings()\n\t\t\t\t.codeEditingEnabled,\n\t\t\tmode: select( editPostStore ).getEditorMode(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { switchEditorMode } = useDispatch( editPostStore );\n\n\tif ( ! isRichEditingEnabled || ! isCodeEditingEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst choices = MODES.map( ( choice ) => {\n\t\tif ( choice.value !== mode ) {\n\t\t\treturn { ...choice, shortcut };\n\t\t}\n\t\treturn choice;\n\t} );\n\n\treturn (\n\t\t<MenuGroup label={ __( 'Editor' ) }>\n\t\t\t<MenuItemsChoice\n\t\t\t\tchoices={ choices }\n\t\t\t\tvalue={ mode }\n\t\t\t\tonSelect={ switchEditorMode }\n\t\t\t/>\n\t\t</MenuGroup>\n\t);\n}\n\nexport default ModeSwitcher;\n"]}
@@ -39,6 +39,10 @@ export default function EditTemplateTitle() {
39
39
  updateEditorSettings
40
40
  } = useDispatch(editorStore);
41
41
 
42
+ if (template.has_theme_file) {
43
+ return null;
44
+ }
45
+
42
46
  let templateTitle = __('Default');
43
47
 
44
48
  if (template !== null && template !== void 0 && template.title) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/template-title/edit-template-title.js"],"names":["mapValues","__","TextControl","useDispatch","useSelect","store","editorStore","coreStore","editPostStore","EditTemplateTitle","template","select","getEditedPostTemplate","editEntityRecord","getEditorSettings","updateEditorSettings","templateTitle","title","slug","newTitle","settings","newAvailableTemplates","availableTemplates","existingTitle","id"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASF,KAAK,IAAIG,aAAlB,QAAuC,gBAAvC;AAEA,eAAe,SAASC,iBAAT,GAA6B;AAC3C,QAAM;AAAEC,IAAAA;AAAF,MAAeN,SAAS,CAAIO,MAAF,IAAc;AAC7C,UAAM;AAAEC,MAAAA;AAAF,QAA4BD,MAAM,CAAEH,aAAF,CAAxC;AACA,WAAO;AACNE,MAAAA,QAAQ,EAAEE,qBAAqB;AADzB,KAAP;AAGA,GAL6B,EAK3B,EAL2B,CAA9B;AAOA,QAAM;AAAEC,IAAAA;AAAF,MAAuBV,WAAW,CAAEI,SAAF,CAAxC;AACA,QAAM;AAAEO,IAAAA;AAAF,MAAwBV,SAAS,CAAEE,WAAF,CAAvC;AACA,QAAM;AAAES,IAAAA;AAAF,MAA2BZ,WAAW,CAAEG,WAAF,CAA5C;;AAEA,MAAIU,aAAa,GAAGf,EAAE,CAAE,SAAF,CAAtB;;AACA,MAAKS,QAAL,aAAKA,QAAL,eAAKA,QAAQ,CAAEO,KAAf,EAAuB;AACtBD,IAAAA,aAAa,GAAGN,QAAQ,CAACO,KAAzB;AACA,GAFD,MAEO,IAAK,CAAC,CAAEP,QAAR,EAAmB;AACzBM,IAAAA,aAAa,GAAGN,QAAQ,CAACQ,IAAzB;AACA;;AAED,SACC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGjB,EAAE,CAAE,OAAF,CADX;AAEC,IAAA,KAAK,EAAGe,aAFT;AAGC,IAAA,IAAI,EAAGf,EAAE,CACR,0EADQ,CAHV;AAMC,IAAA,QAAQ,EAAKkB,QAAF,IAAgB;AAC1B,YAAMC,QAAQ,GAAGN,iBAAiB,EAAlC;AACA,YAAMO,qBAAqB,GAAGrB,SAAS,CACtCoB,QAAQ,CAACE,kBAD6B,EAEtC,CAAEC,aAAF,EAAiBC,EAAjB,KAAyB;AACxB,YAAKA,EAAE,KAAKd,QAAQ,CAACQ,IAArB,EAA4B;AAC3B,iBAAOK,aAAP;AACA;;AACD,eAAOJ,QAAP;AACA,OAPqC,CAAvC;AASAJ,MAAAA,oBAAoB,CAAE,EACrB,GAAGK,QADkB;AAErBE,QAAAA,kBAAkB,EAAED;AAFC,OAAF,CAApB;AAIAR,MAAAA,gBAAgB,CAAE,UAAF,EAAc,aAAd,EAA6BH,QAAQ,CAACc,EAAtC,EAA0C;AACzDP,QAAAA,KAAK,EAAEE;AADkD,OAA1C,CAAhB;AAGA;AAxBF,IADD;AA4BA","sourcesContent":["/**\n * External dependencies\n */\nimport { mapValues } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nexport default function EditTemplateTitle() {\n\tconst { template } = useSelect( ( select ) => {\n\t\tconst { getEditedPostTemplate } = select( editPostStore );\n\t\treturn {\n\t\t\ttemplate: getEditedPostTemplate(),\n\t\t};\n\t}, [] );\n\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { updateEditorSettings } = useDispatch( editorStore );\n\n\tlet templateTitle = __( 'Default' );\n\tif ( template?.title ) {\n\t\ttemplateTitle = template.title;\n\t} else if ( !! template ) {\n\t\ttemplateTitle = template.slug;\n\t}\n\n\treturn (\n\t\t<TextControl\n\t\t\tlabel={ __( 'Title' ) }\n\t\t\tvalue={ templateTitle }\n\t\t\thelp={ __(\n\t\t\t\t'Give the template a title that indicates its purpose, e.g. \"Full Width\".'\n\t\t\t) }\n\t\t\tonChange={ ( newTitle ) => {\n\t\t\t\tconst settings = getEditorSettings();\n\t\t\t\tconst newAvailableTemplates = mapValues(\n\t\t\t\t\tsettings.availableTemplates,\n\t\t\t\t\t( existingTitle, id ) => {\n\t\t\t\t\t\tif ( id !== template.slug ) {\n\t\t\t\t\t\t\treturn existingTitle;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn newTitle;\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tupdateEditorSettings( {\n\t\t\t\t\t...settings,\n\t\t\t\t\tavailableTemplates: newAvailableTemplates,\n\t\t\t\t} );\n\t\t\t\teditEntityRecord( 'postType', 'wp_template', template.id, {\n\t\t\t\t\ttitle: newTitle,\n\t\t\t\t} );\n\t\t\t} }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/header/template-title/edit-template-title.js"],"names":["mapValues","__","TextControl","useDispatch","useSelect","store","editorStore","coreStore","editPostStore","EditTemplateTitle","template","select","getEditedPostTemplate","editEntityRecord","getEditorSettings","updateEditorSettings","has_theme_file","templateTitle","title","slug","newTitle","settings","newAvailableTemplates","availableTemplates","existingTitle","id"],"mappings":";;AAAA;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C,IAAA,IAAI,EAAGhB,EAAE,CACR,0EADQ,CAHV;AAMC,IAAA,QAAQ,EAAKmB,QAAF,IAAgB;AAC1B,YAAMC,QAAQ,GAAGP,iBAAiB,EAAlC;AACA,YAAMQ,qBAAqB,GAAGtB,SAAS,CACtCqB,QAAQ,CAACE,kBAD6B,EAEtC,CAAEC,aAAF,EAAiBC,EAAjB,KAAyB;AACxB,YAAKA,EAAE,KAAKf,QAAQ,CAACS,IAArB,EAA4B;AAC3B,iBAAOK,aAAP;AACA;;AACD,eAAOJ,QAAP;AACA,OAPqC,CAAvC;AASAL,MAAAA,oBAAoB,CAAE,EACrB,GAAGM,QADkB;AAErBE,QAAAA,kBAAkB,EAAED;AAFC,OAAF,CAApB;AAIAT,MAAAA,gBAAgB,CAAE,UAAF,EAAc,aAAd,EAA6BH,QAAQ,CAACe,EAAtC,EAA0C;AACzDP,QAAAA,KAAK,EAAEE;AADkD,OAA1C,CAAhB;AAGA;AAxBF,IADD;AA4BA","sourcesContent":["/**\n * External dependencies\n */\nimport { mapValues } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nexport default function EditTemplateTitle() {\n\tconst { template } = useSelect( ( select ) => {\n\t\tconst { getEditedPostTemplate } = select( editPostStore );\n\t\treturn {\n\t\t\ttemplate: getEditedPostTemplate(),\n\t\t};\n\t}, [] );\n\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { updateEditorSettings } = useDispatch( editorStore );\n\n\tif ( template.has_theme_file ) {\n\t\treturn null;\n\t}\n\n\tlet templateTitle = __( 'Default' );\n\tif ( template?.title ) {\n\t\ttemplateTitle = template.title;\n\t} else if ( !! template ) {\n\t\ttemplateTitle = template.slug;\n\t}\n\n\treturn (\n\t\t<TextControl\n\t\t\tlabel={ __( 'Title' ) }\n\t\t\tvalue={ templateTitle }\n\t\t\thelp={ __(\n\t\t\t\t'Give the template a title that indicates its purpose, e.g. \"Full Width\".'\n\t\t\t) }\n\t\t\tonChange={ ( newTitle ) => {\n\t\t\t\tconst settings = getEditorSettings();\n\t\t\t\tconst newAvailableTemplates = mapValues(\n\t\t\t\t\tsettings.availableTemplates,\n\t\t\t\t\t( existingTitle, id ) => {\n\t\t\t\t\t\tif ( id !== template.slug ) {\n\t\t\t\t\t\t\treturn existingTitle;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn newTitle;\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tupdateEditorSettings( {\n\t\t\t\t\t...settings,\n\t\t\t\t\tavailableTemplates: newAvailableTemplates,\n\t\t\t\t} );\n\t\t\t\teditEntityRecord( 'postType', 'wp_template', template.id, {\n\t\t\t\t\ttitle: newTitle,\n\t\t\t\t} );\n\t\t\t} }\n\t\t/>\n\t);\n}\n"]}
@@ -5,7 +5,7 @@ import { createElement, Fragment } from "@wordpress/element";
5
5
  */
6
6
  import { __, sprintf } from '@wordpress/i18n';
7
7
  import { useSelect, useDispatch } from '@wordpress/data';
8
- import { Dropdown, Button } from '@wordpress/components';
8
+ import { Dropdown, Button, __experimentalText as Text } from '@wordpress/components';
9
9
  import { chevronDown } from '@wordpress/icons';
10
10
  /**
11
11
  * Internal dependencies
@@ -59,6 +59,7 @@ function TemplateTitle() {
59
59
  templateTitle = template.slug;
60
60
  }
61
61
 
62
+ const hasOptions = !!(template.custom || template.wp_id || template.description);
62
63
  return createElement("div", {
63
64
  className: "edit-post-template-top-area"
64
65
  }, createElement(Button, {
@@ -72,7 +73,7 @@ function TemplateTitle() {
72
73
  clearSelectedBlock();
73
74
  setIsEditingTemplate(false);
74
75
  }
75
- }, title), createElement(Dropdown, {
76
+ }, title), hasOptions ? createElement(Dropdown, {
76
77
  position: "bottom center",
77
78
  contentClassName: "edit-post-template-top-area__popover",
78
79
  renderToggle: _ref => {
@@ -88,8 +89,14 @@ function TemplateTitle() {
88
89
  label: __('Template Options')
89
90
  }, templateTitle);
90
91
  },
91
- renderContent: () => createElement(Fragment, null, template.has_theme_file ? createElement(TemplateDescription, null) : createElement(EditTemplateTitle, null), createElement(DeleteTemplate, null))
92
- }));
92
+ renderContent: () => createElement(Fragment, null, createElement(EditTemplateTitle, null), createElement(TemplateDescription, null), createElement(DeleteTemplate, null))
93
+ }) : createElement(Text, {
94
+ className: "edit-post-template-title",
95
+ size: "body",
96
+ style: {
97
+ lineHeight: '24px'
98
+ }
99
+ }, templateTitle));
93
100
  }
94
101
 
95
102
  export default TemplateTitle;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/template-title/index.js"],"names":["__","sprintf","useSelect","useDispatch","Dropdown","Button","chevronDown","store","editPostStore","blockEditorStore","editorStore","DeleteTemplate","EditTemplateTitle","TemplateDescription","TemplateTitle","template","isEditing","title","select","isEditingTemplate","getEditedPostTemplate","getEditedPostAttribute","_isEditing","clearSelectedBlock","setIsEditingTemplate","templateTitle","slug","onToggle","has_theme_file"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,uBAAjC;AACA,SAASC,WAAT,QAA4B,kBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,gBAAvC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AACA,SAASF,KAAK,IAAIG,WAAlB,QAAqC,mBAArC;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,OAAOC,mBAAP,MAAgC,wBAAhC;;AAEA,SAASC,aAAT,GAAyB;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AK,EAAGzB,OAAO;AACd;AACAD,IAAAA,EAAE,CAAE,SAAF,CAFY,EAGdiB,KAHc,CAJhB;AASC,IAAA,OAAO,EAAG,MAAM;AACfM,MAAAA,kBAAkB;AAClBC,MAAAA,oBAAoB,CAAE,KAAF,CAApB;AACA;AAZF,KAcGP,KAdH,CADD,EAiBC,cAAC,QAAD;AACC,IAAA,QAAQ,EAAC,eADV;AAEC,IAAA,gBAAgB,EAAC,sCAFlB;AAGC,IAAA,YAAY,EAAG;AAAA,UAAE;AAAEU,QAAAA;AAAF,OAAF;AAAA,aACd,cAAC,MAAD;AACC,QAAA,SAAS,EAAC,0BADX;AAEC,QAAA,MAAM,MAFP;AAGC,QAAA,IAAI,EAAGrB,WAHR;AAIC,QAAA,WAAW,MAJZ;AAKC,QAAA,OAAO,EAAGqB,QALX;AAMC,QAAA,KAAK,EAAG3B,EAAE,CAAE,kBAAF;AANX,SAQGyB,aARH,CADc;AAAA,KAHhB;AAeC,IAAA,aAAa,EAAG,MACf,8BACGV,QAAQ,CAACa,cAAT,GACD,cAAC,mBAAD,OADC,GAGD,cAAC,iBAAD,OAJF,EAMC,cAAC,cAAD,OAND;AAhBF,IAjBD,CADD;AA8CA;;AAED,eAAed,aAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { chevronDown } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\nimport DeleteTemplate from './delete-template';\nimport EditTemplateTitle from './edit-template-title';\nimport TemplateDescription from './template-description';\n\nfunction TemplateTitle() {\n\tconst { template, isEditing, title } = useSelect( ( select ) => {\n\t\tconst { isEditingTemplate, getEditedPostTemplate } = select(\n\t\t\teditPostStore\n\t\t);\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\n\t\tconst _isEditing = isEditingTemplate();\n\n\t\treturn {\n\t\t\ttemplate: _isEditing ? getEditedPostTemplate() : null,\n\t\t\tisEditing: _isEditing,\n\t\t\ttitle: getEditedPostAttribute( 'title' )\n\t\t\t\t? getEditedPostAttribute( 'title' )\n\t\t\t\t: __( 'Untitled' ),\n\t\t};\n\t}, [] );\n\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\n\tif ( ! isEditing || ! template ) {\n\t\treturn null;\n\t}\n\n\tlet templateTitle = __( 'Default' );\n\tif ( template?.title ) {\n\t\ttemplateTitle = template.title;\n\t} else if ( !! template ) {\n\t\ttemplateTitle = template.slug;\n\t}\n\n\treturn (\n\t\t<div className=\"edit-post-template-top-area\">\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-post-template-post-title\"\n\t\t\t\tisLink\n\t\t\t\tshowTooltip\n\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t/* translators: %s: Title of the referring post, e.g: \"Hello World!\" */\n\t\t\t\t\t__( 'Edit %s' ),\n\t\t\t\t\ttitle\n\t\t\t\t) }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\tsetIsEditingTemplate( false );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ title }\n\t\t\t</Button>\n\t\t\t<Dropdown\n\t\t\t\tposition=\"bottom center\"\n\t\t\t\tcontentClassName=\"edit-post-template-top-area__popover\"\n\t\t\t\trenderToggle={ ( { onToggle } ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"edit-post-template-title\"\n\t\t\t\t\t\tisLink\n\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\tlabel={ __( 'Template Options' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ templateTitle }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\trenderContent={ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ template.has_theme_file ? (\n\t\t\t\t\t\t\t<TemplateDescription />\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<EditTemplateTitle />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<DeleteTemplate />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default TemplateTitle;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/header/template-title/index.js"],"names":["__","sprintf","useSelect","useDispatch","Dropdown","Button","__experimentalText","Text","chevronDown","store","editPostStore","blockEditorStore","editorStore","DeleteTemplate","EditTemplateTitle","TemplateDescription","TemplateTitle","template","isEditing","title","select","isEditingTemplate","getEditedPostTemplate","getEditedPostAttribute","_isEditing","clearSelectedBlock","setIsEditingTemplate","templateTitle","slug","hasOptions","custom","wp_id","description","onToggle","lineHeight"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,QADD,EAECC,MAFD,EAGCC,kBAAkB,IAAIC,IAHvB,QAIO,uBAJP;AAKA,SAASC,WAAT,QAA4B,kBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,gBAAvC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AACA,SAASF,KAAK,IAAIG,WAAlB,QAAqC,mBAArC;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,OAAOC,mBAAP,MAAgC,wBAAhC;;AAEA,SAASC,aAAT,GAAyB;AACxB,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,SAAZ;AAAuBC,IAAAA;AAAvB,MAAiCjB,SAAS,CAAIkB,MAAF,IAAc;AAC/D,U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,EAAG/B,OAAO;AACd;AACAD,IAAAA,EAAE,CAAE,SAAF,CAFY,EAGdmB,KAHc,CAJhB;AASC,IAAA,OAAO,EAAG,MAAM;AACfM,MAAAA,kBAAkB;AAClBC,MAAAA,oBAAoB,CAAE,KAAF,CAApB;AACA;AAZF,KAcGP,KAdH,CADD,EAiBGU,UAAU,GACX,cAAC,QAAD;AACC,IAAA,QAAQ,EAAC,eADV;AAEC,IAAA,gBAAgB,EAAC,sCAFlB;AAGC,IAAA,YAAY,EAAG;AAAA,UAAE;AAAEI,QAAAA;AAAF,OAAF;AAAA,aACd,cAAC,MAAD;AACC,QAAA,SAAS,EAAC,0BADX;AAEC,QAAA,MAAM,MAFP;AAGC,QAAA,IAAI,EAAGzB,WAHR;AAIC,QAAA,WAAW,MAJZ;AAKC,QAAA,OAAO,EAAGyB,QALX;AAMC,QAAA,KAAK,EAAGjC,EAAE,CAAE,kBAAF;AANX,SAQG2B,aARH,CADc;AAAA,KAHhB;AAeC,IAAA,aAAa,EAAG,MACf,8BACC,cAAC,iBAAD,OADD,EAEC,cAAC,mBAAD,OAFD,EAGC,cAAC,cAAD,OAHD;AAhBF,IADW,GAyBX,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,0BADX;AAEC,IAAA,IAAI,EAAC,MAFN;AAGC,IAAA,KAAK,EAAG;AAAEO,MAAAA,UAAU,EAAE;AAAd;AAHT,KAKGP,aALH,CA1CF,CADD;AAqDA;;AAED,eAAeX,aAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tDropdown,\n\tButton,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { chevronDown } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\nimport DeleteTemplate from './delete-template';\nimport EditTemplateTitle from './edit-template-title';\nimport TemplateDescription from './template-description';\n\nfunction TemplateTitle() {\n\tconst { template, isEditing, title } = useSelect( ( select ) => {\n\t\tconst { isEditingTemplate, getEditedPostTemplate } = select(\n\t\t\teditPostStore\n\t\t);\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\n\t\tconst _isEditing = isEditingTemplate();\n\n\t\treturn {\n\t\t\ttemplate: _isEditing ? getEditedPostTemplate() : null,\n\t\t\tisEditing: _isEditing,\n\t\t\ttitle: getEditedPostAttribute( 'title' )\n\t\t\t\t? getEditedPostAttribute( 'title' )\n\t\t\t\t: __( 'Untitled' ),\n\t\t};\n\t}, [] );\n\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\n\tif ( ! isEditing || ! template ) {\n\t\treturn null;\n\t}\n\n\tlet templateTitle = __( 'Default' );\n\tif ( template?.title ) {\n\t\ttemplateTitle = template.title;\n\t} else if ( !! template ) {\n\t\ttemplateTitle = template.slug;\n\t}\n\n\tconst hasOptions = !! (\n\t\ttemplate.custom ||\n\t\ttemplate.wp_id ||\n\t\ttemplate.description\n\t);\n\n\treturn (\n\t\t<div className=\"edit-post-template-top-area\">\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-post-template-post-title\"\n\t\t\t\tisLink\n\t\t\t\tshowTooltip\n\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t/* translators: %s: Title of the referring post, e.g: \"Hello World!\" */\n\t\t\t\t\t__( 'Edit %s' ),\n\t\t\t\t\ttitle\n\t\t\t\t) }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\tsetIsEditingTemplate( false );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ title }\n\t\t\t</Button>\n\t\t\t{ hasOptions ? (\n\t\t\t\t<Dropdown\n\t\t\t\t\tposition=\"bottom center\"\n\t\t\t\t\tcontentClassName=\"edit-post-template-top-area__popover\"\n\t\t\t\t\trenderToggle={ ( { onToggle } ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"edit-post-template-title\"\n\t\t\t\t\t\t\tisLink\n\t\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\tlabel={ __( 'Template Options' ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ templateTitle }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ () => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<EditTemplateTitle />\n\t\t\t\t\t\t\t<TemplateDescription />\n\t\t\t\t\t\t\t<DeleteTemplate />\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\t\t<Text\n\t\t\t\t\tclassName=\"edit-post-template-title\"\n\t\t\t\t\tsize=\"body\"\n\t\t\t\t\tstyle={ { lineHeight: '24px' } }\n\t\t\t\t>\n\t\t\t\t\t{ templateTitle }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default TemplateTitle;\n"]}