@wordpress/editor 13.24.0 → 13.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 (175) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/document-bar/index.js +152 -0
  3. package/build/components/document-bar/index.js.map +1 -0
  4. package/build/components/editor-canvas/edit-template-blocks-notification.js +106 -0
  5. package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
  6. package/build/components/editor-canvas/index.js +292 -0
  7. package/build/components/editor-canvas/index.js.map +1 -0
  8. package/build/components/index.js +24 -8
  9. package/build/components/index.js.map +1 -1
  10. package/build/components/post-publish-button/index.js +1 -0
  11. package/build/components/post-publish-button/index.js.map +1 -1
  12. package/build/components/post-publish-panel/maybe-upload-media.js +2 -4
  13. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  14. package/build/components/post-saved-state/index.js +1 -0
  15. package/build/components/post-saved-state/index.js.map +1 -1
  16. package/build/components/post-schedule/panel.js +1 -1
  17. package/build/components/post-schedule/panel.js.map +1 -1
  18. package/build/components/post-template/block-theme.js +99 -0
  19. package/build/components/post-template/block-theme.js.map +1 -0
  20. package/build/components/post-template/classic-theme.js +171 -0
  21. package/build/components/post-template/classic-theme.js.map +1 -0
  22. package/build/components/post-template/create-new-template-modal.js +98 -0
  23. package/build/components/post-template/create-new-template-modal.js.map +1 -0
  24. package/build/components/post-template/create-new-template.js +55 -0
  25. package/build/components/post-template/create-new-template.js.map +1 -0
  26. package/build/components/post-template/hooks.js +88 -0
  27. package/build/components/post-template/hooks.js.map +1 -0
  28. package/build/components/post-template/panel.js +71 -0
  29. package/build/components/post-template/panel.js.map +1 -0
  30. package/build/components/post-template/reset-default-template.js +48 -0
  31. package/build/components/post-template/reset-default-template.js.map +1 -0
  32. package/build/components/post-template/swap-template-button.js +84 -0
  33. package/build/components/post-template/swap-template-button.js.map +1 -0
  34. package/build/components/post-title/index.native.js +0 -1
  35. package/build/components/post-title/index.native.js.map +1 -1
  36. package/build/components/preview-dropdown/index.js +113 -0
  37. package/build/components/preview-dropdown/index.js.map +1 -0
  38. package/build/components/provider/index.js +36 -77
  39. package/build/components/provider/index.js.map +1 -1
  40. package/build/components/provider/index.native.js +17 -8
  41. package/build/components/provider/index.native.js.map +1 -1
  42. package/build/components/provider/navigation-block-editing-mode.js +40 -0
  43. package/build/components/provider/navigation-block-editing-mode.js.map +1 -0
  44. package/build/components/provider/use-block-editor-settings.js +9 -10
  45. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  46. package/build/hooks/index.js +1 -0
  47. package/build/hooks/index.js.map +1 -1
  48. package/build/hooks/pattern-partial-syncing.js +49 -0
  49. package/build/hooks/pattern-partial-syncing.js.map +1 -0
  50. package/build/private-apis.js +4 -0
  51. package/build/private-apis.js.map +1 -1
  52. package/build/store/actions.js +59 -11
  53. package/build/store/actions.js.map +1 -1
  54. package/build/store/defaults.js +2 -1
  55. package/build/store/defaults.js.map +1 -1
  56. package/build/store/index.js +3 -0
  57. package/build/store/index.js.map +1 -1
  58. package/build/store/private-actions.js +52 -0
  59. package/build/store/private-actions.js.map +1 -0
  60. package/build/store/reducer.js +32 -27
  61. package/build/store/reducer.js.map +1 -1
  62. package/build/store/reducer.native.js +0 -1
  63. package/build/store/reducer.native.js.map +1 -1
  64. package/build/store/selectors.js +31 -10
  65. package/build/store/selectors.js.map +1 -1
  66. package/build-module/components/document-bar/index.js +144 -0
  67. package/build-module/components/document-bar/index.js.map +1 -0
  68. package/build-module/components/editor-canvas/edit-template-blocks-notification.js +100 -0
  69. package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
  70. package/build-module/components/editor-canvas/index.js +283 -0
  71. package/build-module/components/editor-canvas/index.js.map +1 -0
  72. package/build-module/components/index.js +3 -1
  73. package/build-module/components/index.js.map +1 -1
  74. package/build-module/components/post-publish-button/index.js +1 -0
  75. package/build-module/components/post-publish-button/index.js.map +1 -1
  76. package/build-module/components/post-publish-panel/maybe-upload-media.js +2 -4
  77. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  78. package/build-module/components/post-saved-state/index.js +1 -0
  79. package/build-module/components/post-saved-state/index.js.map +1 -1
  80. package/build-module/components/post-schedule/panel.js +1 -1
  81. package/build-module/components/post-schedule/panel.js.map +1 -1
  82. package/build-module/components/post-template/block-theme.js +91 -0
  83. package/build-module/components/post-template/block-theme.js.map +1 -0
  84. package/build-module/components/post-template/classic-theme.js +162 -0
  85. package/build-module/components/post-template/classic-theme.js.map +1 -0
  86. package/build-module/components/post-template/create-new-template-modal.js +91 -0
  87. package/build-module/components/post-template/create-new-template-modal.js.map +1 -0
  88. package/build-module/components/post-template/create-new-template.js +47 -0
  89. package/build-module/components/post-template/create-new-template.js.map +1 -0
  90. package/build-module/components/post-template/hooks.js +78 -0
  91. package/build-module/components/post-template/hooks.js.map +1 -0
  92. package/build-module/components/post-template/panel.js +63 -0
  93. package/build-module/components/post-template/panel.js.map +1 -0
  94. package/build-module/components/post-template/reset-default-template.js +41 -0
  95. package/build-module/components/post-template/reset-default-template.js.map +1 -0
  96. package/build-module/components/post-template/swap-template-button.js +77 -0
  97. package/build-module/components/post-template/swap-template-button.js.map +1 -0
  98. package/build-module/components/post-title/index.native.js +0 -1
  99. package/build-module/components/post-title/index.native.js.map +1 -1
  100. package/build-module/components/preview-dropdown/index.js +105 -0
  101. package/build-module/components/preview-dropdown/index.js.map +1 -0
  102. package/build-module/components/provider/index.js +37 -78
  103. package/build-module/components/provider/index.js.map +1 -1
  104. package/build-module/components/provider/index.native.js +18 -9
  105. package/build-module/components/provider/index.native.js.map +1 -1
  106. package/build-module/components/provider/navigation-block-editing-mode.js +34 -0
  107. package/build-module/components/provider/navigation-block-editing-mode.js.map +1 -0
  108. package/build-module/components/provider/use-block-editor-settings.js +9 -10
  109. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  110. package/build-module/hooks/index.js +1 -0
  111. package/build-module/hooks/index.js.map +1 -1
  112. package/build-module/hooks/pattern-partial-syncing.js +46 -0
  113. package/build-module/hooks/pattern-partial-syncing.js.map +1 -0
  114. package/build-module/private-apis.js +4 -0
  115. package/build-module/private-apis.js.map +1 -1
  116. package/build-module/store/actions.js +53 -9
  117. package/build-module/store/actions.js.map +1 -1
  118. package/build-module/store/defaults.js +2 -1
  119. package/build-module/store/defaults.js.map +1 -1
  120. package/build-module/store/index.js +3 -0
  121. package/build-module/store/index.js.map +1 -1
  122. package/build-module/store/private-actions.js +44 -0
  123. package/build-module/store/private-actions.js.map +1 -0
  124. package/build-module/store/reducer.js +30 -26
  125. package/build-module/store/reducer.js.map +1 -1
  126. package/build-module/store/reducer.native.js +1 -2
  127. package/build-module/store/reducer.native.js.map +1 -1
  128. package/build-module/store/selectors.js +26 -6
  129. package/build-module/store/selectors.js.map +1 -1
  130. package/build-style/style-rtl.css +182 -0
  131. package/build-style/style.css +182 -0
  132. package/package.json +32 -31
  133. package/src/components/document-bar/index.js +182 -0
  134. package/src/components/document-bar/style.scss +130 -0
  135. package/src/components/editor-canvas/edit-template-blocks-notification.js +108 -0
  136. package/src/components/editor-canvas/index.js +381 -0
  137. package/src/components/index.js +3 -1
  138. package/src/components/post-publish-button/index.js +1 -0
  139. package/src/components/post-publish-panel/maybe-upload-media.js +3 -8
  140. package/src/components/post-saved-state/index.js +1 -0
  141. package/src/components/post-saved-state/test/__snapshots__/index.js.snap +2 -2
  142. package/src/components/post-schedule/panel.js +1 -1
  143. package/src/components/post-template/block-theme.js +109 -0
  144. package/src/components/post-template/classic-theme.js +213 -0
  145. package/src/components/post-template/create-new-template-modal.js +139 -0
  146. package/src/components/post-template/create-new-template.js +50 -0
  147. package/src/components/post-template/hooks.js +95 -0
  148. package/src/components/post-template/panel.js +67 -0
  149. package/src/components/post-template/reset-default-template.js +43 -0
  150. package/src/components/post-template/style.scss +52 -0
  151. package/src/components/post-template/swap-template-button.js +83 -0
  152. package/src/components/post-title/index.native.js +0 -1
  153. package/src/components/preview-dropdown/index.js +136 -0
  154. package/src/components/preview-dropdown/style.scss +5 -0
  155. package/src/components/provider/index.js +39 -112
  156. package/src/components/provider/index.native.js +26 -12
  157. package/src/components/provider/navigation-block-editing-mode.js +37 -0
  158. package/src/components/provider/use-block-editor-settings.js +6 -9
  159. package/src/hooks/index.js +1 -0
  160. package/src/hooks/pattern-partial-syncing.js +73 -0
  161. package/src/private-apis.js +4 -0
  162. package/src/store/actions.js +51 -9
  163. package/src/store/defaults.js +1 -0
  164. package/src/store/index.js +3 -0
  165. package/src/store/private-actions.js +61 -0
  166. package/src/store/reducer.js +32 -27
  167. package/src/store/reducer.native.js +0 -2
  168. package/src/store/selectors.js +64 -42
  169. package/src/store/test/selectors.js +88 -147
  170. package/src/style.scss +3 -0
  171. package/build/components/post-template/index.js +0 -66
  172. package/build/components/post-template/index.js.map +0 -1
  173. package/build-module/components/post-template/index.js +0 -57
  174. package/build-module/components/post-template/index.js.map +0 -1
  175. package/src/components/post-template/index.js +0 -64
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","SelectControl","Dropdown","Button","Notice","useSelect","useDispatch","store","coreStore","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","useState","useMemo","addTemplate","noticesStore","editorStore","CreateNewTemplateModal","useAllowSwitchingTemplates","POPOVER_PROPS","className","placement","PostTemplateToggle","isOpen","onClick","templateTitle","select","templateSlug","getEditedPostAttribute","supportsTemplateMode","availableTemplates","getEditorSettings","template","canUser","getCurrentTemplateId","title","slug","createElement","variant","PostTemplateDropdownContent","onClose","_options$find","_selectedOption$value","allowSwitchingTemplate","fetchedTemplates","selectedTemplateSlug","canCreate","canEdit","getEntityRecords","editorSettings","canCreateTemplates","post_type","getCurrentPostType","per_page","undefined","options","Object","entries","fromEntries","map","rendered","value","label","selectedOption","find","option","editPost","createSuccessNotice","setRenderingMode","isCreateModalOpen","setIsCreateModalOpen","help","actions","icon","status","isDismissible","__next40pxDefaultSize","__nextHasNoMarginBottom","hideLabelFromVision","onChange","type","defaultRenderingMode","ClassicThemeControl","popoverProps","focusOnMount","renderToggle","onToggle","renderContent"],"sources":["@wordpress/editor/src/components/post-template/classic-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { SelectControl, Dropdown, Button, Notice } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { addTemplate } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nfunction PostTemplateToggle( { isOpen, onClick } ) {\n\tconst templateTitle = useSelect( ( select ) => {\n\t\tconst templateSlug =\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' );\n\n\t\tconst { supportsTemplateMode, availableTemplates } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\tif ( ! supportsTemplateMode && availableTemplates[ templateSlug ] ) {\n\t\t\treturn availableTemplates[ templateSlug ];\n\t\t}\n\t\tconst template =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) &&\n\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\treturn (\n\t\t\ttemplate?.title ||\n\t\t\ttemplate?.slug ||\n\t\t\tavailableTemplates?.[ templateSlug ]\n\t\t);\n\t}, [] );\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-post-post-template__toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={ __( 'Template options' ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n\nfunction PostTemplateDropdownContent( { onClose } ) {\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst {\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tselectedTemplateSlug,\n\t\tcanCreate,\n\t\tcanEdit,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecords } = select( coreStore );\n\t\t\tconst editorSettings = select( editorStore ).getEditorSettings();\n\t\t\tconst canCreateTemplates = canUser( 'create', 'templates' );\n\n\t\t\treturn {\n\t\t\t\tavailableTemplates: editorSettings.availableTemplates,\n\t\t\t\tfetchedTemplates: canCreateTemplates\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\t\tpost_type:\n\t\t\t\t\t\t\t\tselect( editorStore ).getCurrentPostType(),\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined,\n\t\t\t\tselectedTemplateSlug:\n\t\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' ),\n\t\t\t\tcanCreate:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode,\n\t\t\t\tcanEdit:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode &&\n\t\t\t\t\t!! select( editorStore ).getCurrentTemplateId(),\n\t\t\t};\n\t\t},\n\t\t[ allowSwitchingTemplate ]\n\t);\n\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries( {\n\t\t\t\t...availableTemplates,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\ttitle.rendered,\n\t\t\t\t\t] )\n\t\t\t\t),\n\t\t\t} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),\n\t\t[ availableTemplates, fetchedTemplates ]\n\t);\n\n\tconst selectedOption =\n\t\toptions.find( ( option ) => option.value === selectedTemplateSlug ) ??\n\t\toptions.find( ( option ) => ! option.value ); // The default option has '' value.\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\n\treturn (\n\t\t<div className=\"editor-post-template__classic-theme-dropdown\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Template' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Templates define the way content is displayed when viewing your site.'\n\t\t\t\t) }\n\t\t\t\tactions={\n\t\t\t\t\tcanCreate\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: addTemplate,\n\t\t\t\t\t\t\t\t\tlabel: __( 'Add template' ),\n\t\t\t\t\t\t\t\t\tonClick: () => setIsCreateModalOpen( true ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: []\n\t\t\t\t}\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t{ ! allowSwitchingTemplate ? (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template' ) }\n\t\t\t\t\tvalue={ selectedOption?.value ?? '' }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\teditPost( { template: slug || '' } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canEdit && (\n\t\t\t\t<p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetRenderingMode( 'template-only' );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\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\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\t\t\tsetRenderingMode(\n\t\t\t\t\t\t\t\t\t\t\t\t\tgetEditorSettings()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\t\t\t\t\t\t\t\t\t\t\t),\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\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => setIsCreateModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction ClassicThemeControl() {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<PostTemplateToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t) }\n\t\t\trenderContent={ ( {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KAAM;MACf4C,gBAAgB,CAAE,eAAgB,CAAC;MACnC5B,OAAO,CAAC,CAAC;MACT2B,mBAAmB,CAClBlE,EAAE,CACD,uFACD,CAAC,EACD;QACC+E,IAAI,EAAE,UAAU;QAChBR,OAAO,EAAE,CACR;UACCV,KAAK,EAAE7D,EAAE,CAAE,SAAU,CAAC;UACtBuB,OAAO,EAAEA,CAAA,KACR4C,gBAAgB,CACfrC,iBAAiB,CAAC,CAAC,CACjBkD,oBACH;QACF,CAAC;MAEH,CACD,CAAC;IACF;EAAG,GAEDhF,EAAE,CAAE,eAAgB,CACf,CACN,CACH,EACCoE,iBAAiB,IAClBhC,aAAA,CAACpB,sBAAsB;IACtBuB,OAAO,EAAGA,CAAA,KAAM8B,oBAAoB,CAAE,KAAM;EAAG,CAC/C,CAEE,CAAC;AAER;AAEA,SAASY,mBAAmBA,CAAA,EAAG;EAC9B,OACC7C,aAAA,CAAClC,QAAQ;IACRgF,YAAY,EAAGhE,aAAe;IAC9BiE,YAAY;IACZC,YAAY,EAAGA,CAAE;MAAE9D,MAAM;MAAE+D;IAAS,CAAC,KACpCjD,aAAA,CAACf,kBAAkB;MAACC,MAAM,EAAGA,MAAQ;MAACC,OAAO,EAAG8D;IAAU,CAAE,CAC1D;IACHC,aAAa,EAAGA,CAAE;MAAE/C;IAAQ,CAAC,KAC5BH,aAAA,CAACE,2BAA2B;MAACC,OAAO,EAAGA;IAAS,CAAE;EAChD,CACH,CAAC;AAEJ;AAEA,eAAe0C,mBAAmB"}
@@ -0,0 +1,91 @@
1
+ import { createElement } from "react";
2
+ /**
3
+ * WordPress dependencies
4
+ */
5
+ import { useSelect, useDispatch } from '@wordpress/data';
6
+ import { useState } from '@wordpress/element';
7
+ import { serialize, createBlock } from '@wordpress/blocks';
8
+ import { Modal, TextControl, Button, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
9
+ import { __ } from '@wordpress/i18n';
10
+ import { cleanForSlug } from '@wordpress/url';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { unlock } from '../../lock-unlock';
16
+ import { store as editorStore } from '../../store';
17
+ const DEFAULT_TITLE = __('Custom Template');
18
+ export default function CreateNewTemplateModal({
19
+ onClose
20
+ }) {
21
+ const defaultBlockTemplate = useSelect(select => select(editorStore).getEditorSettings().defaultBlockTemplate, []);
22
+ const {
23
+ createTemplate,
24
+ setRenderingMode
25
+ } = unlock(useDispatch(editorStore));
26
+ const [title, setTitle] = useState('');
27
+ const [isBusy, setIsBusy] = useState(false);
28
+ const cancel = () => {
29
+ setTitle('');
30
+ onClose();
31
+ };
32
+ const submit = async event => {
33
+ event.preventDefault();
34
+ if (isBusy) {
35
+ return;
36
+ }
37
+ setIsBusy(true);
38
+ const newTemplateContent = defaultBlockTemplate !== null && defaultBlockTemplate !== void 0 ? defaultBlockTemplate : serialize([createBlock('core/group', {
39
+ tagName: 'header',
40
+ layout: {
41
+ inherit: true
42
+ }
43
+ }, [createBlock('core/site-title'), createBlock('core/site-tagline')]), createBlock('core/separator'), createBlock('core/group', {
44
+ tagName: 'main'
45
+ }, [createBlock('core/group', {
46
+ layout: {
47
+ inherit: true
48
+ }
49
+ }, [createBlock('core/post-title')]), createBlock('core/post-content', {
50
+ layout: {
51
+ inherit: true
52
+ }
53
+ })])]);
54
+ await createTemplate({
55
+ slug: cleanForSlug(title || DEFAULT_TITLE),
56
+ content: newTemplateContent,
57
+ title: title || DEFAULT_TITLE
58
+ });
59
+ setIsBusy(false);
60
+ cancel();
61
+ setRenderingMode('template-only');
62
+ };
63
+ return createElement(Modal, {
64
+ title: __('Create custom template'),
65
+ onRequestClose: cancel
66
+ }, createElement("form", {
67
+ className: "editor-post-template__create-form",
68
+ onSubmit: submit
69
+ }, createElement(VStack, {
70
+ spacing: "3"
71
+ }, createElement(TextControl, {
72
+ __nextHasNoMarginBottom: true,
73
+ label: __('Name'),
74
+ value: title,
75
+ onChange: setTitle,
76
+ placeholder: DEFAULT_TITLE,
77
+ disabled: isBusy,
78
+ help: __('Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.')
79
+ }), createElement(HStack, {
80
+ justify: "right"
81
+ }, createElement(Button, {
82
+ variant: "tertiary",
83
+ onClick: cancel
84
+ }, __('Cancel')), createElement(Button, {
85
+ variant: "primary",
86
+ type: "submit",
87
+ isBusy: isBusy,
88
+ "aria-disabled": isBusy
89
+ }, __('Create'))))));
90
+ }
91
+ //# sourceMappingURL=create-new-template-modal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useSelect","useDispatch","useState","serialize","createBlock","Modal","TextControl","Button","__experimentalHStack","HStack","__experimentalVStack","VStack","__","cleanForSlug","unlock","store","editorStore","DEFAULT_TITLE","CreateNewTemplateModal","onClose","defaultBlockTemplate","select","getEditorSettings","createTemplate","setRenderingMode","title","setTitle","isBusy","setIsBusy","cancel","submit","event","preventDefault","newTemplateContent","tagName","layout","inherit","slug","content","createElement","onRequestClose","className","onSubmit","spacing","__nextHasNoMarginBottom","label","value","onChange","placeholder","disabled","help","justify","variant","onClick","type"],"sources":["@wordpress/editor/src/components/post-template/create-new-template-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { serialize, createBlock } from '@wordpress/blocks';\nimport {\n\tModal,\n\tTextControl,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cleanForSlug } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst DEFAULT_TITLE = __( 'Custom Template' );\n\nexport default function CreateNewTemplateModal( { onClose } ) {\n\tconst defaultBlockTemplate = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getEditorSettings().defaultBlockTemplate,\n\t\t[]\n\t);\n\n\tconst { createTemplate, setRenderingMode } = unlock(\n\t\tuseDispatch( editorStore )\n\t);\n\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\tconst cancel = () => {\n\t\tsetTitle( '' );\n\t\tonClose();\n\t};\n\n\tconst submit = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst newTemplateContent =\n\t\t\tdefaultBlockTemplate ??\n\t\t\tserialize( [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'header',\n\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock( 'core/site-title' ),\n\t\t\t\t\t\tcreateBlock( 'core/site-tagline' ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\tcreateBlock( 'core/separator' ),\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'main',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[ createBlock( 'core/post-title' ) ]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcreateBlock( 'core/post-content', {\n\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t} ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t] );\n\n\t\tawait createTemplate( {\n\t\t\tslug: cleanForSlug( title || DEFAULT_TITLE ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tcancel();\n\t\tsetRenderingMode( 'template-only' );\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\tonRequestClose={ cancel }\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"editor-post-template__create-form\"\n\t\t\t\tonSubmit={ submit }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ DEFAULT_TITLE }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ cancel }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,EAAEC,WAAW,QAAQ,mBAAmB;AAC1D,SACCC,KAAK,EACLC,WAAW,EACXC,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,EAAE,QAAQ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,EAAE,CAAE,QAAS,CACR,CAAC,EAET2B,aAAA,CAAChC,MAAM;IACN6C,OAAO,EAAC,SAAS;IACjBE,IAAI,EAAC,QAAQ;IACb3B,MAAM,EAAGA,MAAQ;IACjB,iBAAgBA;EAAQ,GAEtBf,EAAE,CAAE,QAAS,CACR,CACD,CACD,CACH,CACA,CAAC;AAEV"}
@@ -0,0 +1,47 @@
1
+ import { createElement, Fragment } from "react";
2
+ /**
3
+ * WordPress dependencies
4
+ */
5
+ import { MenuItem } from '@wordpress/components';
6
+ import { __ } from '@wordpress/i18n';
7
+ import { useSelect } from '@wordpress/data';
8
+ import { store as coreStore } from '@wordpress/core-data';
9
+ import { useState } from '@wordpress/element';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import CreateNewTemplateModal from './create-new-template-modal';
15
+ import { useAllowSwitchingTemplates } from './hooks';
16
+ export default function CreateNewTemplate({
17
+ onClick
18
+ }) {
19
+ const {
20
+ canCreateTemplates
21
+ } = useSelect(select => {
22
+ const {
23
+ canUser
24
+ } = select(coreStore);
25
+ return {
26
+ canCreateTemplates: canUser('create', 'templates')
27
+ };
28
+ }, []);
29
+ const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
30
+ const allowSwitchingTemplate = useAllowSwitchingTemplates();
31
+
32
+ // The default template in a post is indicated by an empty string.
33
+ if (!canCreateTemplates || !allowSwitchingTemplate) {
34
+ return null;
35
+ }
36
+ return createElement(Fragment, null, createElement(MenuItem, {
37
+ onClick: () => {
38
+ setIsCreateModalOpen(true);
39
+ }
40
+ }, __('Create new template')), isCreateModalOpen && createElement(CreateNewTemplateModal, {
41
+ onClose: () => {
42
+ setIsCreateModalOpen(false);
43
+ onClick();
44
+ }
45
+ }));
46
+ }
47
+ //# sourceMappingURL=create-new-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MenuItem","__","useSelect","store","coreStore","useState","CreateNewTemplateModal","useAllowSwitchingTemplates","CreateNewTemplate","onClick","canCreateTemplates","select","canUser","isCreateModalOpen","setIsCreateModalOpen","allowSwitchingTemplate","createElement","Fragment","onClose"],"sources":["@wordpress/editor/src/components/post-template/create-new-template.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nexport default function CreateNewTemplate( { onClick } ) {\n\tconst { canCreateTemplates } = useSelect( ( select ) => {\n\t\tconst { canUser } = select( coreStore );\n\t\treturn {\n\t\t\tcanCreateTemplates: canUser( 'create', 'templates' ),\n\t\t};\n\t}, [] );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\n\t// The default template in a post is indicated by an empty string.\n\tif ( ! canCreateTemplates || ! allowSwitchingTemplate ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsCreateModalOpen( true );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Create new template' ) }\n\t\t\t</MenuItem>\n\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsCreateModalOpen( false );\n\t\t\t\t\t\tonClick();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,0BAA0B,QAAQ,SAAS;AAEpD,eAAe,SAASC,iBAAiBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EACxD,MAAM;IAAEC;EAAmB,CAAC,GAAGR,SAAS,CAAIS,MAAM,IAAM;IACvD,MAAM;MAAEC;IAAQ,CAAC,GAAGD,MAAM,CAAEP,SAAU,CAAC;IACvC,OAAO;MACNM,kBAAkB,EAAEE,OAAO,CAAE,QAAQ,EAAE,WAAY;IACpD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAM,CAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,GAAGT,QAAQ,CAAE,KAAM,CAAC;EACrE,MAAMU,sBAAsB,GAAGR,0BAA0B,CAAC,CAAC;;EAE3D;EACA,IAAK,CAAEG,kBAAkB,IAAI,CAAEK,sBAAsB,EAAG;IACvD,OAAO,IAAI;EACZ;EACA,OACCC,aAAA,CAAAC,QAAA,QACCD,aAAA,CAAChB,QAAQ;IACRS,OAAO,EAAGA,CAAA,KAAM;MACfK,oBAAoB,CAAE,IAAK,CAAC;IAC7B;EAAG,GAEDb,EAAE,CAAE,qBAAsB,CACnB,CAAC,EAETY,iBAAiB,IAClBG,aAAA,CAACV,sBAAsB;IACtBY,OAAO,EAAGA,CAAA,KAAM;MACfJ,oBAAoB,CAAE,KAAM,CAAC;MAC7BL,OAAO,CAAC,CAAC;IACV;EAAG,CACH,CAED,CAAC;AAEL"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect } from '@wordpress/data';
5
+ import { useMemo } from '@wordpress/element';
6
+ import { store as coreStore } from '@wordpress/core-data';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import { store as editorStore } from '../../store';
12
+ export function useEditedPostContext() {
13
+ return useSelect(select => {
14
+ const {
15
+ getCurrentPostId,
16
+ getCurrentPostType
17
+ } = select(editorStore);
18
+ return {
19
+ postId: getCurrentPostId(),
20
+ postType: getCurrentPostType()
21
+ };
22
+ }, []);
23
+ }
24
+ export function useAllowSwitchingTemplates() {
25
+ const {
26
+ postType,
27
+ postId
28
+ } = useEditedPostContext();
29
+ return useSelect(select => {
30
+ const {
31
+ getEntityRecord,
32
+ getEntityRecords
33
+ } = select(coreStore);
34
+ const siteSettings = getEntityRecord('root', 'site');
35
+ const templates = getEntityRecords('postType', 'wp_template', {
36
+ per_page: -1
37
+ });
38
+ const isPostsPage = +postId === siteSettings?.page_for_posts;
39
+ // If current page is set front page or posts page, we also need
40
+ // to check if the current theme has a template for it. If not
41
+ const isFrontPage = postType === 'page' && +postId === siteSettings?.page_on_front && templates?.some(({
42
+ slug
43
+ }) => slug === 'front-page');
44
+ return !isPostsPage && !isFrontPage;
45
+ }, [postId, postType]);
46
+ }
47
+ function useTemplates() {
48
+ return useSelect(select => select(coreStore).getEntityRecords('postType', 'wp_template', {
49
+ per_page: -1,
50
+ post_type: 'page'
51
+ }), []);
52
+ }
53
+ export function useAvailableTemplates() {
54
+ const currentTemplateSlug = useCurrentTemplateSlug();
55
+ const allowSwitchingTemplate = useAllowSwitchingTemplates();
56
+ const templates = useTemplates();
57
+ return useMemo(() => allowSwitchingTemplate && templates?.filter(template => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw // Skip empty templates.
58
+ ), [templates, currentTemplateSlug, allowSwitchingTemplate]);
59
+ }
60
+ export function useCurrentTemplateSlug() {
61
+ const {
62
+ postType,
63
+ postId
64
+ } = useEditedPostContext();
65
+ const templates = useTemplates();
66
+ const entityTemplate = useSelect(select => {
67
+ const post = select(coreStore).getEditedEntityRecord('postType', postType, postId);
68
+ return post?.template;
69
+ }, [postType, postId]);
70
+ if (!entityTemplate) {
71
+ return;
72
+ }
73
+ // If a page has a `template` set and is not included in the list
74
+ // of the theme's templates, do not return it, in order to resolve
75
+ // to the current theme's default template.
76
+ return templates?.find(template => template.slug === entityTemplate)?.slug;
77
+ }
78
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useSelect","useMemo","store","coreStore","editorStore","useEditedPostContext","select","getCurrentPostId","getCurrentPostType","postId","postType","useAllowSwitchingTemplates","getEntityRecord","getEntityRecords","siteSettings","templates","per_page","isPostsPage","page_for_posts","isFrontPage","page_on_front","some","slug","useTemplates","post_type","useAvailableTemplates","currentTemplateSlug","useCurrentTemplateSlug","allowSwitchingTemplate","filter","template","is_custom","content","raw","entityTemplate","post","getEditedEntityRecord","find"],"sources":["@wordpress/editor/src/components/post-template/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function useEditedPostContext() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n}\nexport function useAllowSwitchingTemplates() {\n\tconst { postType, postId } = useEditedPostContext();\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEntityRecords } = select( coreStore );\n\t\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\t\tconst templates = getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t} );\n\t\t\tconst isPostsPage = +postId === siteSettings?.page_for_posts;\n\t\t\t// If current page is set front page or posts page, we also need\n\t\t\t// to check if the current theme has a template for it. If not\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' &&\n\t\t\t\t+postId === siteSettings?.page_on_front &&\n\t\t\t\ttemplates?.some( ( { slug } ) => slug === 'front-page' );\n\t\t\treturn ! isPostsPage && ! isFrontPage;\n\t\t},\n\t\t[ postId, postType ]\n\t);\n}\n\nfunction useTemplates() {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t\tpost_type: 'page',\n\t\t\t} ),\n\t\t[]\n\t);\n}\n\nexport function useAvailableTemplates() {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst templates = useTemplates();\n\treturn useMemo(\n\t\t() =>\n\t\t\tallowSwitchingTemplate &&\n\t\t\ttemplates?.filter(\n\t\t\t\t( template ) =>\n\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\ttemplate.slug !== currentTemplateSlug &&\n\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t),\n\t\t[ templates, currentTemplateSlug, allowSwitchingTemplate ]\n\t);\n}\n\nexport function useCurrentTemplateSlug() {\n\tconst { postType, postId } = useEditedPostContext();\n\tconst templates = useTemplates();\n\tconst entityTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\treturn post?.template;\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tif ( ! entityTemplate ) {\n\t\treturn;\n\t}\n\t// If a page has a `template` set and is not included in the list\n\t// of the theme's templates, do not return it, in order to resolve\n\t// to the current theme's default template.\n\treturn templates?.find( ( template ) => template.slug === entityTemplate )\n\t\t?.slug;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAElD,OAAO,SAASC,oBAAoBA,CAAA,EAAG;EACtC,OAAOL,SAAS,CAAIM,MAAM,IAAM;IAC/B,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,EAAG;EACvC,MAAMC,mBAAmB,GAAGC,sBAAsB,CAAC,CAAC;EACpD,MAAMC,sBAAsB,GAAGjB,0BAA0B,CAAC,CAAC;EAC3D,MAAMI,SAAS,GAAGQ,YAAY,CAAC,CAAC;EAChC,OAAOtB,OAAO,CACb,MACC2B,sBAAsB,IACtBb,SAAS,EAAEc,MAAM,CACdC,QAAQ,IACTA,QAAQ,CAACC,SAAS,IAClBD,QAAQ,CAACR,IAAI,KAAKI,mBAAmB,IACrC,CAAC,CAAEI,QAAQ,CAACE,OAAO,CAACC,GAAG,CAAC;EAC1B,CAAC,EACF,CAAElB,SAAS,EAAEW,mBAAmB,EAAEE,sBAAsB,CACzD,CAAC;AACF;AAEA,OAAO,SAASD,sBAAsBA,CAAA,EAAG;EACxC,MAAM;IAAEjB,QAAQ;IAAED;EAAO,CAAC,GAAGJ,oBAAoB,CAAC,CAAC;EACnD,MAAMU,SAAS,GAAGQ,YAAY,CAAC,CAAC;EAChC,MAAMW,cAAc,GAAGlC,SAAS,CAC7BM,MAAM,IAAM;IACb,MAAM6B,IAAI,GAAG7B,MAAM,CAAEH,SAAU,CAAC,CAACiC,qBAAqB,CACrD,UAAU,EACV1B,QAAQ,EACRD,MACD,CAAC;IACD,OAAO0B,IAAI,EAAEL,QAAQ;EACtB,CAAC,EACD,CAAEpB,QAAQ,EAAED,MAAM,CACnB,CAAC;EAED,IAAK,CAAEyB,cAAc,EAAG;IACvB;EACD;EACA;EACA;EACA;EACA,OAAOnB,SAAS,EAAEsB,IAAI,CAAIP,QAAQ,IAAMA,QAAQ,CAACR,IAAI,KAAKY,cAAe,CAAC,EACvEZ,IAAI;AACR"}
@@ -0,0 +1,63 @@
1
+ import { createElement } from "react";
2
+ /**
3
+ * WordPress dependencies
4
+ */
5
+ import { useSelect } from '@wordpress/data';
6
+ import { __ } from '@wordpress/i18n';
7
+ import { store as coreStore } from '@wordpress/core-data';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { store as editorStore } from '../../store';
13
+ import ClassicThemeControl from './classic-theme';
14
+ import BlockThemeControl from './block-theme';
15
+ import PostPanelRow from '../post-panel-row';
16
+ export default function PostTemplatePanel() {
17
+ const {
18
+ templateId,
19
+ isBlockTheme
20
+ } = useSelect(select => {
21
+ const {
22
+ getCurrentTemplateId,
23
+ getEditorSettings
24
+ } = select(editorStore);
25
+ return {
26
+ templateId: getCurrentTemplateId(),
27
+ isBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme
28
+ };
29
+ }, []);
30
+ const isVisible = true;
31
+ useSelect(select => {
32
+ var _select$canUser;
33
+ const postTypeSlug = select(editorStore).getCurrentPostType();
34
+ const postType = select(coreStore).getPostType(postTypeSlug);
35
+ if (!postType?.viewable) {
36
+ return false;
37
+ }
38
+ const settings = select(editorStore).getEditorSettings();
39
+ const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0;
40
+ if (hasTemplates) {
41
+ return true;
42
+ }
43
+ if (!settings.supportsTemplateMode) {
44
+ return false;
45
+ }
46
+ const canCreateTemplates = (_select$canUser = select(coreStore).canUser('create', 'templates')) !== null && _select$canUser !== void 0 ? _select$canUser : false;
47
+ return canCreateTemplates;
48
+ }, []);
49
+ if (!isBlockTheme && isVisible) {
50
+ return createElement(PostPanelRow, {
51
+ label: __('Template')
52
+ }, createElement(ClassicThemeControl, null));
53
+ }
54
+ if (isBlockTheme && !!templateId) {
55
+ return createElement(PostPanelRow, {
56
+ label: __('Template')
57
+ }, createElement(BlockThemeControl, {
58
+ id: templateId
59
+ }));
60
+ }
61
+ return null;
62
+ }
63
+ //# sourceMappingURL=panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useSelect","__","store","coreStore","editorStore","ClassicThemeControl","BlockThemeControl","PostPanelRow","PostTemplatePanel","templateId","isBlockTheme","select","getCurrentTemplateId","getEditorSettings","__unstableIsBlockBasedTheme","isVisible","_select$canUser","postTypeSlug","getCurrentPostType","postType","getPostType","viewable","settings","hasTemplates","availableTemplates","Object","keys","length","supportsTemplateMode","canCreateTemplates","canUser","createElement","label","id"],"sources":["@wordpress/editor/src/components/post-template/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport ClassicThemeControl from './classic-theme';\nimport BlockThemeControl from './block-theme';\nimport PostPanelRow from '../post-panel-row';\n\nexport default function PostTemplatePanel() {\n\tconst { templateId, isBlockTheme } = useSelect( ( select ) => {\n\t\tconst { getCurrentTemplateId, getEditorSettings } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\ttemplateId: getCurrentTemplateId(),\n\t\t\tisBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme,\n\t\t};\n\t}, [] );\n\n\tconst isVisible = true;\n\tuseSelect( ( select ) => {\n\t\tconst postTypeSlug = select( editorStore ).getCurrentPostType();\n\t\tconst postType = select( coreStore ).getPostType( postTypeSlug );\n\t\tif ( ! postType?.viewable ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst settings = select( editorStore ).getEditorSettings();\n\t\tconst hasTemplates =\n\t\t\t!! settings.availableTemplates &&\n\t\t\tObject.keys( settings.availableTemplates ).length > 0;\n\t\tif ( hasTemplates ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( ! settings.supportsTemplateMode ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst canCreateTemplates =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) ?? false;\n\t\treturn canCreateTemplates;\n\t}, [] );\n\n\tif ( ! isBlockTheme && isVisible ) {\n\t\treturn (\n\t\t\t<PostPanelRow label={ __( 'Template' ) }>\n\t\t\t\t<ClassicThemeControl />\n\t\t\t</PostPanelRow>\n\t\t);\n\t}\n\n\tif ( isBlockTheme && !! templateId ) {\n\t\treturn (\n\t\t\t<PostPanelRow label={ __( 'Template' ) }>\n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kBAAmB,CAAC,CAACG,MAAM,GAAG,CAAC;IACtD,IAAKJ,YAAY,EAAG;MACnB,OAAO,IAAI;IACZ;IAEA,IAAK,CAAED,QAAQ,CAACM,oBAAoB,EAAG;MACtC,OAAO,KAAK;IACb;IAEA,MAAMC,kBAAkB,IAAAb,eAAA,GACvBL,MAAM,CAAER,SAAU,CAAC,CAAC2B,OAAO,CAAE,QAAQ,EAAE,WAAY,CAAC,cAAAd,eAAA,cAAAA,eAAA,GAAI,KAAK;IAC9D,OAAOa,kBAAkB;EAC1B,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAEnB,YAAY,IAAIK,SAAS,EAAG;IAClC,OACCgB,aAAA,CAACxB,YAAY;MAACyB,KAAK,EAAG/B,EAAE,CAAE,UAAW;IAAG,GACvC8B,aAAA,CAAC1B,mBAAmB,MAAE,CACT,CAAC;EAEjB;EAEA,IAAKK,YAAY,IAAI,CAAC,CAAED,UAAU,EAAG;IACpC,OACCsB,aAAA,CAACxB,YAAY;MAACyB,KAAK,EAAG/B,EAAE,CAAE,UAAW;IAAG,GACvC8B,aAAA,CAACzB,iBAAiB;MAAC2B,EAAE,EAAGxB;IAAY,CAAE,CACzB,CAAC;EAEjB;EACA,OAAO,IAAI;AACZ"}
@@ -0,0 +1,41 @@
1
+ import { createElement } from "react";
2
+ /**
3
+ * WordPress dependencies
4
+ */
5
+ import { MenuItem } from '@wordpress/components';
6
+ import { __ } from '@wordpress/i18n';
7
+ import { useDispatch } from '@wordpress/data';
8
+ import { store as coreStore } from '@wordpress/core-data';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import { useAllowSwitchingTemplates, useCurrentTemplateSlug, useEditedPostContext } from './hooks';
14
+ export default function ResetDefaultTemplate({
15
+ onClick
16
+ }) {
17
+ const currentTemplateSlug = useCurrentTemplateSlug();
18
+ const allowSwitchingTemplate = useAllowSwitchingTemplates();
19
+ const {
20
+ postType,
21
+ postId
22
+ } = useEditedPostContext();
23
+ const {
24
+ editEntityRecord
25
+ } = useDispatch(coreStore);
26
+ // The default template in a post is indicated by an empty string.
27
+ if (!currentTemplateSlug || !allowSwitchingTemplate) {
28
+ return null;
29
+ }
30
+ return createElement(MenuItem, {
31
+ onClick: () => {
32
+ editEntityRecord('postType', postType, postId, {
33
+ template: ''
34
+ }, {
35
+ undoIgnore: true
36
+ });
37
+ onClick();
38
+ }
39
+ }, __('Use default template'));
40
+ }
41
+ //# sourceMappingURL=reset-default-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MenuItem","__","useDispatch","store","coreStore","useAllowSwitchingTemplates","useCurrentTemplateSlug","useEditedPostContext","ResetDefaultTemplate","onClick","currentTemplateSlug","allowSwitchingTemplate","postType","postId","editEntityRecord","createElement","template","undoIgnore"],"sources":["@wordpress/editor/src/components/post-template/reset-default-template.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseAllowSwitchingTemplates,\n\tuseCurrentTemplateSlug,\n\tuseEditedPostContext,\n} from './hooks';\n\nexport default function ResetDefaultTemplate( { onClick } ) {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst { postType, postId } = useEditedPostContext();\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\t// The default template in a post is indicated by an empty string.\n\tif ( ! currentTemplateSlug || ! allowSwitchingTemplate ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\t{ template: '' },\n\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t);\n\t\t\t\tonClick();\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Use default template' ) }\n\t\t</MenuItem>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SACCC,0BAA0B,EAC1BC,sBAAsB,EACtBC,oBAAoB,QACd,SAAS;AAEhB,eAAe,SAASC,oBAAoBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EAC3D,MAAMC,mBAAmB,GAAGJ,sBAAsB,CAAC,CAAC;EACpD,MAAMK,sBAAsB,GAAGN,0BAA0B,CAAC,CAAC;EAC3D,MAAM;IAAEO,QAAQ;IAAEC;EAAO,CAAC,GAAGN,oBAAoB,CAAC,CAAC;EACnD,MAAM;IAAEO;EAAiB,CAAC,GAAGZ,WAAW,CAAEE,SAAU,CAAC;EACrD;EACA,IAAK,CAAEM,mBAAmB,IAAI,CAAEC,sBAAsB,EAAG;IACxD,OAAO,IAAI;EACZ;EACA,OACCI,aAAA,CAACf,QAAQ;IACRS,OAAO,EAAGA,CAAA,KAAM;MACfK,gBAAgB,CACf,UAAU,EACVF,QAAQ,EACRC,MAAM,EACN;QAAEG,QAAQ,EAAE;MAAG,CAAC,EAChB;QAAEC,UAAU,EAAE;MAAK,CACpB,CAAC;MACDR,OAAO,CAAC,CAAC;IACV;EAAG,GAEDR,EAAE,CAAE,sBAAuB,CACpB,CAAC;AAEb"}
@@ -0,0 +1,77 @@
1
+ import { createElement, Fragment } from "react";
2
+ /**
3
+ * WordPress dependencies
4
+ */
5
+ import { useMemo, useState, useCallback } from '@wordpress/element';
6
+ import { decodeEntities } from '@wordpress/html-entities';
7
+ import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
8
+ import { MenuItem, Modal } from '@wordpress/components';
9
+ import { __ } from '@wordpress/i18n';
10
+ import { useDispatch } from '@wordpress/data';
11
+ import { store as coreStore } from '@wordpress/core-data';
12
+ import { parse } from '@wordpress/blocks';
13
+ import { useAsyncList } from '@wordpress/compose';
14
+
15
+ /**
16
+ * Internal dependencies
17
+ */
18
+ import { useAvailableTemplates, useEditedPostContext } from './hooks';
19
+ export default function SwapTemplateButton({
20
+ onClick
21
+ }) {
22
+ const [showModal, setShowModal] = useState(false);
23
+ const availableTemplates = useAvailableTemplates();
24
+ const onClose = useCallback(() => {
25
+ setShowModal(false);
26
+ }, []);
27
+ const {
28
+ postType,
29
+ postId
30
+ } = useEditedPostContext();
31
+ const {
32
+ editEntityRecord
33
+ } = useDispatch(coreStore);
34
+ if (!availableTemplates?.length) {
35
+ return null;
36
+ }
37
+ const onTemplateSelect = async template => {
38
+ editEntityRecord('postType', postType, postId, {
39
+ template: template.name
40
+ }, {
41
+ undoIgnore: true
42
+ });
43
+ onClose(); // Close the template suggestions modal first.
44
+ onClick();
45
+ };
46
+ return createElement(Fragment, null, createElement(MenuItem, {
47
+ onClick: () => setShowModal(true)
48
+ }, __('Swap template')), showModal && createElement(Modal, {
49
+ title: __('Choose a template'),
50
+ onRequestClose: onClose,
51
+ overlayClassName: "editor-post-template__swap-template-modal",
52
+ isFullScreen: true
53
+ }, createElement("div", {
54
+ className: "editor-post-template__swap-template-modal-content"
55
+ }, createElement(TemplatesList, {
56
+ onSelect: onTemplateSelect
57
+ }))));
58
+ }
59
+ function TemplatesList({
60
+ onSelect
61
+ }) {
62
+ const availableTemplates = useAvailableTemplates();
63
+ const templatesAsPatterns = useMemo(() => availableTemplates.map(template => ({
64
+ name: template.slug,
65
+ blocks: parse(template.content.raw),
66
+ title: decodeEntities(template.title.rendered),
67
+ id: template.id
68
+ })), [availableTemplates]);
69
+ const shownTemplates = useAsyncList(templatesAsPatterns);
70
+ return createElement(BlockPatternsList, {
71
+ label: __('Templates'),
72
+ blockPatterns: templatesAsPatterns,
73
+ shownPatterns: shownTemplates,
74
+ onClickPattern: onSelect
75
+ });
76
+ }
77
+ //# sourceMappingURL=swap-template-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useMemo","useState","useCallback","decodeEntities","__experimentalBlockPatternsList","BlockPatternsList","MenuItem","Modal","__","useDispatch","store","coreStore","parse","useAsyncList","useAvailableTemplates","useEditedPostContext","SwapTemplateButton","onClick","showModal","setShowModal","availableTemplates","onClose","postType","postId","editEntityRecord","length","onTemplateSelect","template","name","undoIgnore","createElement","Fragment","title","onRequestClose","overlayClassName","isFullScreen","className","TemplatesList","onSelect","templatesAsPatterns","map","slug","blocks","content","raw","rendered","id","shownTemplates","label","blockPatterns","shownPatterns","onClickPattern"],"sources":["@wordpress/editor/src/components/post-template/swap-template-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState, useCallback } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { MenuItem, Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { parse } from '@wordpress/blocks';\nimport { useAsyncList } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useAvailableTemplates, useEditedPostContext } from './hooks';\n\nexport default function SwapTemplateButton( { onClick } ) {\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst availableTemplates = useAvailableTemplates();\n\tconst onClose = useCallback( () => {\n\t\tsetShowModal( false );\n\t}, [] );\n\tconst { postType, postId } = useEditedPostContext();\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tif ( ! availableTemplates?.length ) {\n\t\treturn null;\n\t}\n\tconst onTemplateSelect = async ( template ) => {\n\t\teditEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{ template: template.name },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t\tonClose(); // Close the template suggestions modal first.\n\t\tonClick();\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem onClick={ () => setShowModal( true ) }>\n\t\t\t\t{ __( 'Swap template' ) }\n\t\t\t</MenuItem>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ onClose }\n\t\t\t\t\toverlayClassName=\"editor-post-template__swap-template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"editor-post-template__swap-template-modal-content\">\n\t\t\t\t\t\t<TemplatesList onSelect={ onTemplateSelect } />\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction TemplatesList( { onSelect } ) {\n\tconst availableTemplates = useAvailableTemplates();\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\tconst shownTemplates = useAsyncList( templatesAsPatterns );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tlabel={ __( 'Templates' ) }\n\t\t\tblockPatterns={ templatesAsPatterns }\n\t\t\tshownPatterns={ shownTemplates }\n\t\t\tonClickPattern={ onSelect }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,oBAAoB;AACnE,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,+BAA+B,IAAIC,iBAAiB,QAAQ,yBAAyB;AAC9F,SAASC,QAAQ,EAAEC,KAAK,QAAQ,uBAAuB;AACvD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,SAAS,QAAQ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,GAEZL,aAAA;IAAKM,SAAS,EAAC;EAAmD,GACjEN,aAAA,CAACO,aAAa;IAACC,QAAQ,EAAGZ;EAAkB,CAAE,CAC1C,CACC,CAEP,CAAC;AAEL;AAEA,SAASW,aAAaA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACtC,MAAMlB,kBAAkB,GAAGN,qBAAqB,CAAC,CAAC;EAClD,MAAMyB,mBAAmB,GAAGvC,OAAO,CAClC,MACCoB,kBAAkB,CAACoB,GAAG,CAAIb,QAAQ,KAAQ;IACzCC,IAAI,EAAED,QAAQ,CAACc,IAAI;IACnBC,MAAM,EAAE9B,KAAK,CAAEe,QAAQ,CAACgB,OAAO,CAACC,GAAI,CAAC;IACrCZ,KAAK,EAAE7B,cAAc,CAAEwB,QAAQ,CAACK,KAAK,CAACa,QAAS,CAAC;IAChDC,EAAE,EAAEnB,QAAQ,CAACmB;EACd,CAAC,CAAG,CAAC,EACN,CAAE1B,kBAAkB,CACrB,CAAC;EACD,MAAM2B,cAAc,GAAGlC,YAAY,CAAE0B,mBAAoB,CAAC;EAC1D,OACCT,aAAA,CAACzB,iBAAiB;IACjB2C,KAAK,EAAGxC,EAAE,CAAE,WAAY,CAAG;IAC3ByC,aAAa,EAAGV,mBAAqB;IACrCW,aAAa,EAAGH,cAAgB;IAChCI,cAAc,EAAGb;EAAU,CAC3B,CAAC;AAEJ"}
@@ -129,7 +129,6 @@ class PostTitle extends Component {
129
129
  unstableOnFocus: this.props.onSelect,
130
130
  onBlur: this.props.onBlur // Always assign onBlur as a props.
131
131
  ,
132
- multiline: false,
133
132
  style: titleStyles,
134
133
  styles: styles,
135
134
  fontSize: 24,
@@ -1 +1 @@
1
- {"version":3,"names":["View","Component","create","insert","decodeEntities","withDispatch","withSelect","withFocusOutside","withInstanceId","compose","__","sprintf","pasteHandler","store","blockEditorStore","RichText","editorStore","styles","PostTitle","constructor","props","setRef","bind","onPaste","componentDidUpdate","prevProps","isSelected","isAnyBlockSelected","richTextRef","blur","onUnselect","componentDidMount","innerRef","handleFocusOutside","focus","onSelect","value","onChange","plainText","html","title","onInsertBlockAfter","onUpdate","content","HTML","length","valueToInsert","firstBlock","name","attributes","slice","richText","getTitle","postType","render","placeholder","style","focusedBorderColor","borderStyle","isDimmed","globalStyles","decodedPlaceholder","borderColor","titleStyles","text","color","placeholderColor","createElement","testID","titleContainer","dimmed","accessible","accessibilityLabel","accessibilityHint","Raw","tagName","tagsToEliminate","unstableOnFocus","onBlur","multiline","fontSize","lineHeight","fontWeight","deleteEnter","onSelectionChange","onEnter","onEnterPress","disableEditingMenu","__unstableIsSelected","__unstableOnCreateUndoLevel","select","isPostTitleSelected","getEditedPostAttribute","getSelectedBlockClientId","getBlockRootClientId","getSettings","selectedId","selectionIsNested","__experimentalGlobalStylesBaseStyles","dispatch","undo","redo","togglePostTitleSelection","editPost","clearSelectedBlock","insertDefaultBlock","insertBlocks","undefined","onUndo","onRedo","blocks"],"sources":["@wordpress/editor/src/components/post-title/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { create, insert } from '@wordpress/rich-text';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { withFocusOutside } from '@wordpress/components';\nimport { withInstanceId, compose } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { pasteHandler } from '@wordpress/blocks';\nimport { store as blockEditorStore, RichText } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nclass PostTitle extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.setRef = this.setRef.bind( this );\n\t\tthis.onPaste = this.onPaste.bind( this );\n\t}\n\tcomponentDidUpdate( prevProps ) {\n\t\t// Unselect if any other block is selected and blur the RichText.\n\t\tif (\n\t\t\tthis.props.isSelected &&\n\t\t\t! prevProps.isAnyBlockSelected &&\n\t\t\tthis.props.isAnyBlockSelected\n\t\t) {\n\t\t\tif ( this.richTextRef ) {\n\t\t\t\tthis.richTextRef.blur();\n\t\t\t}\n\t\t\tthis.props.onUnselect();\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.props.innerRef ) {\n\t\t\tthis.props.innerRef( this );\n\t\t}\n\t}\n\n\thandleFocusOutside() {\n\t\tthis.props.onUnselect();\n\t}\n\n\tfocus() {\n\t\tthis.props.onSelect();\n\t}\n\n\tonPaste( { value, onChange, plainText, html } ) {\n\t\tconst { title, onInsertBlockAfter, onUpdate } = this.props;\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t} );\n\n\t\tif ( content.length ) {\n\t\t\tif ( typeof content === 'string' ) {\n\t\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t} else {\n\t\t\t\tconst [ firstBlock ] = content;\n\t\t\t\tif (\n\t\t\t\t\t! title &&\n\t\t\t\t\t( firstBlock.name === 'core/heading' ||\n\t\t\t\t\t\tfirstBlock.name === 'core/paragraph' )\n\t\t\t\t) {\n\t\t\t\t\tonUpdate( firstBlock.attributes.content );\n\t\t\t\t\tonInsertBlockAfter( content.slice( 1 ) );\n\t\t\t\t} else {\n\t\t\t\t\tonInsertBlockAfter( content );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tsetRef( richText ) {\n\t\tthis.richTextRef = richText;\n\t}\n\n\tgetTitle( title, postType ) {\n\t\tif ( 'page' === postType ) {\n\t\t\treturn ! title\n\t\t\t\t? /* translators: accessibility text. empty page title. */\n\t\t\t\t __( 'Page title. Empty' )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: text content of the page title. */\n\t\t\t\t\t\t__( 'Page title. %s' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t );\n\t\t}\n\n\t\treturn ! title\n\t\t\t? /* translators: accessibility text. empty post title. */\n\t\t\t __( 'Post title. Empty' )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: accessibility text. %s: text content of the post title. */\n\t\t\t\t\t__( 'Post title. %s' ),\n\t\t\t\t\ttitle\n\t\t\t );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tplaceholder,\n\t\t\tstyle,\n\t\t\ttitle,\n\t\t\tfocusedBorderColor,\n\t\t\tborderStyle,\n\t\t\tisDimmed,\n\t\t\tpostType,\n\t\t\tglobalStyles,\n\t\t} = this.props;\n\n\t\tconst decodedPlaceholder = decodeEntities( placeholder );\n\t\tconst borderColor = this.props.isSelected\n\t\t\t? focusedBorderColor\n\t\t\t: 'transparent';\n\t\tconst titleStyles = {\n\t\t\t...style,\n\t\t\t...( globalStyles?.text && {\n\t\t\t\tcolor: globalStyles.text,\n\t\t\t\tplaceholderColor: globalStyles.text,\n\t\t\t} ),\n\t\t};\n\n\t\treturn (\n\t\t\t<View\n\t\t\t\ttestID=\"post-title\"\n\t\t\t\tstyle={ [\n\t\t\t\t\tstyles.titleContainer,\n\t\t\t\t\tborderStyle,\n\t\t\t\t\t{ borderColor },\n\t\t\t\t\tisDimmed && styles.dimmed,\n\t\t\t\t] }\n\t\t\t\taccessible={ ! this.props.isSelected }\n\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\taccessibilityHint={ __( 'Updates the title.' ) }\n\t\t\t>\n\t\t\t\t<RichText.Raw\n\t\t\t\t\tsetRef={ this.setRef }\n\t\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\t\ttagName={ 'p' }\n\t\t\t\t\ttagsToEliminate={ [ 'strong' ] }\n\t\t\t\t\tunstableOnFocus={ this.props.onSelect }\n\t\t\t\t\tonBlur={ this.props.onBlur } // Always assign onBlur as a props.\n\t\t\t\t\tmultiline={ false }\n\t\t\t\t\tstyle={ titleStyles }\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tfontSize={ 24 }\n\t\t\t\t\tlineHeight={ 1 }\n\t\t\t\t\tfontWeight={ 'bold' }\n\t\t\t\t\tdeleteEnter={ true }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tthis.props.onUpdate( value );\n\t\t\t\t\t} }\n\t\t\t\t\tonPaste={ this.onPaste }\n\t\t\t\t\tplaceholder={ decodedPlaceholder }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonSelectionChange={ () => {} }\n\t\t\t\t\tonEnter={ this.props.onEnterPress }\n\t\t\t\t\tdisableEditingMenu={ true }\n\t\t\t\t\t__unstableIsSelected={ this.props.isSelected }\n\t\t\t\t\t__unstableOnCreateUndoLevel={ () => {} }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n}\n\nexport default compose(\n\twithSelect( ( select ) => {\n\t\tconst { isPostTitleSelected, getEditedPostAttribute } =\n\t\t\tselect( editorStore );\n\t\tconst { getSelectedBlockClientId, getBlockRootClientId, getSettings } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst selectedId = getSelectedBlockClientId();\n\t\tconst selectionIsNested = !! getBlockRootClientId( selectedId );\n\t\tconst globalStyles =\n\t\t\tgetSettings()?.__experimentalGlobalStylesBaseStyles?.color;\n\n\t\treturn {\n\t\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tisAnyBlockSelected: !! selectedId,\n\t\t\tisSelected: isPostTitleSelected(),\n\t\t\tisDimmed: selectionIsNested,\n\t\t\tglobalStyles,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { undo, redo, togglePostTitleSelection, editPost } =\n\t\t\tdispatch( editorStore );\n\n\t\tconst { clearSelectedBlock, insertDefaultBlock, insertBlocks } =\n\t\t\tdispatch( blockEditorStore );\n\n\t\treturn {\n\t\t\tonEnterPress() {\n\t\t\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t\t\t},\n\t\t\tonUndo: undo,\n\t\t\tonRedo: redo,\n\t\t\tonSelect() {\n\t\t\t\ttogglePostTitleSelection( true );\n\t\t\t\tclearSelectedBlock();\n\t\t\t},\n\t\t\tonUnselect() {\n\t\t\t\ttogglePostTitleSelection( false );\n\t\t\t},\n\t\t\tonUpdate( title ) {\n\t\t\t\teditPost( { title } );\n\t\t\t},\n\t\t\tonInsertBlockAfter( blocks ) {\n\t\t\t\tinsertBlocks( blocks, 0 );\n\t\t\t},\n\t\t};\n\t} ),\n\twithInstanceId,\n\twithFocusOutside\n)( PostTitle );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,cAAc;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,MAAM,EAAEC,MAAM,QAAQ,sBAAsB;AACrD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AAC1D,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,cAAc,EAAEC,OAAO,QAAQ,oBAAoB;AAC5D,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,KAAK,IAAIC,gBAAgB,EAAEC,QAAQ,QAAQ,yBAAyB;AAC7E,SAASF,KAAK,IAAIG,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA,OAAOC,MAAM,MAAM,cAAc;AAEjC,MAAMC,SAAS,SAASjB,SAAS,CAAC;EACjCkB,WAAWA,CAAEC,KAAK,EAAG;IACpB,KAAK,CAAEA,KAAM,CAAC;IAEd,IAAI,CAACC,MAAM,GAAG,IAAI,CAACA,MAAM,CAACC,IAAI,CAAE,IAAK,CAAC;IACtC,IAAI,CAACC,OAAO,GAAG,IAAI,CAACA,OAAO,CAACD,IAAI,CAAE,IAAK,CAAC;EACzC;EACAE,kBAAkBA,CAAEC,SAAS,EAAG;IAC/B;IACA,IACC,IAAI,CAACL,KAAK,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rB,CAAC;IACD1E,UAAUA,CAAA,EAAG;MACZwE,wBAAwB,CAAE,KAAM,CAAC;IAClC,CAAC;IACD5D,QAAQA,CAAEF,KAAK,EAAG;MACjB+D,QAAQ,CAAE;QAAE/D;MAAM,CAAE,CAAC;IACtB,CAAC;IACDC,kBAAkBA,CAAEqE,MAAM,EAAG;MAC5BJ,YAAY,CAAEI,MAAM,EAAE,CAAE,CAAC;IAC1B;EACD,CAAC;AACF,CAAE,CAAC,EACHtG,cAAc,EACdD,gBACD,CAAC,CAAEW,SAAU,CAAC"}
1
+ {"version":3,"names":["View","Component","create","insert","decodeEntities","withDispatch","withSelect","withFocusOutside","withInstanceId","compose","__","sprintf","pasteHandler","store","blockEditorStore","RichText","editorStore","styles","PostTitle","constructor","props","setRef","bind","onPaste","componentDidUpdate","prevProps","isSelected","isAnyBlockSelected","richTextRef","blur","onUnselect","componentDidMount","innerRef","handleFocusOutside","focus","onSelect","value","onChange","plainText","html","title","onInsertBlockAfter","onUpdate","content","HTML","length","valueToInsert","firstBlock","name","attributes","slice","richText","getTitle","postType","render","placeholder","style","focusedBorderColor","borderStyle","isDimmed","globalStyles","decodedPlaceholder","borderColor","titleStyles","text","color","placeholderColor","createElement","testID","titleContainer","dimmed","accessible","accessibilityLabel","accessibilityHint","Raw","tagName","tagsToEliminate","unstableOnFocus","onBlur","fontSize","lineHeight","fontWeight","deleteEnter","onSelectionChange","onEnter","onEnterPress","disableEditingMenu","__unstableIsSelected","__unstableOnCreateUndoLevel","select","isPostTitleSelected","getEditedPostAttribute","getSelectedBlockClientId","getBlockRootClientId","getSettings","selectedId","selectionIsNested","__experimentalGlobalStylesBaseStyles","dispatch","undo","redo","togglePostTitleSelection","editPost","clearSelectedBlock","insertDefaultBlock","insertBlocks","undefined","onUndo","onRedo","blocks"],"sources":["@wordpress/editor/src/components/post-title/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { create, insert } from '@wordpress/rich-text';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { withFocusOutside } from '@wordpress/components';\nimport { withInstanceId, compose } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { pasteHandler } from '@wordpress/blocks';\nimport { store as blockEditorStore, RichText } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nclass PostTitle extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.setRef = this.setRef.bind( this );\n\t\tthis.onPaste = this.onPaste.bind( this );\n\t}\n\tcomponentDidUpdate( prevProps ) {\n\t\t// Unselect if any other block is selected and blur the RichText.\n\t\tif (\n\t\t\tthis.props.isSelected &&\n\t\t\t! prevProps.isAnyBlockSelected &&\n\t\t\tthis.props.isAnyBlockSelected\n\t\t) {\n\t\t\tif ( this.richTextRef ) {\n\t\t\t\tthis.richTextRef.blur();\n\t\t\t}\n\t\t\tthis.props.onUnselect();\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.props.innerRef ) {\n\t\t\tthis.props.innerRef( this );\n\t\t}\n\t}\n\n\thandleFocusOutside() {\n\t\tthis.props.onUnselect();\n\t}\n\n\tfocus() {\n\t\tthis.props.onSelect();\n\t}\n\n\tonPaste( { value, onChange, plainText, html } ) {\n\t\tconst { title, onInsertBlockAfter, onUpdate } = this.props;\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t} );\n\n\t\tif ( content.length ) {\n\t\t\tif ( typeof content === 'string' ) {\n\t\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t} else {\n\t\t\t\tconst [ firstBlock ] = content;\n\t\t\t\tif (\n\t\t\t\t\t! title &&\n\t\t\t\t\t( firstBlock.name === 'core/heading' ||\n\t\t\t\t\t\tfirstBlock.name === 'core/paragraph' )\n\t\t\t\t) {\n\t\t\t\t\tonUpdate( firstBlock.attributes.content );\n\t\t\t\t\tonInsertBlockAfter( content.slice( 1 ) );\n\t\t\t\t} else {\n\t\t\t\t\tonInsertBlockAfter( content );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tsetRef( richText ) {\n\t\tthis.richTextRef = richText;\n\t}\n\n\tgetTitle( title, postType ) {\n\t\tif ( 'page' === postType ) {\n\t\t\treturn ! title\n\t\t\t\t? /* translators: accessibility text. empty page title. */\n\t\t\t\t __( 'Page title. Empty' )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: text content of the page title. */\n\t\t\t\t\t\t__( 'Page title. %s' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t );\n\t\t}\n\n\t\treturn ! title\n\t\t\t? /* translators: accessibility text. empty post title. */\n\t\t\t __( 'Post title. Empty' )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: accessibility text. %s: text content of the post title. */\n\t\t\t\t\t__( 'Post title. %s' ),\n\t\t\t\t\ttitle\n\t\t\t );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tplaceholder,\n\t\t\tstyle,\n\t\t\ttitle,\n\t\t\tfocusedBorderColor,\n\t\t\tborderStyle,\n\t\t\tisDimmed,\n\t\t\tpostType,\n\t\t\tglobalStyles,\n\t\t} = this.props;\n\n\t\tconst decodedPlaceholder = decodeEntities( placeholder );\n\t\tconst borderColor = this.props.isSelected\n\t\t\t? focusedBorderColor\n\t\t\t: 'transparent';\n\t\tconst titleStyles = {\n\t\t\t...style,\n\t\t\t...( globalStyles?.text && {\n\t\t\t\tcolor: globalStyles.text,\n\t\t\t\tplaceholderColor: globalStyles.text,\n\t\t\t} ),\n\t\t};\n\n\t\treturn (\n\t\t\t<View\n\t\t\t\ttestID=\"post-title\"\n\t\t\t\tstyle={ [\n\t\t\t\t\tstyles.titleContainer,\n\t\t\t\t\tborderStyle,\n\t\t\t\t\t{ borderColor },\n\t\t\t\t\tisDimmed && styles.dimmed,\n\t\t\t\t] }\n\t\t\t\taccessible={ ! this.props.isSelected }\n\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\taccessibilityHint={ __( 'Updates the title.' ) }\n\t\t\t>\n\t\t\t\t<RichText.Raw\n\t\t\t\t\tsetRef={ this.setRef }\n\t\t\t\t\taccessibilityLabel={ this.getTitle( title, postType ) }\n\t\t\t\t\ttagName={ 'p' }\n\t\t\t\t\ttagsToEliminate={ [ 'strong' ] }\n\t\t\t\t\tunstableOnFocus={ this.props.onSelect }\n\t\t\t\t\tonBlur={ this.props.onBlur } // Always assign onBlur as a props.\n\t\t\t\t\tstyle={ titleStyles }\n\t\t\t\t\tstyles={ styles }\n\t\t\t\t\tfontSize={ 24 }\n\t\t\t\t\tlineHeight={ 1 }\n\t\t\t\t\tfontWeight={ 'bold' }\n\t\t\t\t\tdeleteEnter={ true }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tthis.props.onUpdate( value );\n\t\t\t\t\t} }\n\t\t\t\t\tonPaste={ this.onPaste }\n\t\t\t\t\tplaceholder={ decodedPlaceholder }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonSelectionChange={ () => {} }\n\t\t\t\t\tonEnter={ this.props.onEnterPress }\n\t\t\t\t\tdisableEditingMenu={ true }\n\t\t\t\t\t__unstableIsSelected={ this.props.isSelected }\n\t\t\t\t\t__unstableOnCreateUndoLevel={ () => {} }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n}\n\nexport default compose(\n\twithSelect( ( select ) => {\n\t\tconst { isPostTitleSelected, getEditedPostAttribute } =\n\t\t\tselect( editorStore );\n\t\tconst { getSelectedBlockClientId, getBlockRootClientId, getSettings } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst selectedId = getSelectedBlockClientId();\n\t\tconst selectionIsNested = !! getBlockRootClientId( selectedId );\n\t\tconst globalStyles =\n\t\t\tgetSettings()?.__experimentalGlobalStylesBaseStyles?.color;\n\n\t\treturn {\n\t\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tisAnyBlockSelected: !! selectedId,\n\t\t\tisSelected: isPostTitleSelected(),\n\t\t\tisDimmed: selectionIsNested,\n\t\t\tglobalStyles,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { undo, redo, togglePostTitleSelection, editPost } =\n\t\t\tdispatch( editorStore );\n\n\t\tconst { clearSelectedBlock, insertDefaultBlock, insertBlocks } =\n\t\t\tdispatch( blockEditorStore );\n\n\t\treturn {\n\t\t\tonEnterPress() {\n\t\t\t\tinsertDefaultBlock( undefined, undefined, 0 );\n\t\t\t},\n\t\t\tonUndo: undo,\n\t\t\tonRedo: redo,\n\t\t\tonSelect() {\n\t\t\t\ttogglePostTitleSelection( true );\n\t\t\t\tclearSelectedBlock();\n\t\t\t},\n\t\t\tonUnselect() {\n\t\t\t\ttogglePostTitleSelection( false );\n\t\t\t},\n\t\t\tonUpdate( title ) {\n\t\t\t\teditPost( { title } );\n\t\t\t},\n\t\t\tonInsertBlockAfter( blocks ) {\n\t\t\t\tinsertBlocks( blocks, 0 );\n\t\t\t},\n\t\t};\n\t} ),\n\twithInstanceId,\n\twithFocusOutside\n)( PostTitle );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,cAAc;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,MAAM,EAAEC,MAAM,QAAQ,sBAAsB;AACrD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AAC1D,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,cAAc,EAAEC,OAAO,QAAQ,oBAAoB;AAC5D,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,YAAY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