@wordpress/edit-post 7.24.1 → 7.25.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.
Files changed (143) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/header/header-toolbar/index.js +8 -4
  3. package/build/components/header/header-toolbar/index.js.map +1 -1
  4. package/build/components/header/index.js +13 -11
  5. package/build/components/header/index.js.map +1 -1
  6. package/build/components/header/mode-switcher/index.js +1 -1
  7. package/build/components/header/mode-switcher/index.js.map +1 -1
  8. package/build/components/header/more-menu/index.js +2 -1
  9. package/build/components/header/more-menu/index.js.map +1 -1
  10. package/build/components/header/writing-menu/index.js +13 -12
  11. package/build/components/header/writing-menu/index.js.map +1 -1
  12. package/build/components/layout/index.js +12 -12
  13. package/build/components/layout/index.js.map +1 -1
  14. package/build/components/preferences-modal/index.js +65 -49
  15. package/build/components/preferences-modal/index.js.map +1 -1
  16. package/build/components/sidebar/post-status/index.js +1 -2
  17. package/build/components/sidebar/post-status/index.js.map +1 -1
  18. package/build/components/sidebar/settings-header/index.js +17 -43
  19. package/build/components/sidebar/settings-header/index.js.map +1 -1
  20. package/build/components/sidebar/settings-sidebar/index.js +80 -20
  21. package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
  22. package/build/components/start-page-options/index.js +3 -3
  23. package/build/components/start-page-options/index.js.map +1 -1
  24. package/build/components/visual-editor/index.js +20 -257
  25. package/build/components/visual-editor/index.js.map +1 -1
  26. package/build/components/welcome-guide/index.js +6 -3
  27. package/build/components/welcome-guide/index.js.map +1 -1
  28. package/build/editor.js +5 -6
  29. package/build/editor.js.map +1 -1
  30. package/build/editor.native.js +1 -2
  31. package/build/editor.native.js.map +1 -1
  32. package/build/index.js +5 -4
  33. package/build/index.js.map +1 -1
  34. package/build/plugins/welcome-guide-menu-item/index.js +2 -6
  35. package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
  36. package/build/store/actions.js +35 -39
  37. package/build/store/actions.js.map +1 -1
  38. package/build/store/reducer.js +1 -34
  39. package/build/store/reducer.js.map +1 -1
  40. package/build/store/selectors.js +22 -12
  41. package/build/store/selectors.js.map +1 -1
  42. package/build-module/components/header/header-toolbar/index.js +8 -4
  43. package/build-module/components/header/header-toolbar/index.js.map +1 -1
  44. package/build-module/components/header/index.js +15 -13
  45. package/build-module/components/header/index.js.map +1 -1
  46. package/build-module/components/header/mode-switcher/index.js +1 -1
  47. package/build-module/components/header/mode-switcher/index.js.map +1 -1
  48. package/build-module/components/header/more-menu/index.js +2 -1
  49. package/build-module/components/header/more-menu/index.js.map +1 -1
  50. package/build-module/components/header/writing-menu/index.js +14 -13
  51. package/build-module/components/header/writing-menu/index.js.map +1 -1
  52. package/build-module/components/layout/index.js +13 -13
  53. package/build-module/components/layout/index.js.map +1 -1
  54. package/build-module/components/preferences-modal/index.js +65 -49
  55. package/build-module/components/preferences-modal/index.js.map +1 -1
  56. package/build-module/components/sidebar/post-status/index.js +2 -3
  57. package/build-module/components/sidebar/post-status/index.js.map +1 -1
  58. package/build-module/components/sidebar/settings-header/index.js +20 -46
  59. package/build-module/components/sidebar/settings-header/index.js.map +1 -1
  60. package/build-module/components/sidebar/settings-sidebar/index.js +80 -21
  61. package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
  62. package/build-module/components/start-page-options/index.js +3 -3
  63. package/build-module/components/start-page-options/index.js.map +1 -1
  64. package/build-module/components/visual-editor/index.js +24 -261
  65. package/build-module/components/visual-editor/index.js.map +1 -1
  66. package/build-module/components/welcome-guide/index.js +6 -3
  67. package/build-module/components/welcome-guide/index.js.map +1 -1
  68. package/build-module/editor.js +5 -6
  69. package/build-module/editor.js.map +1 -1
  70. package/build-module/editor.native.js +1 -2
  71. package/build-module/editor.native.js.map +1 -1
  72. package/build-module/index.js +3 -2
  73. package/build-module/index.js.map +1 -1
  74. package/build-module/plugins/welcome-guide-menu-item/index.js +2 -6
  75. package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
  76. package/build-module/store/actions.js +31 -36
  77. package/build-module/store/actions.js.map +1 -1
  78. package/build-module/store/reducer.js +1 -33
  79. package/build-module/store/reducer.js.map +1 -1
  80. package/build-module/store/selectors.js +18 -9
  81. package/build-module/store/selectors.js.map +1 -1
  82. package/build-style/style-rtl.css +63 -200
  83. package/build-style/style.css +63 -200
  84. package/package.json +32 -32
  85. package/src/components/header/header-toolbar/index.js +4 -0
  86. package/src/components/header/header-toolbar/style.scss +15 -13
  87. package/src/components/header/index.js +28 -13
  88. package/src/components/header/mode-switcher/index.js +2 -1
  89. package/src/components/header/more-menu/index.js +1 -0
  90. package/src/components/header/style.scss +60 -34
  91. package/src/components/header/writing-menu/index.js +16 -18
  92. package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +1 -1
  93. package/src/components/layout/index.js +13 -12
  94. package/src/components/preferences-modal/index.js +109 -96
  95. package/src/components/preferences-modal/test/index.js +1 -52
  96. package/src/components/sidebar/post-status/index.js +2 -2
  97. package/src/components/sidebar/settings-header/index.js +19 -71
  98. package/src/components/sidebar/settings-sidebar/index.js +117 -54
  99. package/src/components/sidebar/style.scss +4 -12
  100. package/src/components/start-page-options/index.js +3 -3
  101. package/src/components/visual-editor/index.js +26 -359
  102. package/src/components/visual-editor/style.scss +0 -15
  103. package/src/components/welcome-guide/index.js +4 -2
  104. package/src/editor.js +7 -7
  105. package/src/editor.native.js +3 -9
  106. package/src/index.js +3 -2
  107. package/src/plugins/welcome-guide-menu-item/index.js +3 -6
  108. package/src/store/actions.js +32 -46
  109. package/src/store/reducer.js +0 -33
  110. package/src/store/selectors.js +23 -9
  111. package/src/store/test/actions.js +0 -28
  112. package/src/style.scss +0 -3
  113. package/src/test/__snapshots__/editor.native.js.snap +21 -0
  114. package/src/test/editor.native.js +90 -56
  115. package/build/components/device-preview/index.js +0 -72
  116. package/build/components/device-preview/index.js.map +0 -1
  117. package/build/components/header/document-actions/index.js +0 -82
  118. package/build/components/header/document-actions/index.js.map +0 -1
  119. package/build/components/sidebar/post-template/create-modal.js +0 -99
  120. package/build/components/sidebar/post-template/create-modal.js.map +0 -1
  121. package/build/components/sidebar/post-template/form.js +0 -110
  122. package/build/components/sidebar/post-template/form.js.map +0 -1
  123. package/build/components/sidebar/post-template/index.js +0 -106
  124. package/build/components/sidebar/post-template/index.js.map +0 -1
  125. package/build-module/components/device-preview/index.js +0 -65
  126. package/build-module/components/device-preview/index.js.map +0 -1
  127. package/build-module/components/header/document-actions/index.js +0 -74
  128. package/build-module/components/header/document-actions/index.js.map +0 -1
  129. package/build-module/components/sidebar/post-template/create-modal.js +0 -92
  130. package/build-module/components/sidebar/post-template/create-modal.js.map +0 -1
  131. package/build-module/components/sidebar/post-template/form.js +0 -102
  132. package/build-module/components/sidebar/post-template/form.js.map +0 -1
  133. package/build-module/components/sidebar/post-template/index.js +0 -98
  134. package/build-module/components/sidebar/post-template/index.js.map +0 -1
  135. package/src/components/device-preview/index.js +0 -73
  136. package/src/components/header/document-actions/index.js +0 -82
  137. package/src/components/header/document-actions/style.scss +0 -64
  138. package/src/components/sidebar/post-template/create-modal.js +0 -140
  139. package/src/components/sidebar/post-template/form.js +0 -141
  140. package/src/components/sidebar/post-template/index.js +0 -120
  141. package/src/components/sidebar/post-template/style.scss +0 -22
  142. package/src/components/sidebar/settings-header/style.scss +0 -74
  143. package/src/components/sidebar/template/style.scss +0 -35
