@wordpress/block-editor 12.11.1 → 12.12.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 (215) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-controls/hook.js +4 -1
  3. package/build/components/block-controls/hook.js.map +1 -1
  4. package/build/components/block-list/block-outline.native.js +1 -1
  5. package/build/components/block-list/block-outline.native.js.map +1 -1
  6. package/build/components/block-list/block.js +2 -0
  7. package/build/components/block-list/block.js.map +1 -1
  8. package/build/components/block-preview/index.js +4 -1
  9. package/build/components/block-preview/index.js.map +1 -1
  10. package/build/components/block-styles/index.js +1 -2
  11. package/build/components/block-styles/index.js.map +1 -1
  12. package/build/components/block-switcher/pattern-transformations-menu.js +2 -4
  13. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  14. package/build/components/block-tools/block-contextual-toolbar.js +1 -0
  15. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  16. package/build/components/dimensions-tool/index.js +22 -22
  17. package/build/components/dimensions-tool/index.js.map +1 -1
  18. package/build/components/dimensions-tool/scale-tool.js +1 -1
  19. package/build/components/dimensions-tool/scale-tool.js.map +1 -1
  20. package/build/components/height-control/index.js +90 -2
  21. package/build/components/height-control/index.js.map +1 -1
  22. package/build/components/iframe/index.js +9 -1
  23. package/build/components/iframe/index.js.map +1 -1
  24. package/build/components/image-editor/aspect-ratio-dropdown.js +0 -6
  25. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  26. package/build/components/index.native.js +8 -0
  27. package/build/components/index.native.js.map +1 -1
  28. package/build/components/link-control/link-preview.js +5 -2
  29. package/build/components/link-control/link-preview.js.map +1 -1
  30. package/build/components/link-control/use-internal-value.js +14 -8
  31. package/build/components/link-control/use-internal-value.js.map +1 -1
  32. package/build/components/list-view/index.js +6 -5
  33. package/build/components/list-view/index.js.map +1 -1
  34. package/build/components/media-replace-flow/index.js +2 -4
  35. package/build/components/media-replace-flow/index.js.map +1 -1
  36. package/build/components/provider/use-block-sync.js +2 -2
  37. package/build/components/provider/use-block-sync.js.map +1 -1
  38. package/build/components/rich-text/index.native.js +14 -3
  39. package/build/components/rich-text/index.native.js.map +1 -1
  40. package/build/components/rich-text/use-delete.js +1 -1
  41. package/build/components/rich-text/use-delete.js.map +1 -1
  42. package/build/components/rich-text/use-paste-handler.js +25 -22
  43. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  44. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +88 -0
  45. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  46. package/build/components/tool-selector/index.js +1 -2
  47. package/build/components/tool-selector/index.js.map +1 -1
  48. package/build/components/use-block-commands/index.js +90 -46
  49. package/build/components/use-block-commands/index.js.map +1 -1
  50. package/build/components/use-setting/index.js +4 -2
  51. package/build/components/use-setting/index.js.map +1 -1
  52. package/build/components/writing-flow/use-arrow-nav.js +4 -0
  53. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  54. package/build/hooks/block-rename-ui.js +5 -5
  55. package/build/hooks/block-rename-ui.js.map +1 -1
  56. package/build/hooks/{metadata-name.js → block-renaming.js} +3 -7
  57. package/build/hooks/block-renaming.js.map +1 -0
  58. package/build/hooks/custom-class-name.js +28 -21
  59. package/build/hooks/custom-class-name.js.map +1 -1
  60. package/build/hooks/duotone.js +28 -1
  61. package/build/hooks/duotone.js.map +1 -1
  62. package/build/hooks/index.js +1 -1
  63. package/build/hooks/index.js.map +1 -1
  64. package/build/hooks/layout.js +6 -6
  65. package/build/hooks/layout.js.map +1 -1
  66. package/build/hooks/metadata.js +6 -27
  67. package/build/hooks/metadata.js.map +1 -1
  68. package/build/hooks/utils.js +1 -1
  69. package/build/hooks/utils.js.map +1 -1
  70. package/build/layouts/grid.js +25 -3
  71. package/build/layouts/grid.js.map +1 -1
  72. package/build/layouts/utils.js +1 -1
  73. package/build/layouts/utils.js.map +1 -1
  74. package/build/lock-unlock.js +1 -1
  75. package/build/lock-unlock.js.map +1 -1
  76. package/build/store/actions.js +13 -5
  77. package/build/store/actions.js.map +1 -1
  78. package/build/utils/parse-css-unit-to-px.js +20 -0
  79. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  80. package/build/utils/pasting.js +1 -1
  81. package/build/utils/pasting.js.map +1 -1
  82. package/build-module/components/block-controls/hook.js +4 -1
  83. package/build-module/components/block-controls/hook.js.map +1 -1
  84. package/build-module/components/block-list/block-outline.native.js +1 -1
  85. package/build-module/components/block-list/block-outline.native.js.map +1 -1
  86. package/build-module/components/block-list/block.js +2 -0
  87. package/build-module/components/block-list/block.js.map +1 -1
  88. package/build-module/components/block-preview/index.js +4 -1
  89. package/build-module/components/block-preview/index.js.map +1 -1
  90. package/build-module/components/block-styles/index.js +1 -2
  91. package/build-module/components/block-styles/index.js.map +1 -1
  92. package/build-module/components/block-switcher/pattern-transformations-menu.js +2 -4
  93. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  94. package/build-module/components/block-tools/block-contextual-toolbar.js +1 -0
  95. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  96. package/build-module/components/dimensions-tool/index.js +22 -22
  97. package/build-module/components/dimensions-tool/index.js.map +1 -1
  98. package/build-module/components/dimensions-tool/scale-tool.js +1 -1
  99. package/build-module/components/dimensions-tool/scale-tool.js.map +1 -1
  100. package/build-module/components/height-control/index.js +90 -2
  101. package/build-module/components/height-control/index.js.map +1 -1
  102. package/build-module/components/iframe/index.js +9 -1
  103. package/build-module/components/iframe/index.js.map +1 -1
  104. package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -6
  105. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  106. package/build-module/components/index.native.js +1 -0
  107. package/build-module/components/index.native.js.map +1 -1
  108. package/build-module/components/link-control/link-preview.js +6 -3
  109. package/build-module/components/link-control/link-preview.js.map +1 -1
  110. package/build-module/components/link-control/use-internal-value.js +14 -9
  111. package/build-module/components/link-control/use-internal-value.js.map +1 -1
  112. package/build-module/components/list-view/index.js +7 -6
  113. package/build-module/components/list-view/index.js.map +1 -1
  114. package/build-module/components/media-replace-flow/index.js +3 -5
  115. package/build-module/components/media-replace-flow/index.js.map +1 -1
  116. package/build-module/components/provider/use-block-sync.js +2 -2
  117. package/build-module/components/provider/use-block-sync.js.map +1 -1
  118. package/build-module/components/rich-text/index.native.js +15 -4
  119. package/build-module/components/rich-text/index.native.js.map +1 -1
  120. package/build-module/components/rich-text/use-delete.js +1 -1
  121. package/build-module/components/rich-text/use-delete.js.map +1 -1
  122. package/build-module/components/rich-text/use-paste-handler.js +25 -22
  123. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  124. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +88 -0
  125. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  126. package/build-module/components/tool-selector/index.js +1 -2
  127. package/build-module/components/tool-selector/index.js.map +1 -1
  128. package/build-module/components/use-block-commands/index.js +90 -46
  129. package/build-module/components/use-block-commands/index.js.map +1 -1
  130. package/build-module/components/use-setting/index.js +4 -2
  131. package/build-module/components/use-setting/index.js.map +1 -1
  132. package/build-module/components/writing-flow/use-arrow-nav.js +4 -0
  133. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  134. package/build-module/hooks/block-rename-ui.js +6 -6
  135. package/build-module/hooks/block-rename-ui.js.map +1 -1
  136. package/build-module/hooks/{metadata-name.js → block-renaming.js} +3 -6
  137. package/build-module/hooks/block-renaming.js.map +1 -0
  138. package/build-module/hooks/custom-class-name.js +28 -21
  139. package/build-module/hooks/custom-class-name.js.map +1 -1
  140. package/build-module/hooks/duotone.js +28 -1
  141. package/build-module/hooks/duotone.js.map +1 -1
  142. package/build-module/hooks/index.js +1 -1
  143. package/build-module/hooks/index.js.map +1 -1
  144. package/build-module/hooks/layout.js +6 -6
  145. package/build-module/hooks/layout.js.map +1 -1
  146. package/build-module/hooks/metadata.js +6 -25
  147. package/build-module/hooks/metadata.js.map +1 -1
  148. package/build-module/hooks/utils.js +1 -1
  149. package/build-module/hooks/utils.js.map +1 -1
  150. package/build-module/layouts/grid.js +25 -3
  151. package/build-module/layouts/grid.js.map +1 -1
  152. package/build-module/layouts/utils.js +1 -1
  153. package/build-module/layouts/utils.js.map +1 -1
  154. package/build-module/lock-unlock.js +1 -1
  155. package/build-module/lock-unlock.js.map +1 -1
  156. package/build-module/store/actions.js +14 -6
  157. package/build-module/store/actions.js.map +1 -1
  158. package/build-module/utils/parse-css-unit-to-px.js +20 -0
  159. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  160. package/build-module/utils/pasting.js +1 -1
  161. package/build-module/utils/pasting.js.map +1 -1
  162. package/build-style/style-rtl.css +11 -6
  163. package/build-style/style.css +11 -6
  164. package/package.json +31 -31
  165. package/src/components/block-controls/hook.js +6 -3
  166. package/src/components/block-list/block-outline.native.js +1 -1
  167. package/src/components/block-list/block.js +2 -0
  168. package/src/components/block-preview/index.js +7 -1
  169. package/src/components/block-styles/index.js +1 -4
  170. package/src/components/block-switcher/pattern-transformations-menu.js +1 -4
  171. package/src/components/block-switcher/style.scss +6 -0
  172. package/src/components/block-tools/block-contextual-toolbar.js +1 -0
  173. package/src/components/block-tools/style.scss +0 -1
  174. package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -1
  175. package/src/components/colors-gradients/style.scss +4 -2
  176. package/src/components/dimensions-tool/index.js +25 -25
  177. package/src/components/dimensions-tool/scale-tool.js +1 -1
  178. package/src/components/height-control/index.js +50 -2
  179. package/src/components/iframe/index.js +8 -1
  180. package/src/components/image-editor/aspect-ratio-dropdown.js +0 -8
  181. package/src/components/index.native.js +1 -0
  182. package/src/components/link-control/README.md +43 -0
  183. package/src/components/link-control/link-preview.js +11 -5
  184. package/src/components/link-control/style.scss +3 -3
  185. package/src/components/link-control/test/index.js +19 -0
  186. package/src/components/link-control/use-internal-value.js +14 -10
  187. package/src/components/list-view/index.js +13 -3
  188. package/src/components/media-replace-flow/index.js +9 -14
  189. package/src/components/provider/test/use-block-sync.js +1 -1
  190. package/src/components/provider/use-block-sync.js +2 -2
  191. package/src/components/rich-text/index.native.js +19 -3
  192. package/src/components/rich-text/use-delete.js +1 -1
  193. package/src/components/rich-text/use-paste-handler.js +27 -24
  194. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +22 -0
  195. package/src/components/tool-selector/index.js +1 -1
  196. package/src/components/use-block-commands/index.js +91 -46
  197. package/src/components/use-setting/index.js +6 -1
  198. package/src/components/writing-flow/use-arrow-nav.js +4 -0
  199. package/src/hooks/block-rename-ui.js +5 -14
  200. package/src/hooks/{metadata-name.js → block-renaming.js} +4 -7
  201. package/src/hooks/custom-class-name.js +36 -31
  202. package/src/hooks/duotone.js +33 -0
  203. package/src/hooks/index.js +1 -1
  204. package/src/hooks/layout.js +6 -6
  205. package/src/hooks/metadata.js +6 -38
  206. package/src/hooks/utils.js +2 -0
  207. package/src/layouts/grid.js +50 -2
  208. package/src/layouts/utils.js +2 -1
  209. package/src/lock-unlock.js +1 -1
  210. package/src/store/actions.js +25 -8
  211. package/src/utils/parse-css-unit-to-px.js +20 -0
  212. package/src/utils/pasting.js +1 -4
  213. package/src/utils/test/pasting.js +12 -19
  214. package/build/hooks/metadata-name.js.map +0 -1
  215. package/build-module/hooks/metadata-name.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["BlockAlignmentControl","BlockAlignmentToolbar","BlockContextProvider","default","BlockControls","BlockFormatControls","BlockEdit","useBlockEditContext","BlockIcon","BlockVerticalAlignmentToolbar","BlockVerticalAlignmentControl","AlignmentControl","AlignmentToolbar","InnerBlocks","useInnerBlocksProps","InspectorControls","InspectorAdvancedControls","JustifyToolbar","JustifyContentControl","LineHeightControl","HeadingLevelDropdown","PlainText","RichText","RichTextShortcut","RichTextToolbarButton","__unstableRichTextInputEvent","MediaReplaceFlow","MediaPlaceholder","MediaUpload","MEDIA_TYPE_IMAGE","MEDIA_TYPE_VIDEO","MEDIA_TYPE_AUDIO","MEDIA_TYPE_ANY","MediaUploadProgress","MEDIA_UPLOAD_STATE_UPLOADING","MEDIA_UPLOAD_STATE_SUCCEEDED","MEDIA_UPLOAD_STATE_FAILED","MEDIA_UPLOAD_STATE_RESET","BlockMediaUpdateProgress","URLInput","BlockInvalidWarning","BlockCaption","Caption","PanelColorSettings","__experimentalPanelColorGradientSettings","useSetting","RecursionProvider","__experimentalRecursionProvider","useHasRecursion","__experimentalUseHasRecursion","Warning","ContrastChecker","useMultipleOriginColorsAndGradients","BottomSheetSettings","BlockSettingsButton","blockSettingsScreens","VideoPlayer","VIDEO_ASPECT_RATIO","getSpacingPresetCssVar","getCustomValueFromPreset","isValueSpacingPreset","BlockList","BlockMover","BlockToolbar","BlockVariationPicker","BlockStyles","DefaultBlockAppender","__unstableEditorStyles","Inserter","useBlockProps","FloatingToolbar","BlockEditorProvider"],"sources":["@wordpress/block-editor/src/components/index.native.js"],"sourcesContent":["// Block Creation Components.\nexport {\n\tBlockAlignmentControl,\n\tBlockAlignmentToolbar,\n} from './block-alignment-control';\nexport { BlockContextProvider } from './block-context';\nexport {\n\tdefault as BlockControls,\n\tBlockFormatControls,\n} from './block-controls';\nexport { default as BlockEdit, useBlockEditContext } from './block-edit';\nexport { default as BlockIcon } from './block-icon';\nexport {\n\tBlockVerticalAlignmentToolbar,\n\tBlockVerticalAlignmentControl,\n} from './block-vertical-alignment-control';\nexport * from './colors';\nexport * from './gradients';\nexport * from './font-sizes';\nexport { AlignmentControl, AlignmentToolbar } from './alignment-control';\nexport { default as InnerBlocks, useInnerBlocksProps } from './inner-blocks';\nexport {\n\tdefault as InspectorControls,\n\tInspectorAdvancedControls,\n} from './inspector-controls';\nexport {\n\tJustifyToolbar,\n\tJustifyContentControl,\n} from './justify-content-control';\nexport { default as LineHeightControl } from './line-height-control';\nexport { default as HeadingLevelDropdown } from './block-heading-level-dropdown';\nexport { default as PlainText } from './plain-text';\nexport {\n\tdefault as RichText,\n\tRichTextShortcut,\n\tRichTextToolbarButton,\n\t__unstableRichTextInputEvent,\n} from './rich-text';\nexport { default as MediaReplaceFlow } from './media-replace-flow';\nexport { default as MediaPlaceholder } from './media-placeholder';\nexport { default as MediaUpload } from './media-upload';\nexport {\n\tMEDIA_TYPE_IMAGE,\n\tMEDIA_TYPE_VIDEO,\n\tMEDIA_TYPE_AUDIO,\n\tMEDIA_TYPE_ANY,\n} from './media-upload/constants';\nexport {\n\tdefault as MediaUploadProgress,\n\tMEDIA_UPLOAD_STATE_UPLOADING,\n\tMEDIA_UPLOAD_STATE_SUCCEEDED,\n\tMEDIA_UPLOAD_STATE_FAILED,\n\tMEDIA_UPLOAD_STATE_RESET,\n} from './media-upload-progress';\nexport { default as BlockMediaUpdateProgress } from './block-media-update-progress';\nexport { default as URLInput } from './url-input';\nexport { default as BlockInvalidWarning } from './block-list/block-invalid-warning';\nexport { default as BlockCaption } from './block-caption';\nexport { default as Caption } from './caption';\nexport { default as PanelColorSettings } from './panel-color-settings';\nexport { default as __experimentalPanelColorGradientSettings } from './colors-gradients/panel-color-gradient-settings';\nexport { default as useSetting } from './use-setting';\nexport {\n\tRecursionProvider as __experimentalRecursionProvider,\n\tuseHasRecursion as __experimentalUseHasRecursion,\n} from './recursion-provider';\nexport { default as Warning } from './warning';\nexport { default as ContrastChecker } from './contrast-checker';\nexport { default as useMultipleOriginColorsAndGradients } from './colors-gradients/use-multiple-origin-colors-and-gradients';\n\nexport {\n\tBottomSheetSettings,\n\tBlockSettingsButton,\n\tblockSettingsScreens,\n} from './block-settings';\nexport { default as VideoPlayer, VIDEO_ASPECT_RATIO } from './video-player';\n\nexport {\n\tgetSpacingPresetCssVar,\n\tgetCustomValueFromPreset,\n\tisValueSpacingPreset,\n} from './spacing-sizes-control/utils';\n// Content Related Components.\nexport { default as BlockList } from './block-list';\nexport { default as BlockMover } from './block-mover';\nexport { default as BlockToolbar } from './block-toolbar';\nexport { default as BlockVariationPicker } from './block-variation-picker';\nexport { default as BlockStyles } from './block-styles';\nexport { default as DefaultBlockAppender } from './default-block-appender';\nexport { default as __unstableEditorStyles } from './editor-styles';\nexport { default as Inserter } from './inserter';\nexport { useBlockProps } from './block-list/use-block-props';\nexport { default as FloatingToolbar } from './floating-toolbar';\n\n// State Related Components.\nexport { default as BlockEditorProvider } from './provider';\n"],"mappings":"AAAA;AACA,SACCA,qBAAqB,EACrBC,qBAAqB,QACf,2BAA2B;AAClC,SAASC,oBAAoB,QAAQ,iBAAiB;AACtD,SACCC,OAAO,IAAIC,aAAa,EACxBC,mBAAmB,QACb,kBAAkB;AACzB,SAASF,OAAO,IAAIG,SAAS,EAAEC,mBAAmB,QAAQ,cAAc;AACxE,SAASJ,OAAO,IAAIK,SAAS,QAAQ,cAAc;AACnD,SACCC,6BAA6B,EAC7BC,6BAA6B,QACvB,oCAAoC;AAC3C,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,cAAc;AAC5B,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,qBAAqB;AACxE,SAAST,OAAO,IAAIU,WAAW,EAAEC,mBAAmB,QAAQ,gBAAgB;AAC5E,SACCX,OAAO,IAAIY,iBAAiB,EAC5BC,yBAAyB,QACnB,sBAAsB;AAC7B,SACCC,cAAc,EACdC,qBAAqB,QACf,2BAA2B;AAClC,SAASf,OAAO,IAAIgB,iBAAiB,QAAQ,uBAAuB;AACpE,SAAShB,OAAO,IAAIiB,oBAAoB,QAAQ,gCAAgC;AAChF,SAASjB,OAAO,IAAIkB,SAAS,QAAQ,cAAc;AACnD,SACClB,OAAO,IAAImB,QAAQ,EACnBC,gBAAgB,EAChBC,qBAAqB,EACrBC,4BAA4B,QACtB,aAAa;AACpB,SAAStB,OAAO,IAAIuB,gBAAgB,QAAQ,sBAAsB;AAClE,SAASvB,OAAO,IAAIwB,gBAAgB,QAAQ,qBAAqB;AACjE,SAASxB,OAAO,IAAIyB,WAAW,QAAQ,gBAAgB;AACvD,SACCC,gBAAgB,EAChBC,gBAAgB,EAChBC,gBAAgB,E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,SAAS9D,OAAO,IAAI+D,oBAAoB,QAAQ,0BAA0B;AAC1E,SAAS/D,OAAO,IAAIgE,sBAAsB,QAAQ,iBAAiB;AACnE,SAAShE,OAAO,IAAIiE,QAAQ,QAAQ,YAAY;AAChD,SAASC,aAAa,QAAQ,8BAA8B;AAC5D,SAASlE,OAAO,IAAImE,eAAe,QAAQ,oBAAoB;;AAE/D;AACA,SAASnE,OAAO,IAAIoE,mBAAmB,QAAQ,YAAY"}
