@wordpress/editor 14.14.0 → 14.15.1

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 (180) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +1 -0
  4. package/build/components/commands/index.js +28 -0
  5. package/build/components/commands/index.js.map +1 -1
  6. package/build/components/document-bar/index.js +2 -1
  7. package/build/components/document-bar/index.js.map +1 -1
  8. package/build/components/document-tools/index.js +3 -6
  9. package/build/components/document-tools/index.js.map +1 -1
  10. package/build/components/editor-help/intro-to-blocks.native.js +1 -1
  11. package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
  12. package/build/components/entities-saved-states/index.js +2 -1
  13. package/build/components/entities-saved-states/index.js.map +1 -1
  14. package/build/components/error-boundary/index.native.js +1 -1
  15. package/build/components/error-boundary/index.native.js.map +1 -1
  16. package/build/components/more-menu/index.js +0 -1
  17. package/build/components/more-menu/index.js.map +1 -1
  18. package/build/components/post-actions/actions.js +9 -4
  19. package/build/components/post-actions/actions.js.map +1 -1
  20. package/build/components/post-actions/index.js +17 -14
  21. package/build/components/post-actions/index.js.map +1 -1
  22. package/build/components/post-actions/set-as-homepage.js +23 -34
  23. package/build/components/post-actions/set-as-homepage.js.map +1 -1
  24. package/build/components/post-actions/set-as-posts-page.js +154 -0
  25. package/build/components/post-actions/set-as-posts-page.js.map +1 -0
  26. package/build/components/post-card-panel/index.js +12 -5
  27. package/build/components/post-card-panel/index.js.map +1 -1
  28. package/build/components/post-publish-panel/maybe-upload-media.js +1 -1
  29. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  30. package/build/components/preferences-modal/index.js +2 -4
  31. package/build/components/preferences-modal/index.js.map +1 -1
  32. package/build/components/preview-dropdown/index.js +0 -1
  33. package/build/components/preview-dropdown/index.js.map +1 -1
  34. package/build/components/provider/disable-non-page-content-blocks.js +65 -13
  35. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
  36. package/build/components/provider/index.js +9 -13
  37. package/build/components/provider/index.js.map +1 -1
  38. package/build/components/provider/use-block-editor-settings.js +3 -1
  39. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  40. package/build/components/start-page-options/index.js +20 -107
  41. package/build/components/start-page-options/index.js.map +1 -1
  42. package/build/components/template-part-menu-items/index.js +2 -10
  43. package/build/components/template-part-menu-items/index.js.map +1 -1
  44. package/build/store/actions.js +0 -2
  45. package/build/store/actions.js.map +1 -1
  46. package/build/store/constants.js +1 -3
  47. package/build/store/constants.js.map +1 -1
  48. package/build/store/private-actions.js +1 -1
  49. package/build/store/private-actions.js.map +1 -1
  50. package/build/store/utils/notice-builder.js +3 -8
  51. package/build/store/utils/notice-builder.js.map +1 -1
  52. package/build/utils/get-item-title.js +32 -0
  53. package/build/utils/get-item-title.js.map +1 -0
  54. package/build/utils/media-sideload/index.js +21 -0
  55. package/build/utils/media-sideload/index.js.map +1 -0
  56. package/build/utils/media-sideload/index.native.js +8 -0
  57. package/build/utils/media-sideload/index.native.js.map +1 -0
  58. package/build/utils/media-upload/index.js +5 -2
  59. package/build/utils/media-upload/index.js.map +1 -1
  60. package/build-module/components/commands/index.js +28 -0
  61. package/build-module/components/commands/index.js.map +1 -1
  62. package/build-module/components/document-bar/index.js +2 -1
  63. package/build-module/components/document-bar/index.js.map +1 -1
  64. package/build-module/components/document-tools/index.js +4 -7
  65. package/build-module/components/document-tools/index.js.map +1 -1
  66. package/build-module/components/editor-help/intro-to-blocks.native.js +1 -1
  67. package/build-module/components/editor-help/intro-to-blocks.native.js.map +1 -1
  68. package/build-module/components/entities-saved-states/index.js +2 -1
  69. package/build-module/components/entities-saved-states/index.js.map +1 -1
  70. package/build-module/components/error-boundary/index.native.js +2 -2
  71. package/build-module/components/error-boundary/index.native.js.map +1 -1
  72. package/build-module/components/more-menu/index.js +0 -1
  73. package/build-module/components/more-menu/index.js.map +1 -1
  74. package/build-module/components/post-actions/actions.js +9 -4
  75. package/build-module/components/post-actions/actions.js.map +1 -1
  76. package/build-module/components/post-actions/index.js +18 -15
  77. package/build-module/components/post-actions/index.js.map +1 -1
  78. package/build-module/components/post-actions/set-as-homepage.js +22 -33
  79. package/build-module/components/post-actions/set-as-homepage.js.map +1 -1
  80. package/build-module/components/post-actions/set-as-posts-page.js +146 -0
  81. package/build-module/components/post-actions/set-as-posts-page.js.map +1 -0
  82. package/build-module/components/post-card-panel/index.js +11 -6
  83. package/build-module/components/post-card-panel/index.js.map +1 -1
  84. package/build-module/components/post-publish-panel/maybe-upload-media.js +2 -2
  85. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  86. package/build-module/components/preferences-modal/index.js +2 -4
  87. package/build-module/components/preferences-modal/index.js.map +1 -1
  88. package/build-module/components/preview-dropdown/index.js +0 -1
  89. package/build-module/components/preview-dropdown/index.js.map +1 -1
  90. package/build-module/components/provider/disable-non-page-content-blocks.js +65 -13
  91. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
  92. package/build-module/components/provider/index.js +10 -14
  93. package/build-module/components/provider/index.js.map +1 -1
  94. package/build-module/components/provider/use-block-editor-settings.js +3 -1
  95. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  96. package/build-module/components/start-page-options/index.js +21 -107
  97. package/build-module/components/start-page-options/index.js.map +1 -1
  98. package/build-module/components/template-part-menu-items/index.js +2 -10
  99. package/build-module/components/template-part-menu-items/index.js.map +1 -1
  100. package/build-module/store/actions.js +0 -2
  101. package/build-module/store/actions.js.map +1 -1
  102. package/build-module/store/constants.js +0 -2
  103. package/build-module/store/constants.js.map +1 -1
  104. package/build-module/store/private-actions.js +1 -1
  105. package/build-module/store/private-actions.js.map +1 -1
  106. package/build-module/store/utils/notice-builder.js +3 -8
  107. package/build-module/store/utils/notice-builder.js.map +1 -1
  108. package/build-module/utils/get-item-title.js +26 -0
  109. package/build-module/utils/get-item-title.js.map +1 -0
  110. package/build-module/utils/media-sideload/index.js +14 -0
  111. package/build-module/utils/media-sideload/index.js.map +1 -0
  112. package/build-module/utils/media-sideload/index.native.js +2 -0
  113. package/build-module/utils/media-sideload/index.native.js.map +1 -0
  114. package/build-module/utils/media-upload/index.js +5 -2
  115. package/build-module/utils/media-upload/index.js.map +1 -1
  116. package/build-style/style-rtl.css +5 -25
  117. package/build-style/style.css +5 -25
  118. package/build-types/components/commands/index.d.ts.map +1 -1
  119. package/build-types/components/document-bar/index.d.ts.map +1 -1
  120. package/build-types/components/document-tools/index.d.ts.map +1 -1
  121. package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
  122. package/build-types/components/more-menu/index.d.ts.map +1 -1
  123. package/build-types/components/post-actions/actions.d.ts.map +1 -1
  124. package/build-types/components/post-actions/index.d.ts.map +1 -1
  125. package/build-types/components/post-actions/set-as-homepage.d.ts.map +1 -1
  126. package/build-types/components/post-actions/set-as-posts-page.d.ts +10 -0
  127. package/build-types/components/post-actions/set-as-posts-page.d.ts.map +1 -0
  128. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  129. package/build-types/components/preferences-modal/index.d.ts.map +1 -1
  130. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  131. package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
  132. package/build-types/components/provider/index.d.ts.map +1 -1
  133. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  134. package/build-types/components/start-page-options/index.d.ts +1 -2
  135. package/build-types/components/start-page-options/index.d.ts.map +1 -1
  136. package/build-types/store/actions.d.ts.map +1 -1
  137. package/build-types/store/constants.d.ts +0 -2
  138. package/build-types/store/constants.d.ts.map +1 -1
  139. package/build-types/store/private-actions.d.ts.map +1 -1
  140. package/build-types/store/utils/notice-builder.d.ts.map +1 -1
  141. package/build-types/utils/get-item-title.d.ts +10 -0
  142. package/build-types/utils/get-item-title.d.ts.map +1 -0
  143. package/build-types/utils/media-sideload/index.d.ts +3 -0
  144. package/build-types/utils/media-sideload/index.d.ts.map +1 -0
  145. package/build-types/utils/media-upload/index.d.ts +3 -1
  146. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  147. package/package.json +37 -37
  148. package/src/components/commands/index.js +29 -0
  149. package/src/components/document-bar/index.js +2 -1
  150. package/src/components/document-tools/index.js +3 -6
  151. package/src/components/document-tools/style.scss +0 -6
  152. package/src/components/editor-help/intro-to-blocks.native.js +1 -1
  153. package/src/components/entities-saved-states/index.js +5 -1
  154. package/src/components/error-boundary/index.native.js +2 -2
  155. package/src/components/more-menu/index.js +0 -1
  156. package/src/components/post-actions/actions.js +12 -4
  157. package/src/components/post-actions/index.js +19 -17
  158. package/src/components/post-actions/set-as-homepage.js +29 -45
  159. package/src/components/post-actions/set-as-posts-page.js +164 -0
  160. package/src/components/post-card-panel/index.js +8 -6
  161. package/src/components/post-card-panel/style.scss +4 -13
  162. package/src/components/post-publish-panel/maybe-upload-media.js +2 -2
  163. package/src/components/preferences-modal/index.js +8 -13
  164. package/src/components/preview-dropdown/index.js +0 -1
  165. package/src/components/provider/disable-non-page-content-blocks.js +64 -13
  166. package/src/components/provider/index.js +13 -27
  167. package/src/components/provider/use-block-editor-settings.js +3 -0
  168. package/src/components/start-page-options/index.js +28 -119
  169. package/src/components/template-part-menu-items/index.js +2 -11
  170. package/src/store/actions.js +0 -2
  171. package/src/store/constants.ts +0 -2
  172. package/src/store/private-actions.js +1 -1
  173. package/src/store/utils/notice-builder.js +3 -8
  174. package/src/store/utils/test/notice-builder.js +3 -4
  175. package/src/utils/get-item-title.js +25 -0
  176. package/src/utils/media-sideload/index.js +13 -0
  177. package/src/utils/media-sideload/index.native.js +1 -0
  178. package/src/utils/media-upload/index.js +4 -1
  179. package/tsconfig.json +1 -4
  180. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_clipboard","_interopRequireDefault","_reactNativeSafeAreaContext","_element","_i18n","_data","_reactNativeBridge","_compose","_icons","_components","_store","_style","_jsxRuntime","getContent","select","editorStore","getEditedPostContent","error","CopyButton","text","label","accessibilityLabel","accessibilityHint","secondary","containerStyle","usePreferredColorSchemeStyle","styles","containerSecondaryStyle","textStyle","textSecondaryStyle","jsx","TouchableOpacity","activeOpacity","style","accessibilityRole","onPress","Clipboard","setString","children","Text","ErrorBoundary","Component","constructor","arguments","state","componentDidCatch","logException","context","component_stack","componentStack","isHandled","handledBy","getDerivedStateFromError","render","props","getStylesFromColorScheme","iconContainerStyle","titleStyle","messageStyle","SafeAreaView","ScrollView","contentContainerStyle","jsxs","View","Icon","icon","warning","__","stack","_default","exports","default","withPreferredColorScheme"],"sources":["@wordpress/editor/src/components/error-boundary/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { ScrollView, Text, TouchableOpacity, View } from 'react-native';\nimport Clipboard from '@react-native-clipboard/clipboard';\nimport { SafeAreaView } from 'react-native-safe-area-context';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { select } from '@wordpress/data';\nimport { logException } from '@wordpress/react-native-bridge';\nimport {\n\tusePreferredColorSchemeStyle,\n\twithPreferredColorScheme,\n} from '@wordpress/compose';\nimport { warning } from '@wordpress/icons';\nimport { Icon } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport styles from './style.scss';\n\nfunction getContent() {\n\ttry {\n\t\t// While `select` in a component is generally discouraged, it is\n\t\t// used here because it (a) reduces the chance of data loss in the\n\t\t// case of additional errors by performing a direct retrieval and\n\t\t// (b) avoids the performance cost associated with unnecessary\n\t\t// content serialization throughout the lifetime of a non-erroring\n\t\t// application.\n\t\treturn select( editorStore ).getEditedPostContent();\n\t} catch ( error ) {}\n}\n\nfunction CopyButton( {\n\ttext,\n\tlabel,\n\taccessibilityLabel,\n\taccessibilityHint,\n\tsecondary = false,\n} ) {\n\tconst containerStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'copy-button__container' ],\n\t\tstyles[ 'copy-button__container--dark' ]\n\t);\n\n\tconst containerSecondaryStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'copy-button__container--secondary' ],\n\t\tstyles[ 'copy-button__container--secondary-dark' ]\n\t);\n\n\tconst textStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'copy-button__text' ],\n\t\tstyles[ 'copy-button__text--dark' ]\n\t);\n\n\tconst textSecondaryStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'copy-button__text--secondary' ],\n\t\tstyles[ 'copy-button__text--secondary-dark' ]\n\t);\n\n\treturn (\n\t\t<TouchableOpacity\n\t\t\tactiveOpacity={ 0.5 }\n\t\t\taccessibilityLabel={ accessibilityLabel }\n\t\t\tstyle={ [ containerStyle, secondary && containerSecondaryStyle ] }\n\t\t\taccessibilityRole=\"button\"\n\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\tonPress={ () => {\n\t\t\t\tClipboard.setString(\n\t\t\t\t\ttypeof text === 'function' ? text() : text || ''\n\t\t\t\t);\n\t\t\t} }\n\t\t>\n\t\t\t<Text style={ [ textStyle, secondary && textSecondaryStyle ] }>\n\t\t\t\t{ label }\n\t\t\t</Text>\n\t\t</TouchableOpacity>\n\t);\n}\n\nclass ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error ) {\n\t\tlogException( error, {\n\t\t\tcontext: {\n\t\t\t\tcomponent_stack: error.componentStack,\n\t\t\t},\n\t\t\tisHandled: true,\n\t\t\thandledBy: 'Editor-level Error Boundary',\n\t\t} );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\tconst { getStylesFromColorScheme } = this.props;\n\n\t\tconst iconContainerStyle = getStylesFromColorScheme(\n\t\t\tstyles[ 'error-boundary__icon-container' ],\n\t\t\tstyles[ 'error-boundary__icon-container--dark' ]\n\t\t);\n\n\t\tconst titleStyle = getStylesFromColorScheme(\n\t\t\tstyles[ 'error-boundary__title' ],\n\t\t\tstyles[ 'error-boundary__title--dark' ]\n\t\t);\n\n\t\tconst messageStyle = getStylesFromColorScheme(\n\t\t\tstyles[ 'error-boundary__message' ],\n\t\t\tstyles[ 'error-boundary__message--dark' ]\n\t\t);\n\n\t\treturn (\n\t\t\t<SafeAreaView>\n\t\t\t\t<ScrollView\n\t\t\t\t\tstyle={ styles[ 'error-boundary__scroll' ] }\n\t\t\t\t\tcontentContainerStyle={\n\t\t\t\t\t\tstyles[ 'error-boundary__scroll-container' ]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<View style={ styles[ 'error-boundary__container' ] }>\n\t\t\t\t\t\t<View style={ iconContainerStyle }>\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\ticon={ warning }\n\t\t\t\t\t\t\t\t{ ...styles[ 'error-boundary__icon' ] }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t\t<Text style={ titleStyle }>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'The editor has encountered an unexpected error'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t<Text style={ messageStyle }>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'You can copy your post text in case your content is impacted. Copy error details to debug and share with support.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t<View\n\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\tstyles[ 'error-boundary__actions-container' ]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\t\tlabel={ __( 'Copy post text' ) }\n\t\t\t\t\t\t\t\taccessibilityLabel={ __(\n\t\t\t\t\t\t\t\t\t'Button to copy post text'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\taccessibilityHint={ __(\n\t\t\t\t\t\t\t\t\t'Tap here to copy post text'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttext={ getContent }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\t\tlabel={ __( 'Copy error details' ) }\n\t\t\t\t\t\t\t\taccessibilityLabel={ __(\n\t\t\t\t\t\t\t\t\t'Button to copy error details'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\taccessibilityHint={ __(\n\t\t\t\t\t\t\t\t\t'Tap here to copy error details'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttext={ error.stack }\n\t\t\t\t\t\t\t\tsecondary\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t</View>\n\t\t\t\t</ScrollView>\n\t\t\t</SafeAreaView>\n\t\t);\n\t}\n}\n\nexport default withPreferredColorScheme( ErrorBoundary );\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,2BAAA,GAAAH,OAAA;AAKA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,kBAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAIA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AAKA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,MAAA,GAAAV,sBAAA,CAAAF,OAAA;AAAkC,IAAAa,WAAA,GAAAb,OAAA;AAzBlC;AACA;AACA;;AAKA;AACA;AACA;;AAYA;AACA;AACA;;AAIA,SAASc,UAAUA,CAAA,EAAG;EACrB,IAAI;IACH;IACA;IACA;IACA;IACA;IACA;IACA,OAAO,IAAAC,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AA+C,QAAE,EAAE,oBAAqB,CAAG;cACpC9C,kBAAkB,EAAG,IAAA8C,QAAE,EACtB,8BACD,CAAG;cACH7C,iBAAiB,EAAG,IAAA6C,QAAE,EACrB,gCACD,CAAG;cACHhD,IAAI,EAAGF,KAAK,CAACmD,KAAO;cACpB7C,SAAS;YAAA,CACT,CAAC;UAAA,CACG,CAAC;QAAA,CACF;MAAC,CACI;IAAC,CACA,CAAC;EAEjB;AACD;AAAC,IAAA8C,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,iCAAwB,EAAEhC,aAAc,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_clipboard","_interopRequireDefault","_reactNativeSafeAreaContext","_element","_i18n","_data","_reactNativeBridge","_compose","_icons","_components","_store","_style","_jsxRuntime","getContent","select","editorStore","getEditedPostContent","error","CopyButton","text","label","accessibilityLabel","accessibilityHint","secondary","containerStyle","usePreferredColorSchemeStyle","styles","containerSecondaryStyle","textStyle","textSecondaryStyle","jsx","TouchableOpacity","activeOpacity","style","accessibilityRole","onPress","Clipboard","setString","children","Text","ErrorBoundary","Component","constructor","arguments","state","componentDidCatch","logException","context","component_stack","componentStack","isHandled","handledBy","getDerivedStateFromError","render","props","getStylesFromColorScheme","iconContainerStyle","titleStyle","messageStyle","SafeAreaView","ScrollView","contentContainerStyle","jsxs","View","Icon","icon","cautionFilled","__","stack","_default","exports","default","withPreferredColorScheme"],"sources":["@wordpress/editor/src/components/error-boundary/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { ScrollView, Text, TouchableOpacity, View } from 'react-native';\nimport Clipboard from '@react-native-clipboard/clipboard';\nimport { SafeAreaView } from 'react-native-safe-area-context';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { select } from '@wordpress/data';\nimport { logException } from '@wordpress/react-native-bridge';\nimport {\n\tusePreferredColorSchemeStyle,\n\twithPreferredColorScheme,\n} from '@wordpress/compose';\nimport { cautionFilled } from '@wordpress/icons';\nimport { Icon } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport styles from './style.scss';\n\nfunction getContent() {\n\ttry {\n\t\t// While `select` in a component is generally discouraged, it is\n\t\t// used here because it (a) reduces the chance of data loss in the\n\t\t// case of additional errors by performing a direct retrieval and\n\t\t// (b) avoids the performance cost associated with unnecessary\n\t\t// content serialization throughout the lifetime of a non-erroring\n\t\t// application.\n\t\treturn select( editorStore ).getEditedPostContent();\n\t} catch ( error ) {}\n}\n\nfunction CopyButton( {\n\ttext,\n\tlabel,\n\taccessibilityLabel,\n\taccessibilityHint,\n\tsecondary = false,\n} ) {\n\tconst containerStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'copy-button__container' ],\n\t\tstyles[ 'copy-button__container--dark' ]\n\t);\n\n\tconst containerSecondaryStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'copy-button__container--secondary' ],\n\t\tstyles[ 'copy-button__container--secondary-dark' ]\n\t);\n\n\tconst textStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'copy-button__text' ],\n\t\tstyles[ 'copy-button__text--dark' ]\n\t);\n\n\tconst textSecondaryStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'copy-button__text--secondary' ],\n\t\tstyles[ 'copy-button__text--secondary-dark' ]\n\t);\n\n\treturn (\n\t\t<TouchableOpacity\n\t\t\tactiveOpacity={ 0.5 }\n\t\t\taccessibilityLabel={ accessibilityLabel }\n\t\t\tstyle={ [ containerStyle, secondary && containerSecondaryStyle ] }\n\t\t\taccessibilityRole=\"button\"\n\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\tonPress={ () => {\n\t\t\t\tClipboard.setString(\n\t\t\t\t\ttypeof text === 'function' ? text() : text || ''\n\t\t\t\t);\n\t\t\t} }\n\t\t>\n\t\t\t<Text style={ [ textStyle, secondary && textSecondaryStyle ] }>\n\t\t\t\t{ label }\n\t\t\t</Text>\n\t\t</TouchableOpacity>\n\t);\n}\n\nclass ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error ) {\n\t\tlogException( error, {\n\t\t\tcontext: {\n\t\t\t\tcomponent_stack: error.componentStack,\n\t\t\t},\n\t\t\tisHandled: true,\n\t\t\thandledBy: 'Editor-level Error Boundary',\n\t\t} );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\tconst { getStylesFromColorScheme } = this.props;\n\n\t\tconst iconContainerStyle = getStylesFromColorScheme(\n\t\t\tstyles[ 'error-boundary__icon-container' ],\n\t\t\tstyles[ 'error-boundary__icon-container--dark' ]\n\t\t);\n\n\t\tconst titleStyle = getStylesFromColorScheme(\n\t\t\tstyles[ 'error-boundary__title' ],\n\t\t\tstyles[ 'error-boundary__title--dark' ]\n\t\t);\n\n\t\tconst messageStyle = getStylesFromColorScheme(\n\t\t\tstyles[ 'error-boundary__message' ],\n\t\t\tstyles[ 'error-boundary__message--dark' ]\n\t\t);\n\n\t\treturn (\n\t\t\t<SafeAreaView>\n\t\t\t\t<ScrollView\n\t\t\t\t\tstyle={ styles[ 'error-boundary__scroll' ] }\n\t\t\t\t\tcontentContainerStyle={\n\t\t\t\t\t\tstyles[ 'error-boundary__scroll-container' ]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<View style={ styles[ 'error-boundary__container' ] }>\n\t\t\t\t\t\t<View style={ iconContainerStyle }>\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\ticon={ cautionFilled }\n\t\t\t\t\t\t\t\t{ ...styles[ 'error-boundary__icon' ] }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t\t<Text style={ titleStyle }>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'The editor has encountered an unexpected error'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t<Text style={ messageStyle }>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'You can copy your post text in case your content is impacted. Copy error details to debug and share with support.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t<View\n\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\tstyles[ 'error-boundary__actions-container' ]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\t\tlabel={ __( 'Copy post text' ) }\n\t\t\t\t\t\t\t\taccessibilityLabel={ __(\n\t\t\t\t\t\t\t\t\t'Button to copy post text'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\taccessibilityHint={ __(\n\t\t\t\t\t\t\t\t\t'Tap here to copy post text'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttext={ getContent }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\t\tlabel={ __( 'Copy error details' ) }\n\t\t\t\t\t\t\t\taccessibilityLabel={ __(\n\t\t\t\t\t\t\t\t\t'Button to copy error details'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\taccessibilityHint={ __(\n\t\t\t\t\t\t\t\t\t'Tap here to copy error details'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttext={ error.stack }\n\t\t\t\t\t\t\t\tsecondary\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t</View>\n\t\t\t\t</ScrollView>\n\t\t\t</SafeAreaView>\n\t\t);\n\t}\n}\n\nexport default withPreferredColorScheme( ErrorBoundary );\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;A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GAAA,EAAChC,YAAA,CAAAyC,IAAI;YAACN,KAAK,EAAGyB,YAAc;YAAApB,QAAA,EACzB,IAAA6B,QAAE,EACH,mHACD;UAAC,CACI,CAAC,eACP,IAAAvD,WAAA,CAAAkD,IAAA,EAAChE,YAAA,CAAAiE,IAAI;YACJ9B,KAAK,EACJP,cAAM,CAAE,mCAAmC,CAC3C;YAAAY,QAAA,gBAED,IAAA1B,WAAA,CAAAkB,GAAA,EAACZ,UAAU;cACVE,KAAK,EAAG,IAAA+C,QAAE,EAAE,gBAAiB,CAAG;cAChC9C,kBAAkB,EAAG,IAAA8C,QAAE,EACtB,0BACD,CAAG;cACH7C,iBAAiB,EAAG,IAAA6C,QAAE,EACrB,4BACD,CAAG;cACHhD,IAAI,EAAGN;YAAY,CACnB,CAAC,eACF,IAAAD,WAAA,CAAAkB,GAAA,EAACZ,UAAU;cACVE,KAAK,EAAG,IAAA+C,QAAE,EAAE,oBAAqB,CAAG;cACpC9C,kBAAkB,EAAG,IAAA8C,QAAE,EACtB,8BACD,CAAG;cACH7C,iBAAiB,EAAG,IAAA6C,QAAE,EACrB,gCACD,CAAG;cACHhD,IAAI,EAAGF,KAAK,CAACmD,KAAO;cACpB7C,SAAS;YAAA,CACT,CAAC;UAAA,CACG,CAAC;QAAA,CACF;MAAC,CACI;IAAC,CACA,CAAC;EAEjB;AACD;AAAC,IAAA8C,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,iCAAwB,EAAEhC,aAAc,CAAC","ignoreList":[]}
@@ -96,7 +96,6 @@ function MoreMenu() {
96
96
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_modeSwitcher.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_interface.ActionItem.Slot, {
97
97
  name: "core/plugin-more-menu",
98
98
  label: (0, _i18n.__)('Plugins'),
99
- as: _components.MenuGroup,
100
99
  fillProps: {
101
100
  onClick: onClose
102
101
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_data","_keycodes","_icons","_components","_preferences","_interface","_copyContentMenuItem","_interopRequireDefault","_modeSwitcher","_toolsMoreMenuGroup","_viewMoreMenuGroup","_store","_jsxRuntime","MoreMenu","openModal","useDispatch","interfaceStore","set","setPreference","preferencesStore","toggleDistractionFree","editorStore","showIconLabels","useSelect","select","get","turnOffDistractionFree","jsx","Fragment","children","DropdownMenu","icon","moreVertical","label","__","popoverProps","placement","className","toggleProps","showTooltip","variant","tooltipPosition","size","onClose","jsxs","MenuGroup","_x","PreferenceToggleMenuItem","scope","name","onToggle","info","messageActivated","messageDeactivated","handleToggling","createNotice","shortcut","displayShortcut","primaryShift","default","Slot","fillProps","ActionItem","as","onClick","MenuItem","access","external","href","target","rel","VisuallyHidden"],"sources":["@wordpress/editor/src/components/more-menu/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { external, moreVertical } from '@wordpress/icons';\nimport {\n\tMenuGroup,\n\tMenuItem,\n\tVisuallyHidden,\n\tDropdownMenu,\n} from '@wordpress/components';\nimport {\n\tPreferenceToggleMenuItem,\n\tstore as preferencesStore,\n} from '@wordpress/preferences';\nimport { store as interfaceStore, ActionItem } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport CopyContentMenuItem from './copy-content-menu-item';\nimport ModeSwitcher from '../mode-switcher';\nimport ToolsMoreMenuGroup from './tools-more-menu-group';\nimport ViewMoreMenuGroup from './view-more-menu-group';\nimport { store as editorStore } from '../../store';\n\nexport default function MoreMenu() {\n\tconst { openModal } = useDispatch( interfaceStore );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tconst { toggleDistractionFree } = useDispatch( editorStore );\n\tconst showIconLabels = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', 'showIconLabels' ),\n\t\t[]\n\t);\n\n\tconst turnOffDistractionFree = () => {\n\t\tsetPreference( 'core', 'distractionFree', false );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\ticon={ moreVertical }\n\t\t\t\tlabel={ __( 'Options' ) }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tplacement: 'bottom-end',\n\t\t\t\t\tclassName: 'more-menu-dropdown__content',\n\t\t\t\t} }\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tshowTooltip: ! showIconLabels,\n\t\t\t\t\t...( showIconLabels && { variant: 'tertiary' } ),\n\t\t\t\t\ttooltipPosition: 'bottom',\n\t\t\t\t\tsize: 'compact',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup label={ _x( 'View', 'noun' ) }>\n\t\t\t\t\t\t\t<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\tscope=\"core\"\n\t\t\t\t\t\t\t\tname=\"fixedToolbar\"\n\t\t\t\t\t\t\t\tonToggle={ turnOffDistractionFree }\n\t\t\t\t\t\t\t\tlabel={ __( 'Top toolbar' ) }\n\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t'Access all block and document tools in a single place'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Top toolbar activated.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Top toolbar deactivated.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\tscope=\"core\"\n\t\t\t\t\t\t\t\tname=\"distractionFree\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Distraction free' ) }\n\t\t\t\t\t\t\t\tinfo={ __( 'Write with calmness' ) }\n\t\t\t\t\t\t\t\thandleToggling={ false }\n\t\t\t\t\t\t\t\tonToggle={ () =>\n\t\t\t\t\t\t\t\t\ttoggleDistractionFree( {\n\t\t\t\t\t\t\t\t\t\tcreateNotice: false,\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\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Distraction free mode activated.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Distraction free mode deactivated.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.primaryShift(\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\t<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\tscope=\"core\"\n\t\t\t\t\t\t\t\tname=\"focusMode\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Spotlight mode' ) }\n\t\t\t\t\t\t\t\tinfo={ __( 'Focus on one block at a time' ) }\n\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Spotlight mode activated.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Spotlight mode deactivated.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<ViewMoreMenuGroup.Slot fillProps={ { onClose } } />\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<ModeSwitcher />\n\t\t\t\t\t\t<ActionItem.Slot\n\t\t\t\t\t\t\tname=\"core/plugin-more-menu\"\n\t\t\t\t\t\t\tlabel={ __( 'Plugins' ) }\n\t\t\t\t\t\t\tas={ MenuGroup }\n\t\t\t\t\t\t\tfillProps={ { onClick: onClose } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<MenuGroup label={ __( 'Tools' ) }>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\topenModal( 'editor/keyboard-shortcut-help' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.access( 'h' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Keyboard shortcuts' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<CopyContentMenuItem />\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/wordpress-block-editor/'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Help' ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<ToolsMoreMenuGroup.Slot\n\t\t\t\t\t\t\t\tfillProps={ { onClose } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\topenModal( 'editor/preferences' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Preferences' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\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AACxB,WAAA,CAAA8D,QAAQ;YACRD,OAAO,EAAGA,CAAA,KACTlD,SAAS,CAAE,+BAAgC,CAC3C;YACD0C,QAAQ,EAAGC,yBAAe,CAACS,MAAM,CAAE,GAAI,CAAG;YAAArC,QAAA,EAExC,IAAAK,QAAE,EAAE,oBAAqB;UAAC,CACnB,CAAC,eACX,IAAAtB,WAAA,CAAAe,GAAA,EAACrB,oBAAA,CAAAqD,OAAmB,IAAE,CAAC,eACvB,IAAA/C,WAAA,CAAAgC,IAAA,EAACzC,WAAA,CAAA8D,QAAQ;YACRlC,IAAI,EAAGoC,eAAU;YACjBC,IAAI,EAAG,IAAAlC,QAAE,EACR,qEACD,CAAG;YACHmC,MAAM,EAAC,QAAQ;YACfC,GAAG,EAAC,qBAAqB;YAAAzC,QAAA,GAEvB,IAAAK,QAAE,EAAE,MAAO,CAAC,eACd,IAAAtB,WAAA,CAAAe,GAAA,EAACxB,WAAA,CAAAoE,cAAc;cAACR,EAAE,EAAC,MAAM;cAAAlC,QAAA,EAEvB;cACA,IAAAK,QAAE,EAAE,sBAAuB;YAAC,CAEd,CAAC;UAAA,CACR,CAAC,eACX,IAAAtB,WAAA,CAAAe,GAAA,EAAClB,mBAAA,CAAAkD,OAAkB,CAACC,IAAI;YACvBC,SAAS,EAAG;cAAElB;YAAQ;UAAG,CACzB,CAAC;QAAA,CACQ,CAAC,eACZ,IAAA/B,WAAA,CAAAe,GAAA,EAACxB,WAAA,CAAA0C,SAAS;UAAAhB,QAAA,eACT,IAAAjB,WAAA,CAAAe,GAAA,EAACxB,WAAA,CAAA8D,QAAQ;YACRD,OAAO,EAAGA,CAAA,KACTlD,SAAS,CAAE,oBAAqB,CAChC;YAAAe,QAAA,EAEC,IAAAK,QAAE,EAAE,aAAc;UAAC,CACZ;QAAC,CACD,CAAC;MAAA,CACX;IACF,CACY;EAAC,CACd,CAAC;AAEL","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_data","_keycodes","_icons","_components","_preferences","_interface","_copyContentMenuItem","_interopRequireDefault","_modeSwitcher","_toolsMoreMenuGroup","_viewMoreMenuGroup","_store","_jsxRuntime","MoreMenu","openModal","useDispatch","interfaceStore","set","setPreference","preferencesStore","toggleDistractionFree","editorStore","showIconLabels","useSelect","select","get","turnOffDistractionFree","jsx","Fragment","children","DropdownMenu","icon","moreVertical","label","__","popoverProps","placement","className","toggleProps","showTooltip","variant","tooltipPosition","size","onClose","jsxs","MenuGroup","_x","PreferenceToggleMenuItem","scope","name","onToggle","info","messageActivated","messageDeactivated","handleToggling","createNotice","shortcut","displayShortcut","primaryShift","default","Slot","fillProps","ActionItem","onClick","MenuItem","access","external","href","target","rel","VisuallyHidden","as"],"sources":["@wordpress/editor/src/components/more-menu/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { external, moreVertical } from '@wordpress/icons';\nimport {\n\tMenuGroup,\n\tMenuItem,\n\tVisuallyHidden,\n\tDropdownMenu,\n} from '@wordpress/components';\nimport {\n\tPreferenceToggleMenuItem,\n\tstore as preferencesStore,\n} from '@wordpress/preferences';\nimport { store as interfaceStore, ActionItem } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport CopyContentMenuItem from './copy-content-menu-item';\nimport ModeSwitcher from '../mode-switcher';\nimport ToolsMoreMenuGroup from './tools-more-menu-group';\nimport ViewMoreMenuGroup from './view-more-menu-group';\nimport { store as editorStore } from '../../store';\n\nexport default function MoreMenu() {\n\tconst { openModal } = useDispatch( interfaceStore );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tconst { toggleDistractionFree } = useDispatch( editorStore );\n\tconst showIconLabels = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', 'showIconLabels' ),\n\t\t[]\n\t);\n\n\tconst turnOffDistractionFree = () => {\n\t\tsetPreference( 'core', 'distractionFree', false );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\ticon={ moreVertical }\n\t\t\t\tlabel={ __( 'Options' ) }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tplacement: 'bottom-end',\n\t\t\t\t\tclassName: 'more-menu-dropdown__content',\n\t\t\t\t} }\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tshowTooltip: ! showIconLabels,\n\t\t\t\t\t...( showIconLabels && { variant: 'tertiary' } ),\n\t\t\t\t\ttooltipPosition: 'bottom',\n\t\t\t\t\tsize: 'compact',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup label={ _x( 'View', 'noun' ) }>\n\t\t\t\t\t\t\t<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\tscope=\"core\"\n\t\t\t\t\t\t\t\tname=\"fixedToolbar\"\n\t\t\t\t\t\t\t\tonToggle={ turnOffDistractionFree }\n\t\t\t\t\t\t\t\tlabel={ __( 'Top toolbar' ) }\n\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t'Access all block and document tools in a single place'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Top toolbar activated.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Top toolbar deactivated.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\tscope=\"core\"\n\t\t\t\t\t\t\t\tname=\"distractionFree\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Distraction free' ) }\n\t\t\t\t\t\t\t\tinfo={ __( 'Write with calmness' ) }\n\t\t\t\t\t\t\t\thandleToggling={ false }\n\t\t\t\t\t\t\t\tonToggle={ () =>\n\t\t\t\t\t\t\t\t\ttoggleDistractionFree( {\n\t\t\t\t\t\t\t\t\t\tcreateNotice: false,\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\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Distraction free mode activated.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Distraction free mode deactivated.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.primaryShift(\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\t<PreferenceToggleMenuItem\n\t\t\t\t\t\t\t\tscope=\"core\"\n\t\t\t\t\t\t\t\tname=\"focusMode\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Spotlight mode' ) }\n\t\t\t\t\t\t\t\tinfo={ __( 'Focus on one block at a time' ) }\n\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Spotlight mode activated.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Spotlight mode deactivated.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<ViewMoreMenuGroup.Slot fillProps={ { onClose } } />\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<ModeSwitcher />\n\t\t\t\t\t\t<ActionItem.Slot\n\t\t\t\t\t\t\tname=\"core/plugin-more-menu\"\n\t\t\t\t\t\t\tlabel={ __( 'Plugins' ) }\n\t\t\t\t\t\t\tfillProps={ { onClick: onClose } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<MenuGroup label={ __( 'Tools' ) }>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\topenModal( 'editor/keyboard-shortcut-help' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.access( 'h' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Keyboard shortcuts' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<CopyContentMenuItem />\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/wordpress-block-editor/'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Help' ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<ToolsMoreMenuGroup.Slot\n\t\t\t\t\t\t\t\tfillProps={ { onClose } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\topenModal( 'editor/preferences' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Preferences' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t</>\n\t);\n}\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D0C,QAAQ,EAAGC,yBAAe,CAACQ,MAAM,CAAE,GAAI,CAAG;YAAApC,QAAA,EAExC,IAAAK,QAAE,EAAE,oBAAqB;UAAC,CACnB,CAAC,eACX,IAAAtB,WAAA,CAAAe,GAAA,EAACrB,oBAAA,CAAAqD,OAAmB,IAAE,CAAC,eACvB,IAAA/C,WAAA,CAAAgC,IAAA,EAACzC,WAAA,CAAA6D,QAAQ;YACRjC,IAAI,EAAGmC,eAAU;YACjBC,IAAI,EAAG,IAAAjC,QAAE,EACR,qEACD,CAAG;YACHkC,MAAM,EAAC,QAAQ;YACfC,GAAG,EAAC,qBAAqB;YAAAxC,QAAA,GAEvB,IAAAK,QAAE,EAAE,MAAO,CAAC,eACd,IAAAtB,WAAA,CAAAe,GAAA,EAACxB,WAAA,CAAAmE,cAAc;cAACC,EAAE,EAAC,MAAM;cAAA1C,QAAA,EAEvB;cACA,IAAAK,QAAE,EAAE,sBAAuB;YAAC,CAEd,CAAC;UAAA,CACR,CAAC,eACX,IAAAtB,WAAA,CAAAe,GAAA,EAAClB,mBAAA,CAAAkD,OAAkB,CAACC,IAAI;YACvBC,SAAS,EAAG;cAAElB;YAAQ;UAAG,CACzB,CAAC;QAAA,CACQ,CAAC,eACZ,IAAA/B,WAAA,CAAAe,GAAA,EAACxB,WAAA,CAAA0C,SAAS;UAAAhB,QAAA,eACT,IAAAjB,WAAA,CAAAe,GAAA,EAACxB,WAAA,CAAA6D,QAAQ;YACRD,OAAO,EAAGA,CAAA,KACTjD,SAAS,CAAE,oBAAqB,CAChC;YAAAe,QAAA,EAEC,IAAAK,QAAE,EAAE,aAAc;UAAC,CACZ;QAAC,CACD,CAAC;MAAA,CACX;IACF,CACY;EAAC,CACd,CAAC;AAEL","ignoreList":[]}
@@ -11,6 +11,7 @@ var _coreData = require("@wordpress/core-data");
11
11
  var _store = require("../../store");
12
12
  var _lockUnlock = require("../../lock-unlock");
13
13
  var _setAsHomepage = require("./set-as-homepage");
14
+ var _setAsPostsPage = require("./set-as-posts-page");
14
15
  var _jsxRuntime = require("react/jsx-runtime");
15
16
  /**
16
17
  * WordPress dependencies
@@ -54,7 +55,8 @@ function usePostActions({
54
55
  };
55
56
  });
56
57
  const setAsHomepageAction = (0, _setAsHomepage.useSetAsHomepageAction)();
57
- const shouldShowSetAsHomepageAction = canManageOptions && !hasFrontPageTemplate;
58
+ const setAsPostsPageAction = (0, _setAsPostsPage.useSetAsPostsPageAction)();
59
+ const shouldShowHomepageActions = canManageOptions && !hasFrontPageTemplate;
58
60
  const {
59
61
  registerPostTypeSchema
60
62
  } = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
@@ -63,10 +65,13 @@ function usePostActions({
63
65
  }, [registerPostTypeSchema, postType]);
64
66
  return (0, _element.useMemo)(() => {
65
67
  let actions = [...defaultActions];
66
- if (shouldShowSetAsHomepageAction) {
67
- actions.push(setAsHomepageAction);
68
+ if (shouldShowHomepageActions) {
69
+ actions.push(setAsHomepageAction, setAsPostsPageAction);
68
70
  }
69
71
 
72
+ // Ensure "Move to trash" is always the last action.
73
+ actions = actions.sort((a, b) => b.id === 'move-to-trash' ? -1 : 0);
74
+
70
75
  // Filter actions based on provided context. If not provided
71
76
  // all actions are returned. We'll have a single entry for getting the actions
72
77
  // and the consumer should provide the context to filter the actions, if needed.
@@ -118,6 +123,6 @@ function usePostActions({
118
123
  }
119
124
  }
120
125
  return actions;
121
- }, [context, defaultActions, onActionPerformed, setAsHomepageAction, shouldShowSetAsHomepageAction]);
126
+ }, [context, defaultActions, onActionPerformed, setAsHomepageAction, setAsPostsPageAction, shouldShowHomepageActions]);
122
127
  }
123
128
  //# sourceMappingURL=actions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_element","_coreData","_store","_lockUnlock","_setAsHomepage","_jsxRuntime","usePostActions","postType","onActionPerformed","context","defaultActions","useSelect","select","getEntityActions","unlock","editorStore","canManageOptions","hasFrontPageTemplate","getEntityRecords","coreStore","templates","per_page","canUser","kind","name","find","template","slug","setAsHomepageAction","useSetAsHomepageAction","shouldShowSetAsHomepageAction","registerPostTypeSchema","useDispatch","useEffect","useMemo","actions","push","filter","action","i","length","callback","existingCallback","items","argsObject","_items","id","RenderModal","ExistingRenderModal","props","jsx"],"sources":["@wordpress/editor/src/components/post-actions/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useSetAsHomepageAction } from './set-as-homepage';\n\nexport function usePostActions( { postType, onActionPerformed, context } ) {\n\tconst { defaultActions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityActions } = unlock( select( editorStore ) );\n\t\t\treturn {\n\t\t\t\tdefaultActions: getEntityActions( 'postType', postType ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst { canManageOptions, hasFrontPageTemplate } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst templates = getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t} );\n\n\t\t\treturn {\n\t\t\t\tcanManageOptions: select( coreStore ).canUser( 'update', {\n\t\t\t\t\tkind: 'root',\n\t\t\t\t\tname: 'site',\n\t\t\t\t} ),\n\t\t\t\thasFrontPageTemplate: !! templates?.find(\n\t\t\t\t\t( template ) => template?.slug === 'front-page'\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t);\n\n\tconst setAsHomepageAction = useSetAsHomepageAction();\n\tconst shouldShowSetAsHomepageAction =\n\t\tcanManageOptions && ! hasFrontPageTemplate;\n\n\tconst { registerPostTypeSchema } = unlock( useDispatch( editorStore ) );\n\tuseEffect( () => {\n\t\tregisterPostTypeSchema( postType );\n\t}, [ registerPostTypeSchema, postType ] );\n\n\treturn useMemo( () => {\n\t\tlet actions = [ ...defaultActions ];\n\t\tif ( shouldShowSetAsHomepageAction ) {\n\t\t\tactions.push( setAsHomepageAction );\n\t\t}\n\n\t\t// Filter actions based on provided context. If not provided\n\t\t// all actions are returned. We'll have a single entry for getting the actions\n\t\t// and the consumer should provide the context to filter the actions, if needed.\n\t\t// Actions should also provide the `context` they support, if it's specific, to\n\t\t// compare with the provided context to get all the actions.\n\t\t// Right now the only supported context is `list`.\n\t\tactions = actions.filter( ( action ) => {\n\t\t\tif ( ! action.context ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn action.context === context;\n\t\t} );\n\n\t\tif ( onActionPerformed ) {\n\t\t\tfor ( let i = 0; i < actions.length; ++i ) {\n\t\t\t\tif ( actions[ i ].callback ) {\n\t\t\t\t\tconst existingCallback = actions[ i ].callback;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tcallback: ( items, argsObject ) => {\n\t\t\t\t\t\t\texistingCallback( items, {\n\t\t\t\t\t\t\t\t...argsObject,\n\t\t\t\t\t\t\t\tonActionPerformed: ( _items ) => {\n\t\t\t\t\t\t\t\t\tif ( argsObject?.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\targsObject.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t_items\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},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif ( actions[ i ].RenderModal ) {\n\t\t\t\t\tconst ExistingRenderModal = actions[ i ].RenderModal;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tRenderModal: ( props ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<ExistingRenderModal\n\t\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\t\tonActionPerformed={ ( _items ) => {\n\t\t\t\t\t\t\t\t\t\tif ( props.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\t\tprops.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t\t_items\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},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn actions;\n\t}, [\n\t\tcontext,\n\t\tdefaultActions,\n\t\tonActionPerformed,\n\t\tsetAsHomepageAction,\n\t\tshouldShowSetAsHomepageAction,\n\t] );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AAA2D,IAAAM,WAAA,GAAAN,OAAA;AAZ3D;AACA;AACA;;AAKA;AACA;AACA;;AAKO,SAASO,cAAcA,CAAE;EAAEC,QAAQ;EAAEC,iBAAiB;EAAEC;AAAQ,CAAC,EAAG;EAC1E,MAAM;IAAEC;EAAe,CAAC,GAAG,IAAAC,eAAS,EACjCC,MAAM,IAAM;IACb,MAAM;MAAEC;IAAiB,CAAC,GAAG,IAAAC,kBAAM,EAAEF,MAAM,CAAEG,YAAY,CAAE,CAAC;IAC5D,OAAO;MACNL,cAAc,EAAEG,gBAAgB,CAAE,UAAU,EAAEN,QAAS;IACxD,CAAC;EACF,CAAC,EACD,CAAEA,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ACArC,iBAAiB,CAChB2B,OAAO,CAAEI,CAAC,CAAE,CAACO,EAAE,EACfD,MACD,CAAC;gBACF;cAAG,CACH,CAAC;YAEJ;UACD,CAAC;QACF;MACD;IACD;IAEA,OAAOV,OAAO;EACf,CAAC,EAAE,CACF1B,OAAO,EACPC,cAAc,EACdF,iBAAiB,EACjBoB,mBAAmB,EACnBE,6BAA6B,CAC5B,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_element","_coreData","_store","_lockUnlock","_setAsHomepage","_setAsPostsPage","_jsxRuntime","usePostActions","postType","onActionPerformed","context","defaultActions","useSelect","select","getEntityActions","unlock","editorStore","canManageOptions","hasFrontPageTemplate","getEntityRecords","coreStore","templates","per_page","canUser","kind","name","find","template","slug","setAsHomepageAction","useSetAsHomepageAction","setAsPostsPageAction","useSetAsPostsPageAction","shouldShowHomepageActions","registerPostTypeSchema","useDispatch","useEffect","useMemo","actions","push","sort","a","b","id","filter","action","i","length","callback","existingCallback","items","argsObject","_items","RenderModal","ExistingRenderModal","props","jsx"],"sources":["@wordpress/editor/src/components/post-actions/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useSetAsHomepageAction } from './set-as-homepage';\nimport { useSetAsPostsPageAction } from './set-as-posts-page';\n\nexport function usePostActions( { postType, onActionPerformed, context } ) {\n\tconst { defaultActions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityActions } = unlock( select( editorStore ) );\n\t\t\treturn {\n\t\t\t\tdefaultActions: getEntityActions( 'postType', postType ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst { canManageOptions, hasFrontPageTemplate } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst templates = getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t} );\n\n\t\t\treturn {\n\t\t\t\tcanManageOptions: select( coreStore ).canUser( 'update', {\n\t\t\t\t\tkind: 'root',\n\t\t\t\t\tname: 'site',\n\t\t\t\t} ),\n\t\t\t\thasFrontPageTemplate: !! templates?.find(\n\t\t\t\t\t( template ) => template?.slug === 'front-page'\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t);\n\n\tconst setAsHomepageAction = useSetAsHomepageAction();\n\tconst setAsPostsPageAction = useSetAsPostsPageAction();\n\tconst shouldShowHomepageActions =\n\t\tcanManageOptions && ! hasFrontPageTemplate;\n\n\tconst { registerPostTypeSchema } = unlock( useDispatch( editorStore ) );\n\tuseEffect( () => {\n\t\tregisterPostTypeSchema( postType );\n\t}, [ registerPostTypeSchema, postType ] );\n\n\treturn useMemo( () => {\n\t\tlet actions = [ ...defaultActions ];\n\t\tif ( shouldShowHomepageActions ) {\n\t\t\tactions.push( setAsHomepageAction, setAsPostsPageAction );\n\t\t}\n\n\t\t// Ensure \"Move to trash\" is always the last action.\n\t\tactions = actions.sort( ( a, b ) =>\n\t\t\tb.id === 'move-to-trash' ? -1 : 0\n\t\t);\n\n\t\t// Filter actions based on provided context. If not provided\n\t\t// all actions are returned. We'll have a single entry for getting the actions\n\t\t// and the consumer should provide the context to filter the actions, if needed.\n\t\t// Actions should also provide the `context` they support, if it's specific, to\n\t\t// compare with the provided context to get all the actions.\n\t\t// Right now the only supported context is `list`.\n\t\tactions = actions.filter( ( action ) => {\n\t\t\tif ( ! action.context ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn action.context === context;\n\t\t} );\n\n\t\tif ( onActionPerformed ) {\n\t\t\tfor ( let i = 0; i < actions.length; ++i ) {\n\t\t\t\tif ( actions[ i ].callback ) {\n\t\t\t\t\tconst existingCallback = actions[ i ].callback;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tcallback: ( items, argsObject ) => {\n\t\t\t\t\t\t\texistingCallback( items, {\n\t\t\t\t\t\t\t\t...argsObject,\n\t\t\t\t\t\t\t\tonActionPerformed: ( _items ) => {\n\t\t\t\t\t\t\t\t\tif ( argsObject?.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\targsObject.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t_items\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},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif ( actions[ i ].RenderModal ) {\n\t\t\t\t\tconst ExistingRenderModal = actions[ i ].RenderModal;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tRenderModal: ( props ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<ExistingRenderModal\n\t\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\t\tonActionPerformed={ ( _items ) => {\n\t\t\t\t\t\t\t\t\t\tif ( props.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\t\tprops.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t\t_items\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},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn actions;\n\t}, [\n\t\tcontext,\n\t\tdefaultActions,\n\t\tonActionPerformed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AC;AACJ","ignoreList":[]}
@@ -71,21 +71,24 @@ function PostActions({
71
71
  });
72
72
  }, [allActions, itemsWithPermissions]);
73
73
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
74
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Menu, {
75
- trigger: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
76
- size: "small",
77
- icon: _icons.moreVertical,
78
- label: (0, _i18n.__)('Actions'),
79
- disabled: !actions.length,
80
- accessibleWhenDisabled: true,
81
- className: "editor-all-actions-button"
82
- }),
74
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(Menu, {
83
75
  placement: "bottom-end",
84
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionsDropdownMenuGroup, {
85
- actions: actions,
86
- items: itemsWithPermissions,
87
- setActiveModalAction: setActiveModalAction
88
- })
76
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Menu.TriggerButton, {
77
+ render: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
78
+ size: "small",
79
+ icon: _icons.moreVertical,
80
+ label: (0, _i18n.__)('Actions'),
81
+ disabled: !actions.length,
82
+ accessibleWhenDisabled: true,
83
+ className: "editor-all-actions-button"
84
+ })
85
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Menu.Popover, {
86
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionsDropdownMenuGroup, {
87
+ actions: actions,
88
+ items: itemsWithPermissions,
89
+ setActiveModalAction: setActiveModalAction
90
+ })
91
+ })]
89
92
  }), !!activeModalAction && /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionModal, {
90
93
  action: activeModalAction,
91
94
  items: itemsWithPermissions,
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_element","_i18n","_components","_icons","_coreData","_lockUnlock","_actions","_jsxRuntime","Menu","kebabCase","unlock","componentsPrivateApis","useEditedEntityRecordsWithPermissions","postType","postIds","items","permissions","useSelect","select","getEditedEntityRecord","getEntityRecordPermissions","coreStore","map","postId","useMemo","item","index","PostActions","onActionPerformed","activeModalAction","setActiveModalAction","useState","_postIds","Array","isArray","itemsWithPermissions","allActions","usePostActions","actions","filter","action","isEligible","some","itemWithPermissions","length","supportsBulk","jsxs","Fragment","children","jsx","trigger","Button","size","icon","moreVertical","label","__","disabled","accessibleWhenDisabled","className","placement","ActionsDropdownMenuGroup","ActionModal","closeModal","DropdownMenuItemTrigger","onClick","Item","ItemLabel","Modal","title","modalHeader","__experimentalHideHeader","hideModalHeader","onRequestClose","focusOnMount","overlayClassName","id","RenderModal","registry","useRegistry","Group","callback"],"sources":["@wordpress/editor/src/components/post-actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tprivateApis as componentsPrivateApis,\n\tButton,\n\tModal,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { usePostActions } from './actions';\n\nconst { Menu, kebabCase } = unlock( componentsPrivateApis );\n\nfunction useEditedEntityRecordsWithPermissions( postType, postIds ) {\n\tconst { items, permissions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, getEntityRecordPermissions } =\n\t\t\t\tunlock( select( coreStore ) );\n\t\t\treturn {\n\t\t\t\titems: postIds.map( ( postId ) =>\n\t\t\t\t\tgetEditedEntityRecord( 'postType', postType, postId )\n\t\t\t\t),\n\t\t\t\tpermissions: postIds.map( ( postId ) =>\n\t\t\t\t\tgetEntityRecordPermissions( 'postType', postType, postId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ postIds, postType ]\n\t);\n\n\treturn useMemo( () => {\n\t\treturn items.map( ( item, index ) => ( {\n\t\t\t...item,\n\t\t\tpermissions: permissions[ index ],\n\t\t} ) );\n\t}, [ items, permissions ] );\n}\n\nexport default function PostActions( { postType, postId, onActionPerformed } ) {\n\tconst [ activeModalAction, setActiveModalAction ] = useState( null );\n\tconst _postIds = useMemo( () => {\n\t\tif ( Array.isArray( postId ) ) {\n\t\t\treturn postId;\n\t\t}\n\t\treturn postId ? [ postId ] : [];\n\t}, [ postId ] );\n\n\tconst itemsWithPermissions = useEditedEntityRecordsWithPermissions(\n\t\tpostType,\n\t\t_postIds\n\t);\n\tconst allActions = usePostActions( { postType, onActionPerformed } );\n\n\tconst actions = useMemo( () => {\n\t\treturn allActions.filter( ( action ) => {\n\t\t\treturn (\n\t\t\t\t( ! action.isEligible ||\n\t\t\t\t\titemsWithPermissions.some( ( itemWithPermissions ) =>\n\t\t\t\t\t\taction.isEligible( itemWithPermissions )\n\t\t\t\t\t) ) &&\n\t\t\t\t( itemsWithPermissions.length < 2 || action.supportsBulk )\n\t\t\t);\n\t\t} );\n\t}, [ allActions, itemsWithPermissions ] );\n\n\treturn (\n\t\t<>\n\t\t\t<Menu\n\t\t\t\ttrigger={\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\tdisabled={ ! actions.length }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\tclassName=\"editor-all-actions-button\"\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\tplacement=\"bottom-end\"\n\t\t\t>\n\t\t\t\t<ActionsDropdownMenuGroup\n\t\t\t\t\tactions={ actions }\n\t\t\t\t\titems={ itemsWithPermissions }\n\t\t\t\t\tsetActiveModalAction={ setActiveModalAction }\n\t\t\t\t/>\n\t\t\t</Menu>\n\t\t\t{ !! activeModalAction && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ activeModalAction }\n\t\t\t\t\titems={ itemsWithPermissions }\n\t\t\t\t\tcloseModal={ () => setActiveModalAction( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n// From now on all the functions on this file are copied as from the dataviews packages,\n// The editor packages should not be using the dataviews packages directly,\n// and the dataviews package should not be using the editor packages directly,\n// so duplicating the code here seems like the least bad option.\n\nfunction DropdownMenuItemTrigger( { action, onClick, items } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Menu.Item onClick={ onClick }>\n\t\t\t<Menu.ItemLabel>{ label }</Menu.ItemLabel>\n\t\t</Menu.Item>\n\t);\n}\n\nexport function ActionModal( { action, items, closeModal } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ action.modalHeader || label }\n\t\t\t__experimentalHideHeader={ !! action.hideModalHeader }\n\t\t\tonRequestClose={ closeModal ?? ( () => {} ) }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t\toverlayClassName={ `editor-action-modal editor-action-modal__${ kebabCase(\n\t\t\t\taction.id\n\t\t\t) }` }\n\t\t>\n\t\t\t<action.RenderModal items={ items } closeModal={ closeModal } />\n\t\t</Modal>\n\t);\n}\n\nfunction ActionsDropdownMenuGroup( { actions, items, setActiveModalAction } ) {\n\tconst registry = useRegistry();\n\treturn (\n\t\t<Menu.Group>\n\t\t\t{ actions.map( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DropdownMenuItemTrigger\n\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\t\t\t\tsetActiveModalAction( action );\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taction.callback( items, { registry } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\titems={ items }\n\t\t\t\t\t/>\n\t\t\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EAUb,CAAC;IAEJ,CAAE;EAAC,CACQ,CAAC;AAEf","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_element","_i18n","_components","_icons","_coreData","_lockUnlock","_actions","_jsxRuntime","Menu","kebabCase","unlock","componentsPrivateApis","useEditedEntityRecordsWithPermissions","postType","postIds","items","permissions","useSelect","select","getEditedEntityRecord","getEntityRecordPermissions","coreStore","map","postId","useMemo","item","index","PostActions","onActionPerformed","activeModalAction","setActiveModalAction","useState","_postIds","Array","isArray","itemsWithPermissions","allActions","usePostActions","actions","filter","action","isEligible","some","itemWithPermissions","length","supportsBulk","jsxs","Fragment","children","placement","jsx","TriggerButton","render","Button","size","icon","moreVertical","label","__","disabled","accessibleWhenDisabled","className","Popover","ActionsDropdownMenuGroup","ActionModal","closeModal","DropdownMenuItemTrigger","onClick","Item","ItemLabel","Modal","title","modalHeader","__experimentalHideHeader","hideModalHeader","onRequestClose","focusOnMount","overlayClassName","id","RenderModal","registry","useRegistry","Group","callback"],"sources":["@wordpress/editor/src/components/post-actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tprivateApis as componentsPrivateApis,\n\tButton,\n\tModal,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { usePostActions } from './actions';\n\nconst { Menu, kebabCase } = unlock( componentsPrivateApis );\n\nfunction useEditedEntityRecordsWithPermissions( postType, postIds ) {\n\tconst { items, permissions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, getEntityRecordPermissions } =\n\t\t\t\tunlock( select( coreStore ) );\n\t\t\treturn {\n\t\t\t\titems: postIds.map( ( postId ) =>\n\t\t\t\t\tgetEditedEntityRecord( 'postType', postType, postId )\n\t\t\t\t),\n\t\t\t\tpermissions: postIds.map( ( postId ) =>\n\t\t\t\t\tgetEntityRecordPermissions( 'postType', postType, postId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ postIds, postType ]\n\t);\n\n\treturn useMemo( () => {\n\t\treturn items.map( ( item, index ) => ( {\n\t\t\t...item,\n\t\t\tpermissions: permissions[ index ],\n\t\t} ) );\n\t}, [ items, permissions ] );\n}\n\nexport default function PostActions( { postType, postId, onActionPerformed } ) {\n\tconst [ activeModalAction, setActiveModalAction ] = useState( null );\n\tconst _postIds = useMemo( () => {\n\t\tif ( Array.isArray( postId ) ) {\n\t\t\treturn postId;\n\t\t}\n\t\treturn postId ? [ postId ] : [];\n\t}, [ postId ] );\n\n\tconst itemsWithPermissions = useEditedEntityRecordsWithPermissions(\n\t\tpostType,\n\t\t_postIds\n\t);\n\tconst allActions = usePostActions( { postType, onActionPerformed } );\n\n\tconst actions = useMemo( () => {\n\t\treturn allActions.filter( ( action ) => {\n\t\t\treturn (\n\t\t\t\t( ! action.isEligible ||\n\t\t\t\t\titemsWithPermissions.some( ( itemWithPermissions ) =>\n\t\t\t\t\t\taction.isEligible( itemWithPermissions )\n\t\t\t\t\t) ) &&\n\t\t\t\t( itemsWithPermissions.length < 2 || action.supportsBulk )\n\t\t\t);\n\t\t} );\n\t}, [ allActions, itemsWithPermissions ] );\n\n\treturn (\n\t\t<>\n\t\t\t<Menu placement=\"bottom-end\">\n\t\t\t\t<Menu.TriggerButton\n\t\t\t\t\trender={\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\t\tdisabled={ ! actions.length }\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tclassName=\"editor-all-actions-button\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<Menu.Popover>\n\t\t\t\t\t<ActionsDropdownMenuGroup\n\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\titems={ itemsWithPermissions }\n\t\t\t\t\t\tsetActiveModalAction={ setActiveModalAction }\n\t\t\t\t\t/>\n\t\t\t\t</Menu.Popover>\n\t\t\t</Menu>\n\t\t\t{ !! activeModalAction && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ activeModalAction }\n\t\t\t\t\titems={ itemsWithPermissions }\n\t\t\t\t\tcloseModal={ () => setActiveModalAction( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n// From now on all the functions on this file are copied as from the dataviews packages,\n// The editor packages should not be using the dataviews packages directly,\n// and the dataviews package should not be using the editor packages directly,\n// so duplicating the code here seems like the least bad option.\n\nfunction DropdownMenuItemTrigger( { action, onClick, items } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Menu.Item onClick={ onClick }>\n\t\t\t<Menu.ItemLabel>{ label }</Menu.ItemLabel>\n\t\t</Menu.Item>\n\t);\n}\n\nexport function ActionModal( { action, items, closeModal } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ action.modalHeader || label }\n\t\t\t__experimentalHideHeader={ !! action.hideModalHeader }\n\t\t\tonRequestClose={ closeModal ?? ( () => {} ) }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t\toverlayClassName={ `editor-action-modal editor-action-modal__${ kebabCase(\n\t\t\t\taction.id\n\t\t\t) }` }\n\t\t>\n\t\t\t<action.RenderModal items={ items } closeModal={ closeModal } />\n\t\t</Modal>\n\t);\n}\n\nfunction ActionsDropdownMenuGroup( { actions, items, setActiveModalAction } ) {\n\tconst registry = useRegistry();\n\treturn (\n\t\t<Menu.Group>\n\t\t\t{ actions.map( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DropdownMenuItemTrigger\n\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\t\t\t\tsetActiveModalAction( action );\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taction.callback( items, { registry } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\titems={ items }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Menu.Group>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAKA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAA2C,IAAAQ,WAAA,GAAAR,OAAA;AAlB3C;AACA;AACA;;AAYA;AACA;AACA;;AAIA,MAAM;EAAES,IAAI;EAAEC;AAAU,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAE3D,SAASC,qCAAqCA,CAAEC,QAAQ,EAAEC,OAAO,EAAG;EACnE,MAAM;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAG,IAAAC,eAAS,EACrCC,MAAM,IAAM;IACb,MAAM;MAAEC,qBAAqB;MAAEC;IAA2B,CAAC,GAC1D,IAAAV,kBAAM,EAAEQ,MAAM,CAAEG,eAAU,CAAE,CAAC;IAC9B,OAAO;MACNN,KAAK,EAAED,OAAO,CAACQ,GAAG,CAAIC,MAAM,IAC3BJ,qBAAqB,CAAE,UAAU,EAAEN,QAAQ,EAAEU,MAAO,CACrD,CAAC;MACDP,WAAW,EAAEF,OAAO,CAACQ,GAAG,CAAIC,MAAM,IACjCH,0BAA0B,CAAE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AW,EAAC,CAAC;EAC9B,oBACC,IAAA1E,WAAA,CAAA2C,GAAA,EAAC1C,IAAI,CAAC0E,KAAK;IAAAlC,QAAA,EACRV,OAAO,CAAChB,GAAG,CAAIkB,MAAM,IAAM;MAC5B,oBACC,IAAAjC,WAAA,CAAA2C,GAAA,EAACgB,uBAAuB;QAEvB1B,MAAM,EAAGA,MAAQ;QACjB2B,OAAO,EAAGA,CAAA,KAAM;UACf,IAAK,aAAa,IAAI3B,MAAM,EAAG;YAC9BV,oBAAoB,CAAEU,MAAO,CAAC;YAC9B;UACD;UACAA,MAAM,CAAC2C,QAAQ,CAAEpE,KAAK,EAAE;YAAEiE;UAAS,CAAE,CAAC;QACvC,CAAG;QACHjE,KAAK,EAAGA;MAAO,GATTyB,MAAM,CAACsC,EAUb,CAAC;IAEJ,CAAE;EAAC,CACQ,CAAC;AAEf","ignoreList":[]}
@@ -10,30 +10,22 @@ var _components = require("@wordpress/components");
10
10
  var _data = require("@wordpress/data");
11
11
  var _coreData = require("@wordpress/core-data");
12
12
  var _notices = require("@wordpress/notices");
13
- var _htmlEntities = require("@wordpress/html-entities");
13
+ var _getItemTitle = require("../../utils/get-item-title");
14
14
  var _jsxRuntime = require("react/jsx-runtime");
15
15
  /**
16
16
  * WordPress dependencies
17
17
  */
18
18
 
19
- const getItemTitle = item => {
20
- if (typeof item.title === 'string') {
21
- return (0, _htmlEntities.decodeEntities)(item.title);
22
- }
23
- if (item.title && 'rendered' in item.title) {
24
- return (0, _htmlEntities.decodeEntities)(item.title.rendered);
25
- }
26
- if (item.title && 'raw' in item.title) {
27
- return (0, _htmlEntities.decodeEntities)(item.title.raw);
28
- }
29
- return '';
30
- };
19
+ /**
20
+ * Internal dependencies
21
+ */
22
+
31
23
  const SetAsHomepageModal = ({
32
24
  items,
33
25
  closeModal
34
26
  }) => {
35
27
  const [item] = items;
36
- const pageTitle = getItemTitle(item);
28
+ const pageTitle = (0, _getItemTitle.getItemTitle)(item);
37
29
  const {
38
30
  showOnFront,
39
31
  currentHomePage,
@@ -51,9 +43,7 @@ const SetAsHomepageModal = ({
51
43
  isSaving: isSavingEntityRecord('root', 'site')
52
44
  };
53
45
  });
54
- const currentHomePageTitle = currentHomePage ? getItemTitle(currentHomePage) : '';
55
46
  const {
56
- saveEditedEntityRecord,
57
47
  saveEntityRecord
58
48
  } = (0, _data.useDispatch)(_coreData.store);
59
49
  const {
@@ -63,25 +53,15 @@ const SetAsHomepageModal = ({
63
53
  async function onSetPageAsHomepage(event) {
64
54
  event.preventDefault();
65
55
  try {
66
- // Save new home page settings.
67
- await saveEditedEntityRecord('root', 'site', undefined, {
68
- page_on_front: item.id,
69
- show_on_front: 'page'
70
- });
71
-
72
- // This second call to a save function is a workaround for a bug in
73
- // `saveEditedEntityRecord`. This forces the root site settings to be updated.
74
- // See https://github.com/WordPress/gutenberg/issues/67161.
75
56
  await saveEntityRecord('root', 'site', {
76
57
  page_on_front: item.id,
77
58
  show_on_front: 'page'
78
59
  });
79
- createSuccessNotice((0, _i18n.__)('Homepage updated'), {
60
+ createSuccessNotice((0, _i18n.__)('Homepage updated.'), {
80
61
  type: 'snackbar'
81
62
  });
82
63
  } catch (error) {
83
- const typedError = error;
84
- const errorMessage = typedError.message && typedError.code !== 'unknown_error' ? typedError.message : (0, _i18n.__)('An error occurred while setting the homepage');
64
+ const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0, _i18n.__)('An error occurred while setting the homepage.');
85
65
  createErrorNotice(errorMessage, {
86
66
  type: 'snackbar'
87
67
  });
@@ -89,12 +69,17 @@ const SetAsHomepageModal = ({
89
69
  closeModal?.();
90
70
  }
91
71
  }
92
- const modalWarning = 'posts' === showOnFront ? (0, _i18n.__)('This will replace the current homepage which is set to display latest posts.') : (0, _i18n.sprintf)(
93
- // translators: %s: title of the current home page.
94
- (0, _i18n.__)('This will replace the current homepage: "%s"'), currentHomePageTitle);
72
+ let modalWarning = '';
73
+ if ('posts' === showOnFront) {
74
+ modalWarning = (0, _i18n.__)('This will replace the current homepage which is set to display latest posts.');
75
+ } else if (currentHomePage) {
76
+ modalWarning = (0, _i18n.sprintf)(
77
+ // translators: %s: title of the current home page.
78
+ (0, _i18n.__)('This will replace the current homepage: "%s"'), (0, _getItemTitle.getItemTitle)(currentHomePage));
79
+ }
95
80
  const modalText = (0, _i18n.sprintf)(
96
81
  // translators: %1$s: title of the page to be set as the homepage, %2$s: homepage replacement warning message.
97
- (0, _i18n.__)('Set "%1$s" as the site homepage? %2$s'), pageTitle, modalWarning);
82
+ (0, _i18n.__)('Set "%1$s" as the site homepage? %2$s'), pageTitle, modalWarning).trim();
98
83
 
99
84
  // translators: Button label to confirm setting the specified page as the homepage.
100
85
  const modalButtonLabel = (0, _i18n.__)('Set homepage');
@@ -133,9 +118,13 @@ const useSetAsHomepageAction = () => {
133
118
  pageForPosts
134
119
  } = (0, _data.useSelect)(select => {
135
120
  const {
136
- getEntityRecord
121
+ getEntityRecord,
122
+ canUser
137
123
  } = select(_coreData.store);
138
- const siteSettings = getEntityRecord('root', 'site');
124
+ const siteSettings = canUser('read', {
125
+ kind: 'root',
126
+ name: 'site'
127
+ }) ? getEntityRecord('root', 'site') : undefined;
139
128
  return {
140
129
  pageOnFront: siteSettings?.page_on_front,
141
130
  pageForPosts: siteSettings?.page_for_posts
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_element","_components","_data","_coreData","_notices","_htmlEntities","_jsxRuntime","getItemTitle","item","title","decodeEntities","rendered","raw","SetAsHomepageModal","items","closeModal","pageTitle","showOnFront","currentHomePage","isSaving","useSelect","select","getEntityRecord","isSavingEntityRecord","coreStore","siteSettings","currentHomePageItem","page_on_front","show_on_front","currentHomePageTitle","saveEditedEntityRecord","saveEntityRecord","useDispatch","createSuccessNotice","createErrorNotice","noticesStore","onSetPageAsHomepage","event","preventDefault","undefined","id","__","type","error","typedError","errorMessage","message","code","modalWarning","sprintf","modalText","modalButtonLabel","jsx","onSubmit","children","jsxs","__experimentalVStack","spacing","__experimentalText","__experimentalHStack","justify","Button","__next40pxDefaultSize","variant","onClick","disabled","accessibleWhenDisabled","useSetAsHomepageAction","pageOnFront","pageForPosts","page_for_posts","useMemo","label","isEligible","post","status","RenderModal","exports"],"sources":["@wordpress/editor/src/components/post-actions/set-as-homepage.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\n\nconst getItemTitle = ( item ) => {\n\tif ( typeof item.title === 'string' ) {\n\t\treturn decodeEntities( item.title );\n\t}\n\tif ( item.title && 'rendered' in item.title ) {\n\t\treturn decodeEntities( item.title.rendered );\n\t}\n\tif ( item.title && 'raw' in item.title ) {\n\t\treturn decodeEntities( item.title.raw );\n\t}\n\treturn '';\n};\n\nconst SetAsHomepageModal = ( { items, closeModal } ) => {\n\tconst [ item ] = items;\n\tconst pageTitle = getItemTitle( item );\n\tconst { showOnFront, currentHomePage, isSaving } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, isSavingEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\t\tconst currentHomePageItem = getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'page',\n\t\t\t\tsiteSettings?.page_on_front\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tshowOnFront: siteSettings?.show_on_front,\n\t\t\t\tcurrentHomePage: currentHomePageItem,\n\t\t\t\tisSaving: isSavingEntityRecord( 'root', 'site' ),\n\t\t\t};\n\t\t}\n\t);\n\tconst currentHomePageTitle = currentHomePage\n\t\t? getItemTitle( currentHomePage )\n\t\t: '';\n\n\tconst { saveEditedEntityRecord, saveEntityRecord } =\n\t\tuseDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tasync function onSetPageAsHomepage( event ) {\n\t\tevent.preventDefault();\n\n\t\ttry {\n\t\t\t// Save new home page settings.\n\t\t\tawait saveEditedEntityRecord( 'root', 'site', undefined, {\n\t\t\t\tpage_on_front: item.id,\n\t\t\t\tshow_on_front: 'page',\n\t\t\t} );\n\n\t\t\t// This second call to a save function is a workaround for a bug in\n\t\t\t// `saveEditedEntityRecord`. This forces the root site settings to be updated.\n\t\t\t// See https://github.com/WordPress/gutenberg/issues/67161.\n\t\t\tawait saveEntityRecord( 'root', 'site', {\n\t\t\t\tpage_on_front: item.id,\n\t\t\t\tshow_on_front: 'page',\n\t\t\t} );\n\n\t\t\tcreateSuccessNotice( __( 'Homepage updated' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst typedError = error;\n\t\t\tconst errorMessage =\n\t\t\t\ttypedError.message && typedError.code !== 'unknown_error'\n\t\t\t\t\t? typedError.message\n\t\t\t\t\t: __( 'An error occurred while setting the homepage' );\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t} finally {\n\t\t\tcloseModal?.();\n\t\t}\n\t}\n\n\tconst modalWarning =\n\t\t'posts' === showOnFront\n\t\t\t? __(\n\t\t\t\t\t'This will replace the current homepage which is set to display latest posts.'\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %s: title of the current home page.\n\t\t\t\t\t__( 'This will replace the current homepage: \"%s\"' ),\n\t\t\t\t\tcurrentHomePageTitle\n\t\t\t );\n\n\tconst modalText = sprintf(\n\t\t// translators: %1$s: title of the page to be set as the homepage, %2$s: homepage replacement warning message.\n\t\t__( 'Set \"%1$s\" as the site homepage? %2$s' ),\n\t\tpageTitle,\n\t\tmodalWarning\n\t);\n\n\t// translators: Button label to confirm setting the specified page as the homepage.\n\tconst modalButtonLabel = __( 'Set homepage' );\n\n\treturn (\n\t\t<form onSubmit={ onSetPageAsHomepage }>\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>{ modalText }</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tdisabled={ isSaving }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\tdisabled={ isSaving }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ modalButtonLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n};\n\nexport const useSetAsHomepageAction = () => {\n\tconst { pageOnFront, pageForPosts } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\treturn {\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t};\n\t} );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'set-as-homepage',\n\t\t\tlabel: __( 'Set as homepage' ),\n\t\t\tisEligible( post ) {\n\t\t\t\tif ( post.status !== 'publish' ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif ( post.type !== 'page' ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Don't show the action if the page is already set as the homepage.\n\t\t\t\tif ( pageOnFront === post.id ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Don't show the action if the page is already set as the page for posts.\n\t\t\t\tif ( pageForPosts === post.id ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tRenderModal: SetAsHomepageModal,\n\t\t} ),\n\t\t[ pageForPosts, pageOnFront ]\n\t);\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AAA0D,IAAAO,WAAA,GAAAP,OAAA;AAd1D;AACA;AACA;;AAcA,MAAMQ,YAAY,GAAKC,IAAI,IAAM;EAChC,IAAK,OAAOA,IAAI,CAACC,KAAK,KAAK,QAAQ,EAAG;IACrC,OAAO,IAAAC,4BAAc,EAAEF,IAAI,CAACC,KAAM,CAAC;EACpC;EACA,IAAKD,IAAI,CAACC,KAAK,IAAI,UAAU,IAAID,IAAI,CAACC,KAAK,EAAG;IAC7C,OAAO,IAAAC,4BAAc,EAAEF,IAAI,CAACC,KAAK,CAACE,QAAS,CAAC;EAC7C;EACA,IAAKH,IAAI,CAACC,KAAK,IAAI,KAAK,IAAID,IAAI,CAACC,KAAK,EAAG;IACxC,OAAO,IAAAC,4BAAc,EAAEF,IAAI,CAACC,KAAK,CAACG,GAAI,CAAC;EACxC;EACA,OAAO,EAAE;AACV,CAAC;AAED,MAAMC,kBAAkB,GAAGA,CAAE;EAAEC,KAAK;EAAEC;AAAW,CAAC,KAAM;EACvD,MAAM,CAAEP,IAAI,CAAE,GAAGM,KAAK;EACtB,MAAME,SAAS,GAAGT,YAAY,CAAEC,IAAK,CAAC;EACtC,MAAM;IAAES,WAAW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MACb;MAEA,OAAO,IAAI;IACZ,CAAC;IACDoC,WAAW,EAAE/D;EACd,CAAC,CAAE,EACH,CAAEwD,YAAY,EAAED,WAAW,CAC5B,CAAC;AACF,CAAC;AAACS,OAAA,CAAAV,sBAAA,GAAAA,sBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_element","_components","_data","_coreData","_notices","_getItemTitle","_jsxRuntime","SetAsHomepageModal","items","closeModal","item","pageTitle","getItemTitle","showOnFront","currentHomePage","isSaving","useSelect","select","getEntityRecord","isSavingEntityRecord","coreStore","siteSettings","currentHomePageItem","page_on_front","show_on_front","saveEntityRecord","useDispatch","createSuccessNotice","createErrorNotice","noticesStore","onSetPageAsHomepage","event","preventDefault","id","__","type","error","errorMessage","message","code","modalWarning","sprintf","modalText","trim","modalButtonLabel","jsx","onSubmit","children","jsxs","__experimentalVStack","spacing","__experimentalText","__experimentalHStack","justify","Button","__next40pxDefaultSize","variant","onClick","disabled","accessibleWhenDisabled","useSetAsHomepageAction","pageOnFront","pageForPosts","canUser","kind","name","undefined","page_for_posts","useMemo","label","isEligible","post","status","RenderModal","exports"],"sources":["@wordpress/editor/src/components/post-actions/set-as-homepage.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from '../../utils/get-item-title';\n\nconst SetAsHomepageModal = ( { items, closeModal } ) => {\n\tconst [ item ] = items;\n\tconst pageTitle = getItemTitle( item );\n\tconst { showOnFront, currentHomePage, isSaving } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, isSavingEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\t\tconst currentHomePageItem = getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'page',\n\t\t\t\tsiteSettings?.page_on_front\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tshowOnFront: siteSettings?.show_on_front,\n\t\t\t\tcurrentHomePage: currentHomePageItem,\n\t\t\t\tisSaving: isSavingEntityRecord( 'root', 'site' ),\n\t\t\t};\n\t\t}\n\t);\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tasync function onSetPageAsHomepage( event ) {\n\t\tevent.preventDefault();\n\n\t\ttry {\n\t\t\tawait saveEntityRecord( 'root', 'site', {\n\t\t\t\tpage_on_front: item.id,\n\t\t\t\tshow_on_front: 'page',\n\t\t\t} );\n\n\t\t\tcreateSuccessNotice( __( 'Homepage updated.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while setting the homepage.' );\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t} finally {\n\t\t\tcloseModal?.();\n\t\t}\n\t}\n\n\tlet modalWarning = '';\n\tif ( 'posts' === showOnFront ) {\n\t\tmodalWarning = __(\n\t\t\t'This will replace the current homepage which is set to display latest posts.'\n\t\t);\n\t} else if ( currentHomePage ) {\n\t\tmodalWarning = sprintf(\n\t\t\t// translators: %s: title of the current home page.\n\t\t\t__( 'This will replace the current homepage: \"%s\"' ),\n\t\t\tgetItemTitle( currentHomePage )\n\t\t);\n\t}\n\n\tconst modalText = sprintf(\n\t\t// translators: %1$s: title of the page to be set as the homepage, %2$s: homepage replacement warning message.\n\t\t__( 'Set \"%1$s\" as the site homepage? %2$s' ),\n\t\tpageTitle,\n\t\tmodalWarning\n\t).trim();\n\n\t// translators: Button label to confirm setting the specified page as the homepage.\n\tconst modalButtonLabel = __( 'Set homepage' );\n\n\treturn (\n\t\t<form onSubmit={ onSetPageAsHomepage }>\n\t\t\t<VStack spacing=\"5\">\n\t\t\t\t<Text>{ modalText }</Text>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tcloseModal?.();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tdisabled={ isSaving }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\tdisabled={ isSaving }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ modalButtonLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n};\n\nexport const useSetAsHomepageAction = () => {\n\tconst { pageOnFront, pageForPosts } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, canUser } = select( coreStore );\n\t\tconst siteSettings = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t};\n\t} );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tid: 'set-as-homepage',\n\t\t\tlabel: __( 'Set as homepage' ),\n\t\t\tisEligible( post ) {\n\t\t\t\tif ( post.status !== 'publish' ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif ( post.type !== 'page' ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Don't show the action if the page is already set as the homepage.\n\t\t\t\tif ( pageOnFront === post.id ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Don't show the action if the page is already set as the page for posts.\n\t\t\t\tif ( pageForPosts === post.id ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tRenderModal: SetAsHomepageModal,\n\t\t} ),\n\t\t[ pageForPosts, pageOnFront ]\n\t);\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAKA,IAAAM,aAAA,GAAAN,OAAA;AAA0D,IAAAO,WAAA,GAAAP,OAAA;AAlB1D;AACA;AACA;;AAaA;AACA;AACA;;AAGA,MAAMQ,kBAAkB,GAAGA,CAAE;EAAEC,KAAK;EAAEC;AAAW,CAAC,KAAM;EACvD,MAAM,CAAEC,IAAI,CAAE,GAAGF,KAAK;EACtB,MAAMG,SAAS,GAAG,IAAAC,0BAAY,EAAEF,IAAK,CAAC;EACtC,MAAM;IAAEG,WAAW;IAAEC,eAAe;IAAEC;EAAS,CAAC,GAAG,IAAAC,eAAS,EACzDC,MAAM,IAAM;IACb,MAAM;MAAEC,eAAe;MAAEC;IAAqB,CAAC,GAC9CF,MAAM,CAAEG,eAAU,CAAC;IACpB,MAAMC,YAAY,GAAGH,eAAe,CAAE,MAAM,EAAE,MAAO,CAAC;IACtD,MAAMI,mBAAmB,GAAGJ,eAAe,CAC1C,UAAU,EACV,MAAM,EACNG,YAAY,EAAEE,aACf,CAAC;IACD,OAAO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