@@ -1 +1 @@
1
- {"version":3,"names":["Modal","__","useState","useMemo","store","blockEditorStore","__experimentalBlockPatternsList","BlockPatternsList","useSelect","useDispatch","useAsyncList","editorStore","editPostStore","useStartPatterns","blockPatternsWithPostContentBlockType","postType","select","getPatternsByBlockTypes","getCurrentPostType","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","blockPatterns","onChoosePattern","shownBlockPatterns","resetEditorBlocks","createElement","shownPatterns","onClickPattern","_pattern","blocks","StartPageOptionsModal","onClose","startPatterns","hasStartPattern","length","className","title","isFullScreen","onRequestClose","StartPageOptions","isClosed","setIsClosed","shouldEnableModal","isCleanNewPost","isEditingTemplate","isFeatureActive"],"sources":["@wordpress/edit-post/src/components/start-page-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nfunction useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declared and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes } = select( blockEditorStore );\n\t\t\tconst { getCurrentPostType } = select( editorStore );\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType:\n\t\t\t\t\tgetPatternsByBlockTypes( 'core/post-content' ),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\t// filter patterns without postTypes declared if the current postType is page\n\t\t// or patterns that declare the current postType in its post type array.\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { blockPatterns, onChoosePattern } ) {\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\tconst { resetEditorBlocks } = useDispatch( editorStore );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartPageOptionsModal( { onClose } ) {\n\tconst startPatterns = useStartPatterns();\n\tconst hasStartPattern = startPatterns.length > 0;\n\n\tif ( ! hasStartPattern ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-post-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<div className=\"edit-post-start-page-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tblockPatterns={ startPatterns }\n\t\t\t\t\tonChoosePattern={ onClose }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartPageOptions() {\n\tconst [ isClosed, setIsClosed ] = useState( false );\n\tconst shouldEnableModal = useSelect( ( select ) => {\n\t\tconst { isCleanNewPost } = select( editorStore );\n\t\tconst { isEditingTemplate, isFeatureActive } = select( editPostStore );\n\n\t\treturn (\n\t\t\t! isEditingTemplate() &&\n\t\t\t! isFeatureActive( 'welcomeGuide' ) &&\n\t\t\tisCleanNewPost()\n\t\t);\n\t}, [] );\n\n\tif ( ! shouldEnableModal || isClosed ) {\n\t\treturn null;\n\t}\n\n\treturn <StartPageOptionsModal onClose={ () => setIsClosed( true ) } />;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SACCC,KAAK,IAAIC,gBAAgB,EACzBC,+BAA+B,IAAIC,iBAAiB,QAC9C,yBAAyB;AAChC,SAASC,SAAS,EAAEC,W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AMU,WAAW,CAAE,IAAK;EAAG,CAAE,CAAC;AACvE"}
1
+ {"version":3,"names":["Modal","__","useState","useMemo","store","blockEditorStore","__experimentalBlockPatternsList","BlockPatternsList","useSelect","useDispatch","useAsyncList","editorStore","editPostStore","useStartPatterns","blockPatternsWithPostContentBlockType","postType","select","getPatternsByBlockTypes","getCurrentPostType","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","blockPatterns","onChoosePattern","shownBlockPatterns","resetEditorBlocks","createElement","shownPatterns","onClickPattern","_pattern","blocks","StartPageOptionsModal","onClose","startPatterns","hasStartPattern","length","className","title","isFullScreen","onRequestClose","StartPageOptions","isClosed","setIsClosed","shouldEnableModal","isCleanNewPost","getRenderingMode","isFeatureActive"],"sources":["@wordpress/edit-post/src/components/start-page-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nfunction useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declared and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes } = select( blockEditorStore );\n\t\t\tconst { getCurrentPostType } = select( editorStore );\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType:\n\t\t\t\t\tgetPatternsByBlockTypes( 'core/post-content' ),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\t// filter patterns without postTypes declared if the current postType is page\n\t\t// or patterns that declare the current postType in its post type array.\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { blockPatterns, onChoosePattern } ) {\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\tconst { resetEditorBlocks } = useDispatch( editorStore );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartPageOptionsModal( { onClose } ) {\n\tconst startPatterns = useStartPatterns();\n\tconst hasStartPattern = startPatterns.length > 0;\n\n\tif ( ! hasStartPattern ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-post-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<div className=\"edit-post-start-page-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tblockPatterns={ startPatterns }\n\t\t\t\t\tonChoosePattern={ onClose }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartPageOptions() {\n\tconst [ isClosed, setIsClosed ] = useState( false );\n\tconst shouldEnableModal = useSelect( ( select ) => {\n\t\tconst { isCleanNewPost, getRenderingMode } = select( editorStore );\n\t\tconst { isFeatureActive } = select( editPostStore );\n\n\t\treturn (\n\t\t\tgetRenderingMode() === 'post-only' &&\n\t\t\t! isFeatureActive( 'welcomeGuide' ) &&\n\t\t\tisCleanNewPost()\n\t\t);\n\t}, [] );\n\n\tif ( ! shouldEnableModal || isClosed ) {\n\t\treturn null;\n\t}\n\n\treturn <StartPageOptionsModal onClose={ () => setIsClosed( true ) } />;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SACCC,KAAK,IAAIC,gBAAgB,EACzBC,+BAA+B,IAAIC,iBAAiB,QAC9C,yBAAyB;AAChC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASN,KAAK,IAAIO,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA,SAASP,KAAK,IAAIQ,aAAa,QAAQ,aAAa;AAEpD,SAASC,gBAAgBA,CAAA,EAAG;EAC3B;EACA;EACA;EACA,MAAM;IAAEC,qCAAqC;IAAEC;EAAS,CAAC,GAAGP,SAAS,CAClEQ,MAAM,IAAM;IACb,MAAM;MAAEC;IAAwB,CAAC,GAAGD,MAAM,CAAEX,gBAAiB,CAAC;IAC9D,MAAM;MAAEa;IAAmB,CAAC,GAAGF,MAAM,CAAEL,WAAY,CAAC;IACpD,OAAO;MACNG,qCAAqC,EACpCG,uBAAuB,CAAE,mBAAoB,CAAC;MAC/CF,QAAQ,EAAEG,kBAAkB,CAAC;IAC9B,CAAC;EACF,CAAC,EACD,EACD,CAAC;EAED,OAAOf,OAAO,CAAE,MAAM;IACrB;IACA;IACA,OAAOW,qCAAqC,CAACK,MAAM,CAAIC,OAAO,IAAM;MACnE,OACGL,QAAQ,KAAK,MAAM,IAAI,CAAEK,OAAO,CAACC,SAAS,IAC1CC,KAAK,CAACC,OAAO,CAAEH,OAAO,CAACC,SAAU,CAAC,IACnCD,OAAO,CAACC,SAAS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,MAAM,IAAM;IAClD,MAAM;MAAEgC,cAAc;MAAEC;IAAiB,CAAC,GAAGjC,MAAM,CAAEL,WAAY,CAAC;IAClE,MAAM;MAAEuC;IAAgB,CAAC,GAAGlC,MAAM,CAAEJ,aAAc,CAAC;IAEnD,OACCqC,gBAAgB,CAAC,CAAC,KAAK,WAAW,IAClC,CAAEC,eAAe,CAAE,cAAe,CAAC,IACnCF,cAAc,CAAC,CAAC;EAElB,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAED,iBAAiB,IAAIF,QAAQ,EAAG;IACtC,OAAO,IAAI;EACZ;EAEA,OAAOf,aAAA,CAACK,qBAAqB;IAACC,OAAO,EAAGA,CAAA,KAAMU,WAAW,CAAE,IAAK;EAAG,CAAE,CAAC;AACvE"}
@@ -1,4 +1,4 @@
1
- import { createElement, Fragment } from "react";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * External dependencies
4
4
  */
@@ -7,14 +7,10 @@ import classnames from 'classnames';
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
- import { PostTitle, store as editorStore } from '@wordpress/editor';
11
- import { BlockList, BlockTools, store as blockEditorStore, __unstableUseTypewriter as useTypewriter, __unstableUseTypingObserver as useTypingObserver, __experimentalUseResizeCanvas as useResizeCanvas, useSettings, __experimentalRecursionProvider as RecursionProvider, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
12
- import { useEffect, useRef, useMemo } from '@wordpress/element';
13
- import { __unstableMotion as motion } from '@wordpress/components';
10
+ import { store as editorStore, privateApis as editorPrivateApis } from '@wordpress/editor';
11
+ import { useMemo } from '@wordpress/element';
14
12
  import { useSelect } from '@wordpress/data';
15
- import { useMergeRefs } from '@wordpress/compose';
16
- import { parse, store as blocksStore } from '@wordpress/blocks';
17
- import { store as coreStore } from '@wordpress/core-data';
13
+ import { store as blocksStore } from '@wordpress/blocks';
18
14
 
19
15
  /**
20
16
  * Internal dependencies
@@ -22,296 +18,63 @@ import { store as coreStore } from '@wordpress/core-data';
22
18
  import { store as editPostStore } from '../../store';
23
19
  import { unlock } from '../../lock-unlock';
24
20
  const {
25
- LayoutStyle,
26
- useLayoutClasses,
27
- useLayoutStyles,
28
- ExperimentalBlockCanvas: BlockCanvas
29
- } = unlock(blockEditorPrivateApis);
21
+ EditorCanvas
22
+ } = unlock(editorPrivateApis);
30
23
  const isGutenbergPlugin = process.env.IS_GUTENBERG_PLUGIN ? true : false;
31
-
32
- /**
33
- * Given an array of nested blocks, find the first Post Content
34
- * block inside it, recursing through any nesting levels,
35
- * and return its attributes.
36
- *
37
- * @param {Array} blocks A list of blocks.
38
- *
39
- * @return {Object | undefined} The Post Content block.
40
- */
41
- function getPostContentAttributes(blocks) {
42
- for (let i = 0; i < blocks.length; i++) {
43
- if (blocks[i].name === 'core/post-content') {
44
- return blocks[i].attributes;
45
- }
46
- if (blocks[i].innerBlocks.length) {
47
- const nestedPostContent = getPostContentAttributes(blocks[i].innerBlocks);
48
- if (nestedPostContent) {
49
- return nestedPostContent;
50
- }
51
- }
52
- }
53
- }
54
- function checkForPostContentAtRootLevel(blocks) {
55
- for (let i = 0; i < blocks.length; i++) {
56
- if (blocks[i].name === 'core/post-content') {
57
- return true;
58
- }
59
- }
60
- return false;
61
- }
62
24
  export default function VisualEditor({
63
25
  styles
64
26
  }) {
65
27
  const {
66
- deviceType,
67
28
  isWelcomeGuideVisible,
68
- isTemplateMode,
69
- postContentAttributes,
70
- editedPostTemplate = {},
71
- wrapperBlockName,
72
- wrapperUniqueId,
29
+ renderingMode,
73
30
  isBlockBasedTheme,
74
31
  hasV3BlocksOnly
75
32
  } = useSelect(select => {
76
33
  const {
77
- isFeatureActive,
78
- isEditingTemplate,
79
- getEditedPostTemplate,
80
- __experimentalGetPreviewDeviceType
34
+ isFeatureActive
81
35
  } = select(editPostStore);
82
36
  const {
83
- getCurrentPostId,
84
- getCurrentPostType,
85
- getEditorSettings
37
+ getEditorSettings,
38
+ getRenderingMode
86
39
  } = select(editorStore);
87
40
  const {
88
41
  getBlockTypes
89
42
  } = select(blocksStore);
90
- const _isTemplateMode = isEditingTemplate();
91
- const postTypeSlug = getCurrentPostType();
92
- let _wrapperBlockName;
93
- if (postTypeSlug === 'wp_block') {
94
- _wrapperBlockName = 'core/block';
95
- } else if (!_isTemplateMode) {
96
- _wrapperBlockName = 'core/post-content';
97
- }
98
43
  const editorSettings = getEditorSettings();
99
- const supportsTemplateMode = editorSettings.supportsTemplateMode;
100
- const postType = select(coreStore).getPostType(postTypeSlug);
101
- const canEditTemplate = select(coreStore).canUser('create', 'templates');
102
44
  return {
103
- deviceType: __experimentalGetPreviewDeviceType(),
104
45
  isWelcomeGuideVisible: isFeatureActive('welcomeGuide'),
105
- isTemplateMode: _isTemplateMode,
106
- postContentAttributes: getEditorSettings().postContentAttributes,
107
- // Post template fetch returns a 404 on classic themes, which
108
- // messes with e2e tests, so check it's a block theme first.
109
- editedPostTemplate: postType?.viewable && supportsTemplateMode && canEditTemplate ? getEditedPostTemplate() : undefined,
110
- wrapperBlockName: _wrapperBlockName,
111
- wrapperUniqueId: getCurrentPostId(),
46
+ renderingMode: getRenderingMode(),
112
47
  isBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme,
113
48
  hasV3BlocksOnly: getBlockTypes().every(type => {
114
49
  return type.apiVersion >= 3;
115
50
  })
116
51
  };
117
52
  }, []);
118
- const {
119
- isCleanNewPost
120
- } = useSelect(editorStore);
121
53
  const hasMetaBoxes = useSelect(select => select(editPostStore).hasMetaBoxes(), []);
122
- const {
123
- hasRootPaddingAwareAlignments,
124
- isFocusMode,
125
- themeHasDisabledLayoutStyles,
126
- themeSupportsLayout
127
- } = useSelect(select => {
128
- const _settings = select(blockEditorStore).getSettings();
129
- return {
130
- themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
131
- themeSupportsLayout: _settings.supportsLayout,
132
- isFocusMode: _settings.focusMode,
133
- hasRootPaddingAwareAlignments: _settings.__experimentalFeatures?.useRootPaddingAwareAlignments
134
- };
135
- }, []);
136
- const desktopCanvasStyles = {
137
- height: '100%',
138
- width: '100%',
139
- marginLeft: 'auto',
140
- marginRight: 'auto',
141
- display: 'flex',
142
- flexFlow: 'column',
143
- // Default background color so that grey
144
- // .edit-post-editor-regions__content color doesn't show through.
145
- background: 'white'
146
- };
147
- const templateModeStyles = {
148
- ...desktopCanvasStyles,
149
- borderRadius: '2px 2px 0 0',
150
- border: '1px solid #ddd',
151
- borderBottom: 0
152
- };
153
- const resizedCanvasStyles = useResizeCanvas(deviceType, isTemplateMode);
154
- const [globalLayoutSettings] = useSettings('layout');
155
- const previewMode = 'is-' + deviceType.toLowerCase() + '-preview';
156
- let animatedStyles = isTemplateMode ? templateModeStyles : desktopCanvasStyles;
157
- if (resizedCanvasStyles) {
158
- animatedStyles = resizedCanvasStyles;
159
- }
160
54
  let paddingBottom;
161
55
 
162
56
  // Add a constant padding for the typewritter effect. When typing at the
163
57
  // bottom, there needs to be room to scroll up.
164
- if (!hasMetaBoxes && !resizedCanvasStyles && !isTemplateMode) {
58
+ if (!hasMetaBoxes && renderingMode === 'post-only') {
165
59
  paddingBottom = '40vh';
166
60
  }
167
- const ref = useRef();
168
- const contentRef = useMergeRefs([ref, useTypewriter()]);
169
-
170
- // fallbackLayout is used if there is no Post Content,
171
- // and for Post Title.
172
- const fallbackLayout = useMemo(() => {
173
- if (isTemplateMode) {
174
- return {
175
- type: 'default'
176
- };
177
- }
178
- if (themeSupportsLayout) {
179
- // We need to ensure support for wide and full alignments,
180
- // so we add the constrained type.
181
- return {
182
- ...globalLayoutSettings,
183
- type: 'constrained'
184
- };
185
- }
186
- // Set default layout for classic themes so all alignments are supported.
187
- return {
188
- type: 'default'
189
- };
190
- }, [isTemplateMode, themeSupportsLayout, globalLayoutSettings]);
191
- const newestPostContentAttributes = useMemo(() => {
192
- if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) {
193
- return postContentAttributes;
194
- }
195
- // When in template editing mode, we can access the blocks directly.
196
- if (editedPostTemplate?.blocks) {
197
- return getPostContentAttributes(editedPostTemplate?.blocks);
198
- }
199
- // If there are no blocks, we have to parse the content string.
200
- // Best double-check it's a string otherwise the parse function gets unhappy.
201
- const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
202
- return getPostContentAttributes(parse(parseableContent)) || {};
203
- }, [editedPostTemplate?.content, editedPostTemplate?.blocks, postContentAttributes]);
204
- const hasPostContentAtRootLevel = useMemo(() => {
205
- if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) {
206
- return false;
207
- }
208
- // When in template editing mode, we can access the blocks directly.
209
- if (editedPostTemplate?.blocks) {
210
- return checkForPostContentAtRootLevel(editedPostTemplate?.blocks);
211
- }
212
- // If there are no blocks, we have to parse the content string.
213
- // Best double-check it's a string otherwise the parse function gets unhappy.
214
- const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
215
- return checkForPostContentAtRootLevel(parse(parseableContent)) || false;
216
- }, [editedPostTemplate?.content, editedPostTemplate?.blocks]);
217
- const {
218
- layout = {},
219
- align = ''
220
- } = newestPostContentAttributes || {};
221
- const postContentLayoutClasses = useLayoutClasses(newestPostContentAttributes, 'core/post-content');
222
- const blockListLayoutClass = classnames({
223
- 'is-layout-flow': !themeSupportsLayout
224
- }, themeSupportsLayout && postContentLayoutClasses, align && `align${align}`);
225
- const postContentLayoutStyles = useLayoutStyles(newestPostContentAttributes, 'core/post-content', '.block-editor-block-list__layout.is-root-container');
226
-
227
- // Update type for blocks using legacy layouts.
228
- const postContentLayout = useMemo(() => {
229
- return layout && (layout?.type === 'constrained' || layout?.inherit || layout?.contentSize || layout?.wideSize) ? {
230
- ...globalLayoutSettings,
231
- ...layout,
232
- type: 'constrained'
233
- } : {
234
- ...globalLayoutSettings,
235
- ...layout,
236
- type: 'default'
237
- };
238
- }, [layout?.type, layout?.inherit, layout?.contentSize, layout?.wideSize, globalLayoutSettings]);
239
-
240
- // If there is a Post Content block we use its layout for the block list;
241
- // if not, this must be a classic theme, in which case we use the fallback layout.
242
- const blockListLayout = postContentAttributes ? postContentLayout : fallbackLayout;
243
- const postEditorLayout = blockListLayout?.type === 'default' && !hasPostContentAtRootLevel ? fallbackLayout : blockListLayout;
244
- const observeTypingRef = useTypingObserver();
245
- const titleRef = useRef();
246
- useEffect(() => {
247
- if (isWelcomeGuideVisible || !isCleanNewPost()) {
248
- return;
249
- }
250
- titleRef?.current?.focus();
251
- }, [isWelcomeGuideVisible, isCleanNewPost]);
252
61
  styles = useMemo(() => [...styles, {
253
62
  // We should move this in to future to the body.
254
- css: `.edit-post-visual-editor__post-title-wrapper{margin-top:4rem}` + (paddingBottom ? `body{padding-bottom:${paddingBottom}}` : '')
255
- }], [styles]);
256
-
257
- // Add some styles for alignwide/alignfull Post Content and its children.
258
- const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}
259
- .is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}
260
- .is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
261
- .is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
262
- const isToBeIframed = (hasV3BlocksOnly || isGutenbergPlugin && isBlockBasedTheme) && !hasMetaBoxes || isTemplateMode || deviceType === 'Tablet' || deviceType === 'Mobile';
263
- return createElement(BlockTools, {
264
- __unstableContentRef: ref,
63
+ css: paddingBottom ? `body{padding-bottom:${paddingBottom}}` : ''
64
+ }], [styles, paddingBottom]);
65
+ const isToBeIframed = (hasV3BlocksOnly || isGutenbergPlugin && isBlockBasedTheme) && !hasMetaBoxes || renderingMode === 'template-only';
66
+ return createElement("div", {
265
67
  className: classnames('edit-post-visual-editor', {
266
- 'is-template-mode': isTemplateMode,
68
+ 'is-template-mode': renderingMode === 'template-only',
267
69
  'has-inline-canvas': !isToBeIframed
268
70
  })
269
- }, createElement(motion.div, {
270
- className: "edit-post-visual-editor__content-area",
271
- animate: {
272
- padding: isTemplateMode ? '48px 48px 0' : 0
273
- }
274
- }, createElement(motion.div, {
275
- animate: animatedStyles,
276
- initial: desktopCanvasStyles,
277
- className: previewMode
278
- }, createElement(BlockCanvas, {
279
- shouldIframe: isToBeIframed,
280
- contentRef: contentRef,
281
- styles: styles,
282
- height: "100%"
283
- }, themeSupportsLayout && !themeHasDisabledLayoutStyles && !isTemplateMode && createElement(Fragment, null, createElement(LayoutStyle, {
284
- selector: ".edit-post-visual-editor__post-title-wrapper",
285
- layout: fallbackLayout
286
- }), createElement(LayoutStyle, {
287
- selector: ".block-editor-block-list__layout.is-root-container",
288
- layout: postEditorLayout
289
- }), align && createElement(LayoutStyle, {
290
- css: alignCSS
291
- }), postContentLayoutStyles && createElement(LayoutStyle, {
292
- layout: postContentLayout,
293
- css: postContentLayoutStyles
294
- })), !isTemplateMode && createElement("div", {
295
- className: classnames('edit-post-visual-editor__post-title-wrapper', {
296
- 'is-focus-mode': isFocusMode,
297
- 'has-global-padding': hasRootPaddingAwareAlignments
298
- }),
299
- contentEditable: false,
300
- ref: observeTypingRef
301
- }, createElement(PostTitle, {
302
- ref: titleRef
303
- })), createElement(RecursionProvider, {
304
- blockName: wrapperBlockName,
305
- uniqueId: wrapperUniqueId
306
- }, createElement(BlockList, {
307
- className: isTemplateMode ? 'wp-site-blocks' : `${blockListLayoutClass} wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
71
+ }, createElement(EditorCanvas, {
72
+ disableIframe: !isToBeIframed,
73
+ styles: styles
74
+ // We should auto-focus the canvas (title) on load.
75
+ // eslint-disable-next-line jsx-a11y/no-autofocus
308
76
  ,
309
-
310
- layout: blockListLayout,
311
- dropZoneElement:
312
- // When iframed, pass in the html element of the iframe to
313
- // ensure the drop zone extends to the edges of the iframe.
314
- isToBeIframed ? ref.current?.parentNode : ref.current
315
- }))))));
77
+ autoFocus: !isWelcomeGuideVisible
78
+ }));
316
79
  }
317
80
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","PostTitle","store","editorStore","BlockList","BlockTools","blockEditorStore","__unstableUseTypewriter","useTypewriter","__unstableUseTypingObserver","useTypingObserver","__experimentalUseResizeCanvas","useResizeCanvas","useSettings","__experimentalRecursionProvider","RecursionProvider","privateApis","blockEditorPrivateApis","useEffect","useRef","useMemo","__unstableMotion","motion","useSelect","useMergeRefs","parse","blocksStore","coreStore","editPostStore","unlock","LayoutStyle","useLayoutClasses","useLayoutStyles","ExperimentalBlockCanvas","BlockCanvas","isGutenbergPlugin","process","env","IS_GUTENBERG_PLUGIN","getPostContentAttributes","blocks","i","length","name","attributes","innerBlocks","nestedPostContent","checkForPostContentAtRootLevel","VisualEditor","styles","deviceType","isWelcomeGuideVisible","isTemplateMode","postContentAttributes","editedPostTemplate","wrapperBlockName","wrapperUniqueId","isBlockBasedTheme","hasV3BlocksOnly","select","isFeatureActive","isEditingTemplate","getEditedPostTemplate","__experimentalGetPreviewDeviceType","getCurrentPostId","getCurrentPostType","getEditorSettings","getBlockTypes","_isTemplateMode","postTypeSlug","_wrapperBlockName","editorSettings","supportsTemplateMode","postType","getPostType","canEditTemplate","canUser","viewable","undefined","__unstableIsBlockBasedTheme","every","type","apiVersion","isCleanNewPost","hasMetaBoxes","hasRootPaddingAwareAlignments","isFocusMode","themeHasDisabledLayoutStyles","themeSupportsLayout","_settings","getSettings","disableLayoutStyles","supportsLayout","focusMode","__experimentalFeatures","useRootPaddingAwareAlignments","desktopCanvasStyles","height","width","marginLeft","marginRight","display","flexFlow","background","templateModeStyles","borderRadius","border","borderBottom","resizedCanvasStyles","globalLayoutSettings","previewMode","toLowerCase","animatedStyles","paddingBottom","ref","contentRef","fallbackLayout","newestPostContentAttributes","content","parseableContent","hasPostContentAtRootLevel","layout","align","postContentLayoutClasses","blockListLayoutClass","postContentLayoutStyles","postContentLayout","inherit","contentSize","wideSize","blockListLayout","postEditorLayout","observeTypingRef","titleRef","current","focus","css","alignCSS","isToBeIframed","createElement","__unstableContentRef","className","div","animate","padding","initial","shouldIframe","Fragment","selector","contentEditable","blockName","uniqueId","dropZoneElement","parentNode"],"sources":["@wordpress/edit-post/src/components/visual-editor/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { PostTitle, store as editorStore } from '@wordpress/editor';\nimport {\n\tBlockList,\n\tBlockTools,\n\tstore as blockEditorStore,\n\t__unstableUseTypewriter as useTypewriter,\n\t__unstableUseTypingObserver as useTypingObserver,\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\tuseSettings,\n\t__experimentalRecursionProvider as RecursionProvider,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useMemo } from '@wordpress/element';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { parse, store as blocksStore } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst {\n\tLayoutStyle,\n\tuseLayoutClasses,\n\tuseLayoutStyles,\n\tExperimentalBlockCanvas: BlockCanvas,\n} = unlock( blockEditorPrivateApis );\n\nconst isGutenbergPlugin = process.env.IS_GUTENBERG_PLUGIN ? true : false;\n\n/**\n * Given an array of nested blocks, find the first Post Content\n * block inside it, recursing through any nesting levels,\n * and return its attributes.\n *\n * @param {Array} blocks A list of blocks.\n *\n * @return {Object | undefined} The Post Content block.\n */\nfunction getPostContentAttributes( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn blocks[ i ].attributes;\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tconst nestedPostContent = getPostContentAttributes(\n\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t);\n\n\t\t\tif ( nestedPostContent ) {\n\t\t\t\treturn nestedPostContent;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction checkForPostContentAtRootLevel( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nexport default function VisualEditor( { styles } ) {\n\tconst {\n\t\tdeviceType,\n\t\tisWelcomeGuideVisible,\n\t\tisTemplateMode,\n\t\tpostContentAttributes,\n\t\teditedPostTemplate = {},\n\t\twrapperBlockName,\n\t\twrapperUniqueId,\n\t\tisBlockBasedTheme,\n\t\thasV3BlocksOnly,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisFeatureActive,\n\t\t\tisEditingTemplate,\n\t\t\tgetEditedPostTemplate,\n\t\t\t__experimentalGetPreviewDeviceType,\n\t\t} = select( editPostStore );\n\t\tconst { getCurrentPostId, getCurrentPostType, getEditorSettings } =\n\t\t\tselect( editorStore );\n\t\tconst { getBlockTypes } = select( blocksStore );\n\t\tconst _isTemplateMode = isEditingTemplate();\n\t\tconst postTypeSlug = getCurrentPostType();\n\t\tlet _wrapperBlockName;\n\n\t\tif ( postTypeSlug === 'wp_block' ) {\n\t\t\t_wrapperBlockName = 'core/block';\n\t\t} else if ( ! _isTemplateMode ) {\n\t\t\t_wrapperBlockName = 'core/post-content';\n\t\t}\n\n\t\tconst editorSettings = getEditorSettings();\n\t\tconst supportsTemplateMode = editorSettings.supportsTemplateMode;\n\t\tconst postType = select( coreStore ).getPostType( postTypeSlug );\n\t\tconst canEditTemplate = select( coreStore ).canUser(\n\t\t\t'create',\n\t\t\t'templates'\n\t\t);\n\n\t\treturn {\n\t\t\tdeviceType: __experimentalGetPreviewDeviceType(),\n\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t\tisTemplateMode: _isTemplateMode,\n\t\t\tpostContentAttributes: getEditorSettings().postContentAttributes,\n\t\t\t// Post template fetch returns a 404 on classic themes, which\n\t\t\t// messes with e2e tests, so check it's a block theme first.\n\t\t\teditedPostTemplate:\n\t\t\t\tpostType?.viewable && supportsTemplateMode && canEditTemplate\n\t\t\t\t\t? getEditedPostTemplate()\n\t\t\t\t\t: undefined,\n\t\t\twrapperBlockName: _wrapperBlockName,\n\t\t\twrapperUniqueId: getCurrentPostId(),\n\t\t\tisBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme,\n\t\t\thasV3BlocksOnly: getBlockTypes().every( ( type ) => {\n\t\t\t\treturn type.apiVersion >= 3;\n\t\t\t} ),\n\t\t};\n\t}, [] );\n\tconst { isCleanNewPost } = useSelect( editorStore );\n\tconst hasMetaBoxes = useSelect(\n\t\t( select ) => select( editPostStore ).hasMetaBoxes(),\n\t\t[]\n\t);\n\tconst {\n\t\thasRootPaddingAwareAlignments,\n\t\tisFocusMode,\n\t\tthemeHasDisabledLayoutStyles,\n\t\tthemeSupportsLayout,\n\t} = useSelect( ( select ) => {\n\t\tconst _settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tthemeHasDisabledLayoutStyles: _settings.disableLayoutStyles,\n\t\t\tthemeSupportsLayout: _settings.supportsLayout,\n\t\t\tisFocusMode: _settings.focusMode,\n\t\t\thasRootPaddingAwareAlignments:\n\t\t\t\t_settings.__experimentalFeatures?.useRootPaddingAwareAlignments,\n\t\t};\n\t}, [] );\n\tconst desktopCanvasStyles = {\n\t\theight: '100%',\n\t\twidth: '100%',\n\t\tmarginLeft: 'auto',\n\t\tmarginRight: 'auto',\n\t\tdisplay: 'flex',\n\t\tflexFlow: 'column',\n\t\t// Default background color so that grey\n\t\t// .edit-post-editor-regions__content color doesn't show through.\n\t\tbackground: 'white',\n\t};\n\tconst templateModeStyles = {\n\t\t...desktopCanvasStyles,\n\t\tborderRadius: '2px 2px 0 0',\n\t\tborder: '1px solid #ddd',\n\t\tborderBottom: 0,\n\t};\n\tconst resizedCanvasStyles = useResizeCanvas( deviceType, isTemplateMode );\n\tconst [ globalLayoutSettings ] = useSettings( 'layout' );\n\tconst previewMode = 'is-' + deviceType.toLowerCase() + '-preview';\n\n\tlet animatedStyles = isTemplateMode\n\t\t? templateModeStyles\n\t\t: desktopCanvasStyles;\n\tif ( resizedCanvasStyles ) {\n\t\tanimatedStyles = resizedCanvasStyles;\n\t}\n\n\tlet paddingBottom;\n\n\t// Add a constant padding for the typewritter effect. When typing at the\n\t// bottom, there needs to be room to scroll up.\n\tif ( ! hasMetaBoxes && ! resizedCanvasStyles && ! isTemplateMode ) {\n\t\tpaddingBottom = '40vh';\n\t}\n\n\tconst ref = useRef();\n\tconst contentRef = useMergeRefs( [ ref, useTypewriter() ] );\n\n\t// fallbackLayout is used if there is no Post Content,\n\t// and for Post Title.\n\tconst fallbackLayout = useMemo( () => {\n\t\tif ( isTemplateMode ) {\n\t\t\treturn { type: 'default' };\n\t\t}\n\n\t\tif ( themeSupportsLayout ) {\n\t\t\t// We need to ensure support for wide and full alignments,\n\t\t\t// so we add the constrained type.\n\t\t\treturn { ...globalLayoutSettings, type: 'constrained' };\n\t\t}\n\t\t// Set default layout for classic themes so all alignments are supported.\n\t\treturn { type: 'default' };\n\t}, [ isTemplateMode, themeSupportsLayout, globalLayoutSettings ] );\n\n\tconst newestPostContentAttributes = useMemo( () => {\n\t\tif ( ! editedPostTemplate?.content && ! editedPostTemplate?.blocks ) {\n\t\t\treturn postContentAttributes;\n\t\t}\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn getPostContentAttributes( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn getPostContentAttributes( parse( parseableContent ) ) || {};\n\t}, [\n\t\teditedPostTemplate?.content,\n\t\teditedPostTemplate?.blocks,\n\t\tpostContentAttributes,\n\t] );\n\n\tconst hasPostContentAtRootLevel = useMemo( () => {\n\t\tif ( ! editedPostTemplate?.content && ! editedPostTemplate?.blocks ) {\n\t\t\treturn false;\n\t\t}\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn checkForPostContentAtRootLevel( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn (\n\t\t\tcheckForPostContentAtRootLevel( parse( parseableContent ) ) || false\n\t\t);\n\t}, [ editedPostTemplate?.content, editedPostTemplate?.blocks ] );\n\n\tconst { layout = {}, align = '' } = newestPostContentAttributes || {};\n\n\tconst postContentLayoutClasses = useLayoutClasses(\n\t\tnewestPostContentAttributes,\n\t\t'core/post-content'\n\t);\n\n\tconst blockListLayoutClass = classnames(\n\t\t{\n\t\t\t'is-layout-flow': ! themeSupportsLayout,\n\t\t},\n\t\tthemeSupportsLayout && postContentLayoutClasses,\n\t\talign && `align${ align }`\n\t);\n\n\tconst postContentLayoutStyles = useLayoutStyles(\n\t\tnewestPostContentAttributes,\n\t\t'core/post-content',\n\t\t'.block-editor-block-list__layout.is-root-container'\n\t);\n\n\t// Update type for blocks using legacy layouts.\n\tconst postContentLayout = useMemo( () => {\n\t\treturn layout &&\n\t\t\t( layout?.type === 'constrained' ||\n\t\t\t\tlayout?.inherit ||\n\t\t\t\tlayout?.contentSize ||\n\t\t\t\tlayout?.wideSize )\n\t\t\t? { ...globalLayoutSettings, ...layout, type: 'constrained' }\n\t\t\t: { ...globalLayoutSettings, ...layout, type: 'default' };\n\t}, [\n\t\tlayout?.type,\n\t\tlayout?.inherit,\n\t\tlayout?.contentSize,\n\t\tlayout?.wideSize,\n\t\tglobalLayoutSettings,\n\t] );\n\n\t// If there is a Post Content block we use its layout for the block list;\n\t// if not, this must be a classic theme, in which case we use the fallback layout.\n\tconst blockListLayout = postContentAttributes\n\t\t? postContentLayout\n\t\t: fallbackLayout;\n\n\tconst postEditorLayout =\n\t\tblockListLayout?.type === 'default' && ! hasPostContentAtRootLevel\n\t\t\t? fallbackLayout\n\t\t\t: blockListLayout;\n\n\tconst observeTypingRef = useTypingObserver();\n\tconst titleRef = useRef();\n\tuseEffect( () => {\n\t\tif ( isWelcomeGuideVisible || ! isCleanNewPost() ) {\n\t\t\treturn;\n\t\t}\n\t\ttitleRef?.current?.focus();\n\t}, [ isWelcomeGuideVisible, isCleanNewPost ] );\n\n\tstyles = useMemo(\n\t\t() => [\n\t\t\t...styles,\n\t\t\t{\n\t\t\t\t// We should move this in to future to the body.\n\t\t\t\tcss:\n\t\t\t\t\t`.edit-post-visual-editor__post-title-wrapper{margin-top:4rem}` +\n\t\t\t\t\t( paddingBottom\n\t\t\t\t\t\t? `body{padding-bottom:${ paddingBottom }}`\n\t\t\t\t\t\t: '' ),\n\t\t\t},\n\t\t],\n\t\t[ styles ]\n\t);\n\n\t// Add some styles for alignwide/alignfull Post Content and its children.\n\tconst alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}\n\t\t.is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}\n\t\t.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}\n\t\t.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;\n\n\tconst isToBeIframed =\n\t\t( ( hasV3BlocksOnly || ( isGutenbergPlugin && isBlockBasedTheme ) ) &&\n\t\t\t! hasMetaBoxes ) ||\n\t\tisTemplateMode ||\n\t\tdeviceType === 'Tablet' ||\n\t\tdeviceType === 'Mobile';\n\n\treturn (\n\t\t<BlockTools\n\t\t\t__unstableContentRef={ ref }\n\t\t\tclassName={ classnames( 'edit-post-visual-editor', {\n\t\t\t\t'is-template-mode': isTemplateMode,\n\t\t\t\t'has-inline-canvas': ! isToBeIframed,\n\t\t\t} ) }\n\t\t>\n\t\t\t<motion.div\n\t\t\t\tclassName=\"edit-post-visual-editor__content-area\"\n\t\t\t\tanimate={ {\n\t\t\t\t\tpadding: isTemplateMode ? '48px 48px 0' : 0,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tanimate={ animatedStyles }\n\t\t\t\t\tinitial={ desktopCanvasStyles }\n\t\t\t\t\tclassName={ previewMode }\n\t\t\t\t>\n\t\t\t\t\t<BlockCanvas\n\t\t\t\t\t\tshouldIframe={ isToBeIframed }\n\t\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t\t\tstyles={ styles }\n\t\t\t\t\t\theight=\"100%\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ themeSupportsLayout &&\n\t\t\t\t\t\t\t! themeHasDisabledLayoutStyles &&\n\t\t\t\t\t\t\t! isTemplateMode && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\t\tselector=\".edit-post-visual-editor__post-title-wrapper\"\n\t\t\t\t\t\t\t\t\t\tlayout={ fallbackLayout }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\t\tselector=\".block-editor-block-list__layout.is-root-container\"\n\t\t\t\t\t\t\t\t\t\tlayout={ postEditorLayout }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ align && (\n\t\t\t\t\t\t\t\t\t\t<LayoutStyle css={ alignCSS } />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ postContentLayoutStyles && (\n\t\t\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\t\t\tlayout={ postContentLayout }\n\t\t\t\t\t\t\t\t\t\t\tcss={ postContentLayoutStyles }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! isTemplateMode && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'edit-post-visual-editor__post-title-wrapper',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'is-focus-mode': isFocusMode,\n\t\t\t\t\t\t\t\t\t\t'has-global-padding':\n\t\t\t\t\t\t\t\t\t\t\thasRootPaddingAwareAlignments,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tcontentEditable={ false }\n\t\t\t\t\t\t\t\tref={ observeTypingRef }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostTitle ref={ titleRef } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<RecursionProvider\n\t\t\t\t\t\t\tblockName={ wrapperBlockName }\n\t\t\t\t\t\t\tuniqueId={ wrapperUniqueId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\tisTemplateMode\n\t\t\t\t\t\t\t\t\t\t? 'wp-site-blocks'\n\t\t\t\t\t\t\t\t\t\t: `${ blockListLayoutClass } wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlayout={ blockListLayout }\n\t\t\t\t\t\t\t\tdropZoneElement={\n\t\t\t\t\t\t\t\t\t// When iframed, pass in the html element of the iframe to\n\t\t\t\t\t\t\t\t\t// ensure the drop zone extends to the edges of the iframe.\n\t\t\t\t\t\t\t\t\tisToBeIframed\n\t\t\t\t\t\t\t\t\t\t? ref.current?.parentNode\n\t\t\t\t\t\t\t\t\t\t: ref.current\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</RecursionProvider>\n\t\t\t\t\t</BlockCanvas>\n\t\t\t\t</motion.div>\n\t\t\t</motion.div>\n\t\t</BlockTools>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,EAAEC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACnE,SACCC,SAAS,EACTC,UAAU,EACVH,KAAK,IAAII,gBAAgB,EACzBC,uBAAuB,IAAIC,aAAa,EACxCC,2BAA2B,IAAIC,iBAAiB,EAChDC,6BAA6B,IAAIC,eAAe,EAChDC,WAAW,EACXC,+BAA+B,IAAIC,iBAAiB,EACpDC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,SAAS,EAAEC,MAAM,EAAEC,OAAO,QAAQ,oBAAoB;AAC/D,SAASC,gBAAgB,IAAIC,MAAM,QAAQ,uBAAuB;AAClE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,KAAK,EAAEvB,KAAK,IAAIwB,WAAW,QAAQ,mBAAmB;AAC/D,SAASxB,KAAK,IAAIyB,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASzB,KAAK,IAAI0B,aAAa,QAAQ,aAAa;AACpD,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAM;EACLC,WAAW;EACXC,gBAAgB;EAChBC,eAAe;EACfC,uBAAuB,EAAEC;AAC1B,CAAC,GAAGL,MAAM,CAAEZ,sBAAuB,CAAC;AAEpC,MAAMkB,iBAAiB,GAAGC,OAAO,CAACC,GAAG,CAACC,mBAAmB,GAAG,IAAI,GAAG,KAAK;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,S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IACF,CACD,CAAG;IACHgE,eAAe,EAAG,KAAO;IACzBnC,GAAG,EAAGkB;EAAkB,GAExBO,aAAA,CAAC1I,SAAS;IAACiH,GAAG,EAAGmB;EAAU,CAAE,CACzB,CACL,EACDM,aAAA,CAAC5H,iBAAiB;IACjBuI,SAAS,EAAG/F,gBAAkB;IAC9BgG,QAAQ,EAAG/F;EAAiB,GAE5BmF,aAAA,CAACvI,SAAS;IACTyI,SAAS,EACRzF,cAAc,GACX,gBAAgB,GACf,GAAGwE,oBAAsB,wBAAuB,CAAC;IACrD;;IACDH,MAAM,EAAGS,eAAiB;IAC1BsB,eAAe;IACd;IACA;IACAd,aAAa,GACVxB,GAAG,CAACoB,OAAO,EAAEmB,UAAU,GACvBvC,GAAG,CAACoB;EACP,CACD,CACiB,CACP,CACF,CACD,CACD,CAAC;AAEf"}
1
+ {"version":3,"names":["classnames","store","editorStore","privateApis","editorPrivateApis","useMemo","useSelect","blocksStore","editPostStore","unlock","EditorCanvas","isGutenbergPlugin","process","env","IS_GUTENBERG_PLUGIN","VisualEditor","styles","isWelcomeGuideVisible","renderingMode","isBlockBasedTheme","hasV3BlocksOnly","select","isFeatureActive","getEditorSettings","getRenderingMode","getBlockTypes","editorSettings","__unstableIsBlockBasedTheme","every","type","apiVersion","hasMetaBoxes","paddingBottom","css","isToBeIframed","createElement","className","disableIframe","autoFocus"],"sources":["@wordpress/edit-post/src/components/visual-editor/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { EditorCanvas } = unlock( editorPrivateApis );\n\nconst isGutenbergPlugin = process.env.IS_GUTENBERG_PLUGIN ? true : false;\n\nexport default function VisualEditor( { styles } ) {\n\tconst {\n\t\tisWelcomeGuideVisible,\n\t\trenderingMode,\n\t\tisBlockBasedTheme,\n\t\thasV3BlocksOnly,\n\t} = useSelect( ( select ) => {\n\t\tconst { isFeatureActive } = select( editPostStore );\n\t\tconst { getEditorSettings, getRenderingMode } = select( editorStore );\n\t\tconst { getBlockTypes } = select( blocksStore );\n\t\tconst editorSettings = getEditorSettings();\n\n\t\treturn {\n\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t\trenderingMode: getRenderingMode(),\n\t\t\tisBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme,\n\t\t\thasV3BlocksOnly: getBlockTypes().every( ( type ) => {\n\t\t\t\treturn type.apiVersion >= 3;\n\t\t\t} ),\n\t\t};\n\t}, [] );\n\tconst hasMetaBoxes = useSelect(\n\t\t( select ) => select( editPostStore ).hasMetaBoxes(),\n\t\t[]\n\t);\n\n\tlet paddingBottom;\n\n\t// Add a constant padding for the typewritter effect. When typing at the\n\t// bottom, there needs to be room to scroll up.\n\tif ( ! hasMetaBoxes && renderingMode === 'post-only' ) {\n\t\tpaddingBottom = '40vh';\n\t}\n\n\tstyles = useMemo(\n\t\t() => [\n\t\t\t...styles,\n\t\t\t{\n\t\t\t\t// We should move this in to future to the body.\n\t\t\t\tcss: paddingBottom\n\t\t\t\t\t? `body{padding-bottom:${ paddingBottom }}`\n\t\t\t\t\t: '',\n\t\t\t},\n\t\t],\n\t\t[ styles, paddingBottom ]\n\t);\n\n\tconst isToBeIframed =\n\t\t( ( hasV3BlocksOnly || ( isGutenbergPlugin && isBlockBasedTheme ) ) &&\n\t\t\t! hasMetaBoxes ) ||\n\t\trenderingMode === 'template-only';\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'edit-post-visual-editor', {\n\t\t\t\t'is-template-mode': renderingMode === 'template-only',\n\t\t\t\t'has-inline-canvas': ! isToBeIframed,\n\t\t\t} ) }\n\t\t>\n\t\t\t<EditorCanvas\n\t\t\t\tdisableIframe={ ! isToBeIframed }\n\t\t\t\tstyles={ styles }\n\t\t\t\t// We should auto-focus the canvas (title) on load.\n\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\tautoFocus={ ! isWelcomeGuideVisible }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,KAAK,IAAIC,WAAW,EACpBC,WAAW,IAAIC,iBAAiB,QAC1B,mBAAmB;AAC1B,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASL,KAAK,IAAIM,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA,SAASN,KAAK,IAAIO,aAAa,QAAQ,aAAa;AACpD,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAM;EAAEC;AAAa,CAAC,GAAGD,MAAM,CAAEL,iBAAkB,CAAC;AAEpD,MAAMO,iBAAiB,GAAGC,OAAO,CAACC,GAAG,CAACC,mBAAmB,GAAG,IAAI,GAAG,KAAK;AAExE,eAAe,SAASC,YAAYA,CAAE;EAAEC;AAAO,CAAC,EAAG;EAClD,MAAM;IACLC,qBAAqB;IACrBC,aAAa;IACbC,iBAAiB;IACjBC;EACD,CAAC,GAAGd,SAAS,CAAIe,MAAM,IAAM;IAC5B,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAEb,aAAc,CAAC;IACnD,MAAM;MAAEe,iBAAiB;MAAEC;IAAiB,CAAC,GAAGH,MAAM,CAAEnB,WAAY,CAAC;IACrE,MAAM;MAAEuB;IAAc,CAAC,GAAGJ,MAAM,CAAEd,WAAY,CAAC;IAC/C,MAAMmB,cAAc,GAAGH,iBAAiB,CAAC,CAAC;IAE1C,OAAO;MACNN,qBAAqB,EAAEK,eAAe,CAAE,cAAe,CAAC;MACxDJ,aAAa,EAAEM,gBAAgB,CAAC,CAAC;MACjCL,iBAAiB,EAAEO,cAAc,CAACC,2BAA2B;MAC7DP,eAAe,EAAEK,aAAa,CAAC,CAAC,CAACG,KAAK,CAAIC,IAAI,IAAM;QACnD,OAAOA,IAAI,CAACC,UAAU,IAAI,CAAC;MAC5B,CAAE;IACH,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAMC,YAAY,GAAGzB,SAAS,CAC3Be,MAAM,IAAMA,MAAM,CAAEb,aAAc,CAAC,CAACuB,YAAY,CAAC,CAAC,EACpD,EACD,CAAC;EAED,IAAIC,aAAa;;EAEjB;EACA;EACA,IAAK,CAAED,YAAY,IAAIb,aAAa,KAAK,WAAW,EAAG;IACtDc,aAAa,GAAG,MAAM;EACvB;EAEAhB,MAAM,GAAGX,OAAO,CACf,MAAM,CACL,GAAGW,MAAM,EACT;IACC;IACAiB,GAAG,EAAED,aAAa,GACd,uBAAuBA,aAAe,GAAE,GACzC;EACJ,CAAC,CACD,EACD,CAAEhB,MAAM,EAAEgB,aAAa,CACxB,CAAC;EAED,MAAME,aAAa,GAChB,CAAEd,eAAe,IAAMT,iBAAiB,IAAIQ,iBAAmB,KAChE,CAAEY,YAAY,IACfb,aAAa,KAAK,eAAe;EAElC,OACCiB,aAAA;IACCC,SAAS,EAAGpC,UAAU,CAAE,yBAAyB,EAAE;MAClD,kBAAkB,EAAEkB,aAAa,KAAK,eAAe;MACrD,mBAAmB,EAAE,CAAEgB;IACxB,CAAE;EAAG,GAELC,aAAA,CAACzB,YAAY;IACZ2B,aAAa,EAAG,CAAEH,aAAe;IACjClB,MAAM,EAAGA;IACT;IACA;IAAA;IACAsB,SAAS,EAAG,CAAErB;EAAuB,CACrC,CACG,CAAC;AAER"}
@@ -3,6 +3,7 @@ import { createElement } from "react";
3
3
  * WordPress dependencies
4
4
  */
5
5
  import { useSelect } from '@wordpress/data';
6
+ import { store as editorStore } from '@wordpress/editor';
6
7
 
7
8
  /**
8
9
  * Internal dependencies
@@ -16,10 +17,12 @@ export default function WelcomeGuide() {
16
17
  isTemplateMode
17
18
  } = useSelect(select => {
18
19
  const {
19
- isFeatureActive,
20
- isEditingTemplate
20
+ isFeatureActive
21
21
  } = select(editPostStore);
22
- const _isTemplateMode = isEditingTemplate();
22
+ const {
23
+ getRenderingMode
24
+ } = select(editorStore);
25
+ const _isTemplateMode = getRenderingMode() === 'template-only';
23
26
  const feature = _isTemplateMode ? 'welcomeGuideTemplate' : 'welcomeGuide';
24
27
  return {
25
28
  isActive: isFeatureActive(feature),
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","WelcomeGuideDefault","WelcomeGuideTemplate","store","editPostStore","WelcomeGuide","isActive","isTemplateMode","select","isFeatureActive","isEditingTemplate","_isTemplateMode","feature","createElement"],"sources":["@wordpress/edit-post/src/components/welcome-guide/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuideDefault from './default';\nimport WelcomeGuideTemplate from './template';\nimport { store as editPostStore } from '../../store';\n\nexport default function WelcomeGuide() {\n\tconst { isActive, isTemplateMode } = useSelect( ( select ) => {\n\t\tconst { isFeatureActive, isEditingTemplate } = select( editPostStore );\n\t\tconst _isTemplateMode = isEditingTemplate();\n\t\tconst feature = _isTemplateMode\n\t\t\t? 'welcomeGuideTemplate'\n\t\t\t: 'welcomeGuide';\n\n\t\treturn {\n\t\t\tisActive: isFeatureActive( feature ),\n\t\t\tisTemplateMode: _isTemplateMode,\n\t\t};\n\t}, [] );\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn isTemplateMode ? <WelcomeGuideTemplate /> : <WelcomeGuideDefault />;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,OAAOC,mBAAmB,MAAM,WAAW;AAC3C,OAAOC,oBAAoB,MAAM,YAAY;AAC7C,SAASC,KAAK,IAAIC,aAAa,QAAQ,aAAa;AAEpD,eAAe,SAASC,YAAYA,CAAA,EAAG;EACtC,MAAM;IAAEC,QAAQ;IAAEC;EAAe,CAAC,GAAGP,SAAS,CAAIQ,MAAM,IAAM;IAC7D,MAAM;MAAEC,eAAe;MAAEC;IAAkB,CAAC,GAAGF,MAAM,CAAEJ,aAAc,CAAC;IACtE,MAAMO,eAAe,GAAGD,iBAAiB,CAAC,CAAC;IAC3C,MAAME,OAAO,GAAGD,eAAe,GAC5B,sBAAsB,GACtB,cAAc;IAEjB,OAAO;MACNL,QAAQ,EAAEG,eAAe,CAAEG,OAAQ,CAAC;MACpCL,cAAc,EAAEI;IACjB,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAEL,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,OAAOC,cAAc,GAAGM,aAAA,CAACX,oBAAoB,MAAE,CAAC,GAAGW,aAAA,CAACZ,mBAAmB,MAAE,CAAC;AAC3E"}
1
+ {"version":3,"names":["useSelect","store","editorStore","WelcomeGuideDefault","WelcomeGuideTemplate","editPostStore","WelcomeGuide","isActive","isTemplateMode","select","isFeatureActive","getRenderingMode","_isTemplateMode","feature","createElement"],"sources":["@wordpress/edit-post/src/components/welcome-guide/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuideDefault from './default';\nimport WelcomeGuideTemplate from './template';\nimport { store as editPostStore } from '../../store';\n\nexport default function WelcomeGuide() {\n\tconst { isActive, isTemplateMode } = useSelect( ( select ) => {\n\t\tconst { isFeatureActive } = select( editPostStore );\n\t\tconst { getRenderingMode } = select( editorStore );\n\t\tconst _isTemplateMode = getRenderingMode() === 'template-only';\n\t\tconst feature = _isTemplateMode\n\t\t\t? 'welcomeGuideTemplate'\n\t\t\t: 'welcomeGuide';\n\n\t\treturn {\n\t\t\tisActive: isFeatureActive( feature ),\n\t\t\tisTemplateMode: _isTemplateMode,\n\t\t};\n\t}, [] );\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn isTemplateMode ? <WelcomeGuideTemplate /> : <WelcomeGuideDefault />;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA,OAAOC,mBAAmB,MAAM,WAAW;AAC3C,OAAOC,oBAAoB,MAAM,YAAY;AAC7C,SAASH,KAAK,IAAII,aAAa,QAAQ,aAAa;AAEpD,eAAe,SAASC,YAAYA,CAAA,EAAG;EACtC,MAAM;IAAEC,QAAQ;IAAEC;EAAe,CAAC,GAAGR,SAAS,CAAIS,MAAM,IAAM;IAC7D,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAEJ,aAAc,CAAC;IACnD,MAAM;MAAEM;IAAiB,CAAC,GAAGF,MAAM,CAAEP,WAAY,CAAC;IAClD,MAAMU,eAAe,GAAGD,gBAAgB,CAAC,CAAC,KAAK,eAAe;IAC9D,MAAME,OAAO,GAAGD,eAAe,GAC5B,sBAAsB,GACtB,cAAc;IAEjB,OAAO;MACNL,QAAQ,EAAEG,eAAe,CAAEG,OAAQ,CAAC;MACpCL,cAAc,EAAEI;IACjB,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAEL,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,OAAOC,cAAc,GAAGM,aAAA,CAACV,oBAAoB,MAAE,CAAC,GAAGU,aAAA,CAACX,mBAAmB,MAAE,CAAC;AAC3E"}
@@ -10,6 +10,7 @@ import { SlotFillProvider } from '@wordpress/components';
10
10
  import { store as coreStore } from '@wordpress/core-data';
11
11
  import { store as preferencesStore } from '@wordpress/preferences';
12
12
  import { CommandMenu } from '@wordpress/commands';
13
+ import { useViewportMatch } from '@wordpress/compose';
13
14
 
14
15
  /**
15
16
  * Internal dependencies
@@ -28,6 +29,7 @@ function Editor({
28
29
  initialEdits,
29
30
  ...props
30
31
  }) {
32
+ const isLargeViewport = useViewportMatch('medium');
31
33
  const {
32
34
  hasFixedToolbar,
33
35
  focusMode,
@@ -38,13 +40,11 @@ function Editor({
38
40
  hiddenBlockTypes,
39
41
  blockTypes,
40
42
  keepCaretInsideBlock,
41
- isTemplateMode,
42
43
  template
43
44
  } = useSelect(select => {
44
45
  var _getPostType$viewable;
45
46
  const {
46
47
  isFeatureActive,
47
- isEditingTemplate,
48
48
  getEditedPostTemplate,
49
49
  getHiddenBlockTypes
50
50
  } = select(editPostStore);
@@ -76,7 +76,7 @@ function Editor({
76
76
  const isViewable = (_getPostType$viewable = getPostType(postType)?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false;
77
77
  const canEditTemplate = canUser('create', 'templates');
78
78
  return {
79
- hasFixedToolbar: isFeatureActive('fixedToolbar'),
79
+ hasFixedToolbar: isFeatureActive('fixedToolbar') || !isLargeViewport,
80
80
  focusMode: isFeatureActive('focusMode'),
81
81
  isDistractionFree: isFeatureActive('distractionFree'),
82
82
  hasInlineToolbar: isFeatureActive('inlineToolbar'),
@@ -84,11 +84,10 @@ function Editor({
84
84
  hiddenBlockTypes: getHiddenBlockTypes(),
85
85
  blockTypes: getBlockTypes(),
86
86
  keepCaretInsideBlock: isFeatureActive('keepCaretInsideBlock'),
87
- isTemplateMode: isEditingTemplate(),
88
87
  template: supportsTemplateMode && isViewable && canEditTemplate ? getEditedPostTemplate() : null,
89
88
  post: postObject
90
89
  };
91
- }, [postType, postId]);
90
+ }, [postType, postId, isLargeViewport]);
92
91
  const {
93
92
  updatePreferredStyleVariations,
94
93
  setIsInserterOpened
@@ -132,7 +131,7 @@ function Editor({
132
131
  post: post,
133
132
  initialEdits: initialEdits,
134
133
  useSubRegistry: false,
135
- __unstableTemplate: isTemplateMode ? template : undefined,
134
+ __unstableTemplate: template,
136
135
  ...props
137
136
  }, createElement(ErrorBoundary, null, createElement(CommandMenu, null), createElement(EditorInitialization, {
138
137
  postId: postId
@@ -1 +1 @@
1
- {"version":3,"names":["store","blocksStore","useSelect","useDispatch","ErrorBoundary","PostLockedModal","editorStore","privateApis","editorPrivateApis","useMemo","SlotFillProvider","coreStore","preferencesStore","CommandMenu","Layout","EditorInitialization","editPostStore","unlock","ExperimentalEditorProvider","Editor","postId","postType","settings","initialEdits","props","hasFixedToolbar","focusMode","isDistractionFree","hasInlineToolbar","post","preferredStyleVariations","hiddenBlockTypes","blockTypes","keepCaretInsideBlock","isTemplateMode","template","select","_getPostType$viewable","isFeatureActive","isEditingTemplate","getEditedPostTemplate","getHiddenBlockTypes","getEntityRecord","getPostType","getEntityRecords","canUser","getEditorSettings","getBlockTypes","isTemplate","includes","postObject","posts","wp_id","supportsTemplateMode","isViewable","viewable","canEditTemplate","get","updatePreferredStyleVariations","setIsInserterOpened","editorSettings","result","__experimentalPreferredStyleVariations","value","onChange","__experimentalSetIsInserterOpened","defaultAllowedBlockTypes","allowedBlockTypes","length","map","name","filter","type","createElement","useSubRegistry","__unstableTemplate","undefined"],"sources":["@wordpress/edit-post/src/editor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useMemo } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { CommandMenu } from '@wordpress/commands';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport EditorInitialization from './components/editor-initialization';\nimport { store as editPostStore } from './store';\nimport { unlock } from './lock-unlock';\n\nconst { ExperimentalEditorProvider } = unlock( editorPrivateApis );\n\nfunction Editor( { postId, postType, settings, initialEdits, ...props } ) {\n\tconst {\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\tisDistractionFree,\n\t\thasInlineToolbar,\n\t\tpost,\n\t\tpreferredStyleVariations,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\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\tisEditingTemplate,\n\t\t\t\tgetEditedPostTemplate,\n\t\t\t\tgetHiddenBlockTypes,\n\t\t\t} = select( editPostStore );\n\t\t\tconst { getEntityRecord, getPostType, getEntityRecords, canUser } =\n\t\t\t\tselect( coreStore );\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 =\n\t\t\t\tgetEditorSettings().supportsTemplateMode;\n\t\t\tconst isViewable = getPostType( postType )?.viewable ?? false;\n\t\t\tconst canEditTemplate = canUser( 'create', 'templates' );\n\n\t\t\treturn {\n\t\t\t\thasFixedToolbar: isFeatureActive( 'fixedToolbar' ),\n\t\t\t\tfocusMode: isFeatureActive( 'focusMode' ),\n\t\t\t\tisDistractionFree: isFeatureActive( 'distractionFree' ),\n\t\t\t\thasInlineToolbar: isFeatureActive( 'inlineToolbar' ),\n\t\t\t\tpreferredStyleVariations: select( preferencesStore ).get(\n\t\t\t\t\t'core/edit-post',\n\t\t\t\t\t'preferredStyleVariations'\n\t\t\t\t),\n\t\t\t\thiddenBlockTypes: getHiddenBlockTypes(),\n\t\t\t\tblockTypes: getBlockTypes(),\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 && canEditTemplate\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 } =\n\t\tuseDispatch( editPostStore );\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\tisDistractionFree,\n\t\t\thasInlineToolbar,\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 ( hiddenBlockTypes.length > 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? blockTypes.map( ( { name } ) => name )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\tresult.allowedBlockTypes = defaultAllowedBlockTypes.filter(\n\t\t\t\t( type ) => ! hiddenBlockTypes.includes( type )\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}, [\n\t\tsettings,\n\t\thasFixedToolbar,\n\t\thasInlineToolbar,\n\t\tfocusMode,\n\t\tisDistractionFree,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\tpreferredStyleVariations,\n\t\tsetIsInserterOpened,\n\t\tupdatePreferredStyleVariations,\n\t\tkeepCaretInsideBlock,\n\t] );\n\n\tif ( ! post ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ExperimentalEditorProvider\n\t\t\t\tsettings={ editorSettings }\n\t\t\t\tpost={ post }\n\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t__unstableTemplate={ isTemplateMode ? template : undefined }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t<CommandMenu />\n\t\t\t\t\t<EditorInitialization postId={ postId } />\n\t\t\t\t\t<Layout />\n\t\t\t\t</ErrorBoundary>\n\t\t\t\t<PostLockedModal />\n\t\t\t</ExperimentalEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n\nexport default Editor;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,aAAa,EACbC,eAAe,EACfL,KAAK,IAAIM,WAAW,EACpBC,WAAW,IAAIC,iBAAiB,QAC1B,mBAAmB;AAC1B,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASV,KAAK,IAAIW,SAAS,QAAQ,sBAAsB;AACzD,SAASX,KAAK,IAAIY,gBAAgB,QAAQ,wBAAwB;AAClE,SAASC,WAAW,QAAQ,qBAAqB;;AA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;EAAQ,CAAE,CAAC,EAC1CqD,aAAA,CAAC3D,MAAM,MAAE,CACK,CAAC,EAChB2D,aAAA,CAACpE,eAAe,MAAE,CACS,CACX,CAAC;AAErB;AAEA,eAAec,MAAM"}
1
+ {"version":3,"names":["store","blocksStore","useSelect","useDispatch","ErrorBoundary","PostLockedModal","editorStore","privateApis","editorPrivateApis","useMemo","SlotFillProvider","coreStore","preferencesStore","CommandMenu","useViewportMatch","Layout","EditorInitialization","editPostStore","unlock","ExperimentalEditorProvider","Editor","postId","postType","settings","initialEdits","props","isLargeViewport","hasFixedToolbar","focusMode","isDistractionFree","hasInlineToolbar","post","preferredStyleVariations","hiddenBlockTypes","blockTypes","keepCaretInsideBlock","template","select","_getPostType$viewable","isFeatureActive","getEditedPostTemplate","getHiddenBlockTypes","getEntityRecord","getPostType","getEntityRecords","canUser","getEditorSettings","getBlockTypes","isTemplate","includes","postObject","posts","wp_id","supportsTemplateMode","isViewable","viewable","canEditTemplate","get","updatePreferredStyleVariations","setIsInserterOpened","editorSettings","result","__experimentalPreferredStyleVariations","value","onChange","__experimentalSetIsInserterOpened","defaultAllowedBlockTypes","allowedBlockTypes","length","map","name","filter","type","createElement","useSubRegistry","__unstableTemplate"],"sources":["@wordpress/edit-post/src/editor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useMemo } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { CommandMenu } from '@wordpress/commands';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport EditorInitialization from './components/editor-initialization';\nimport { store as editPostStore } from './store';\nimport { unlock } from './lock-unlock';\n\nconst { ExperimentalEditorProvider } = unlock( editorPrivateApis );\n\nfunction Editor( { postId, postType, settings, initialEdits, ...props } ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\n\tconst {\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\tisDistractionFree,\n\t\thasInlineToolbar,\n\t\tpost,\n\t\tpreferredStyleVariations,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\tkeepCaretInsideBlock,\n\t\ttemplate,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisFeatureActive,\n\t\t\t\tgetEditedPostTemplate,\n\t\t\t\tgetHiddenBlockTypes,\n\t\t\t} = select( editPostStore );\n\t\t\tconst { getEntityRecord, getPostType, getEntityRecords, canUser } =\n\t\t\t\tselect( coreStore );\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 =\n\t\t\t\tgetEditorSettings().supportsTemplateMode;\n\t\t\tconst isViewable = getPostType( postType )?.viewable ?? false;\n\t\t\tconst canEditTemplate = canUser( 'create', 'templates' );\n\t\t\treturn {\n\t\t\t\thasFixedToolbar:\n\t\t\t\t\tisFeatureActive( 'fixedToolbar' ) || ! isLargeViewport,\n\t\t\t\tfocusMode: isFeatureActive( 'focusMode' ),\n\t\t\t\tisDistractionFree: isFeatureActive( 'distractionFree' ),\n\t\t\t\thasInlineToolbar: isFeatureActive( 'inlineToolbar' ),\n\t\t\t\tpreferredStyleVariations: select( preferencesStore ).get(\n\t\t\t\t\t'core/edit-post',\n\t\t\t\t\t'preferredStyleVariations'\n\t\t\t\t),\n\t\t\t\thiddenBlockTypes: getHiddenBlockTypes(),\n\t\t\t\tblockTypes: getBlockTypes(),\n\t\t\t\tkeepCaretInsideBlock: isFeatureActive( 'keepCaretInsideBlock' ),\n\t\t\t\ttemplate:\n\t\t\t\t\tsupportsTemplateMode && isViewable && canEditTemplate\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, isLargeViewport ]\n\t);\n\n\tconst { updatePreferredStyleVariations, setIsInserterOpened } =\n\t\tuseDispatch( editPostStore );\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\tisDistractionFree,\n\t\t\thasInlineToolbar,\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 ( hiddenBlockTypes.length > 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? blockTypes.map( ( { name } ) => name )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\tresult.allowedBlockTypes = defaultAllowedBlockTypes.filter(\n\t\t\t\t( type ) => ! hiddenBlockTypes.includes( type )\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}, [\n\t\tsettings,\n\t\thasFixedToolbar,\n\t\thasInlineToolbar,\n\t\tfocusMode,\n\t\tisDistractionFree,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\tpreferredStyleVariations,\n\t\tsetIsInserterOpened,\n\t\tupdatePreferredStyleVariations,\n\t\tkeepCaretInsideBlock,\n\t] );\n\n\tif ( ! post ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ExperimentalEditorProvider\n\t\t\t\tsettings={ editorSettings }\n\t\t\t\tpost={ post }\n\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t__unstableTemplate={ template }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t<CommandMenu />\n\t\t\t\t\t<EditorInitialization postId={ postId } />\n\t\t\t\t\t<Layout />\n\t\t\t\t</ErrorBoundary>\n\t\t\t\t<PostLockedModal />\n\t\t\t</ExperimentalEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n\nexport default Editor;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,aAAa,EACbC,eAAe,EACfL,KAAK,IAAIM,WAAW,EACpBC,WAAW,IAAIC,iBAAiB,QAC1B,mBAAmB;AAC1B,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASV,KAAK,IAAIW,SAAS,QAAQ,sBAAsB;AACzD,SAASX,KAAK,IAAIY,gBAA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qE,aAAA,CAAC5D,WAAW,MAAE,CAAC,EACf4D,aAAA,CAACzD,oBAAoB;IAACK,MAAM,EAAGA;EAAQ,CAAE,CAAC,EAC1CoD,aAAA,CAAC1D,MAAM,MAAE,CACK,CAAC,EAChB0D,aAAA,CAACpE,eAAe,MAAE,CACS,CACX,CAAC;AAErB;AAEA,eAAee,MAAM"}
@@ -155,14 +155,13 @@ export default compose([withSelect(select => {
155
155
  const {
156
156
  isFeatureActive,
157
157
  getEditorMode,
158
- __experimentalGetPreviewDeviceType,
159
158
  getHiddenBlockTypes
160
159
  } = select(editPostStore);
161
160
  const {
162
161
  getBlockTypes
163
162
  } = select(blocksStore);
164
163
  return {
165
- hasFixedToolbar: isFeatureActive('fixedToolbar') || __experimentalGetPreviewDeviceType() !== 'Desktop',
164
+ hasFixedToolbar: isFeatureActive('fixedToolbar'),
166
165
  focusMode: isFeatureActive('focusMode'),
167
166
  mode: getEditorMode(),
168
167
  hiddenBlockTypes: getHiddenBlockTypes(),