1
+ {"version":3,"names":["BlockAlignmentControl","BlockAlignmentToolbar","BlockContextProvider","default","BlockControls","BlockFormatControls","BlockEdit","useBlockEditContext","BlockIcon","BlockVerticalAlignmentToolbar","BlockVerticalAlignmentControl","AlignmentControl","AlignmentToolbar","InnerBlocks","useInnerBlocksProps","InspectorControls","InspectorAdvancedControls","JustifyToolbar","JustifyContentControl","LineHeightControl","HeadingLevelDropdown","PlainText","RichText","RichTextShortcut","RichTextToolbarButton","__unstableRichTextInputEvent","MediaReplaceFlow","MediaPlaceholder","MediaUpload","MEDIA_TYPE_IMAGE","MEDIA_TYPE_VIDEO","MEDIA_TYPE_AUDIO","MEDIA_TYPE_ANY","MediaUploadProgress","MEDIA_UPLOAD_STATE_UPLOADING","MEDIA_UPLOAD_STATE_SUCCEEDED","MEDIA_UPLOAD_STATE_FAILED","MEDIA_UPLOAD_STATE_RESET","BlockMediaUpdateProgress","URLInput","BlockInvalidWarning","BlockCaption","Caption","PanelColorSettings","__experimentalPanelColorGradientSettings","useSetting","RecursionProvider","__experimentalRecursionProvider","useHasRecursion","__experimentalUseHasRecursion","Warning","ContrastChecker","useMultipleOriginColorsAndGradients","UnsupportedBlockDetails","BottomSheetSettings","BlockSettingsButton","blockSettingsScreens","VideoPlayer","VIDEO_ASPECT_RATIO","getSpacingPresetCssVar","getCustomValueFromPreset","isValueSpacingPreset","BlockList","BlockMover","BlockToolbar","BlockVariationPicker","BlockStyles","DefaultBlockAppender","__unstableEditorStyles","Inserter","useBlockProps","FloatingToolbar","BlockEditorProvider"],"sources":["@wordpress/block-editor/src/components/index.native.js"],"sourcesContent":["// Block Creation Components.\nexport {\n\tBlockAlignmentControl,\n\tBlockAlignmentToolbar,\n} from './block-alignment-control';\nexport { BlockContextProvider } from './block-context';\nexport {\n\tdefault as BlockControls,\n\tBlockFormatControls,\n} from './block-controls';\nexport { default as BlockEdit, useBlockEditContext } from './block-edit';\nexport { default as BlockIcon } from './block-icon';\nexport {\n\tBlockVerticalAlignmentToolbar,\n\tBlockVerticalAlignmentControl,\n} from './block-vertical-alignment-control';\nexport * from './colors';\nexport * from './gradients';\nexport * from './font-sizes';\nexport { AlignmentControl, AlignmentToolbar } from './alignment-control';\nexport { default as InnerBlocks, useInnerBlocksProps } from './inner-blocks';\nexport {\n\tdefault as InspectorControls,\n\tInspectorAdvancedControls,\n} from './inspector-controls';\nexport {\n\tJustifyToolbar,\n\tJustifyContentControl,\n} from './justify-content-control';\nexport { default as LineHeightControl } from './line-height-control';\nexport { default as HeadingLevelDropdown } from './block-heading-level-dropdown';\nexport { default as PlainText } from './plain-text';\nexport {\n\tdefault as RichText,\n\tRichTextShortcut,\n\tRichTextToolbarButton,\n\t__unstableRichTextInputEvent,\n} from './rich-text';\nexport { default as MediaReplaceFlow } from './media-replace-flow';\nexport { default as MediaPlaceholder } from './media-placeholder';\nexport { default as MediaUpload } from './media-upload';\nexport {\n\tMEDIA_TYPE_IMAGE,\n\tMEDIA_TYPE_VIDEO,\n\tMEDIA_TYPE_AUDIO,\n\tMEDIA_TYPE_ANY,\n} from './media-upload/constants';\nexport {\n\tdefault as MediaUploadProgress,\n\tMEDIA_UPLOAD_STATE_UPLOADING,\n\tMEDIA_UPLOAD_STATE_SUCCEEDED,\n\tMEDIA_UPLOAD_STATE_FAILED,\n\tMEDIA_UPLOAD_STATE_RESET,\n} from './media-upload-progress';\nexport { default as BlockMediaUpdateProgress } from './block-media-update-progress';\nexport { default as URLInput } from './url-input';\nexport { default as BlockInvalidWarning } from './block-list/block-invalid-warning';\nexport { default as BlockCaption } from './block-caption';\nexport { default as Caption } from './caption';\nexport { default as PanelColorSettings } from './panel-color-settings';\nexport { default as __experimentalPanelColorGradientSettings } from './colors-gradients/panel-color-gradient-settings';\nexport { default as useSetting } from './use-setting';\nexport {\n\tRecursionProvider as __experimentalRecursionProvider,\n\tuseHasRecursion as __experimentalUseHasRecursion,\n} from './recursion-provider';\nexport { default as Warning } from './warning';\nexport { default as ContrastChecker } from './contrast-checker';\nexport { default as useMultipleOriginColorsAndGradients } from './colors-gradients/use-multiple-origin-colors-and-gradients';\nexport { default as UnsupportedBlockDetails } from './unsupported-block-details';\n\nexport {\n\tBottomSheetSettings,\n\tBlockSettingsButton,\n\tblockSettingsScreens,\n} from './block-settings';\nexport { default as VideoPlayer, VIDEO_ASPECT_RATIO } from './video-player';\n\nexport {\n\tgetSpacingPresetCssVar,\n\tgetCustomValueFromPreset,\n\tisValueSpacingPreset,\n} from './spacing-sizes-control/utils';\n// Content Related Components.\nexport { default as BlockList } from './block-list';\nexport { default as BlockMover } from './block-mover';\nexport { default as BlockToolbar } from './block-toolbar';\nexport { default as BlockVariationPicker } from './block-variation-picker';\nexport { default as BlockStyles } from './block-styles';\nexport { default as DefaultBlockAppender } from './default-block-appender';\nexport { default as __unstableEditorStyles } from './editor-styles';\nexport { default as Inserter } from './inserter';\nexport { useBlockProps } from './block-list/use-block-props';\nexport { default as FloatingToolbar } from './floating-toolbar';\n\n// State Related Components.\nexport { default as BlockEditorProvider } from './provider';\n"],"mappings":"AAAA;AACA,SACCA,qBAAqB,EACrBC,qBAAqB,QACf,2BAA2B;AAClC,SAASC,oBAAoB,QAAQ,iBAAiB;AACtD,SACCC,OAAO,IAAIC,aAAa,EACxBC,mBAAmB,QACb,kBAAkB;AACzB,SAASF,OAAO,IAAIG,SAAS,EAAEC,mBAAmB,QAAQ,cAAc;AACxE,SAASJ,OAAO,IAAIK,SAAS,QAAQ,cAAc;AACnD,SACCC,6BAA6B,EAC7BC,6BAA6B,QACvB,oCA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tH,SAASzC,OAAO,IAAI0C,UAAU,QAAQ,eAAe;AACrD,SACCC,iBAAiB,IAAIC,+BAA+B,EACpDC,eAAe,IAAIC,6BAA6B,QAC1C,sBAAsB;AAC7B,SAAS9C,OAAO,IAAI+C,OAAO,QAAQ,WAAW;AAC9C,SAAS/C,OAAO,IAAIgD,eAAe,QAAQ,oBAAoB;AAC/D,SAAShD,OAAO,IAAIiD,mCAAmC,QAAQ,6DAA6D;AAC5H,SAASjD,OAAO,IAAIkD,uBAAuB,QAAQ,6BAA6B;AAEhF,SACCC,mBAAmB,EACnBC,mBAAmB,EACnBC,oBAAoB,QACd,kBAAkB;AACzB,SAASrD,OAAO,IAAIsD,WAAW,EAAEC,kBAAkB,QAAQ,gBAAgB;AAE3E,SACCC,sBAAsB,EACtBC,wBAAwB,EACxBC,oBAAoB,QACd,+BAA+B;AACtC;AACA,SAAS1D,OAAO,IAAI2D,SAAS,QAAQ,cAAc;AACnD,SAAS3D,OAAO,IAAI4D,UAAU,QAAQ,eAAe;AACrD,SAAS5D,OAAO,IAAI6D,YAAY,QAAQ,iBAAiB;AACzD,SAAS7D,OAAO,IAAI8D,oBAAoB,QAAQ,0BAA0B;AAC1E,SAAS9D,OAAO,IAAI+D,WAAW,QAAQ,gBAAgB;AACvD,SAAS/D,OAAO,IAAIgE,oBAAoB,QAAQ,0BAA0B;AAC1E,SAAShE,OAAO,IAAIiE,sBAAsB,QAAQ,iBAAiB;AACnE,SAASjE,OAAO,IAAIkE,QAAQ,QAAQ,YAAY;AAChD,SAASC,aAAa,QAAQ,8BAA8B;AAC5D,SAASnE,OAAO,IAAIoE,eAAe,QAAQ,oBAAoB;;AAE/D;AACA,SAASpE,OAAO,IAAIqE,mBAAmB,QAAQ,YAAY"}
@@ -8,7 +8,7 @@ import classnames from 'classnames';
8
8
  * WordPress dependencies
9
9
  */
10
10
  import { __ } from '@wordpress/i18n';
11
- import { Button, ExternalLink, __experimentalText as Text } from '@wordpress/components';
11
+ import { Button, ExternalLink, __experimentalText as Text, Tooltip } from '@wordpress/components';
12
12
  import { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';
13
13
  import { Icon, globe, info, linkOff, edit } from '@wordpress/icons';
14
14
  import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
@@ -76,10 +76,13 @@ export default function LinkPreview({
76
76
  })
77
77
  }, icon), createElement("span", {
78
78
  className: "block-editor-link-control__search-item-details"
79
- }, !isEmptyURL ? createElement(Fragment, null, createElement(ExternalLink, {
79
+ }, !isEmptyURL ? createElement(Fragment, null, createElement(Tooltip, {
80
+ text: value.url,
81
+ placement: "bottom-start"
82
+ }, createElement(ExternalLink, {
80
83
  className: "block-editor-link-control__search-item-title",
81
84
  href: value.url
82
- }, displayTitle), value?.url && displayTitle !== displayURL && createElement("span", {
85
+ }, displayTitle)), value?.url && displayTitle !== displayURL && createElement("span", {
83
86
  className: "block-editor-link-control__search-item-info"
84
87
  }, displayURL)) : createElement("span", {
85
88
  className: "block-editor-link-control__search-item-error-notice"
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","__","Button","ExternalLink","__experimentalText","Text","filterURLForDisplay","safeDecodeURI","Icon","globe","info","linkOff","edit","__unstableStripHTML","stripHTML","ViewerSlot","useRichUrlData","LinkPreview","value","onEditClick","hasRichPreviews","hasUnlinkControl","onRemove","additionalControls","showRichPreviews","url","richData","isFetching","hasRichData","Object","keys","length","displayURL","isEmptyURL","displayTitle","title","icon","createElement","src","alt","size","className","Fragment","href","label","onClick","iconSize","fillProps","image","description","truncate","numberOfLines"],"sources":["@wordpress/block-editor/src/components/link-control/link-preview.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tExternalLink,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';\nimport { Icon, globe, info, linkOff, edit } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { ViewerSlot } from './viewer-slot';\n\nimport useRichUrlData from './use-rich-url-data';\n\nexport default function LinkPreview( {\n\tvalue,\n\tonEditClick,\n\thasRichPreviews = false,\n\thasUnlinkControl = false,\n\tonRemove,\n\tadditionalControls,\n} ) {\n\t// Avoid fetching if rich previews are not desired.\n\tconst showRichPreviews = hasRichPreviews ? value?.url : null;\n\n\tconst { richData, isFetching } = useRichUrlData( showRichPreviews );\n\n\t// Rich data may be an empty object so test for that.\n\tconst hasRichData = richData && Object.keys( richData ).length;\n\n\tconst displayURL =\n\t\t( value && filterURLForDisplay( safeDecodeURI( value.url ), 16 ) ) ||\n\t\t'';\n\n\t// url can be undefined if the href attribute is unset\n\tconst isEmptyURL = ! value?.url?.length;\n\n\tconst displayTitle =\n\t\t! isEmptyURL &&\n\t\tstripHTML( richData?.title || value?.title || displayURL );\n\n\tlet icon;\n\n\tif ( richData?.icon ) {\n\t\ticon = <img src={ richData?.icon } alt=\"\" />;\n\t} else if ( isEmptyURL ) {\n\t\ticon = <Icon icon={ info } size={ 32 } />;\n\t} else {\n\t\ticon = <Icon icon={ globe } />;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\taria-label={ __( 'Currently selected' ) }\n\t\t\tclassName={ classnames( 'block-editor-link-control__search-item', {\n\t\t\t\t'is-current': true,\n\t\t\t\t'is-rich': hasRichData,\n\t\t\t\t'is-fetching': !! isFetching,\n\t\t\t\t'is-preview': true,\n\t\t\t\t'is-error': isEmptyURL,\n\t\t\t\t'is-url-title': displayTitle === displayURL,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div className=\"block-editor-link-control__search-item-top\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-link-control__search-item-icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-image': richData?.icon,\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{ icon }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"block-editor-link-control__search-item-details\">\n\t\t\t\t\t\t{ ! isEmptyURL ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-title\"\n\t\t\t\t\t\t\t\t\thref={ value.url }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t\t\t\t</ExternalLink>\n\n\t\t\t\t\t\t\t\t{ value?.url && displayTitle !== displayURL && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-info\">\n\t\t\t\t\t\t\t\t\t\t{ displayURL }\n\t\t\t\t\t\t\t\t\t</span>\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\t\t<span className=\"block-editor-link-control__search-item-error-notice\">\n\t\t\t\t\t\t\t\t{ __( 'Link is empty' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\n\t\t\t\t<Button\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action\"\n\t\t\t\t\tonClick={ onEditClick }\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t/>\n\t\t\t\t{ hasUnlinkControl && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Unlink' ) }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action block-editor-link-control__unlink\"\n\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<ViewerSlot fillProps={ value } />\n\t\t\t</div>\n\n\t\t\t{ !! (\n\t\t\t\t( hasRichData &&\n\t\t\t\t\t( richData?.image || richData?.description ) ) ||\n\t\t\t\tisFetching\n\t\t\t) && (\n\t\t\t\t<div className=\"block-editor-link-control__search-item-bottom\">\n\t\t\t\t\t{ ( richData?.image || isFetching ) && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\taria-hidden={ ! richData?.image }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-link-control__search-item-image',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-placeholder': ! richData?.image,\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\t\t{ richData?.image && (\n\t\t\t\t\t\t\t\t<img src={ richData?.image } alt=\"\" />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ( richData?.description || isFetching ) && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\taria-hidden={ ! richData?.description }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-link-control__search-item-description',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-placeholder': ! richData?.description,\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\t\t{ richData?.description && (\n\t\t\t\t\t\t\t\t<Text truncate numberOfLines=\"2\">\n\t\t\t\t\t\t\t\t\t{ richData.description }\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ additionalControls && additionalControls() }\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YA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C6C,QAAQ;IAACC,aAAa,EAAC;EAAG,GAC7BzB,QAAQ,CAACuB,WACN,CAEH,CAEF,CACL,EAEC1B,kBAAkB,IAAIA,kBAAkB,CAAC,CACvC,CAAC;AAER"}
1
+ {"version":3,"names":["classnames","__","Button","ExternalLink","__experimentalText","Text","Tooltip","filterURLForDisplay","safeDecodeURI","Icon","globe","info","linkOff","edit","__unstableStripHTML","stripHTML","ViewerSlot","useRichUrlData","LinkPreview","value","onEditClick","hasRichPreviews","hasUnlinkControl","onRemove","additionalControls","showRichPreviews","url","richData","isFetching","hasRichData","Object","keys","length","displayURL","isEmptyURL","displayTitle","title","icon","createElement","src","alt","size","className","Fragment","text","placement","href","label","onClick","iconSize","fillProps","image","description","truncate","numberOfLines"],"sources":["@wordpress/block-editor/src/components/link-control/link-preview.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tExternalLink,\n\t__experimentalText as Text,\n\tTooltip,\n} from '@wordpress/components';\nimport { filterURLForDisplay, safeDecodeURI } from '@wordpress/url';\nimport { Icon, globe, info, linkOff, edit } from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { ViewerSlot } from './viewer-slot';\n\nimport useRichUrlData from './use-rich-url-data';\n\nexport default function LinkPreview( {\n\tvalue,\n\tonEditClick,\n\thasRichPreviews = false,\n\thasUnlinkControl = false,\n\tonRemove,\n\tadditionalControls,\n} ) {\n\t// Avoid fetching if rich previews are not desired.\n\tconst showRichPreviews = hasRichPreviews ? value?.url : null;\n\n\tconst { richData, isFetching } = useRichUrlData( showRichPreviews );\n\n\t// Rich data may be an empty object so test for that.\n\tconst hasRichData = richData && Object.keys( richData ).length;\n\n\tconst displayURL =\n\t\t( value && filterURLForDisplay( safeDecodeURI( value.url ), 16 ) ) ||\n\t\t'';\n\n\t// url can be undefined if the href attribute is unset\n\tconst isEmptyURL = ! value?.url?.length;\n\n\tconst displayTitle =\n\t\t! isEmptyURL &&\n\t\tstripHTML( richData?.title || value?.title || displayURL );\n\n\tlet icon;\n\n\tif ( richData?.icon ) {\n\t\ticon = <img src={ richData?.icon } alt=\"\" />;\n\t} else if ( isEmptyURL ) {\n\t\ticon = <Icon icon={ info } size={ 32 } />;\n\t} else {\n\t\ticon = <Icon icon={ globe } />;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\taria-label={ __( 'Currently selected' ) }\n\t\t\tclassName={ classnames( 'block-editor-link-control__search-item', {\n\t\t\t\t'is-current': true,\n\t\t\t\t'is-rich': hasRichData,\n\t\t\t\t'is-fetching': !! isFetching,\n\t\t\t\t'is-preview': true,\n\t\t\t\t'is-error': isEmptyURL,\n\t\t\t\t'is-url-title': displayTitle === displayURL,\n\t\t\t} ) }\n\t\t>\n\t\t\t<div className=\"block-editor-link-control__search-item-top\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-link-control__search-item-icon',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-image': richData?.icon,\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{ icon }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"block-editor-link-control__search-item-details\">\n\t\t\t\t\t\t{ ! isEmptyURL ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<Tooltip\n\t\t\t\t\t\t\t\t\ttext={ value.url }\n\t\t\t\t\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-title\"\n\t\t\t\t\t\t\t\t\t\thref={ value.url }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ displayTitle }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t</Tooltip>\n\n\t\t\t\t\t\t\t\t{ value?.url && displayTitle !== displayURL && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-link-control__search-item-info\">\n\t\t\t\t\t\t\t\t\t\t{ displayURL }\n\t\t\t\t\t\t\t\t\t</span>\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\t\t<span className=\"block-editor-link-control__search-item-error-notice\">\n\t\t\t\t\t\t\t\t{ __( 'Link is empty' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\n\t\t\t\t<Button\n\t\t\t\t\ticon={ edit }\n\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action\"\n\t\t\t\t\tonClick={ onEditClick }\n\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t/>\n\t\t\t\t{ hasUnlinkControl && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\tlabel={ __( 'Unlink' ) }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-item-action block-editor-link-control__unlink\"\n\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<ViewerSlot fillProps={ value } />\n\t\t\t</div>\n\n\t\t\t{ !! (\n\t\t\t\t( hasRichData &&\n\t\t\t\t\t( richData?.image || richData?.description ) ) ||\n\t\t\t\tisFetching\n\t\t\t) && (\n\t\t\t\t<div className=\"block-editor-link-control__search-item-bottom\">\n\t\t\t\t\t{ ( richData?.image || isFetching ) && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\taria-hidden={ ! richData?.image }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-link-control__search-item-image',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-placeholder': ! richData?.image,\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\t\t{ richData?.image && (\n\t\t\t\t\t\t\t\t<img src={ richData?.image } alt=\"\" />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ( richData?.description || isFetching ) && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\taria-hidden={ ! richData?.description }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-link-control__search-item-description',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-placeholder': ! richData?.description,\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\t\t{ richData?.description && (\n\t\t\t\t\t\t\t\t<Text truncate numberOfLines=\"2\">\n\t\t\t\t\t\t\t\t\t{ richData.description }\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ additionalControls && additionalControls() }\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,MAAM,EACNC,YAAY,EACZC,kBAAkB,IAAIC,IAAI,EAC1BC,OAAO,QACD,uBAAuB;AAC9B,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,gBAAgB;AACnE,SAASC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,OAAO,EAAEC,IAAI,QAAQ,kBAAkB;AACnE,SAASC,mBAAmB,IAAI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
4
- import { useState, useEffect } from '@wordpress/element';
4
+ import { useState } from '@wordpress/element';
5
+
6
+ /**
7
+ * External dependencies
8
+ */
9
+ import fastDeepEqual from 'fast-deep-equal';
5
10
  export default function useInternalValue(value) {
6
11
  const [internalValue, setInternalValue] = useState(value || {});
12
+ const [previousValue, setPreviousValue] = useState(value);
7
13
 
8
14
  // If the value prop changes, update the internal state.
9
- useEffect(() => {
10
- setInternalValue(prevValue => {
11
- if (value && value !== prevValue) {
12
- return value;
13
- }
14
- return prevValue;
15
- });
16
- }, [value]);
15
+ // See:
16
+ // - https://github.com/WordPress/gutenberg/pull/51387#issuecomment-1722927384.
17
+ // - https://react.dev/reference/react/useState#storing-information-from-previous-renders.
18
+ if (!fastDeepEqual(value, previousValue)) {
19
+ setPreviousValue(value);
20
+ setInternalValue(value);
21
+ }
17
22
  const setInternalURLInputValue = nextValue => {
18
23
  setInternalValue({
19
24
  ...internalValue,
@@ -1 +1 @@
1
- {"version":3,"names":["useState","useEffect","useInternalValue","value","internalValue","setInternalValue","prevValue","setInternalURLInputValue","nextValue","url","setInternalTextInputValue","title","createSetInternalSettingValueHandler","settingsKeys","settingsUpdates","Object","keys","reduce","acc","key","includes"],"sources":["@wordpress/block-editor/src/components/link-control/use-internal-value.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\n\nexport default function useInternalValue( value ) {\n\tconst [ internalValue, setInternalValue ] = useState( value || {} );\n\n\t// If the value prop changes, update the internal state.\n\tuseEffect( () => {\n\t\tsetInternalValue( ( prevValue ) => {\n\t\t\tif ( value && value !== prevValue ) {\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\treturn prevValue;\n\t\t} );\n\t}, [ value ] );\n\n\tconst setInternalURLInputValue = ( nextValue ) => {\n\t\tsetInternalValue( {\n\t\t\t...internalValue,\n\t\t\turl: nextValue,\n\t\t} );\n\t};\n\n\tconst setInternalTextInputValue = ( nextValue ) => {\n\t\tsetInternalValue( {\n\t\t\t...internalValue,\n\t\t\ttitle: nextValue,\n\t\t} );\n\t};\n\n\tconst createSetInternalSettingValueHandler =\n\t\t( settingsKeys ) => ( nextValue ) => {\n\t\t\t// Only apply settings values which are defined in the settings prop.\n\t\t\tconst settingsUpdates = Object.keys( nextValue ).reduce(\n\t\t\t\t( acc, key ) => {\n\t\t\t\t\tif ( settingsKeys.includes( key ) ) {\n\t\t\t\t\t\tacc[ key ] = nextValue[ key ];\n\t\t\t\t\t}\n\t\t\t\t\treturn acc;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\tsetInternalValue( {\n\t\t\t\t...internalValue,\n\t\t\t\t...settingsUpdates,\n\t\t\t} );\n\t\t};\n\n\treturn [\n\t\tinternalValue,\n\t\tsetInternalValue,\n\t\tsetInternalURLInputValue,\n\t\tsetInternalTextInputValue,\n\t\tcreateSetInternalSettingValueHandler,\n\t];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;AAExD,eAAe,SAASC,gBAAgBA,CAAEC,KAAK,EAAG;EACjD,MAAM,CAAEC,aAAa,EAAEC,gBAAgB,CAAE,GAAGL,QAAQ,CAAEG,KAAK,IAAI,CAAC,CAAE,CAAC;;EAEnE;EACAF,SAAS,CAAE,MAAM;IAChBI,gBAAgB,CAAIC,SAAS,IAAM;MAClC,IAAKH,KAAK,IAAIA,KAAK,KAAKG,SAAS,EAAG;QACnC,OAAOH,KAAK;MACb;MAEA,OAAOG,SAAS;IACjB,CAAE,CAAC;EACJ,CAAC,EAAE,CAAEH,KAAK,CAAG,CAAC;EAEd,MAAMI,wBAAwB,GAAKC,SAAS,IAAM;IACjDH,gBAAgB,CAAE;MACjB,GAAGD,aAAa;MAChBK,GAAG,EAAED;IACN,CAAE,CAAC;EACJ,CAAC;EAED,MAAME,yBAAyB,GAAKF,SAAS,IAAM;IAClDH,gBAAgB,CAAE;MACjB,GAAGD,aAAa;MAChBO,KAAK,EAAEH;IACR,CAAE,CAAC;EACJ,CAAC;EAED,MAAMI,oCAAoC,GACvCC,YAAY,IAAQL,SAAS,IAAM;IACpC;IACA,MAAMM,eAAe,GAAGC,MAAM,CAACC,IAAI,CAAER,SAAU,CAAC,CAACS,MAAM,CACtD,CAAEC,GAAG,EAAEC,GAAG,KAAM;MACf,IAAKN,YAAY,CAACO,QAAQ,CAAED,GAAI,CAAC,EAAG;QACnCD,GAAG,CAAEC,GAAG,CAAE,GAAGX,SAAS,CAAEW,GAAG,CAAE;MAC9B;MACA,OAAOD,GAAG;IACX,CAAC,EACD,CAAC,CACF,CAAC;IAEDb,gBAAgB,CAAE;MACjB,GAAGD,aAAa;MAChB,GAAGU;IACJ,CAAE,CAAC;EACJ,CAAC;EAEF,OAAO,CACNV,aAAa,EACbC,gBAAgB,EAChBE,wBAAwB,EACxBG,yBAAyB,EACzBE,oCAAoC,CACpC;AACF"}
1
+ {"version":3,"names":["useState","fastDeepEqual","useInternalValue","value","internalValue","setInternalValue","previousValue","setPreviousValue","setInternalURLInputValue","nextValue","url","setInternalTextInputValue","title","createSetInternalSettingValueHandler","settingsKeys","settingsUpdates","Object","keys","reduce","acc","key","includes"],"sources":["@wordpress/block-editor/src/components/link-control/use-internal-value.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\n/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal';\n\nexport default function useInternalValue( value ) {\n\tconst [ internalValue, setInternalValue ] = useState( value || {} );\n\tconst [ previousValue, setPreviousValue ] = useState( value );\n\n\t// If the value prop changes, update the internal state.\n\t// See:\n\t// - https://github.com/WordPress/gutenberg/pull/51387#issuecomment-1722927384.\n\t// - https://react.dev/reference/react/useState#storing-information-from-previous-renders.\n\tif ( ! fastDeepEqual( value, previousValue ) ) {\n\t\tsetPreviousValue( value );\n\t\tsetInternalValue( value );\n\t}\n\n\tconst setInternalURLInputValue = ( nextValue ) => {\n\t\tsetInternalValue( {\n\t\t\t...internalValue,\n\t\t\turl: nextValue,\n\t\t} );\n\t};\n\n\tconst setInternalTextInputValue = ( nextValue ) => {\n\t\tsetInternalValue( {\n\t\t\t...internalValue,\n\t\t\ttitle: nextValue,\n\t\t} );\n\t};\n\n\tconst createSetInternalSettingValueHandler =\n\t\t( settingsKeys ) => ( nextValue ) => {\n\t\t\t// Only apply settings values which are defined in the settings prop.\n\t\t\tconst settingsUpdates = Object.keys( nextValue ).reduce(\n\t\t\t\t( acc, key ) => {\n\t\t\t\t\tif ( settingsKeys.includes( key ) ) {\n\t\t\t\t\t\tacc[ key ] = nextValue[ key ];\n\t\t\t\t\t}\n\t\t\t\t\treturn acc;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\tsetInternalValue( {\n\t\t\t\t...internalValue,\n\t\t\t\t...settingsUpdates,\n\t\t\t} );\n\t\t};\n\n\treturn [\n\t\tinternalValue,\n\t\tsetInternalValue,\n\t\tsetInternalURLInputValue,\n\t\tsetInternalTextInputValue,\n\t\tcreateSetInternalSettingValueHandler,\n\t];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,OAAOC,aAAa,MAAM,iBAAiB;AAE3C,eAAe,SAASC,gBAAgBA,CAAEC,KAAK,EAAG;EACjD,MAAM,CAAEC,aAAa,EAAEC,gBAAgB,CAAE,GAAGL,QAAQ,CAAEG,KAAK,IAAI,CAAC,CAAE,CAAC;EACnE,MAAM,CAAEG,aAAa,EAAEC,gBAAgB,CAAE,GAAGP,QAAQ,CAAEG,KAAM,CAAC;;EAE7D;EACA;EACA;EACA;EACA,IAAK,CAAEF,aAAa,CAAEE,KAAK,EAAEG,aAAc,CAAC,EAAG;IAC9CC,gBAAgB,CAAEJ,KAAM,CAAC;IACzBE,gBAAgB,CAAEF,KAAM,CAAC;EAC1B;EAEA,MAAMK,wBAAwB,GAAKC,SAAS,IAAM;IACjDJ,gBAAgB,CAAE;MACjB,GAAGD,aAAa;MAChBM,GAAG,EAAED;IACN,CAAE,CAAC;EACJ,CAAC;EAED,MAAME,yBAAyB,GAAKF,SAAS,IAAM;IAClDJ,gBAAgB,CAAE;MACjB,GAAGD,aAAa;MAChBQ,KAAK,EAAEH;IACR,CAAE,CAAC;EACJ,CAAC;EAED,MAAMI,oCAAoC,GACvCC,YAAY,IAAQL,SAAS,IAAM;IACpC;IACA,MAAMM,eAAe,GAAGC,MAAM,CAACC,IAAI,CAAER,SAAU,CAAC,CAACS,MAAM,CACtD,CAAEC,GAAG,EAAEC,GAAG,KAAM;MACf,IAAKN,YAAY,CAACO,QAAQ,CAAED,GAAI,CAAC,EAAG;QACnCD,GAAG,CAAEC,GAAG,CAAE,GAAGX,SAAS,CAAEW,GAAG,CAAE;MAC9B;MACA,OAAOD,GAAG;IACX,CAAC,EACD,CAAC,CACF,CAAC;IAEDd,gBAAgB,CAAE;MACjB,GAAGD,aAAa;MAChB,GAAGW;IACJ,CAAE,CAAC;EACJ,CAAC;EAEF,OAAO,CACNX,aAAa,EACbC,gBAAgB,EAChBG,wBAAwB,EACxBG,yBAAyB,EACzBE,oCAAoC,CACpC;AACF"}
@@ -3,7 +3,7 @@ import { createElement } from "react";
3
3
  * WordPress dependencies
4
4
  */
5
5
  import { useInstanceId, useMergeRefs, __experimentalUseFixedWindowList as useFixedWindowList } from '@wordpress/compose';
6
- import { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';
6
+ import { __experimentalTreeGrid as TreeGrid, VisuallyHidden } from '@wordpress/components';
7
7
  import { AsyncModeProvider, useSelect } from '@wordpress/data';
8
8
  import deprecated from '@wordpress/deprecated';
9
9
  import { useCallback, useEffect, useMemo, useRef, useReducer, forwardRef, useState } from '@wordpress/element';
@@ -204,12 +204,15 @@ function ListViewComponent({
204
204
  if (!clientIdsTree.length && !showAppender) {
205
205
  return null;
206
206
  }
207
+ const describedById = description && `block-editor-list-view-description-${instanceId}`;
207
208
  return createElement(AsyncModeProvider, {
208
209
  value: true
209
210
  }, createElement(ListViewDropIndicator, {
210
211
  listViewRef: elementRef,
211
212
  blockDropTarget: blockDropTarget
212
- }), createElement(TreeGrid, {
213
+ }), description && createElement(VisuallyHidden, {
214
+ id: describedById
215
+ }, description), createElement(TreeGrid, {
213
216
  id: id,
214
217
  className: "block-editor-list-view-tree",
215
218
  "aria-label": __('Block navigation structure'),
@@ -217,10 +220,8 @@ function ListViewComponent({
217
220
  onCollapseRow: collapseRow,
218
221
  onExpandRow: expandRow,
219
222
  onFocusRow: focusRow,
220
- applicationAriaLabel: __('Block navigation structure')
221
- // eslint-disable-next-line jsx-a11y/aria-props
222
- ,
223
- "aria-description": description
223
+ applicationAriaLabel: __('Block navigation structure'),
224
+ "aria-describedby": describedById
224
225
  }, createElement(ListViewContext.Provider, {
225
226
  value: contextValue
226
227
  }, createElement(ListViewBranch, {
@@ -1 +1 @@
1
- {"version":3,"names":["useInstanceId","useMergeRefs","__experimentalUseFixedWindowList","useFixedWindowList","__experimentalTreeGrid","TreeGrid","AsyncModeProvider","useSelect","deprecated","useCallback","useEffect","useMemo","useRef","useReducer","forwardRef","useState","__","ListViewBranch","ListViewContext","ListViewDropIndicator","useBlockSelection","useListViewClientIds","useListViewDropZone","useListViewExpandSelectedItem","store","blockEditorStore","BlockSettingsDropdown","focusListItem","expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","ListViewComponent","blocks","dropZoneElement","showBlockMovers","isExpanded","showAppender","blockSettingsMenu","BlockSettingsMenu","rootClientId","description","onSelect","additionalBlockContent","AdditionalBlockContent","ref","since","alternative","instanceId","clientIdsTree","draggedClientIds","selectedClientIds","getBlock","visibleBlockCount","shouldShowInnerBlocks","select","getGlobalBlockCount","getClientIdsOfDescendants","__unstableGetEditorMode","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","insertedBlock","setInsertedBlock","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","blockClientId","focusPosition","expand","clientId","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","listViewInstanceId","treeGridElementRef","fixedListWindow","useWindowing","windowOverscan","createElement","value","listViewRef","className","onCollapseRow","onExpandRow","onFocusRow","applicationAriaLabel","Provider","parentId","selectBlock","PrivateListView","props","undefined"],"sources":["@wordpress/block-editor/src/components/list-view/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseInstanceId,\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockSettingsDropdown } from '../block-settings-menu/block-settings-dropdown';\nimport { focusListItem } from './utils';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/** @typedef {import('react').ComponentType} ComponentType */\n/** @typedef {import('react').Ref<HTMLElement>} Ref */\n\n/**\n * Show a hierarchical list of blocks.\n *\n * @param {Object} props Components props.\n * @param {string} props.id An HTML element id for the root element of ListView.\n * @param {Array} props.blocks _deprecated_ Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {?HTMLElement} props.dropZoneElement Optional element to be used as the drop zone.\n * @param {?boolean} props.showBlockMovers Flag to enable block movers. Defaults to `false`.\n * @param {?boolean} props.isExpanded Flag to determine whether nested levels are expanded by default. Defaults to `false`.\n * @param {?boolean} props.showAppender Flag to show or hide the block appender. Defaults to `false`.\n * @param {?ComponentType} props.blockSettingsMenu Optional more menu substitution. Defaults to the standard `BlockSettingsDropdown` component.\n * @param {string} props.rootClientId The client id of the root block from which we determine the blocks to show in the list.\n * @param {string} props.description Optional accessible description for the tree grid component.\n * @param {?Function} props.onSelect Optional callback to be invoked when a block is selected. Receives the block object that was selected.\n * @param {?ComponentType} props.additionalBlockContent Component that renders additional block content UI.\n * @param {Ref} ref Forwarded ref\n */\nfunction ListViewComponent(\n\t{\n\t\tid,\n\t\tblocks,\n\t\tdropZoneElement,\n\t\tshowBlockMovers = false,\n\t\tisExpanded = false,\n\t\tshowAppender = false,\n\t\tblockSettingsMenu: BlockSettingsMenu = BlockSettingsDropdown,\n\t\trootClientId,\n\t\tdescription,\n\t\tonSelect,\n\t\tadditionalBlockContent: AdditionalBlockContent,\n\t},\n\tref\n) {\n\t// This can be removed once we no longer need to support the blocks prop.\n\tif ( blocks ) {\n\t\tdeprecated(\n\t\t\t'`blocks` property in `wp.blockEditor.__experimentalListView`',\n\t\t\t{\n\t\t\t\tsince: '6.3',\n\t\t\t\talternative: '`rootClientId` property',\n\t\t\t}\n\t\t);\n\t}\n\n\tconst instanceId = useInstanceId( ListViewComponent );\n\tconst { clientIdsTree, draggedClientIds, selectedClientIds } =\n\t\tuseListViewClientIds( { blocks, rootClientId } );\n\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst { visibleBlockCount, shouldShowInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t\tshouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone( {\n\t\tdropZoneElement,\n\t} );\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst [ insertedBlock, setInsertedBlock ] = useState( null );\n\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t/**\n\t\t * @param {MouseEvent | KeyboardEvent | undefined} event\n\t\t * @param {string} blockClientId\n\t\t * @param {null | undefined | -1 | 1} focusPosition\n\t\t */\n\t\t( event, blockClientId, focusPosition ) => {\n\t\t\tupdateBlockSelection( event, blockClientId, null, focusPosition );\n\t\t\tsetSelectedTreeId( blockClientId );\n\t\t\tif ( onSelect ) {\n\t\t\t\tonSelect( getBlock( blockClientId ) );\n\t\t\t}\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection, onSelect, getBlock ]\n\t);\n\tuseEffect( () => {\n\t\t// If a blocks are already selected when the list view is initially\n\t\t// mounted, shift focus to the first selected block.\n\t\tif ( selectedClientIds?.length ) {\n\t\t\tfocusListItem( selectedClientIds[ 0 ], elementRef );\n\t\t}\n\t\t// Disable reason: Only focus on the selected item when the list view is mounted.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tconst expand = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'expand', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'collapse', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tBlockSettingsMenu,\n\t\t\tlistViewInstanceId: instanceId,\n\t\t\tAdditionalBlockContent,\n\t\t\tinsertedBlock,\n\t\t\tsetInsertedBlock,\n\t\t\ttreeGridElementRef: elementRef,\n\t\t} ),\n\t\t[\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tBlockSettingsMenu,\n\t\t\tinstanceId,\n\t\t\tAdditionalBlockContent,\n\t\t\tinsertedBlock,\n\t\t\tsetInsertedBlock,\n\t\t]\n\t);\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\t// Ensure that the windowing logic is recalculated when the expanded state changes.\n\t\t\t// This is necessary because expanding a collapsed block in a short list view can\n\t\t\t// switch the list view to a tall list view with a scrollbar, and vice versa.\n\t\t\t// When this happens, the windowing logic needs to be recalculated to ensure that\n\t\t\t// the correct number of blocks are rendered, by rechecking for a scroll container.\n\t\t\texpandedState,\n\t\t\tuseWindowing: true,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\t// If there are no blocks to show and we're not showing the appender, do not render the list view.\n\tif ( ! clientIdsTree.length && ! showAppender ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<TreeGrid\n\t\t\t\tid={ id }\n\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\tref={ treeGridRef }\n\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\tonFocusRow={ focusRow }\n\t\t\t\tapplicationAriaLabel={ __( 'Block navigation structure' ) }\n\t\t\t\t// eslint-disable-next-line jsx-a11y/aria-props\n\t\t\t\taria-description={ description }\n\t\t\t>\n\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\tparentId={ rootClientId }\n\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t\tshowAppender={ showAppender }\n\t\t\t\t\t/>\n\t\t\t\t</ListViewContext.Provider>\n\t\t\t</TreeGrid>\n\t\t</AsyncModeProvider>\n\t);\n}\n\n// This is the private API for the ListView component.\n// It allows access to all props, not just the public ones.\nexport const PrivateListView = forwardRef( ListViewComponent );\n\n// This is the public API for the ListView component.\n// We wrap the PrivateListView component to hide some props from the public API.\nexport default forwardRef( ( props, ref ) => {\n\treturn (\n\t\t<PrivateListView\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t\tshowAppender={ false }\n\t\t\trootClientId={ null }\n\t\t\tonSelect={ null }\n\t\t\tadditionalBlockContent={ null }\n\t\t\tblockSettingsMenu={ undefined }\n\t\t/>\n\t);\n} );\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,YAAY,EACZC,gCAAgC,IAAIC,kBAAkB,QAChD,oBAAoB;AAC3B,SAASC,sBAAsB,IAAIC,QAAQ,QAAQ,uBAAuB;AAC1E,SAASC,iBAAiB,EAAEC,SAAS,QAAQ,iBAAiB;AAC9D,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,SACCC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,UAAU,EACVC,UAAU,EACVC,QAAQ,QACF,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,cAAc,MAAM,UAAU;AACrC,SAASC,eAAe,QAAQ,WAAW;AAC3C,OAAOC,qBAAqB,MAAM,kBAA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AAG,IAAM;IAC/BL,iBAAiB,EAAGsE;EAAW,CAC/B,CAAC;AAEJ,CAAE,CAAC"}
1
+ {"version":3,"names":["useInstanceId","useMergeRefs","__experimentalUseFixedWindowList","useFixedWindowList","__experimentalTreeGrid","TreeGrid","VisuallyHidden","AsyncModeProvider","useSelect","deprecated","useCallback","useEffect","useMemo","useRef","useReducer","forwardRef","useState","__","ListViewBranch","ListViewContext","ListViewDropIndicator","useBlockSelection","useListViewClientIds","useListViewDropZone","useListViewExpandSelectedItem","store","blockEditorStore","BlockSettingsDropdown","focusListItem","expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","ListViewComponent","blocks","dropZoneElement","showBlockMovers","isExpanded","showAppender","blockSettingsMenu","BlockSettingsMenu","rootClientId","description","onSelect","additionalBlockContent","AdditionalBlockContent","ref","since","alternative","instanceId","clientIdsTree","draggedClientIds","selectedClientIds","getBlock","visibleBlockCount","shouldShowInnerBlocks","select","getGlobalBlockCount","getClientIdsOfDescendants","__unstableGetEditorMode","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","insertedBlock","setInsertedBlock","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","blockClientId","focusPosition","expand","clientId","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","listViewInstanceId","treeGridElementRef","fixedListWindow","useWindowing","windowOverscan","describedById","createElement","value","listViewRef","className","onCollapseRow","onExpandRow","onFocusRow","applicationAriaLabel","Provider","parentId","selectBlock","PrivateListView","props","undefined"],"sources":["@wordpress/block-editor/src/components/list-view/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseInstanceId,\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport {\n\t__experimentalTreeGrid as TreeGrid,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockSettingsDropdown } from '../block-settings-menu/block-settings-dropdown';\nimport { focusListItem } from './utils';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/** @typedef {import('react').ComponentType} ComponentType */\n/** @typedef {import('react').Ref<HTMLElement>} Ref */\n\n/**\n * Show a hierarchical list of blocks.\n *\n * @param {Object} props Components props.\n * @param {string} props.id An HTML element id for the root element of ListView.\n * @param {Array} props.blocks _deprecated_ Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {?HTMLElement} props.dropZoneElement Optional element to be used as the drop zone.\n * @param {?boolean} props.showBlockMovers Flag to enable block movers. Defaults to `false`.\n * @param {?boolean} props.isExpanded Flag to determine whether nested levels are expanded by default. Defaults to `false`.\n * @param {?boolean} props.showAppender Flag to show or hide the block appender. Defaults to `false`.\n * @param {?ComponentType} props.blockSettingsMenu Optional more menu substitution. Defaults to the standard `BlockSettingsDropdown` component.\n * @param {string} props.rootClientId The client id of the root block from which we determine the blocks to show in the list.\n * @param {string} props.description Optional accessible description for the tree grid component.\n * @param {?Function} props.onSelect Optional callback to be invoked when a block is selected. Receives the block object that was selected.\n * @param {?ComponentType} props.additionalBlockContent Component that renders additional block content UI.\n * @param {Ref} ref Forwarded ref\n */\nfunction ListViewComponent(\n\t{\n\t\tid,\n\t\tblocks,\n\t\tdropZoneElement,\n\t\tshowBlockMovers = false,\n\t\tisExpanded = false,\n\t\tshowAppender = false,\n\t\tblockSettingsMenu: BlockSettingsMenu = BlockSettingsDropdown,\n\t\trootClientId,\n\t\tdescription,\n\t\tonSelect,\n\t\tadditionalBlockContent: AdditionalBlockContent,\n\t},\n\tref\n) {\n\t// This can be removed once we no longer need to support the blocks prop.\n\tif ( blocks ) {\n\t\tdeprecated(\n\t\t\t'`blocks` property in `wp.blockEditor.__experimentalListView`',\n\t\t\t{\n\t\t\t\tsince: '6.3',\n\t\t\t\talternative: '`rootClientId` property',\n\t\t\t}\n\t\t);\n\t}\n\n\tconst instanceId = useInstanceId( ListViewComponent );\n\tconst { clientIdsTree, draggedClientIds, selectedClientIds } =\n\t\tuseListViewClientIds( { blocks, rootClientId } );\n\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst { visibleBlockCount, shouldShowInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t\tshouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone( {\n\t\tdropZoneElement,\n\t} );\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst [ insertedBlock, setInsertedBlock ] = useState( null );\n\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t/**\n\t\t * @param {MouseEvent | KeyboardEvent | undefined} event\n\t\t * @param {string} blockClientId\n\t\t * @param {null | undefined | -1 | 1} focusPosition\n\t\t */\n\t\t( event, blockClientId, focusPosition ) => {\n\t\t\tupdateBlockSelection( event, blockClientId, null, focusPosition );\n\t\t\tsetSelectedTreeId( blockClientId );\n\t\t\tif ( onSelect ) {\n\t\t\t\tonSelect( getBlock( blockClientId ) );\n\t\t\t}\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection, onSelect, getBlock ]\n\t);\n\tuseEffect( () => {\n\t\t// If a blocks are already selected when the list view is initially\n\t\t// mounted, shift focus to the first selected block.\n\t\tif ( selectedClientIds?.length ) {\n\t\t\tfocusListItem( selectedClientIds[ 0 ], elementRef );\n\t\t}\n\t\t// Disable reason: Only focus on the selected item when the list view is mounted.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tconst expand = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'expand', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'collapse', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tBlockSettingsMenu,\n\t\t\tlistViewInstanceId: instanceId,\n\t\t\tAdditionalBlockContent,\n\t\t\tinsertedBlock,\n\t\t\tsetInsertedBlock,\n\t\t\ttreeGridElementRef: elementRef,\n\t\t} ),\n\t\t[\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tBlockSettingsMenu,\n\t\t\tinstanceId,\n\t\t\tAdditionalBlockContent,\n\t\t\tinsertedBlock,\n\t\t\tsetInsertedBlock,\n\t\t]\n\t);\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\t// Ensure that the windowing logic is recalculated when the expanded state changes.\n\t\t\t// This is necessary because expanding a collapsed block in a short list view can\n\t\t\t// switch the list view to a tall list view with a scrollbar, and vice versa.\n\t\t\t// When this happens, the windowing logic needs to be recalculated to ensure that\n\t\t\t// the correct number of blocks are rendered, by rechecking for a scroll container.\n\t\t\texpandedState,\n\t\t\tuseWindowing: true,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\t// If there are no blocks to show and we're not showing the appender, do not render the list view.\n\tif ( ! clientIdsTree.length && ! showAppender ) {\n\t\treturn null;\n\t}\n\n\tconst describedById =\n\t\tdescription && `block-editor-list-view-description-${ instanceId }`;\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t{ description && (\n\t\t\t\t<VisuallyHidden id={ describedById }>\n\t\t\t\t\t{ description }\n\t\t\t\t</VisuallyHidden>\n\t\t\t) }\n\t\t\t<TreeGrid\n\t\t\t\tid={ id }\n\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\tref={ treeGridRef }\n\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\tonFocusRow={ focusRow }\n\t\t\t\tapplicationAriaLabel={ __( 'Block navigation structure' ) }\n\t\t\t\taria-describedby={ describedById }\n\t\t\t>\n\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\tparentId={ rootClientId }\n\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t\tshowAppender={ showAppender }\n\t\t\t\t\t/>\n\t\t\t\t</ListViewContext.Provider>\n\t\t\t</TreeGrid>\n\t\t</AsyncModeProvider>\n\t);\n}\n\n// This is the private API for the ListView component.\n// It allows access to all props, not just the public ones.\nexport const PrivateListView = forwardRef( ListViewComponent );\n\n// This is the public API for the ListView component.\n// We wrap the PrivateListView component to hide some props from the public API.\nexport default forwardRef( ( props, ref ) => {\n\treturn (\n\t\t<PrivateListView\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t\tshowAppender={ false }\n\t\t\trootClientId={ null }\n\t\t\tonSelect={ null }\n\t\t\tadditionalBlockContent={ null }\n\t\t\tblockSettingsMenu={ undefined }\n\t\t/>\n\t);\n} );\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,YAAY,EACZC,gCAAgC,IAAIC,kBAAkB,QAChD,oBAAoB;AAC3B,SACCC,sBAAsB,IAAIC,QAAQ,EAClCC,cAAc,QACR,uBAAuB;AAC9B,SAASC,iBAAiB,EAAEC,SAAS,QAAQ,iBAAiB;AAC9D,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,SACCC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,UAAU,EACVC,UAAU,EACVC,QAAQ,QACF,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,cAAc,MAAM,UAAU;AACrC,SAASC,eAAe,QAAQ,WAAW;AAC3C,OAAOC,qBAAqB,MAAM,kBAAkB;AACpD,OAAOC,iBAAiB,MAAM,uBAAuB;AACrD,OAAOC,oBAAoB,MAAM,4BAA4B;AAC7D,OAAOC,mBAAmB,MAAM,2BAA2B;AAC3D,OAAOC,6BAA6B,MAAM,sCAAsC;AAChF,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,qBAAqB,QAAQ,gDAAgD;AACtF,SAASC,aAAa,QAAQ,SAAS;AAEvC,MAAMC,QAAQ,GAAGA,C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Ac;IAAC+B,EAAE,EAAGkE;EAAe,GACjCtD,WACa,CAChB,EACDuD,aAAA,CAACnG,QAAQ;IACRgC,EAAE,EAAGA,EAAI;IACTsE,SAAS,EAAC,6BAA6B;IACvC,cAAa1F,EAAE,CAAE,4BAA6B,CAAG;IACjDoC,GAAG,EAAGuB,WAAa;IACnBgC,aAAa,EAAGhB,WAAa;IAC7BiB,WAAW,EAAGrB,SAAW;IACzBsB,UAAU,EAAGjB,QAAU;IACvBkB,oBAAoB,EAAG9F,EAAE,CAAE,4BAA6B,CAAG;IAC3D,oBAAmBsF;EAAe,GAElCC,aAAA,CAACrF,eAAe,CAAC6F,QAAQ;IAACP,KAAK,EAAGR;EAAc,GAC/CO,aAAA,CAACtF,cAAc;IACduB,MAAM,EAAGgB,aAAe;IACxBwD,QAAQ,EAAGjE,YAAc;IACzBkE,WAAW,EAAGjC,iBAAmB;IACjCtC,eAAe,EAAGA,eAAiB;IACnCyD,eAAe,EAAGA,eAAiB;IACnCzC,iBAAiB,EAAGA,iBAAmB;IACvCf,UAAU,EAAGA,UAAY;IACzBkB,qBAAqB,EAAGA,qBAAuB;IAC/CjB,YAAY,EAAGA;EAAc,CAC7B,CACwB,CACjB,CACQ,CAAC;AAEtB;;AAEA;AACA;AACA,OAAO,MAAMsE,eAAe,GAAGpG,UAAU,CAAEyB,iBAAkB,CAAC;;AAE9D;AACA;AACA,eAAezB,UAAU,CAAE,CAAEqG,KAAK,EAAE/D,GAAG,KAAM;EAC5C,OACCmD,aAAA,CAACW,eAAe;IACf9D,GAAG,EAAGA,GAAK;IAAA,GACN+D,KAAK;IACVvE,YAAY,EAAG,KAAO;IACtBG,YAAY,EAAG,IAAM;IACrBE,QAAQ,EAAG,IAAM;IACjBC,sBAAsB,EAAG,IAAM;IAC/BL,iBAAiB,EAAGuE;EAAW,CAC/B,CAAC;AAEJ,CAAE,CAAC"}
@@ -10,7 +10,7 @@ import classnames from 'classnames';
10
10
  import { useRef } from '@wordpress/element';
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import { speak } from '@wordpress/a11y';
13
- import { FormFileUpload, NavigableMenu, MenuItem, ToolbarButton, Dropdown, withFilters, Tooltip } from '@wordpress/components';
13
+ import { FormFileUpload, NavigableMenu, MenuItem, ToolbarButton, Dropdown, withFilters } from '@wordpress/components';
14
14
  import { useSelect, withDispatch } from '@wordpress/data';
15
15
  import { DOWN } from '@wordpress/keycodes';
16
16
  import { postFeaturedImage, upload, media as mediaIcon } from '@wordpress/icons';
@@ -171,9 +171,7 @@ const MediaReplaceFlow = ({
171
171
  })
172
172
  }, createElement("span", {
173
173
  className: "block-editor-media-replace-flow__image-url-label"
174
- }, __('Current media URL:')), createElement(Tooltip, {
175
- text: mediaURL
176
- }, createElement("div", null, createElement(LinkControl, {
174
+ }, __('Current media URL:')), createElement(LinkControl, {
177
175
  value: {
178
176
  url: mediaURL
179
177
  },
@@ -185,7 +183,7 @@ const MediaReplaceFlow = ({
185
183
  onSelectURL(url);
186
184
  editMediaButtonRef.current.focus();
187
185
  }
188
- })))))
186
+ })))
189
187
  });
190
188
  };
191
189
 
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","useRef","__","speak","FormFileUpload","NavigableMenu","MenuItem","ToolbarButton","Dropdown","withFilters","Tooltip","useSelect","withDispatch","DOWN","postFeaturedImage","upload","media","mediaIcon","compose","__unstableStripHTML","stripHTML","store","noticesStore","MediaUpload","MediaUploadCheck","LinkControl","blockEditorStore","noop","uniqueId","MediaReplaceFlow","mediaURL","mediaId","mediaIds","allowedTypes","accept","onError","onSelect","onSelectURL","onToggleFeaturedImage","useFeaturedImage","onFilesUpload","name","createNotice","removeNotice","children","multiple","addToGallery","handleUpload","popoverProps","mediaUpload","select","getSettings","canUpload","editMediaButtonRef","errorNoticeID","onUploadError","message","safeMessage","setTimeout","id","isDismissible","selectMedia","closeMenu","uploadFiles","event","files","target","filesList","onFileChange","openOnArrowDown","keyCode","preventDefault","click","onlyAllowsImages","length","every","allowedType","startsWith","gallery","createElement","contentClassName","renderToggle","isOpen","onToggle","ref","onClick","onKeyDown","renderContent","onClose","Fragment","className","value","render","open","icon","onChange","openFileDialog","isPressed","text","url","settings","showSuggestions","current","focus","dispatch"],"sources":["@wordpress/block-editor/src/components/media-replace-flow/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport {\n\tFormFileUpload,\n\tNavigableMenu,\n\tMenuItem,\n\tToolbarButton,\n\tDropdown,\n\twithFilters,\n\tTooltip,\n} from '@wordpress/components';\nimport { useSelect, withDispatch } from '@wordpress/data';\nimport { DOWN } from '@wordpress/keycodes';\nimport {\n\tpostFeaturedImage,\n\tupload,\n\tmedia as mediaIcon,\n} from '@wordpress/icons';\nimport { compose } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport LinkControl from '../link-control';\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\nlet uniqueId = 0;\n\nconst MediaReplaceFlow = ( {\n\tmediaURL,\n\tmediaId,\n\tmediaIds,\n\tallowedTypes,\n\taccept,\n\tonError,\n\tonSelect,\n\tonSelectURL,\n\tonToggleFeaturedImage,\n\tuseFeaturedImage,\n\tonFilesUpload = noop,\n\tname = __( 'Replace' ),\n\tcreateNotice,\n\tremoveNotice,\n\tchildren,\n\tmultiple = false,\n\taddToGallery,\n\thandleUpload = true,\n\tpopoverProps,\n} ) => {\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).getSettings().mediaUpload;\n\t}, [] );\n\tconst canUpload = !! mediaUpload;\n\tconst editMediaButtonRef = useRef();\n\tconst errorNoticeID = `block-editor/media-replace-flow/error-notice/${ ++uniqueId }`;\n\n\tconst onUploadError = ( message ) => {\n\t\tconst safeMessage = stripHTML( message );\n\t\tif ( onError ) {\n\t\t\tonError( safeMessage );\n\t\t\treturn;\n\t\t}\n\t\t// We need to set a timeout for showing the notice\n\t\t// so that VoiceOver and possibly other screen readers\n\t\t// can announce the error afer the toolbar button\n\t\t// regains focus once the upload dialog closes.\n\t\t// Otherwise VO simply skips over the notice and announces\n\t\t// the focused element and the open menu.\n\t\tsetTimeout( () => {\n\t\t\tcreateNotice( 'error', safeMessage, {\n\t\t\t\tspeak: true,\n\t\t\t\tid: errorNoticeID,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}, 1000 );\n\t};\n\n\tconst selectMedia = ( media, closeMenu ) => {\n\t\tif ( useFeaturedImage && onToggleFeaturedImage ) {\n\t\t\tonToggleFeaturedImage();\n\t\t}\n\t\tcloseMenu();\n\t\t// Calling `onSelect` after the state update since it might unmount the component.\n\t\tonSelect( media );\n\t\tspeak( __( 'The media file has been replaced' ) );\n\t\tremoveNotice( errorNoticeID );\n\t};\n\n\tconst uploadFiles = ( event, closeMenu ) => {\n\t\tconst files = event.target.files;\n\t\tif ( ! handleUpload ) {\n\t\t\tcloseMenu();\n\t\t\treturn onSelect( files );\n\t\t}\n\t\tonFilesUpload( files );\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: ( [ media ] ) => {\n\t\t\t\tselectMedia( media, closeMenu );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst openOnArrowDown = ( event ) => {\n\t\tif ( event.keyCode === DOWN ) {\n\t\t\tevent.preventDefault();\n\t\t\tevent.target.click();\n\t\t}\n\t};\n\n\tconst onlyAllowsImages = () => {\n\t\tif ( ! allowedTypes || allowedTypes.length === 0 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn allowedTypes.every(\n\t\t\t( allowedType ) =>\n\t\t\t\tallowedType === 'image' || allowedType.startsWith( 'image/' )\n\t\t);\n\t};\n\n\tconst gallery = multiple && onlyAllowsImages();\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ popoverProps }\n\t\t\tcontentClassName=\"block-editor-media-replace-flow__options\"\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tref={ editMediaButtonRef }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t>\n\t\t\t\t\t{ name }\n\t\t\t\t</ToolbarButton>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<NavigableMenu className=\"block-editor-media-replace-flow__media-upload-menu\">\n\t\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\tgallery={ gallery }\n\t\t\t\t\t\t\t\taddToGallery={ addToGallery }\n\t\t\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\t\t\tvalue={ multiple ? mediaIds : mediaId }\n\t\t\t\t\t\t\t\tonSelect={ ( media ) =>\n\t\t\t\t\t\t\t\t\tselectMedia( media, onClose )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\ticon={ mediaIcon }\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Open Media Library' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\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<FormFileUpload\n\t\t\t\t\t\t\t\tonChange={ ( event ) => {\n\t\t\t\t\t\t\t\t\tuploadFiles( event, onClose );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\t\t\tmultiple={ !! multiple }\n\t\t\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\topenFileDialog();\n\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\t\t{ __( 'Upload' ) }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\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</MediaUploadCheck>\n\t\t\t\t\t\t{ onToggleFeaturedImage && (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ postFeaturedImage }\n\t\t\t\t\t\t\t\tonClick={ onToggleFeaturedImage }\n\t\t\t\t\t\t\t\tisPressed={ useFeaturedImage }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Use featured image' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t{ onSelectURL && (\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t\t\t\t\t<form\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-media-flow__url-input',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'has-siblings':\n\t\t\t\t\t\t\t\t\t\tcanUpload || onToggleFeaturedImage,\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\t\t<span className=\"block-editor-media-replace-flow__image-url-label\">\n\t\t\t\t\t\t\t\t{ __( 'Current media URL:' ) }\n\t\t\t\t\t\t\t</span>\n\n\t\t\t\t\t\t\t<Tooltip text={ mediaURL }>\n\t\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t<LinkControl\n\t\t\t\t\t\t\t\t\t\tvalue={ { url: mediaURL } }\n\t\t\t\t\t\t\t\t\t\tsettings={ [] }\n\t\t\t\t\t\t\t\t\t\tshowSuggestions={ false }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( { url } ) => {\n\t\t\t\t\t\t\t\t\t\t\tonSelectURL( url );\n\t\t\t\t\t\t\t\t\t\t\teditMediaButtonRef.current.focus();\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</div>\n\t\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-replace-flow/README.md\n */\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { createNotice, removeNotice } = dispatch( noticesStore );\n\t\treturn {\n\t\t\tcreateNotice,\n\t\t\tremoveNotice,\n\t\t};\n\t} ),\n\twithFilters( 'editor.MediaReplaceFlow' ),\n] )( MediaReplaceFlow );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SACCC,cAAc,EACdC,aAAa,EACbC,QAAQ,EACRC,aAAa,EACbC,QAAQ,EACRC,WAAW,EACXC,OAAO,QACD,uBAAuB;AAC9B,SAASC,SA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AAI,CAAC,KAAM;QACzB9D,WAAW,CAAE8D,GAAI,CAAC;QAClB9C,kBAAkB,CAACiD,OAAO,CAACC,KAAK,CAAC,CAAC;MACnC;IAAG,CACH,CACG,CACG,CACJ,CAEN;EACA,CACH,CAAC;AAEJ,CAAC;;AAED;AACA;AACA;AACA,eAAerF,OAAO,CAAE,CACvBN,YAAY,CAAI4F,QAAQ,IAAM;EAC7B,MAAM;IAAE9D,YAAY;IAAEC;EAAa,CAAC,GAAG6D,QAAQ,CAAElF,YAAa,CAAC;EAC/D,OAAO;IACNoB,YAAY;IACZC;EACD,CAAC;AACF,CAAE,CAAC,EACHlC,WAAW,CAAE,yBAA0B,CAAC,CACvC,CAAC,CAAEoB,gBAAiB,CAAC"}
1
+ {"version":3,"names":["classnames","useRef","__","speak","FormFileUpload","NavigableMenu","MenuItem","ToolbarButton","Dropdown","withFilters","useSelect","withDispatch","DOWN","postFeaturedImage","upload","media","mediaIcon","compose","__unstableStripHTML","stripHTML","store","noticesStore","MediaUpload","MediaUploadCheck","LinkControl","blockEditorStore","noop","uniqueId","MediaReplaceFlow","mediaURL","mediaId","mediaIds","allowedTypes","accept","onError","onSelect","onSelectURL","onToggleFeaturedImage","useFeaturedImage","onFilesUpload","name","createNotice","removeNotice","children","multiple","addToGallery","handleUpload","popoverProps","mediaUpload","select","getSettings","canUpload","editMediaButtonRef","errorNoticeID","onUploadError","message","safeMessage","setTimeout","id","isDismissible","selectMedia","closeMenu","uploadFiles","event","files","target","filesList","onFileChange","openOnArrowDown","keyCode","preventDefault","click","onlyAllowsImages","length","every","allowedType","startsWith","gallery","createElement","contentClassName","renderToggle","isOpen","onToggle","ref","onClick","onKeyDown","renderContent","onClose","Fragment","className","value","render","open","icon","onChange","openFileDialog","isPressed","url","settings","showSuggestions","current","focus","dispatch"],"sources":["@wordpress/block-editor/src/components/media-replace-flow/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport {\n\tFormFileUpload,\n\tNavigableMenu,\n\tMenuItem,\n\tToolbarButton,\n\tDropdown,\n\twithFilters,\n} from '@wordpress/components';\nimport { useSelect, withDispatch } from '@wordpress/data';\nimport { DOWN } from '@wordpress/keycodes';\nimport {\n\tpostFeaturedImage,\n\tupload,\n\tmedia as mediaIcon,\n} from '@wordpress/icons';\nimport { compose } from '@wordpress/compose';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport LinkControl from '../link-control';\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\nlet uniqueId = 0;\n\nconst MediaReplaceFlow = ( {\n\tmediaURL,\n\tmediaId,\n\tmediaIds,\n\tallowedTypes,\n\taccept,\n\tonError,\n\tonSelect,\n\tonSelectURL,\n\tonToggleFeaturedImage,\n\tuseFeaturedImage,\n\tonFilesUpload = noop,\n\tname = __( 'Replace' ),\n\tcreateNotice,\n\tremoveNotice,\n\tchildren,\n\tmultiple = false,\n\taddToGallery,\n\thandleUpload = true,\n\tpopoverProps,\n} ) => {\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).getSettings().mediaUpload;\n\t}, [] );\n\tconst canUpload = !! mediaUpload;\n\tconst editMediaButtonRef = useRef();\n\tconst errorNoticeID = `block-editor/media-replace-flow/error-notice/${ ++uniqueId }`;\n\n\tconst onUploadError = ( message ) => {\n\t\tconst safeMessage = stripHTML( message );\n\t\tif ( onError ) {\n\t\t\tonError( safeMessage );\n\t\t\treturn;\n\t\t}\n\t\t// We need to set a timeout for showing the notice\n\t\t// so that VoiceOver and possibly other screen readers\n\t\t// can announce the error afer the toolbar button\n\t\t// regains focus once the upload dialog closes.\n\t\t// Otherwise VO simply skips over the notice and announces\n\t\t// the focused element and the open menu.\n\t\tsetTimeout( () => {\n\t\t\tcreateNotice( 'error', safeMessage, {\n\t\t\t\tspeak: true,\n\t\t\t\tid: errorNoticeID,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}, 1000 );\n\t};\n\n\tconst selectMedia = ( media, closeMenu ) => {\n\t\tif ( useFeaturedImage && onToggleFeaturedImage ) {\n\t\t\tonToggleFeaturedImage();\n\t\t}\n\t\tcloseMenu();\n\t\t// Calling `onSelect` after the state update since it might unmount the component.\n\t\tonSelect( media );\n\t\tspeak( __( 'The media file has been replaced' ) );\n\t\tremoveNotice( errorNoticeID );\n\t};\n\n\tconst uploadFiles = ( event, closeMenu ) => {\n\t\tconst files = event.target.files;\n\t\tif ( ! handleUpload ) {\n\t\t\tcloseMenu();\n\t\t\treturn onSelect( files );\n\t\t}\n\t\tonFilesUpload( files );\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: ( [ media ] ) => {\n\t\t\t\tselectMedia( media, closeMenu );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst openOnArrowDown = ( event ) => {\n\t\tif ( event.keyCode === DOWN ) {\n\t\t\tevent.preventDefault();\n\t\t\tevent.target.click();\n\t\t}\n\t};\n\n\tconst onlyAllowsImages = () => {\n\t\tif ( ! allowedTypes || allowedTypes.length === 0 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn allowedTypes.every(\n\t\t\t( allowedType ) =>\n\t\t\t\tallowedType === 'image' || allowedType.startsWith( 'image/' )\n\t\t);\n\t};\n\n\tconst gallery = multiple && onlyAllowsImages();\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ popoverProps }\n\t\t\tcontentClassName=\"block-editor-media-replace-flow__options\"\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tref={ editMediaButtonRef }\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t>\n\t\t\t\t\t{ name }\n\t\t\t\t</ToolbarButton>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<NavigableMenu className=\"block-editor-media-replace-flow__media-upload-menu\">\n\t\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\tgallery={ gallery }\n\t\t\t\t\t\t\t\taddToGallery={ addToGallery }\n\t\t\t\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\t\t\t\tvalue={ multiple ? mediaIds : mediaId }\n\t\t\t\t\t\t\t\tonSelect={ ( media ) =>\n\t\t\t\t\t\t\t\t\tselectMedia( media, onClose )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\ticon={ mediaIcon }\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Open Media Library' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\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<FormFileUpload\n\t\t\t\t\t\t\t\tonChange={ ( event ) => {\n\t\t\t\t\t\t\t\t\tuploadFiles( event, onClose );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\t\t\tmultiple={ !! multiple }\n\t\t\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\topenFileDialog();\n\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\t\t{ __( 'Upload' ) }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\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</MediaUploadCheck>\n\t\t\t\t\t\t{ onToggleFeaturedImage && (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\ticon={ postFeaturedImage }\n\t\t\t\t\t\t\t\tonClick={ onToggleFeaturedImage }\n\t\t\t\t\t\t\t\tisPressed={ useFeaturedImage }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Use featured image' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t{ onSelectURL && (\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t\t\t\t\t<form\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-media-flow__url-input',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'has-siblings':\n\t\t\t\t\t\t\t\t\t\tcanUpload || onToggleFeaturedImage,\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\t\t<span className=\"block-editor-media-replace-flow__image-url-label\">\n\t\t\t\t\t\t\t\t{ __( 'Current media URL:' ) }\n\t\t\t\t\t\t\t</span>\n\n\t\t\t\t\t\t\t<LinkControl\n\t\t\t\t\t\t\t\tvalue={ { url: mediaURL } }\n\t\t\t\t\t\t\t\tsettings={ [] }\n\t\t\t\t\t\t\t\tshowSuggestions={ false }\n\t\t\t\t\t\t\t\tonChange={ ( { url } ) => {\n\t\t\t\t\t\t\t\t\tonSelectURL( url );\n\t\t\t\t\t\t\t\t\teditMediaButtonRef.current.focus();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t/>\n\t);\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-replace-flow/README.md\n */\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { createNotice, removeNotice } = dispatch( noticesStore );\n\t\treturn {\n\t\t\tcreateNotice,\n\t\t\tremoveNotice,\n\t\t};\n\t} ),\n\twithFilters( 'editor.MediaReplaceFlow' ),\n] )( MediaReplaceFlow );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SACCC,cAAc,EACdC,aAAa,EACbC,QAAQ,EACRC,aAAa,EACbC,QAAQ,EACRC,WAAW,QACL,uBAAuB;AAC9B,SAASC,SAAS,EAAEC,YAAY,QAAQ,iBAAiB;AACzD,SAASC,IAAI,QAAQ,qBAAqB;AAC1C,SACCC,iBAAiB,EACjBC,MAAM,EACNC,KAAK,IAAIC,SAAS,QACZ,kBAAkB;AACzB,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;AACjE,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,OAAOC,WAAW,MAAM,iBAAiB;AACzC,OAAOC,gBAAgB,MAAM,uBAAuB;AACpD,OAAOC,WAAW,MAAM,iBAAiB;AACzC,SAASJ,KAAK,IAAIK,gBA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  // bound sync, unset the outbound value to avoid considering it in
168
168
  // subsequent renders.
169
169
  pendingChanges.current.outgoing = [];
170
- const hadSelecton = hasSelectedBlock();
170
+ const hadSelection = hasSelectedBlock();
171
171
  const selectionAnchor = getSelectionStart();
172
172
  const selectionFocus = getSelectionEnd();
173
173
  setControlledBlocks();
@@ -175,7 +175,7 @@ export default function useBlockSync({
175
175
  resetSelection(controlledSelection.selectionStart, controlledSelection.selectionEnd, controlledSelection.initialPosition);
176
176
  } else {
177
177
  const selectionStillExists = getBlock(selectionAnchor.clientId);
178
- if (hadSelecton && !selectionStillExists) {
178
+ if (hadSelection && !selectionStillExists) {
179
179
  selectBlock(clientId);
180
180
  } else {
181
181
  resetSelection(selectionAnchor, selectionFocus);
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","useRegistry","useSelect","cloneBlock","store","blockEditorStore","noop","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","resetBlocks","resetSelection","replaceInnerBlocks","selectBlock","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","hasSelectedBlock","getBlockName","getBlocks","getSelectionStart","getSelectionEnd","getBlock","select","isControlled","areInnerBlocksControlled","pendingChanges","incoming","outgoing","subscribed","setControlledBlocks","batch","storeBlocks","map","block","current","unsetControlledBlocks","onInputRef","onChangeRef","includes","length","hadSelecton","selectionAnchor","selectionFocus","selectionStart","selectionEnd","initialPosition","selectionStillExists","getSelectedBlocksInitialCaretPosition","isLastBlockChangePersistent","__unstableIsLastBlockChangeIgnored","blocks","isPersistent","previousAreBlocksDifferent","unsubscribe","subscribe","isStillControlled","newIsPersistent","newBlocks","areBlocksDifferent","didPersistenceChange","push","updateParent"],"sources":["@wordpress/block-editor/src/components/provider/use-block-sync.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\n/**\n * A function to call when the block value has been updated in the block-editor\n * store.\n *\n * @callback onBlockUpdate\n * @param {Object[]} blocks The updated blocks.\n * @param {Object} options The updated block options, such as selectionStart\n * and selectionEnd.\n */\n\n/**\n * useBlockSync is a side effect which handles bidirectional sync between the\n * block-editor store and a controlling data source which provides blocks. This\n * is most commonly used by the BlockEditorProvider to synchronize the contents\n * of the block-editor store with the root entity, like a post.\n *\n * Another example would be the template part block, which provides blocks from\n * a separate entity data source than a root entity. This hook syncs edits to\n * the template part in the block editor back to the entity and vice-versa.\n *\n * Here are some of its basic functions:\n * - Initalizes the block-editor store for the given clientID to the blocks\n * given via props.\n * - Adds incoming changes (like undo) to the block-editor store.\n * - Adds outgoing changes (like editing content) to the controlling entity,\n * determining if a change should be considered persistent or not.\n * - Handles edge cases and race conditions which occur in those operations.\n * - Ignores changes which happen to other entities (like nested inner block\n * controllers.\n * - Passes selection state from the block-editor store to the controlling entity.\n *\n * @param {Object} props Props for the block sync hook\n * @param {string} props.clientId The client ID of the inner block controller.\n * If none is passed, then it is assumed to be a\n * root controller rather than an inner block\n * controller.\n * @param {Object[]} props.value The control value for the blocks. This value\n * is used to initalize the block-editor store\n * and for resetting the blocks to incoming\n * changes like undo.\n * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.\n * @param {onBlockUpdate} props.onChange Function to call when a persistent\n * change has been made in the block-editor blocks\n * for the given clientId. For example, after\n * this function is called, an entity is marked\n * dirty because it has changes to save.\n * @param {onBlockUpdate} props.onInput Function to call when a non-persistent\n * change has been made in the block-editor blocks\n * for the given clientId. When this is called,\n * controlling sources do not become dirty.\n */\nexport default function useBlockSync( {\n\tclientId = null,\n\tvalue: controlledBlocks,\n\tselection: controlledSelection,\n\tonChange = noop,\n\tonInput = noop,\n} ) {\n\tconst registry = useRegistry();\n\n\tconst {\n\t\tresetBlocks,\n\t\tresetSelection,\n\t\treplaceInnerBlocks,\n\t\tselectBlock,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst {\n\t\thasSelectedBlock,\n\t\tgetBlockName,\n\t\tgetBlocks,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlock,\n\t} = registry.select( blockEditorStore );\n\tconst isControlled = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\t! clientId ||\n\t\t\t\tselect( blockEditorStore ).areInnerBlocksControlled( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst pendingChanges = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribed = useRef( false );\n\n\tconst setControlledBlocks = () => {\n\t\tif ( ! controlledBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't need to persist this change because we only replace\n\t\t// controlled inner blocks when the change was caused by an entity,\n\t\t// and so it would already be persisted.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\t// It is important to batch here because otherwise,\n\t\t\t// as soon as `setHasControlledInnerBlocks` is called\n\t\t\t// the effect to restore might be triggered\n\t\t\t// before the actual blocks get set properly in state.\n\t\t\tregistry.batch( () => {\n\t\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\t\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\tif ( subscribed.current ) {\n\t\t\t\t\tpendingChanges.current.incoming = storeBlocks;\n\t\t\t\t}\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\t\t\t} );\n\t\t} else {\n\t\t\tif ( subscribed.current ) {\n\t\t\t\tpendingChanges.current.incoming = controlledBlocks;\n\t\t\t}\n\t\t\tresetBlocks( controlledBlocks );\n\t\t}\n\t};\n\n\t// Clean up the changes made by setControlledBlocks() when the component\n\t// containing useBlockSync() unmounts.\n\tconst unsetControlledBlocks = () => {\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\tsetHasControlledInnerBlocks( clientId, false );\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\treplaceInnerBlocks( clientId, [] );\n\t\t} else {\n\t\t\tresetBlocks( [] );\n\t\t}\n\t};\n\n\t// Add a subscription to the block-editor registry to detect when changes\n\t// have been made. This lets us inform the data source of changes. This\n\t// is an effect so that the subscriber can run synchronously without\n\t// waiting for React renders for changes.\n\tconst onInputRef = useRef( onInput );\n\tconst onChangeRef = useRef( onChange );\n\tuseEffect( () => {\n\t\tonInputRef.current = onInput;\n\t\tonChangeRef.current = onChange;\n\t}, [ onInput, onChange ] );\n\n\t// Determine if blocks need to be reset when they change.\n\tuseEffect( () => {\n\t\tif ( pendingChanges.current.outgoing.includes( controlledBlocks ) ) {\n\t\t\t// Skip block reset if the value matches expected outbound sync\n\t\t\t// triggered by this component by a preceding change detection.\n\t\t\t// Only skip if the value matches expectation, since a reset should\n\t\t\t// still occur if the value is modified (not equal by reference),\n\t\t\t// to allow that the consumer may apply modifications to reflect\n\t\t\t// back on the editor.\n\t\t\tif (\n\t\t\t\tpendingChanges.current.outgoing[\n\t\t\t\t\tpendingChanges.current.outgoing.length - 1\n\t\t\t\t] === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChanges.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( getBlocks( clientId ) !== controlledBlocks ) {\n\t\t\t// Reset changing value in all other cases than the sync described\n\t\t\t// above. Since this can be reached in an update following an out-\n\t\t\t// bound sync, unset the outbound value to avoid considering it in\n\t\t\t// subsequent renders.\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tconst hadSelecton = hasSelectedBlock();\n\t\t\tconst selectionAnchor = getSelectionStart();\n\t\t\tconst selectionFocus = getSelectionEnd();\n\t\t\tsetControlledBlocks();\n\n\t\t\tif ( controlledSelection ) {\n\t\t\t\tresetSelection(\n\t\t\t\t\tcontrolledSelection.selectionStart,\n\t\t\t\t\tcontrolledSelection.selectionEnd,\n\t\t\t\t\tcontrolledSelection.initialPosition\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst selectionStillExists = getBlock(\n\t\t\t\t\tselectionAnchor.clientId\n\t\t\t\t);\n\t\t\t\tif ( hadSelecton && ! selectionStillExists ) {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t} else {\n\t\t\t\t\tresetSelection( selectionAnchor, selectionFocus );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\n\t\t// When the block becomes uncontrolled, it means its inner state has been reset\n\t\t// we need to take the blocks again from the external value property.\n\t\tif ( ! isControlled ) {\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\t\t}\n\t}, [ isControlled ] );\n\n\tuseEffect( () => {\n\t\tconst {\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\tisLastBlockChangePersistent,\n\t\t\t__unstableIsLastBlockChangeIgnored,\n\t\t\tareInnerBlocksControlled,\n\t\t} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet previousAreBlocksDifferent = false;\n\n\t\tsubscribed.current = true;\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Sometimes, when changing block lists, lingering subscriptions\n\t\t\t// might trigger before they are cleaned up. If the block for which\n\t\t\t// the subscription runs is no longer in the store, this would clear\n\t\t\t// its parent entity's block list. To avoid this, we bail out if\n\t\t\t// the subscription is triggering for a block (`clientId !== null`)\n\t\t\t// and its block name can't be found because it's not on the list.\n\t\t\t// (`getBlockName( clientId ) === null`).\n\t\t\tif ( clientId !== null && getBlockName( clientId ) === null )\n\t\t\t\treturn;\n\n\t\t\t// When RESET_BLOCKS on parent blocks get called, the controlled blocks\n\t\t\t// can reset to uncontrolled, in these situations, it means we need to populate\n\t\t\t// the blocks again from the external blocks (the value property here)\n\t\t\t// and we should stop triggering onChange\n\t\t\tconst isStillControlled =\n\t\t\t\t! clientId || areInnerBlocksControlled( clientId );\n\t\t\tif ( ! isStillControlled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newIsPersistent = isLastBlockChangePersistent();\n\t\t\tconst newBlocks = getBlocks( clientId );\n\t\t\tconst areBlocksDifferent = newBlocks !== blocks;\n\t\t\tblocks = newBlocks;\n\t\t\tif (\n\t\t\t\tareBlocksDifferent &&\n\t\t\t\t( pendingChanges.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChanges.current.incoming = null;\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Since we often dispatch an action to mark the previous action as\n\t\t\t// persistent, we need to make sure that the blocks changed on the\n\t\t\t// previous action before committing the change.\n\t\t\tconst didPersistenceChange =\n\t\t\t\tpreviousAreBlocksDifferent &&\n\t\t\t\t! areBlocksDifferent &&\n\t\t\t\tnewIsPersistent &&\n\t\t\t\t! isPersistent;\n\n\t\t\tif ( areBlocksDifferent || didPersistenceChange ) {\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t// We know that onChange/onInput will update controlledBlocks.\n\t\t\t\t// We need to be aware that it was caused by an outgoing change\n\t\t\t\t// so that we do not treat it as an incoming change later on,\n\t\t\t\t// which would cause a block reset.\n\t\t\t\tpendingChanges.current.outgoing.push( blocks );\n\n\t\t\t\t// Inform the controlling entity that changes have been made to\n\t\t\t\t// the block-editor store they should be aware about.\n\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t: onInputRef.current;\n\t\t\t\tupdateParent( blocks, {\n\t\t\t\t\tselection: {\n\t\t\t\t\t\tselectionStart: getSelectionStart(),\n\t\t\t\t\t\tselectionEnd: getSelectionEnd(),\n\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\tpreviousAreBlocksDifferent = areBlocksDifferent;\n\t\t}, blockEditorStore );\n\n\t\treturn () => {\n\t\t\tsubscribed.current = false;\n\t\t\tunsubscribe();\n\t\t};\n\t}, [ registry, clientId ] );\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tunsetControlledBlocks();\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AACtD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,UAAU,QAAQ,mBAAmB;;AAE9C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAEvD,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,YAAYA,CAAE;EACrCC,QAAQ,GAAG,IAAI;EACfC,KAAK,EAAEC,gBAAgB;EACvBC,SAAS,EAAEC,mBAAmB;EAC9BC,QAAQ,GAAGP,IAAI;EACfQ,OAAO,GAAGR;AACX,CAAC,EAAG;EACH,MAAMS,QAAQ,GAAGd,WAAW,CAAC,CAAC;EAE9B,MAAM;IACLe,WAAW;IACXC,cAAc;IACdC,kBAAkB;IAClBC,WAAW;IACXC,2BAA2B;IAC3BC;EACD,CAAC,GAAGN,QAAQ,CAACO,QAAQ,CAAEjB,gBAAiB,CAAC;EACzC,MAAM;IACLkB,gBAAgB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,SAAS,CAAE,MAAM;IAChB,OAAO,MAAM;MACZ2C,qBAAqB,CAAC,CAAC;IACxB,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
1
+ {"version":3,"names":["useEffect","useRef","useRegistry","useSelect","cloneBlock","store","blockEditorStore","noop","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","resetBlocks","resetSelection","replaceInnerBlocks","selectBlock","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","hasSelectedBlock","getBlockName","getBlocks","getSelectionStart","getSelectionEnd","getBlock","select","isControlled","areInnerBlocksControlled","pendingChanges","incoming","outgoing","subscribed","setControlledBlocks","batch","storeBlocks","map","block","current","unsetControlledBlocks","onInputRef","onChangeRef","includes","length","hadSelection","selectionAnchor","selectionFocus","selectionStart","selectionEnd","initialPosition","selectionStillExists","getSelectedBlocksInitialCaretPosition","isLastBlockChangePersistent","__unstableIsLastBlockChangeIgnored","blocks","isPersistent","previousAreBlocksDifferent","unsubscribe","subscribe","isStillControlled","newIsPersistent","newBlocks","areBlocksDifferent","didPersistenceChange","push","updateParent"],"sources":["@wordpress/block-editor/src/components/provider/use-block-sync.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\n/**\n * A function to call when the block value has been updated in the block-editor\n * store.\n *\n * @callback onBlockUpdate\n * @param {Object[]} blocks The updated blocks.\n * @param {Object} options The updated block options, such as selectionStart\n * and selectionEnd.\n */\n\n/**\n * useBlockSync is a side effect which handles bidirectional sync between the\n * block-editor store and a controlling data source which provides blocks. This\n * is most commonly used by the BlockEditorProvider to synchronize the contents\n * of the block-editor store with the root entity, like a post.\n *\n * Another example would be the template part block, which provides blocks from\n * a separate entity data source than a root entity. This hook syncs edits to\n * the template part in the block editor back to the entity and vice-versa.\n *\n * Here are some of its basic functions:\n * - Initalizes the block-editor store for the given clientID to the blocks\n * given via props.\n * - Adds incoming changes (like undo) to the block-editor store.\n * - Adds outgoing changes (like editing content) to the controlling entity,\n * determining if a change should be considered persistent or not.\n * - Handles edge cases and race conditions which occur in those operations.\n * - Ignores changes which happen to other entities (like nested inner block\n * controllers.\n * - Passes selection state from the block-editor store to the controlling entity.\n *\n * @param {Object} props Props for the block sync hook\n * @param {string} props.clientId The client ID of the inner block controller.\n * If none is passed, then it is assumed to be a\n * root controller rather than an inner block\n * controller.\n * @param {Object[]} props.value The control value for the blocks. This value\n * is used to initalize the block-editor store\n * and for resetting the blocks to incoming\n * changes like undo.\n * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.\n * @param {onBlockUpdate} props.onChange Function to call when a persistent\n * change has been made in the block-editor blocks\n * for the given clientId. For example, after\n * this function is called, an entity is marked\n * dirty because it has changes to save.\n * @param {onBlockUpdate} props.onInput Function to call when a non-persistent\n * change has been made in the block-editor blocks\n * for the given clientId. When this is called,\n * controlling sources do not become dirty.\n */\nexport default function useBlockSync( {\n\tclientId = null,\n\tvalue: controlledBlocks,\n\tselection: controlledSelection,\n\tonChange = noop,\n\tonInput = noop,\n} ) {\n\tconst registry = useRegistry();\n\n\tconst {\n\t\tresetBlocks,\n\t\tresetSelection,\n\t\treplaceInnerBlocks,\n\t\tselectBlock,\n\t\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst {\n\t\thasSelectedBlock,\n\t\tgetBlockName,\n\t\tgetBlocks,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlock,\n\t} = registry.select( blockEditorStore );\n\tconst isControlled = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\t! clientId ||\n\t\t\t\tselect( blockEditorStore ).areInnerBlocksControlled( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst pendingChanges = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribed = useRef( false );\n\n\tconst setControlledBlocks = () => {\n\t\tif ( ! controlledBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't need to persist this change because we only replace\n\t\t// controlled inner blocks when the change was caused by an entity,\n\t\t// and so it would already be persisted.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\t// It is important to batch here because otherwise,\n\t\t\t// as soon as `setHasControlledInnerBlocks` is called\n\t\t\t// the effect to restore might be triggered\n\t\t\t// before the actual blocks get set properly in state.\n\t\t\tregistry.batch( () => {\n\t\t\t\tsetHasControlledInnerBlocks( clientId, true );\n\t\t\t\tconst storeBlocks = controlledBlocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock( block )\n\t\t\t\t);\n\t\t\t\tif ( subscribed.current ) {\n\t\t\t\t\tpendingChanges.current.incoming = storeBlocks;\n\t\t\t\t}\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks( clientId, storeBlocks );\n\t\t\t} );\n\t\t} else {\n\t\t\tif ( subscribed.current ) {\n\t\t\t\tpendingChanges.current.incoming = controlledBlocks;\n\t\t\t}\n\t\t\tresetBlocks( controlledBlocks );\n\t\t}\n\t};\n\n\t// Clean up the changes made by setControlledBlocks() when the component\n\t// containing useBlockSync() unmounts.\n\tconst unsetControlledBlocks = () => {\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tif ( clientId ) {\n\t\t\tsetHasControlledInnerBlocks( clientId, false );\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\treplaceInnerBlocks( clientId, [] );\n\t\t} else {\n\t\t\tresetBlocks( [] );\n\t\t}\n\t};\n\n\t// Add a subscription to the block-editor registry to detect when changes\n\t// have been made. This lets us inform the data source of changes. This\n\t// is an effect so that the subscriber can run synchronously without\n\t// waiting for React renders for changes.\n\tconst onInputRef = useRef( onInput );\n\tconst onChangeRef = useRef( onChange );\n\tuseEffect( () => {\n\t\tonInputRef.current = onInput;\n\t\tonChangeRef.current = onChange;\n\t}, [ onInput, onChange ] );\n\n\t// Determine if blocks need to be reset when they change.\n\tuseEffect( () => {\n\t\tif ( pendingChanges.current.outgoing.includes( controlledBlocks ) ) {\n\t\t\t// Skip block reset if the value matches expected outbound sync\n\t\t\t// triggered by this component by a preceding change detection.\n\t\t\t// Only skip if the value matches expectation, since a reset should\n\t\t\t// still occur if the value is modified (not equal by reference),\n\t\t\t// to allow that the consumer may apply modifications to reflect\n\t\t\t// back on the editor.\n\t\t\tif (\n\t\t\t\tpendingChanges.current.outgoing[\n\t\t\t\t\tpendingChanges.current.outgoing.length - 1\n\t\t\t\t] === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChanges.current.outgoing = [];\n\t\t\t}\n\t\t} else if ( getBlocks( clientId ) !== controlledBlocks ) {\n\t\t\t// Reset changing value in all other cases than the sync described\n\t\t\t// above. Since this can be reached in an update following an out-\n\t\t\t// bound sync, unset the outbound value to avoid considering it in\n\t\t\t// subsequent renders.\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tconst hadSelection = hasSelectedBlock();\n\t\t\tconst selectionAnchor = getSelectionStart();\n\t\t\tconst selectionFocus = getSelectionEnd();\n\t\t\tsetControlledBlocks();\n\n\t\t\tif ( controlledSelection ) {\n\t\t\t\tresetSelection(\n\t\t\t\t\tcontrolledSelection.selectionStart,\n\t\t\t\t\tcontrolledSelection.selectionEnd,\n\t\t\t\t\tcontrolledSelection.initialPosition\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst selectionStillExists = getBlock(\n\t\t\t\t\tselectionAnchor.clientId\n\t\t\t\t);\n\t\t\t\tif ( hadSelection && ! selectionStillExists ) {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t} else {\n\t\t\t\t\tresetSelection( selectionAnchor, selectionFocus );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tuseEffect( () => {\n\t\t// When the block becomes uncontrolled, it means its inner state has been reset\n\t\t// we need to take the blocks again from the external value property.\n\t\tif ( ! isControlled ) {\n\t\t\tpendingChanges.current.outgoing = [];\n\t\t\tsetControlledBlocks();\n\t\t}\n\t}, [ isControlled ] );\n\n\tuseEffect( () => {\n\t\tconst {\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\tisLastBlockChangePersistent,\n\t\t\t__unstableIsLastBlockChangeIgnored,\n\t\t\tareInnerBlocksControlled,\n\t\t} = registry.select( blockEditorStore );\n\n\t\tlet blocks = getBlocks( clientId );\n\t\tlet isPersistent = isLastBlockChangePersistent();\n\t\tlet previousAreBlocksDifferent = false;\n\n\t\tsubscribed.current = true;\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Sometimes, when changing block lists, lingering subscriptions\n\t\t\t// might trigger before they are cleaned up. If the block for which\n\t\t\t// the subscription runs is no longer in the store, this would clear\n\t\t\t// its parent entity's block list. To avoid this, we bail out if\n\t\t\t// the subscription is triggering for a block (`clientId !== null`)\n\t\t\t// and its block name can't be found because it's not on the list.\n\t\t\t// (`getBlockName( clientId ) === null`).\n\t\t\tif ( clientId !== null && getBlockName( clientId ) === null )\n\t\t\t\treturn;\n\n\t\t\t// When RESET_BLOCKS on parent blocks get called, the controlled blocks\n\t\t\t// can reset to uncontrolled, in these situations, it means we need to populate\n\t\t\t// the blocks again from the external blocks (the value property here)\n\t\t\t// and we should stop triggering onChange\n\t\t\tconst isStillControlled =\n\t\t\t\t! clientId || areInnerBlocksControlled( clientId );\n\t\t\tif ( ! isStillControlled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst newIsPersistent = isLastBlockChangePersistent();\n\t\t\tconst newBlocks = getBlocks( clientId );\n\t\t\tconst areBlocksDifferent = newBlocks !== blocks;\n\t\t\tblocks = newBlocks;\n\t\t\tif (\n\t\t\t\tareBlocksDifferent &&\n\t\t\t\t( pendingChanges.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChanges.current.incoming = null;\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Since we often dispatch an action to mark the previous action as\n\t\t\t// persistent, we need to make sure that the blocks changed on the\n\t\t\t// previous action before committing the change.\n\t\t\tconst didPersistenceChange =\n\t\t\t\tpreviousAreBlocksDifferent &&\n\t\t\t\t! areBlocksDifferent &&\n\t\t\t\tnewIsPersistent &&\n\t\t\t\t! isPersistent;\n\n\t\t\tif ( areBlocksDifferent || didPersistenceChange ) {\n\t\t\t\tisPersistent = newIsPersistent;\n\t\t\t\t// We know that onChange/onInput will update controlledBlocks.\n\t\t\t\t// We need to be aware that it was caused by an outgoing change\n\t\t\t\t// so that we do not treat it as an incoming change later on,\n\t\t\t\t// which would cause a block reset.\n\t\t\t\tpendingChanges.current.outgoing.push( blocks );\n\n\t\t\t\t// Inform the controlling entity that changes have been made to\n\t\t\t\t// the block-editor store they should be aware about.\n\t\t\t\tconst updateParent = isPersistent\n\t\t\t\t\t? onChangeRef.current\n\t\t\t\t\t: onInputRef.current;\n\t\t\t\tupdateParent( blocks, {\n\t\t\t\t\tselection: {\n\t\t\t\t\t\tselectionStart: getSelectionStart(),\n\t\t\t\t\t\tselectionEnd: getSelectionEnd(),\n\t\t\t\t\t\tinitialPosition:\n\t\t\t\t\t\t\tgetSelectedBlocksInitialCaretPosition(),\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t\tpreviousAreBlocksDifferent = areBlocksDifferent;\n\t\t}, blockEditorStore );\n\n\t\treturn () => {\n\t\t\tsubscribed.current = false;\n\t\t\tunsubscribe();\n\t\t};\n\t}, [ registry, clientId ] );\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tunsetControlledBlocks();\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,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CAACS,OAAO,CAACR,QAAQ,GAAG,IAAI;QACtCyB,YAAY,GAAGK,eAAe;QAC9B;MACD;;MAEA;MACA;MACA;MACA,MAAMG,oBAAoB,GACzBP,0BAA0B,IAC1B,CAAEM,kBAAkB,IACpBF,eAAe,IACf,CAAEL,YAAY;MAEf,IAAKO,kBAAkB,IAAIC,oBAAoB,EAAG;QACjDR,YAAY,GAAGK,eAAe;QAC9B;QACA;QACA;QACA;QACA/B,cAAc,CAACS,OAAO,CAACP,QAAQ,CAACiC,IAAI,CAAEV,MAAO,CAAC;;QAE9C;QACA;QACA,MAAMW,YAAY,GAAGV,YAAY,GAC9Bd,WAAW,CAACH,OAAO,GACnBE,UAAU,CAACF,OAAO;QACrB2B,YAAY,CAAEX,MAAM,EAAE;UACrB9C,SAAS,EAAE;YACVuC,cAAc,EAAExB,iBAAiB,CAAC,CAAC;YACnCyB,YAAY,EAAExB,eAAe,CAAC,CAAC;YAC/ByB,eAAe,EACdE,qCAAqC,CAAC;UACxC;QACD,CAAE,CAAC;MACJ;MACAK,0BAA0B,GAAGM,kBAAkB;IAChD,CAAC,EAAE5D,gBAAiB,CAAC;IAErB,OAAO,MAAM;MACZ8B,UAAU,CAACM,OAAO,GAAG,KAAK;MAC1BmB,WAAW,CAAC,CAAC;IACd,CAAC;EACF,CAAC,EAAE,CAAE7C,QAAQ,EAAEP,QAAQ,CAAG,CAAC;EAE3BT,SAAS,CAAE,MAAM;IAChB,OAAO,MAAM;MACZ2C,qBAAqB,CAAC,CAAC;IACxB,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
@@ -11,7 +11,7 @@ import { Platform, useRef, useCallback, forwardRef } from '@wordpress/element';
11
11
  import { useDispatch, useSelect } from '@wordpress/data';
12
12
  import { pasteHandler, children as childrenSource, getBlockTransforms, findTransform, isUnmodifiedDefaultBlock } from '@wordpress/blocks';
13
13
  import { useInstanceId, useMergeRefs } from '@wordpress/compose';
14
- import { __experimentalRichText as RichText, __unstableCreateElement, isEmpty, insert, create, split, toHTMLString, slice } from '@wordpress/rich-text';
14
+ import { __experimentalRichText as RichText, __unstableCreateElement, isEmpty, insert, remove, create, split, toHTMLString, slice } from '@wordpress/rich-text';
15
15
  import { isURL } from '@wordpress/url';
16
16
 
17
17
  /**
@@ -48,6 +48,7 @@ function RichTextWrapper({
48
48
  onSplit,
49
49
  __unstableOnSplitAtEnd: onSplitAtEnd,
50
50
  __unstableOnSplitMiddle: onSplitMiddle,
51
+ __unstableOnSplitAtDoubleLineEnd: onSplitAtDoubleLineEnd,
51
52
  identifier,
52
53
  preserveWhiteSpace,
53
54
  __unstablePastePlainText: pastePlainText,
@@ -273,14 +274,24 @@ function RichTextWrapper({
273
274
  end: splitEnd
274
275
  } = value;
275
276
  const canSplitAtEnd = onSplitAtEnd && splitStart === splitEnd && splitEnd === text.length;
276
- if (shiftKey || !canSplit && !canSplitAtEnd) {
277
+ if (shiftKey) {
277
278
  if (!disableLineBreaks) {
278
279
  onChange(insert(value, '\n'));
279
280
  }
280
- } else if (!canSplit && canSplitAtEnd) {
281
- onSplitAtEnd();
282
281
  } else if (canSplit) {
283
282
  splitValue(value);
283
+ } else if (canSplitAtEnd) {
284
+ onSplitAtEnd();
285
+ } else if (
286
+ // For some blocks it's desirable to split at the end of the
287
+ // block when there are two line breaks at the end of the
288
+ // block, so triple Enter exits the block.
289
+ onSplitAtDoubleLineEnd && splitStart === splitEnd && splitEnd === text.length && text.slice(-2) === '\n\n') {
290
+ value.start = value.end - 2;
291
+ onChange(remove(value));
292
+ onSplitAtDoubleLineEnd();
293
+ } else if (!disableLineBreaks) {
294
+ onChange(insert(value, '\n'));
284
295
  }
285
296
  },
286
297
  // eslint-disable-next-line react-hooks/exhaustive-deps