@wordpress/block-editor 14.10.0 → 14.11.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 (247) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/build/components/background-image-control/index.js +0 -1
  3. package/build/components/background-image-control/index.js.map +1 -1
  4. package/build/components/block-actions/index.js +0 -3
  5. package/build/components/block-actions/index.js.map +1 -1
  6. package/build/components/block-inspector/index.js +6 -11
  7. package/build/components/block-inspector/index.js.map +1 -1
  8. package/build/components/block-list/use-block-props/use-focus-handler.js +1 -1
  9. package/build/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  10. package/build/components/block-rename/modal.js +36 -11
  11. package/build/components/block-rename/modal.js.map +1 -1
  12. package/build/components/block-rename/rename-control.js +2 -43
  13. package/build/components/block-rename/rename-control.js.map +1 -1
  14. package/build/components/block-settings-menu/block-settings-dropdown.js +12 -3
  15. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  16. package/build/components/block-styles/preview.native.js +1 -1
  17. package/build/components/block-styles/preview.native.js.map +1 -1
  18. package/build/components/block-switcher/block-transformations-menu.js +7 -7
  19. package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
  20. package/build/components/block-switcher/block-variation-transformations.js +2 -2
  21. package/build/components/block-switcher/block-variation-transformations.js.map +1 -1
  22. package/build/components/block-switcher/index.js +1 -1
  23. package/build/components/block-switcher/index.js.map +1 -1
  24. package/build/components/block-switcher/use-transformed-patterns.js +1 -1
  25. package/build/components/block-switcher/use-transformed-patterns.js.map +1 -1
  26. package/build/components/block-toolbar/index.native.js +2 -2
  27. package/build/components/block-toolbar/index.native.js.map +1 -1
  28. package/build/components/date-format-picker/index.js +1 -1
  29. package/build/components/date-format-picker/index.js.map +1 -1
  30. package/build/components/global-styles/filters-panel.js +2 -2
  31. package/build/components/global-styles/filters-panel.js.map +1 -1
  32. package/build/components/global-styles/image-settings-panel.js +2 -2
  33. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  34. package/build/components/global-styles/use-global-styles-output.js +3 -3
  35. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  36. package/build/components/iframe/get-compatibility-styles.js +1 -1
  37. package/build/components/iframe/get-compatibility-styles.js.map +1 -1
  38. package/build/components/iframe/index.js +1 -1
  39. package/build/components/iframe/index.js.map +1 -1
  40. package/build/components/image-size-control/index.js +2 -1
  41. package/build/components/image-size-control/index.js.map +1 -1
  42. package/build/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
  43. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  44. package/build/components/inserter/reusable-blocks-tab.native.js +1 -1
  45. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  46. package/build/components/line-height-control/index.native.js +1 -1
  47. package/build/components/line-height-control/index.native.js.map +1 -1
  48. package/build/components/link-control/index.js +1 -1
  49. package/build/components/link-control/index.js.map +1 -1
  50. package/build/components/link-control/use-search-handler.js +1 -1
  51. package/build/components/link-control/use-search-handler.js.map +1 -1
  52. package/build/components/list-view/block-select-button.js +5 -2
  53. package/build/components/list-view/block-select-button.js.map +1 -1
  54. package/build/components/media-placeholder/index.js +1 -0
  55. package/build/components/media-placeholder/index.js.map +1 -1
  56. package/build/components/observe-typing/index.js +1 -1
  57. package/build/components/observe-typing/index.js.map +1 -1
  58. package/build/components/provider/index.js +0 -2
  59. package/build/components/provider/index.js.map +1 -1
  60. package/build/components/provider/use-block-sync.js +2 -2
  61. package/build/components/provider/use-block-sync.js.map +1 -1
  62. package/build/components/rich-text/event-listeners/input-rules.js +3 -3
  63. package/build/components/rich-text/event-listeners/input-rules.js.map +1 -1
  64. package/build/components/rich-text/native/use-format-types.js +1 -1
  65. package/build/components/rich-text/native/use-format-types.js.map +1 -1
  66. package/build/components/rich-text/use-format-types.js +1 -1
  67. package/build/components/rich-text/use-format-types.js.map +1 -1
  68. package/build/components/tabbed-sidebar/index.js +39 -0
  69. package/build/components/tabbed-sidebar/index.js.map +1 -1
  70. package/build/components/typewriter/index.js +1 -1
  71. package/build/components/typewriter/index.js.map +1 -1
  72. package/build/components/url-popover/image-url-input-ui.js +3 -3
  73. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  74. package/build/components/use-block-commands/index.js +1 -1
  75. package/build/components/use-block-commands/index.js.map +1 -1
  76. package/build/components/use-moving-animation/index.js +1 -1
  77. package/build/components/use-moving-animation/index.js.map +1 -1
  78. package/build/store/actions.js +1 -1
  79. package/build/store/actions.js.map +1 -1
  80. package/build/store/selectors.js +5 -5
  81. package/build/store/selectors.js.map +1 -1
  82. package/build/utils/transform-styles/index.js +1 -1
  83. package/build/utils/transform-styles/index.js.map +1 -1
  84. package/build/utils/use-notify-copy.js +19 -11
  85. package/build/utils/use-notify-copy.js.map +1 -1
  86. package/build-module/components/background-image-control/index.js +0 -1
  87. package/build-module/components/background-image-control/index.js.map +1 -1
  88. package/build-module/components/block-actions/index.js +0 -3
  89. package/build-module/components/block-actions/index.js.map +1 -1
  90. package/build-module/components/block-inspector/index.js +6 -11
  91. package/build-module/components/block-inspector/index.js.map +1 -1
  92. package/build-module/components/block-list/use-block-props/use-focus-handler.js +1 -1
  93. package/build-module/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  94. package/build-module/components/block-rename/modal.js +36 -11
  95. package/build-module/components/block-rename/modal.js.map +1 -1
  96. package/build-module/components/block-rename/rename-control.js +2 -43
  97. package/build-module/components/block-rename/rename-control.js.map +1 -1
  98. package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -3
  99. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  100. package/build-module/components/block-styles/preview.native.js +1 -1
  101. package/build-module/components/block-styles/preview.native.js.map +1 -1
  102. package/build-module/components/block-switcher/block-transformations-menu.js +7 -7
  103. package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
  104. package/build-module/components/block-switcher/block-variation-transformations.js +2 -2
  105. package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -1
  106. package/build-module/components/block-switcher/index.js +1 -1
  107. package/build-module/components/block-switcher/index.js.map +1 -1
  108. package/build-module/components/block-switcher/use-transformed-patterns.js +1 -1
  109. package/build-module/components/block-switcher/use-transformed-patterns.js.map +1 -1
  110. package/build-module/components/block-toolbar/index.native.js +2 -2
  111. package/build-module/components/block-toolbar/index.native.js.map +1 -1
  112. package/build-module/components/date-format-picker/index.js +1 -1
  113. package/build-module/components/date-format-picker/index.js.map +1 -1
  114. package/build-module/components/global-styles/filters-panel.js +2 -2
  115. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  116. package/build-module/components/global-styles/image-settings-panel.js +2 -2
  117. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  118. package/build-module/components/global-styles/use-global-styles-output.js +3 -3
  119. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  120. package/build-module/components/iframe/get-compatibility-styles.js +1 -1
  121. package/build-module/components/iframe/get-compatibility-styles.js.map +1 -1
  122. package/build-module/components/iframe/index.js +1 -1
  123. package/build-module/components/iframe/index.js.map +1 -1
  124. package/build-module/components/image-size-control/index.js +3 -2
  125. package/build-module/components/image-size-control/index.js.map +1 -1
  126. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
  127. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  128. package/build-module/components/inserter/reusable-blocks-tab.native.js +1 -1
  129. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  130. package/build-module/components/line-height-control/index.native.js +1 -1
  131. package/build-module/components/line-height-control/index.native.js.map +1 -1
  132. package/build-module/components/link-control/index.js +1 -1
  133. package/build-module/components/link-control/index.js.map +1 -1
  134. package/build-module/components/link-control/use-search-handler.js +1 -1
  135. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  136. package/build-module/components/list-view/block-select-button.js +6 -3
  137. package/build-module/components/list-view/block-select-button.js.map +1 -1
  138. package/build-module/components/media-placeholder/index.js +1 -0
  139. package/build-module/components/media-placeholder/index.js.map +1 -1
  140. package/build-module/components/observe-typing/index.js +1 -1
  141. package/build-module/components/observe-typing/index.js.map +1 -1
  142. package/build-module/components/provider/index.js +0 -1
  143. package/build-module/components/provider/index.js.map +1 -1
  144. package/build-module/components/provider/use-block-sync.js +2 -2
  145. package/build-module/components/provider/use-block-sync.js.map +1 -1
  146. package/build-module/components/rich-text/event-listeners/input-rules.js +3 -3
  147. package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -1
  148. package/build-module/components/rich-text/native/use-format-types.js +1 -1
  149. package/build-module/components/rich-text/native/use-format-types.js.map +1 -1
  150. package/build-module/components/rich-text/use-format-types.js +1 -1
  151. package/build-module/components/rich-text/use-format-types.js.map +1 -1
  152. package/build-module/components/tabbed-sidebar/index.js +39 -0
  153. package/build-module/components/tabbed-sidebar/index.js.map +1 -1
  154. package/build-module/components/typewriter/index.js +1 -1
  155. package/build-module/components/typewriter/index.js.map +1 -1
  156. package/build-module/components/url-popover/image-url-input-ui.js +3 -3
  157. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  158. package/build-module/components/use-block-commands/index.js +1 -1
  159. package/build-module/components/use-block-commands/index.js.map +1 -1
  160. package/build-module/components/use-moving-animation/index.js +1 -1
  161. package/build-module/components/use-moving-animation/index.js.map +1 -1
  162. package/build-module/store/actions.js +1 -1
  163. package/build-module/store/actions.js.map +1 -1
  164. package/build-module/store/selectors.js +5 -5
  165. package/build-module/store/selectors.js.map +1 -1
  166. package/build-module/utils/transform-styles/index.js +1 -1
  167. package/build-module/utils/transform-styles/index.js.map +1 -1
  168. package/build-module/utils/use-notify-copy.js +19 -11
  169. package/build-module/utils/use-notify-copy.js.map +1 -1
  170. package/build-style/content-rtl.css +0 -9
  171. package/build-style/content.css +0 -9
  172. package/build-style/style-rtl.css +18 -21
  173. package/build-style/style.css +18 -21
  174. package/package.json +34 -33
  175. package/src/components/background-image-control/index.js +0 -1
  176. package/src/components/block-actions/index.js +0 -3
  177. package/src/components/block-icon/content.scss +1 -1
  178. package/src/components/{block-card → block-icon}/stories/index.story.js +16 -26
  179. package/src/components/block-icon/style.scss +1 -1
  180. package/src/components/block-inspector/index.js +7 -10
  181. package/src/components/block-list/use-block-props/use-focus-handler.js +1 -1
  182. package/src/components/block-preview/style.scss +1 -1
  183. package/src/components/block-rename/modal.js +40 -12
  184. package/src/components/block-rename/rename-control.js +1 -53
  185. package/src/components/block-settings-menu/block-settings-dropdown.js +16 -2
  186. package/src/components/block-styles/preview.native.js +1 -1
  187. package/src/components/block-switcher/block-transformations-menu.js +9 -9
  188. package/src/components/block-switcher/block-variation-transformations.js +2 -2
  189. package/src/components/block-switcher/index.js +1 -1
  190. package/src/components/block-switcher/use-transformed-patterns.js +1 -1
  191. package/src/components/block-toolbar/index.native.js +2 -2
  192. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  193. package/src/components/colors-gradients/style.scss +1 -0
  194. package/src/components/colors-gradients/test/control.js +2 -2
  195. package/src/components/date-format-picker/index.js +1 -1
  196. package/src/components/duotone-control/style.scss +2 -2
  197. package/src/components/global-styles/filters-panel.js +4 -2
  198. package/src/components/global-styles/image-settings-panel.js +2 -2
  199. package/src/components/global-styles/test/typography-utils.js +1 -1
  200. package/src/components/global-styles/use-global-styles-output.js +3 -3
  201. package/src/components/iframe/get-compatibility-styles.js +1 -1
  202. package/src/components/iframe/index.js +1 -1
  203. package/src/components/image-size-control/index.js +6 -2
  204. package/src/components/inner-blocks/README.md +1 -1
  205. package/src/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
  206. package/src/components/inserter/reusable-blocks-tab.native.js +1 -1
  207. package/src/components/line-height-control/index.native.js +1 -1
  208. package/src/components/link-control/README.md +2 -2
  209. package/src/components/link-control/index.js +1 -1
  210. package/src/components/link-control/test/index.js +3 -3
  211. package/src/components/link-control/use-search-handler.js +1 -1
  212. package/src/components/list-view/README.md +1 -1
  213. package/src/components/list-view/block-select-button.js +5 -5
  214. package/src/components/list-view/style.scss +3 -7
  215. package/src/components/media-placeholder/content.scss +0 -8
  216. package/src/components/media-placeholder/index.js +1 -0
  217. package/src/components/media-placeholder/style.scss +7 -0
  218. package/src/components/observe-typing/index.js +1 -1
  219. package/src/components/provider/index.js +0 -1
  220. package/src/components/provider/use-block-sync.js +2 -2
  221. package/src/components/resolution-tool/stories/index.story.js +52 -2
  222. package/src/components/rich-text/README.md +1 -1
  223. package/src/components/rich-text/event-listeners/input-rules.js +3 -3
  224. package/src/components/rich-text/native/use-format-types.js +1 -1
  225. package/src/components/rich-text/use-format-types.js +1 -1
  226. package/src/components/tabbed-sidebar/README.md +24 -13
  227. package/src/components/tabbed-sidebar/index.js +38 -0
  228. package/src/components/tabbed-sidebar/stories/index.story.js +104 -0
  229. package/src/components/typewriter/index.js +1 -1
  230. package/src/components/unit-control/README.md +1 -1
  231. package/src/components/unit-control/stories/index.story.js +124 -0
  232. package/src/components/url-popover/image-url-input-ui.js +3 -3
  233. package/src/components/use-block-commands/index.js +1 -1
  234. package/src/components/use-moving-animation/index.js +1 -1
  235. package/src/components/use-settings/README.md +1 -1
  236. package/src/components/warning/content.scss +1 -1
  237. package/src/components/writing-flow/test/index.js +1 -1
  238. package/src/hooks/color.scss +0 -7
  239. package/src/store/actions.js +1 -1
  240. package/src/store/selectors.js +5 -5
  241. package/src/store/test/private-selectors.js +1 -1
  242. package/src/store/test/selectors.js +3 -3
  243. package/src/style.scss +1 -0
  244. package/src/utils/test/sorting.js +1 -1
  245. package/src/utils/transform-styles/index.js +1 -1
  246. package/src/utils/use-notify-copy.js +51 -43
  247. package/tsconfig.json +1 -0
@@ -1 +1 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_element","_icons","_keycodes","_data","_blockIcon","_useBlockDisplayInformation","_useBlockDisplayTitle","_expander","_blockLock","_useListViewImages","_store","_jsxRuntime","ListViewBlockSelectButton","className","block","clientId","onClick","onContextMenu","onMouseDown","onToggleExpanded","tabIndex","onFocus","onDragStart","onDragEnd","draggable","isExpanded","ariaDescribedBy","ref","blockInformation","useBlockDisplayInformation","blockTitle","useBlockDisplayTitle","context","isLocked","useBlockLock","isContentOnly","useSelect","select","blockEditorStore","getBlockEditingMode","shouldShowLockIcon","isSticky","positionType","images","useListViewImages","onDragStartHandler","event","dataTransfer","clearData","onKeyDown","keyCode","ENTER","SPACE","jsxs","clsx","href","children","jsx","default","icon","showColors","__experimentalHStack","alignment","justify","spacing","__experimentalTruncate","ellipsizeMode","anchor","Icon","pinSmall","length","map","image","index","style","backgroundImage","url","zIndex","lock","_default","exports","forwardRef"],"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, lockSmall as lock, pinSmall } from '@wordpress/icons';\nimport { SPACE, ENTER } from '@wordpress/keycodes';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport ListViewExpander from './expander';\nimport { useBlockLock } from '../block-lock';\nimport useListViewImages from './use-list-view-images';\nimport { store as blockEditorStore } from '../../store';\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock: { clientId },\n\t\tonClick,\n\t\tonContextMenu,\n\t\tonMouseDown,\n\t\tonToggleExpanded,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t\tisExpanded,\n\t\tariaDescribedBy,\n\t},\n\tref\n) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst { isLocked } = useBlockLock( clientId );\n\tconst { isContentOnly } = useSelect(\n\t\t( select ) => ( {\n\t\t\tisContentOnly:\n\t\t\t\tselect( blockEditorStore ).getBlockEditingMode( clientId ) ===\n\t\t\t\t'contentOnly',\n\t\t} ),\n\t\t[ clientId ]\n\t);\n\tconst shouldShowLockIcon = isLocked && ! isContentOnly;\n\tconst isSticky = blockInformation?.positionType === 'sticky';\n\tconst images = useListViewImages( { clientId, isExpanded } );\n\n\t// The `href` attribute triggers the browser's native HTML drag operations.\n\t// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.\n\t// We need to clear any HTML drag data to prevent `pasteHandler` from firing\n\t// inside the `useOnBlockDrop` hook.\n\tconst onDragStartHandler = ( event ) => {\n\t\tevent.dataTransfer.clearData();\n\t\tonDragStart?.( event );\n\t};\n\n\t/**\n\t * @param {KeyboardEvent} event\n\t */\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER || event.keyCode === SPACE ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<a\n\t\t\tclassName={ clsx(\n\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\tonClick={ onClick }\n\t\t\tonContextMenu={ onContextMenu }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\tonMouseDown={ onMouseDown }\n\t\t\tref={ ref }\n\t\t\ttabIndex={ tabIndex }\n\t\t\tonFocus={ onFocus }\n\t\t\tonDragStart={ onDragStartHandler }\n\t\t\tonDragEnd={ onDragEnd }\n\t\t\tdraggable={ draggable }\n\t\t\thref={ `#block-${ clientId }` }\n\t\t\taria-describedby={ ariaDescribedBy }\n\t\t\taria-expanded={ isExpanded }\n\t\t>\n\t\t\t<ListViewExpander onClick={ onToggleExpanded } />\n\t\t\t<BlockIcon\n\t\t\t\ticon={ blockInformation?.icon }\n\t\t\t\tshowColors\n\t\t\t\tcontext=\"list-view\"\n\t\t\t/>\n\t\t\t<HStack\n\t\t\t\talignment=\"center\"\n\t\t\t\tclassName=\"block-editor-list-view-block-select-button__label-wrapper\"\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tspacing={ 1 }\n\t\t\t>\n\t\t\t\t<span className=\"block-editor-list-view-block-select-button__title\">\n\t\t\t\t\t<Truncate ellipsizeMode=\"auto\">{ blockTitle }</Truncate>\n\t\t\t\t</span>\n\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor-wrapper\">\n\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__anchor\"\n\t\t\t\t\t\t\tellipsizeMode=\"auto\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ isSticky && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__sticky\">\n\t\t\t\t\t\t<Icon icon={ pinSmall } />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ images.length ? (\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__images\"\n\t\t\t\t\t\taria-hidden\n\t\t\t\t\t>\n\t\t\t\t\t\t{ images.map( ( image, index ) => (\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__image\"\n\t\t\t\t\t\t\t\tkey={ image.clientId }\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tbackgroundImage: `url(${ image.url })`,\n\t\t\t\t\t\t\t\t\tzIndex: images.length - index, // Ensure the first image is on top, and subsequent images are behind.\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</span>\n\t\t\t\t) : null }\n\t\t\t\t{ shouldShowLockIcon && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__lock\">\n\t\t\t\t\t\t<Icon icon={ lock } />\n\t\t\t\t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,EAETb,MAAM,CAAC4B,GAAG,CAAE,CAAEC,KAAK,EAAEC,KAAK,kBAC3B,IAAA9D,WAAA,CAAA8C,GAAA;UACC5C,SAAS,EAAC,mDAAmD;UAE7D6D,KAAK,EAAG;YACPC,eAAe,EAAE,OAAQH,KAAK,CAACI,GAAG,GAAI;YACtCC,MAAM,EAAElC,MAAM,CAAC2B,MAAM,GAAGG,KAAK,CAAE;UAChC;QAAG,GAJGD,KAAK,CAACzD,QAKZ,CACA;MAAC,CACE,CAAC,GACJ,IAAI,EACNyB,kBAAkB,iBACnB,IAAA7B,WAAA,CAAA8C,GAAA;QAAM5C,SAAS,EAAC,kDAAkD;QAAA2C,QAAA,eACjE,IAAA7C,WAAA,CAAA8C,GAAA,EAACxD,MAAA,CAAAmE,IAAI;UAACT,IAAI,EAAGmB;QAAM,CAAE;MAAC,CACjB,CACN;IAAA,CACM,CAAC;EAAA,CACP,CAAC;AAEN;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAtB,OAAA,GAEc,IAAAuB,mBAAU,EAAErE,yBAA0B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_element","_icons","_keycodes","_data","_blockIcon","_useBlockDisplayInformation","_useBlockDisplayTitle","_expander","_blockLock","_useListViewImages","_store","_lockUnlock","_jsxRuntime","Badge","unlock","componentsPrivateApis","ListViewBlockSelectButton","className","block","clientId","onClick","onContextMenu","onMouseDown","onToggleExpanded","tabIndex","onFocus","onDragStart","onDragEnd","draggable","isExpanded","ariaDescribedBy","ref","blockInformation","useBlockDisplayInformation","blockTitle","useBlockDisplayTitle","context","isLocked","useBlockLock","isContentOnly","useSelect","select","blockEditorStore","getBlockEditingMode","shouldShowLockIcon","isSticky","positionType","images","useListViewImages","onDragStartHandler","event","dataTransfer","clearData","onKeyDown","keyCode","ENTER","SPACE","jsxs","clsx","href","children","jsx","default","icon","showColors","__experimentalHStack","alignment","justify","spacing","__experimentalTruncate","ellipsizeMode","anchor","Icon","pinSmall","length","map","image","index","style","backgroundImage","url","zIndex","lock","_default","exports","forwardRef"],"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, lockSmall as lock, pinSmall } from '@wordpress/icons';\nimport { SPACE, ENTER } from '@wordpress/keycodes';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport ListViewExpander from './expander';\nimport { useBlockLock } from '../block-lock';\nimport useListViewImages from './use-list-view-images';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nconst { Badge } = unlock( componentsPrivateApis );\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock: { clientId },\n\t\tonClick,\n\t\tonContextMenu,\n\t\tonMouseDown,\n\t\tonToggleExpanded,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t\tisExpanded,\n\t\tariaDescribedBy,\n\t},\n\tref\n) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst { isLocked } = useBlockLock( clientId );\n\tconst { isContentOnly } = useSelect(\n\t\t( select ) => ( {\n\t\t\tisContentOnly:\n\t\t\t\tselect( blockEditorStore ).getBlockEditingMode( clientId ) ===\n\t\t\t\t'contentOnly',\n\t\t} ),\n\t\t[ clientId ]\n\t);\n\tconst shouldShowLockIcon = isLocked && ! isContentOnly;\n\tconst isSticky = blockInformation?.positionType === 'sticky';\n\tconst images = useListViewImages( { clientId, isExpanded } );\n\n\t// The `href` attribute triggers the browser's native HTML drag operations.\n\t// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.\n\t// We need to clear any HTML drag data to prevent `pasteHandler` from firing\n\t// inside the `useOnBlockDrop` hook.\n\tconst onDragStartHandler = ( event ) => {\n\t\tevent.dataTransfer.clearData();\n\t\tonDragStart?.( event );\n\t};\n\n\t/**\n\t * @param {KeyboardEvent} event\n\t */\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER || event.keyCode === SPACE ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<a\n\t\t\tclassName={ clsx(\n\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\tonClick={ onClick }\n\t\t\tonContextMenu={ onContextMenu }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\tonMouseDown={ onMouseDown }\n\t\t\tref={ ref }\n\t\t\ttabIndex={ tabIndex }\n\t\t\tonFocus={ onFocus }\n\t\t\tonDragStart={ onDragStartHandler }\n\t\t\tonDragEnd={ onDragEnd }\n\t\t\tdraggable={ draggable }\n\t\t\thref={ `#block-${ clientId }` }\n\t\t\taria-describedby={ ariaDescribedBy }\n\t\t\taria-expanded={ isExpanded }\n\t\t>\n\t\t\t<ListViewExpander onClick={ onToggleExpanded } />\n\t\t\t<BlockIcon\n\t\t\t\ticon={ blockInformation?.icon }\n\t\t\t\tshowColors\n\t\t\t\tcontext=\"list-view\"\n\t\t\t/>\n\t\t\t<HStack\n\t\t\t\talignment=\"center\"\n\t\t\t\tclassName=\"block-editor-list-view-block-select-button__label-wrapper\"\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tspacing={ 1 }\n\t\t\t>\n\t\t\t\t<span className=\"block-editor-list-view-block-select-button__title\">\n\t\t\t\t\t<Truncate ellipsizeMode=\"auto\">{ blockTitle }</Truncate>\n\t\t\t\t</span>\n\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor-wrapper\">\n\t\t\t\t\t\t<Badge className=\"block-editor-list-view-block-select-button__anchor\">\n\t\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t\t</Badge>\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ isSticky && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__sticky\">\n\t\t\t\t\t\t<Icon icon={ pinSmall } />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ images.length ? (\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__images\"\n\t\t\t\t\t\taria-hidden\n\t\t\t\t\t>\n\t\t\t\t\t\t{ images.map( ( image, index ) => (\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__image\"\n\t\t\t\t\t\t\t\tkey={ image.clientId }\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tbackgroundImage: `url(${ image.url })`,\n\t\t\t\t\t\t\t\t\tzIndex: images.length - index, // Ensure the first image is on top, and subsequent images are behind.\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</span>\n\t\t\t\t) : null }\n\t\t\t\t{ shouldShowLockIcon && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__lock\">\n\t\t\t\t\t\t<Icon icon={ lock } />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</a>\n\t);\n}\n\nexport default forwardRef( ListViewBlockSelectButton );\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,S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C,MAAM,EAAElC,MAAM,CAAC2B,MAAM,GAAGG,KAAK,CAAE;UAChC;QAAG,GAJGD,KAAK,CAACzD,QAKZ,CACA;MAAC,CACE,CAAC,GACJ,IAAI,EACNyB,kBAAkB,iBACnB,IAAAhC,WAAA,CAAAiD,GAAA;QAAM5C,SAAS,EAAC,kDAAkD;QAAA2C,QAAA,eACjE,IAAAhD,WAAA,CAAAiD,GAAA,EAAC5D,MAAA,CAAAuE,IAAI;UAACT,IAAI,EAAGmB;QAAM,CAAE;MAAC,CACjB,CACN;IAAA,CACM,CAAC;EAAA,CACP,CAAC;AAEN;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAtB,OAAA,GAEc,IAAAuB,mBAAU,EAAErE,yBAA0B,CAAC","ignoreList":[]}
@@ -48,6 +48,7 @@ const InsertFromURLPopover = ({
48
48
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalInputControl, {
49
49
  __next40pxDefaultSize: true,
50
50
  label: (0, _i18n.__)('URL'),
51
+ type: "url",
51
52
  hideLabelFromVision: true,
52
53
  placeholder: (0, _i18n.__)('Paste or type URL'),
53
54
  onChange: onChange,
@@ -1 +1 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_data","_icons","_deprecated","_mediaUpload","_check","_urlPopover","_store","_useOnBlockDrop","_jsxRuntime","noop","InsertFromURLPopover","src","onChange","onSubmit","onClose","popoverAnchor","jsx","default","anchor","children","className","__experimentalInputControl","__next40pxDefaultSize","label","__","hideLabelFromVision","placeholder","value","suffix","__experimentalInputControlSuffixWrapper","variant","Button","size","icon","keyboardReturn","type","URLSelectionUI","onChangeSrc","onSelectURL","setPopoverAnchor","useState","isURLInputVisible","setIsURLInputVisible","openURLInput","closeURLInput","focus","onSubmitSrc","event","preventDefault","jsxs","onClick","isPressed","ref","MediaPlaceholder","allowedTypes","labels","mediaPreview","notices","isAppender","accept","addToGallery","multiple","handleUpload","disableDropZone","disableMediaButtons","onError","onSelect","onCancel","onToggleFeaturedImage","onDoubleClick","onFilesPreUpload","onHTMLDrop","deprecatedOnHTMLDrop","mediaLibraryButton","style","deprecated","since","version","mediaUpload","useSelect","select","getSettings","blockEditorStore","setSrc","useEffect","_value$src","onlyAllowsImages","length","every","allowedType","startsWith","onFilesUpload","files","setMedia","lastMediaPassed","newMedia","filteredMedia","filter","item","id","some","Number","urlSlug","url","includes","concat","map","media","cutOffIndex","lastIndexOf","slice","filesList","onFileChange","handleBlocksDrop","blocks","parseDropEvent","uploadedMediaList","Promise","all","block","blockType","name","split","attributes","resolve","reject","window","fetch","then","response","blob","additionalData","title","alt_text","alt","caption","catch","err","onUpload","target","defaultRenderPlaceholder","content","instructions","undefined","typesAllowed","firstAllowedType","isOneType","isAudio","isImage","isVideo","placeholderClassName","clsx","Placeholder","preview","renderPlaceholder","renderDropZone","DropZone","onFilesDrop","onDrop","isEligible","dataTransfer","prefix","types","push","renderCancelLink","renderUrlSelectionUI","renderFeaturedImageToggle","renderMediaUploadChecked","defaultButton","open","libraryButton","uploadMediaLibraryButton","gallery","mode","Array","isArray","render","Fragment","FormFileUpload","openFileDialog","_x","fallback","_default","exports","withFilters"],"sources":["@wordpress/block-editor/src/components/media-placeholder/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tFormFileUpload,\n\tPlaceholder,\n\tDropZone,\n\t__experimentalInputControl as InputControl,\n\t__experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,\n\twithFilters,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { keyboardReturn } from '@wordpress/icons';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport URLPopover from '../url-popover';\nimport { store as blockEditorStore } from '../../store';\nimport { parseDropEvent } from '../use-on-block-drop';\n\nconst noop = () => {};\n\nconst InsertFromURLPopover = ( {\n\tsrc,\n\tonChange,\n\tonSubmit,\n\tonClose,\n\tpopoverAnchor,\n} ) => (\n\t<URLPopover anchor={ popoverAnchor } onClose={ onClose }>\n\t\t<form\n\t\t\tclassName=\"block-editor-media-placeholder__url-input-form\"\n\t\t\tonSubmit={ onSubmit }\n\t\t>\n\t\t\t<InputControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'URL' ) }\n\t\t\t\thideLabelFromVision\n\t\t\t\tplaceholder={ __( 'Paste or type URL' ) }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ src }\n\t\t\t\tsuffix={\n\t\t\t\t\t<InputControlSuffixWrapper variant=\"control\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ticon={ keyboardReturn }\n\t\t\t\t\t\t\tlabel={ __( 'Apply' ) }\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</InputControlSuffixWrapper>\n\t\t\t\t}\n\t\t\t/>\n\t\t</form>\n\t</URLPopover>\n);\n\nconst URLSelectionUI = ( { src, onChangeSrc, onSelectURL } ) => {\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst [ isURLInputVisible, setIsURLInputVisible ] = useState( false );\n\n\tconst openURLInput = () => {\n\t\tsetIsURLInputVisible( true );\n\t};\n\tconst closeURLInput = () => {\n\t\tsetIsURLInputVisible( false );\n\t\tpopoverAnchor?.focus();\n\t};\n\n\tconst onSubmitSrc = ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( src && onSelectURL ) {\n\t\t\tonSelectURL( src );\n\t\t\tcloseURLInput();\n\t\t}\n\t};\n\n\treturn (\n\t\t<div className=\"block-editor-media-placeholder__url-input-container\">\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"block-editor-media-placeholder__button\"\n\t\t\t\tonClick={ openURLInput }\n\t\t\t\tisPressed={ isURLInputVisible }\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t>\n\t\t\t\t{ __( 'Insert from URL' ) }\n\t\t\t</Button>\n\t\t\t{ isURLInputVisible && (\n\t\t\t\t<InsertFromURLPopover\n\t\t\t\t\tsrc={ src }\n\t\t\t\t\tonChange={ onChangeSrc }\n\t\t\t\t\tonSubmit={ onSubmitSrc }\n\t\t\t\t\tonClose={ closeURLInput }\n\t\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n};\n\nexport function MediaPlaceholder( {\n\tvalue = {},\n\tallowedTypes,\n\tclassName,\n\ticon,\n\tlabels = {},\n\tmediaPreview,\n\tnotices,\n\tisAppender,\n\taccept,\n\taddToGallery,\n\tmultiple = false,\n\thandleUpload = true,\n\tdisableDropZone,\n\tdisableMediaButtons,\n\tonError,\n\tonSelect,\n\tonCancel,\n\tonSelectURL,\n\tonToggleFeaturedImage,\n\tonDoubleClick,\n\tonFilesPreUpload = noop,\n\tonHTMLDrop: deprecatedOnHTMLDrop,\n\tchildren,\n\tmediaLibraryButton,\n\tplaceholder,\n\tstyle,\n} ) {\n\tif ( deprecatedOnHTMLDrop ) {\n\t\tdeprecated( 'wp.blockEditor.MediaPlaceholder onHTMLDrop prop', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t} );\n\t}\n\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().mediaUpload;\n\t}, [] );\n\tconst [ src, setSrc ] = useState( '' );\n\n\tuseEffect( () => {\n\t\tsetSrc( value?.src ?? '' );\n\t}, [ value?.src ] );\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 onFilesUpload = ( files ) => {\n\t\tif (\n\t\t\t! handleUpload ||\n\t\t\t( typeof handleUpload === 'function' && ! handleUpload( files ) )\n\t\t) {\n\t\t\treturn onSelect( files );\n\t\t}\n\t\tonFilesPreUpload( files );\n\t\tlet setMedia;\n\t\tif ( multiple ) {\n\t\t\tif ( addToGallery ) {\n\t\t\t\t// Since the setMedia function runs multiple times per upload group\n\t\t\t\t// and is passed newMedia containing every item in its group each time, we must\n\t\t\t\t// filter out whatever this upload group had previously returned to the\n\t\t\t\t// gallery before adding and returning the image array with replacement newMedia\n\t\t\t\t// values.\n\n\t\t\t\t// Define an array to store urls from newMedia between subsequent function calls.\n\t\t\t\tlet lastMediaPassed = [];\n\t\t\t\tsetMedia = ( newMedia ) => {\n\t\t\t\t\t// Remove any images this upload group is responsible for (lastMediaPassed).\n\t\t\t\t\t// Their replacements are contained in newMedia.\n\t\t\t\t\tconst filteredMedia = ( value ?? [] ).filter( ( item ) => {\n\t\t\t\t\t\t// If Item has id, only remove it if lastMediaPassed has an item with that id.\n\t\t\t\t\t\tif ( item.id ) {\n\t\t\t\t\t\t\treturn ! lastMediaPassed.some(\n\t\t\t\t\t\t\t\t// Be sure to convert to number for comparison.\n\t\t\t\t\t\t\t\t( { id } ) => Number( id ) === Number( item.id )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Compare transient images via .includes since gallery may append extra info onto the url.\n\t\t\t\t\t\treturn ! lastMediaPassed.some( ( { urlSlug } ) =>\n\t\t\t\t\t\t\titem.url.includes( urlSlug )\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\t\t\t\t\t// Return the filtered media array along with newMedia.\n\t\t\t\t\tonSelect( filteredMedia.concat( newMedia ) );\n\t\t\t\t\t// Reset lastMediaPassed and set it with ids and urls from newMedia.\n\t\t\t\t\tlastMediaPassed = newMedia.map( ( media ) => {\n\t\t\t\t\t\t// Add everything up to '.fileType' to compare via .includes.\n\t\t\t\t\t\tconst cutOffIndex = media.url.lastIndexOf( '.' );\n\t\t\t\t\t\tconst urlSlug = media.url.slice( 0, cutOffIndex );\n\t\t\t\t\t\treturn { id: media.id, urlSlug };\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tsetMedia = onSelect;\n\t\t\t}\n\t\t} else {\n\t\t\tsetMedia = ( [ media ] ) => onSelect( media );\n\t\t}\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: setMedia,\n\t\t\tonError,\n\t\t} );\n\t};\n\n\tasync function handleBlocksDrop( event ) {\n\t\tconst { blocks } = parseDropEvent( event );\n\n\t\tif ( ! blocks?.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst uploadedMediaList = await Promise.all(\n\t\t\tblocks.map( ( block ) => {\n\t\t\t\tconst blockType = block.name.split( '/' )[ 1 ];\n\t\t\t\tif ( block.attributes.id ) {\n\t\t\t\t\tblock.attributes.type = blockType;\n\t\t\t\t\treturn block.attributes;\n\t\t\t\t}\n\t\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\t\twindow\n\t\t\t\t\t\t.fetch( block.attributes.url )\n\t\t\t\t\t\t.then( ( response ) => response.blob() )\n\t\t\t\t\t\t.then( ( blob ) =>\n\t\t\t\t\t\t\tmediaUpload( {\n\t\t\t\t\t\t\t\tfilesList: [ blob ],\n\t\t\t\t\t\t\t\tadditionalData: {\n\t\t\t\t\t\t\t\t\ttitle: block.attributes.title,\n\t\t\t\t\t\t\t\t\talt_text: block.attributes.alt,\n\t\t\t\t\t\t\t\t\tcaption: block.attributes.caption,\n\t\t\t\t\t\t\t\t\ttype: blockType,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tonFileChange: ( [ media ] ) => {\n\t\t\t\t\t\t\t\t\tif ( media.id ) {\n\t\t\t\t\t\t\t\t\t\tresolve( media );\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\tallowedTypes,\n\t\t\t\t\t\t\t\tonError: reject,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.catch( () => resolve( block.attributes.url ) );\n\t\t\t\t} );\n\t\t\t} )\n\t\t).catch( ( err ) => onError( err ) );\n\n\t\tif ( multiple ) {\n\t\t\tonSelect( uploadedMediaList );\n\t\t} else {\n\t\t\tonSelect( uploadedMediaList[ 0 ] );\n\t\t}\n\t}\n\n\tconst onUpload = ( event ) => {\n\t\tonFilesUpload( event.target.files );\n\t};\n\n\tconst defaultRenderPlaceholder = ( content ) => {\n\t\tlet { instructions, title } = labels;\n\n\t\tif ( ! mediaUpload && ! onSelectURL ) {\n\t\t\tinstructions = __(\n\t\t\t\t'To edit this block, you need permission to upload media.'\n\t\t\t);\n\t\t}\n\n\t\tif ( instructions === undefined || title === undefined ) {\n\t\t\tconst typesAllowed = allowedTypes ?? [];\n\n\t\t\tconst [ firstAllowedType ] = typesAllowed;\n\t\t\tconst isOneType = 1 === typesAllowed.length;\n\t\t\tconst isAudio = isOneType && 'audio' === firstAllowedType;\n\t\t\tconst isImage = isOneType && 'image' === firstAllowedType;\n\t\t\tconst isVideo = isOneType && 'video' === firstAllowedType;\n\n\t\t\tif ( instructions === undefined && mediaUpload ) {\n\t\t\t\tinstructions = __(\n\t\t\t\t\t'Drag and drop an image or video, upload, or choose from your library.'\n\t\t\t\t);\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Drag and drop an audio file, upload, or choose from your library.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Drag and drop an image, upload, or choose from your library.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Drag and drop a video, upload, or choose from your library.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( title === undefined ) {\n\t\t\t\ttitle = __( 'Media' );\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\ttitle = __( 'Audio' );\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\ttitle = __( 'Image' );\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\ttitle = __( 'Video' );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst placeholderClassName = clsx(\n\t\t\t'block-editor-media-placeholder',\n\t\t\tclassName,\n\t\t\t{\n\t\t\t\t'is-appender': isAppender,\n\t\t\t}\n\t\t);\n\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ title }\n\t\t\t\tinstructions={ instructions }\n\t\t\t\tclassName={ placeholderClassName }\n\t\t\t\tnotices={ notices }\n\t\t\t\tonDoubleClick={ onDoubleClick }\n\t\t\t\tpreview={ mediaPreview }\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t\t{ children }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\tconst renderPlaceholder = placeholder ?? defaultRenderPlaceholder;\n\n\tconst renderDropZone = () => {\n\t\tif ( disableDropZone ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<DropZone\n\t\t\t\tonFilesDrop={ onFilesUpload }\n\t\t\t\tonDrop={ handleBlocksDrop }\n\t\t\t\tisEligible={ ( dataTransfer ) => {\n\t\t\t\t\tconst prefix = 'wp-block:core/';\n\t\t\t\t\tconst types = [];\n\t\t\t\t\tfor ( const type of dataTransfer.types ) {\n\t\t\t\t\t\tif ( type.startsWith( prefix ) ) {\n\t\t\t\t\t\t\ttypes.push( type.slice( prefix.length ) );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn (\n\t\t\t\t\t\ttypes.every( ( type ) =>\n\t\t\t\t\t\t\tallowedTypes.includes( type )\n\t\t\t\t\t\t) && ( multiple ? true : types.length === 1 )\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t};\n\n\tconst renderCancelLink = () => {\n\t\treturn (\n\t\t\tonCancel && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tclassName=\"block-editor-media-placeholder__cancel-button\"\n\t\t\t\t\ttitle={ __( 'Cancel' ) }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\tonClick={ onCancel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</Button>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderUrlSelectionUI = () => {\n\t\treturn (\n\t\t\tonSelectURL && (\n\t\t\t\t<URLSelectionUI\n\t\t\t\t\tsrc={ src }\n\t\t\t\t\tonChangeSrc={ setSrc }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t/>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderFeaturedImageToggle = () => {\n\t\treturn (\n\t\t\tonToggleFeaturedImage && (\n\t\t\t\t<div className=\"block-editor-media-placeholder__url-input-container\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tclassName=\"block-editor-media-placeholder__button\"\n\t\t\t\t\t\tonClick={ onToggleFeaturedImage }\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Use featured image' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderMediaUploadChecked = () => {\n\t\tconst defaultButton = ( { open } ) => {\n\t\t\treturn (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\topen();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Media Library' ) }\n\t\t\t\t</Button>\n\t\t\t);\n\t\t};\n\t\tconst libraryButton = mediaLibraryButton ?? defaultButton;\n\t\tconst uploadMediaLibraryButton = (\n\t\t\t<MediaUpload\n\t\t\t\taddToGallery={ addToGallery }\n\t\t\t\tgallery={ multiple && onlyAllowsImages() }\n\t\t\t\tmultiple={ multiple }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\tmode=\"browse\"\n\t\t\t\tvalue={\n\t\t\t\t\tArray.isArray( value )\n\t\t\t\t\t\t? value.map( ( { id } ) => id )\n\t\t\t\t\t\t: value.id\n\t\t\t\t}\n\t\t\t\trender={ libraryButton }\n\t\t\t/>\n\t\t);\n\n\t\tif ( mediaUpload && isAppender ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ !! multiple }\n\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\tconst content = (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tonClick={ openFileDialog }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ _x( 'Upload', 'verb' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t{ uploadMediaLibraryButton }\n\t\t\t\t\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t\t\t\t\t{ renderFeaturedImageToggle() }\n\t\t\t\t\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn renderPlaceholder( content );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\tif ( mediaUpload ) {\n\t\t\tconst content = (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\trender={ ( { openFileDialog } ) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tonClick={ openFileDialog }\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ _x( 'Upload', 'verb' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ !! multiple }\n\t\t\t\t\t/>\n\t\t\t\t\t{ uploadMediaLibraryButton }\n\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t{ renderFeaturedImageToggle() }\n\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t</>\n\t\t\t);\n\t\t\treturn renderPlaceholder( content );\n\t\t}\n\n\t\treturn renderPlaceholder( uploadMediaLibraryButton );\n\t};\n\n\tif ( disableMediaButtons ) {\n\t\treturn <MediaUploadCheck>{ renderDropZone() }</MediaUploadCheck>;\n\t}\n\n\treturn (\n\t\t<MediaUploadCheck\n\t\t\tfallback={ renderPlaceholder( renderUrlSelectionUI() ) }\n\t\t>\n\t\t\t{ renderMediaUploadChecked() }\n\t\t</MediaUploadCheck>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-placeholder/README.md\n */\nexport default withFilters( 'editor.MediaPlaceholder' )( MediaPlaceholder );\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AASA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAP,sBAAA,CAAAC,OAAA;AAKA,IAAAO,YAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,MAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,WAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,eAAA,GAAAX,OAAA;AAAsD,IAAAY,WAAA,GAAAZ,OAAA;AA9BtD;AACA;AACA;;AAGA;AACA;AACA;;AAgBA;AACA;AACA;;AAOA,MAAMa,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,MAAMC,oBAAoB,GAAGA,CAAE;EAC9BC,GAAG;EACHC,QAAQ;EACRC,QAAQ;EACRC,OAAO;EACPC;AACD,CAAC,kBACA,IAAAP,WAAA,CAAAQ,GAAA,EAACX,WAAA,CAAAY,OAAU;EAACC,MAAM,EAAGH,aAAe;EAACD,OAAO,EAAGA,OAAS;EAAAK,QAAA,eACvD,IAAAX,WAAA,CAAAQ,GAAA;IACCI,SAAS,EAAC,gDAAgD;IAC1DP,QAAQ,EAAGA,QAAU;IAAAM,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G;UAAe,CAAC,kBAC5B,IAAA3K,WAAA,CAAAQ,GAAA,EAACnB,WAAA,CAAAkC,MAAM;YACNT,qBAAqB;YACrB4B,OAAO,EAAGiI,cAAgB;YAC1BrJ,OAAO,EAAC,SAAS;YACjBV,SAAS,EAAG,IAAAmI,aAAI,EACf,wCAAwC,EACxC,+CACD,CAAG;YAAApI,QAAA,EAED,IAAAiK,QAAE,EAAE,QAAQ,EAAE,MAAO;UAAC,CACjB,CACN;UACHxK,QAAQ,EAAG8H,QAAU;UACrB/E,MAAM,EAAGA,MAAQ;UACjBE,QAAQ,EAAG,CAAC,CAAEA;QAAU,CACxB,CAAC,EACA8G,wBAAwB,EACxBN,oBAAoB,CAAC,CAAC,EACtBC,yBAAyB,CAAC,CAAC,EAC3BF,gBAAgB,CAAC,CAAC;MAAA,CACnB,CACF;MACD,OAAOV,iBAAiB,CAAEb,OAAQ,CAAC;IACpC;IAEA,OAAOa,iBAAiB,CAAEiB,wBAAyB,CAAC;EACrD,CAAC;EAED,IAAK3G,mBAAmB,EAAG;IAC1B,oBAAO,IAAAxD,WAAA,CAAAQ,GAAA,EAACZ,MAAA,CAAAa,OAAgB;MAAAE,QAAA,EAAGwI,cAAc,CAAC;IAAC,CAAoB,CAAC;EACjE;EAEA,oBACC,IAAAnJ,WAAA,CAAAQ,GAAA,EAACZ,MAAA,CAAAa,OAAgB;IAChBoK,QAAQ,EAAG3B,iBAAiB,CAAEW,oBAAoB,CAAC,CAAE,CAAG;IAAAlJ,QAAA,EAEtDoJ,wBAAwB,CAAC;EAAC,CACX,CAAC;AAErB;;AAEA;AACA;AACA;AAFA,IAAAe,QAAA,GAAAC,OAAA,CAAAtK,OAAA,GAGe,IAAAuK,uBAAW,EAAE,yBAA0B,CAAC,CAAEnI,gBAAiB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_element","_data","_icons","_deprecated","_mediaUpload","_check","_urlPopover","_store","_useOnBlockDrop","_jsxRuntime","noop","InsertFromURLPopover","src","onChange","onSubmit","onClose","popoverAnchor","jsx","default","anchor","children","className","__experimentalInputControl","__next40pxDefaultSize","label","__","type","hideLabelFromVision","placeholder","value","suffix","__experimentalInputControlSuffixWrapper","variant","Button","size","icon","keyboardReturn","URLSelectionUI","onChangeSrc","onSelectURL","setPopoverAnchor","useState","isURLInputVisible","setIsURLInputVisible","openURLInput","closeURLInput","focus","onSubmitSrc","event","preventDefault","jsxs","onClick","isPressed","ref","MediaPlaceholder","allowedTypes","labels","mediaPreview","notices","isAppender","accept","addToGallery","multiple","handleUpload","disableDropZone","disableMediaButtons","onError","onSelect","onCancel","onToggleFeaturedImage","onDoubleClick","onFilesPreUpload","onHTMLDrop","deprecatedOnHTMLDrop","mediaLibraryButton","style","deprecated","since","version","mediaUpload","useSelect","select","getSettings","blockEditorStore","setSrc","useEffect","_value$src","onlyAllowsImages","length","every","allowedType","startsWith","onFilesUpload","files","setMedia","lastMediaPassed","newMedia","filteredMedia","filter","item","id","some","Number","urlSlug","url","includes","concat","map","media","cutOffIndex","lastIndexOf","slice","filesList","onFileChange","handleBlocksDrop","blocks","parseDropEvent","uploadedMediaList","Promise","all","block","blockType","name","split","attributes","resolve","reject","window","fetch","then","response","blob","additionalData","title","alt_text","alt","caption","catch","err","onUpload","target","defaultRenderPlaceholder","content","instructions","undefined","typesAllowed","firstAllowedType","isOneType","isAudio","isImage","isVideo","placeholderClassName","clsx","Placeholder","preview","renderPlaceholder","renderDropZone","DropZone","onFilesDrop","onDrop","isEligible","dataTransfer","prefix","types","push","renderCancelLink","renderUrlSelectionUI","renderFeaturedImageToggle","renderMediaUploadChecked","defaultButton","open","libraryButton","uploadMediaLibraryButton","gallery","mode","Array","isArray","render","Fragment","FormFileUpload","openFileDialog","_x","fallback","_default","exports","withFilters"],"sources":["@wordpress/block-editor/src/components/media-placeholder/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tFormFileUpload,\n\tPlaceholder,\n\tDropZone,\n\t__experimentalInputControl as InputControl,\n\t__experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,\n\twithFilters,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { keyboardReturn } from '@wordpress/icons';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport MediaUpload from '../media-upload';\nimport MediaUploadCheck from '../media-upload/check';\nimport URLPopover from '../url-popover';\nimport { store as blockEditorStore } from '../../store';\nimport { parseDropEvent } from '../use-on-block-drop';\n\nconst noop = () => {};\n\nconst InsertFromURLPopover = ( {\n\tsrc,\n\tonChange,\n\tonSubmit,\n\tonClose,\n\tpopoverAnchor,\n} ) => (\n\t<URLPopover anchor={ popoverAnchor } onClose={ onClose }>\n\t\t<form\n\t\t\tclassName=\"block-editor-media-placeholder__url-input-form\"\n\t\t\tonSubmit={ onSubmit }\n\t\t>\n\t\t\t<InputControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'URL' ) }\n\t\t\t\ttype=\"url\"\n\t\t\t\thideLabelFromVision\n\t\t\t\tplaceholder={ __( 'Paste or type URL' ) }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ src }\n\t\t\t\tsuffix={\n\t\t\t\t\t<InputControlSuffixWrapper variant=\"control\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ticon={ keyboardReturn }\n\t\t\t\t\t\t\tlabel={ __( 'Apply' ) }\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</InputControlSuffixWrapper>\n\t\t\t\t}\n\t\t\t/>\n\t\t</form>\n\t</URLPopover>\n);\n\nconst URLSelectionUI = ( { src, onChangeSrc, onSelectURL } ) => {\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst [ isURLInputVisible, setIsURLInputVisible ] = useState( false );\n\n\tconst openURLInput = () => {\n\t\tsetIsURLInputVisible( true );\n\t};\n\tconst closeURLInput = () => {\n\t\tsetIsURLInputVisible( false );\n\t\tpopoverAnchor?.focus();\n\t};\n\n\tconst onSubmitSrc = ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( src && onSelectURL ) {\n\t\t\tonSelectURL( src );\n\t\t\tcloseURLInput();\n\t\t}\n\t};\n\n\treturn (\n\t\t<div className=\"block-editor-media-placeholder__url-input-container\">\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"block-editor-media-placeholder__button\"\n\t\t\t\tonClick={ openURLInput }\n\t\t\t\tisPressed={ isURLInputVisible }\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\tref={ setPopoverAnchor }\n\t\t\t>\n\t\t\t\t{ __( 'Insert from URL' ) }\n\t\t\t</Button>\n\t\t\t{ isURLInputVisible && (\n\t\t\t\t<InsertFromURLPopover\n\t\t\t\t\tsrc={ src }\n\t\t\t\t\tonChange={ onChangeSrc }\n\t\t\t\t\tonSubmit={ onSubmitSrc }\n\t\t\t\t\tonClose={ closeURLInput }\n\t\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n};\n\nexport function MediaPlaceholder( {\n\tvalue = {},\n\tallowedTypes,\n\tclassName,\n\ticon,\n\tlabels = {},\n\tmediaPreview,\n\tnotices,\n\tisAppender,\n\taccept,\n\taddToGallery,\n\tmultiple = false,\n\thandleUpload = true,\n\tdisableDropZone,\n\tdisableMediaButtons,\n\tonError,\n\tonSelect,\n\tonCancel,\n\tonSelectURL,\n\tonToggleFeaturedImage,\n\tonDoubleClick,\n\tonFilesPreUpload = noop,\n\tonHTMLDrop: deprecatedOnHTMLDrop,\n\tchildren,\n\tmediaLibraryButton,\n\tplaceholder,\n\tstyle,\n} ) {\n\tif ( deprecatedOnHTMLDrop ) {\n\t\tdeprecated( 'wp.blockEditor.MediaPlaceholder onHTMLDrop prop', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t} );\n\t}\n\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().mediaUpload;\n\t}, [] );\n\tconst [ src, setSrc ] = useState( '' );\n\n\tuseEffect( () => {\n\t\tsetSrc( value?.src ?? '' );\n\t}, [ value?.src ] );\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 onFilesUpload = ( files ) => {\n\t\tif (\n\t\t\t! handleUpload ||\n\t\t\t( typeof handleUpload === 'function' && ! handleUpload( files ) )\n\t\t) {\n\t\t\treturn onSelect( files );\n\t\t}\n\t\tonFilesPreUpload( files );\n\t\tlet setMedia;\n\t\tif ( multiple ) {\n\t\t\tif ( addToGallery ) {\n\t\t\t\t// Since the setMedia function runs multiple times per upload group\n\t\t\t\t// and is passed newMedia containing every item in its group each time, we must\n\t\t\t\t// filter out whatever this upload group had previously returned to the\n\t\t\t\t// gallery before adding and returning the image array with replacement newMedia\n\t\t\t\t// values.\n\n\t\t\t\t// Define an array to store urls from newMedia between subsequent function calls.\n\t\t\t\tlet lastMediaPassed = [];\n\t\t\t\tsetMedia = ( newMedia ) => {\n\t\t\t\t\t// Remove any images this upload group is responsible for (lastMediaPassed).\n\t\t\t\t\t// Their replacements are contained in newMedia.\n\t\t\t\t\tconst filteredMedia = ( value ?? [] ).filter( ( item ) => {\n\t\t\t\t\t\t// If Item has id, only remove it if lastMediaPassed has an item with that id.\n\t\t\t\t\t\tif ( item.id ) {\n\t\t\t\t\t\t\treturn ! lastMediaPassed.some(\n\t\t\t\t\t\t\t\t// Be sure to convert to number for comparison.\n\t\t\t\t\t\t\t\t( { id } ) => Number( id ) === Number( item.id )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Compare transient images via .includes since gallery may append extra info onto the url.\n\t\t\t\t\t\treturn ! lastMediaPassed.some( ( { urlSlug } ) =>\n\t\t\t\t\t\t\titem.url.includes( urlSlug )\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\t\t\t\t\t// Return the filtered media array along with newMedia.\n\t\t\t\t\tonSelect( filteredMedia.concat( newMedia ) );\n\t\t\t\t\t// Reset lastMediaPassed and set it with ids and urls from newMedia.\n\t\t\t\t\tlastMediaPassed = newMedia.map( ( media ) => {\n\t\t\t\t\t\t// Add everything up to '.fileType' to compare via .includes.\n\t\t\t\t\t\tconst cutOffIndex = media.url.lastIndexOf( '.' );\n\t\t\t\t\t\tconst urlSlug = media.url.slice( 0, cutOffIndex );\n\t\t\t\t\t\treturn { id: media.id, urlSlug };\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tsetMedia = onSelect;\n\t\t\t}\n\t\t} else {\n\t\t\tsetMedia = ( [ media ] ) => onSelect( media );\n\t\t}\n\t\tmediaUpload( {\n\t\t\tallowedTypes,\n\t\t\tfilesList: files,\n\t\t\tonFileChange: setMedia,\n\t\t\tonError,\n\t\t} );\n\t};\n\n\tasync function handleBlocksDrop( event ) {\n\t\tconst { blocks } = parseDropEvent( event );\n\n\t\tif ( ! blocks?.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst uploadedMediaList = await Promise.all(\n\t\t\tblocks.map( ( block ) => {\n\t\t\t\tconst blockType = block.name.split( '/' )[ 1 ];\n\t\t\t\tif ( block.attributes.id ) {\n\t\t\t\t\tblock.attributes.type = blockType;\n\t\t\t\t\treturn block.attributes;\n\t\t\t\t}\n\t\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\t\twindow\n\t\t\t\t\t\t.fetch( block.attributes.url )\n\t\t\t\t\t\t.then( ( response ) => response.blob() )\n\t\t\t\t\t\t.then( ( blob ) =>\n\t\t\t\t\t\t\tmediaUpload( {\n\t\t\t\t\t\t\t\tfilesList: [ blob ],\n\t\t\t\t\t\t\t\tadditionalData: {\n\t\t\t\t\t\t\t\t\ttitle: block.attributes.title,\n\t\t\t\t\t\t\t\t\talt_text: block.attributes.alt,\n\t\t\t\t\t\t\t\t\tcaption: block.attributes.caption,\n\t\t\t\t\t\t\t\t\ttype: blockType,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tonFileChange: ( [ media ] ) => {\n\t\t\t\t\t\t\t\t\tif ( media.id ) {\n\t\t\t\t\t\t\t\t\t\tresolve( media );\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\tallowedTypes,\n\t\t\t\t\t\t\t\tonError: reject,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.catch( () => resolve( block.attributes.url ) );\n\t\t\t\t} );\n\t\t\t} )\n\t\t).catch( ( err ) => onError( err ) );\n\n\t\tif ( multiple ) {\n\t\t\tonSelect( uploadedMediaList );\n\t\t} else {\n\t\t\tonSelect( uploadedMediaList[ 0 ] );\n\t\t}\n\t}\n\n\tconst onUpload = ( event ) => {\n\t\tonFilesUpload( event.target.files );\n\t};\n\n\tconst defaultRenderPlaceholder = ( content ) => {\n\t\tlet { instructions, title } = labels;\n\n\t\tif ( ! mediaUpload && ! onSelectURL ) {\n\t\t\tinstructions = __(\n\t\t\t\t'To edit this block, you need permission to upload media.'\n\t\t\t);\n\t\t}\n\n\t\tif ( instructions === undefined || title === undefined ) {\n\t\t\tconst typesAllowed = allowedTypes ?? [];\n\n\t\t\tconst [ firstAllowedType ] = typesAllowed;\n\t\t\tconst isOneType = 1 === typesAllowed.length;\n\t\t\tconst isAudio = isOneType && 'audio' === firstAllowedType;\n\t\t\tconst isImage = isOneType && 'image' === firstAllowedType;\n\t\t\tconst isVideo = isOneType && 'video' === firstAllowedType;\n\n\t\t\tif ( instructions === undefined && mediaUpload ) {\n\t\t\t\tinstructions = __(\n\t\t\t\t\t'Drag and drop an image or video, upload, or choose from your library.'\n\t\t\t\t);\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Drag and drop an audio file, upload, or choose from your library.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Drag and drop an image, upload, or choose from your library.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\tinstructions = __(\n\t\t\t\t\t\t'Drag and drop a video, upload, or choose from your library.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( title === undefined ) {\n\t\t\t\ttitle = __( 'Media' );\n\n\t\t\t\tif ( isAudio ) {\n\t\t\t\t\ttitle = __( 'Audio' );\n\t\t\t\t} else if ( isImage ) {\n\t\t\t\t\ttitle = __( 'Image' );\n\t\t\t\t} else if ( isVideo ) {\n\t\t\t\t\ttitle = __( 'Video' );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst placeholderClassName = clsx(\n\t\t\t'block-editor-media-placeholder',\n\t\t\tclassName,\n\t\t\t{\n\t\t\t\t'is-appender': isAppender,\n\t\t\t}\n\t\t);\n\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ title }\n\t\t\t\tinstructions={ instructions }\n\t\t\t\tclassName={ placeholderClassName }\n\t\t\t\tnotices={ notices }\n\t\t\t\tonDoubleClick={ onDoubleClick }\n\t\t\t\tpreview={ mediaPreview }\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t\t{ children }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\tconst renderPlaceholder = placeholder ?? defaultRenderPlaceholder;\n\n\tconst renderDropZone = () => {\n\t\tif ( disableDropZone ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<DropZone\n\t\t\t\tonFilesDrop={ onFilesUpload }\n\t\t\t\tonDrop={ handleBlocksDrop }\n\t\t\t\tisEligible={ ( dataTransfer ) => {\n\t\t\t\t\tconst prefix = 'wp-block:core/';\n\t\t\t\t\tconst types = [];\n\t\t\t\t\tfor ( const type of dataTransfer.types ) {\n\t\t\t\t\t\tif ( type.startsWith( prefix ) ) {\n\t\t\t\t\t\t\ttypes.push( type.slice( prefix.length ) );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn (\n\t\t\t\t\t\ttypes.every( ( type ) =>\n\t\t\t\t\t\t\tallowedTypes.includes( type )\n\t\t\t\t\t\t) && ( multiple ? true : types.length === 1 )\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t};\n\n\tconst renderCancelLink = () => {\n\t\treturn (\n\t\t\tonCancel && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tclassName=\"block-editor-media-placeholder__cancel-button\"\n\t\t\t\t\ttitle={ __( 'Cancel' ) }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\tonClick={ onCancel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</Button>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderUrlSelectionUI = () => {\n\t\treturn (\n\t\t\tonSelectURL && (\n\t\t\t\t<URLSelectionUI\n\t\t\t\t\tsrc={ src }\n\t\t\t\t\tonChangeSrc={ setSrc }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t/>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderFeaturedImageToggle = () => {\n\t\treturn (\n\t\t\tonToggleFeaturedImage && (\n\t\t\t\t<div className=\"block-editor-media-placeholder__url-input-container\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tclassName=\"block-editor-media-placeholder__button\"\n\t\t\t\t\t\tonClick={ onToggleFeaturedImage }\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Use featured image' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t)\n\t\t);\n\t};\n\n\tconst renderMediaUploadChecked = () => {\n\t\tconst defaultButton = ( { open } ) => {\n\t\t\treturn (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\topen();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Media Library' ) }\n\t\t\t\t</Button>\n\t\t\t);\n\t\t};\n\t\tconst libraryButton = mediaLibraryButton ?? defaultButton;\n\t\tconst uploadMediaLibraryButton = (\n\t\t\t<MediaUpload\n\t\t\t\taddToGallery={ addToGallery }\n\t\t\t\tgallery={ multiple && onlyAllowsImages() }\n\t\t\t\tmultiple={ multiple }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\tmode=\"browse\"\n\t\t\t\tvalue={\n\t\t\t\t\tArray.isArray( value )\n\t\t\t\t\t\t? value.map( ( { id } ) => id )\n\t\t\t\t\t\t: value.id\n\t\t\t\t}\n\t\t\t\trender={ libraryButton }\n\t\t\t/>\n\t\t);\n\n\t\tif ( mediaUpload && isAppender ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ !! multiple }\n\t\t\t\t\t\trender={ ( { openFileDialog } ) => {\n\t\t\t\t\t\t\tconst content = (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tonClick={ openFileDialog }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ _x( 'Upload', 'verb' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t{ uploadMediaLibraryButton }\n\t\t\t\t\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t\t\t\t\t{ renderFeaturedImageToggle() }\n\t\t\t\t\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn renderPlaceholder( content );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\tif ( mediaUpload ) {\n\t\t\tconst content = (\n\t\t\t\t<>\n\t\t\t\t\t{ renderDropZone() }\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\trender={ ( { openFileDialog } ) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tonClick={ openFileDialog }\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__button',\n\t\t\t\t\t\t\t\t\t'block-editor-media-placeholder__upload-button'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ _x( 'Upload', 'verb' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ onUpload }\n\t\t\t\t\t\taccept={ accept }\n\t\t\t\t\t\tmultiple={ !! multiple }\n\t\t\t\t\t/>\n\t\t\t\t\t{ uploadMediaLibraryButton }\n\t\t\t\t\t{ renderUrlSelectionUI() }\n\t\t\t\t\t{ renderFeaturedImageToggle() }\n\t\t\t\t\t{ renderCancelLink() }\n\t\t\t\t</>\n\t\t\t);\n\t\t\treturn renderPlaceholder( content );\n\t\t}\n\n\t\treturn renderPlaceholder( uploadMediaLibraryButton );\n\t};\n\n\tif ( disableMediaButtons ) {\n\t\treturn <MediaUploadCheck>{ renderDropZone() }</MediaUploadCheck>;\n\t}\n\n\treturn (\n\t\t<MediaUploadCheck\n\t\t\tfallback={ renderPlaceholder( renderUrlSelectionUI() ) }\n\t\t>\n\t\t\t{ renderMediaUploadChecked() }\n\t\t</MediaUploadCheck>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-placeholder/README.md\n */\nexport default withFilters( 'editor.MediaPlaceholder' )( MediaPlaceholder );\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AASA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAP,sBAAA,CAAAC,OAAA;AAKA,IAAAO,YAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,MAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,WAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,eAAA,GAAAX,OAAA;AAAsD,IAAAY,WAAA,GAAAZ,OAAA;AA9BtD;AACA;A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C,IAAAnJ,WAAA,CAAAQ,GAAA,EAACZ,MAAA,CAAAa,OAAgB;IAChBoK,QAAQ,EAAG3B,iBAAiB,CAAEW,oBAAoB,CAAC,CAAE,CAAG;IAAAlJ,QAAA,EAEtDoJ,wBAAwB,CAAC;EAAC,CACX,CAAC;AAErB;;AAEA;AACA;AACA;AAFA,IAAAe,QAAA,GAAAC,OAAA,CAAAtK,OAAA,GAGe,IAAAuK,uBAAW,EAAE,yBAA0B,CAAC,CAAEnI,gBAAiB,CAAC","ignoreList":[]}
@@ -92,7 +92,7 @@ function useMouseMoveTypingReset() {
92
92
  * Sets and removes the `isTyping` flag based on user actions:
93
93
  *
94
94
  * - Sets the flag if the user types within the given element.
95
- * - Removes the flag when the user selects some text, focusses a non-text
95
+ * - Removes the flag when the user selects some text, focuses a non-text
96
96
  * field, presses ESC or TAB, or moves the mouse in the document.
97
97
  */
98
98
  function useTypingObserver() {
@@ -1 +1 @@
1
- {"version":3,"names":["_compose","require","_data","_dom","_keycodes","_store","_jsxRuntime","KEY_DOWN_ELIGIBLE_KEY_CODES","Set","UP","RIGHT","DOWN","LEFT","ENTER","BACKSPACE","isKeyDownEligibleForStartTyping","event","keyCode","shiftKey","has","useMouseMoveTypingReset","isTyping","useSelect","select","blockEditorStore","stopTyping","useDispatch","useRefEffect","node","ownerDocument","lastClientX","lastClientY","stopTypingOnMouseMove","clientX","clientY","addEventListener","removeEventListener","useTypingObserver","_isTyping","startTyping","ref1","ref2","defaultView","selection","getSelection","timerId","stopTypingOnNonTextField","target","setTimeout","isTextField","stopTypingOnEscapeKey","ESCAPE","TAB","stopTypingOnSelectionUncollapse","isCollapsed","clearTimeout","startTypingInTextField","type","contains","useMergeRefs","ObserveTyping","children","jsx","ref","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/observe-typing/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport {\n\tUP,\n\tRIGHT,\n\tDOWN,\n\tLEFT,\n\tENTER,\n\tBACKSPACE,\n\tESCAPE,\n\tTAB,\n} from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Set of key codes upon which typing is to be initiated on a keydown event.\n *\n * @type {Set<number>}\n */\nconst KEY_DOWN_ELIGIBLE_KEY_CODES = new Set( [\n\tUP,\n\tRIGHT,\n\tDOWN,\n\tLEFT,\n\tENTER,\n\tBACKSPACE,\n] );\n\n/**\n * Returns true if a given keydown event can be inferred as intent to start\n * typing, or false otherwise. A keydown is considered eligible if it is a\n * text navigation without shift active.\n *\n * @param {KeyboardEvent} event Keydown event to test.\n *\n * @return {boolean} Whether event is eligible to start typing.\n */\nfunction isKeyDownEligibleForStartTyping( event ) {\n\tconst { keyCode, shiftKey } = event;\n\treturn ! shiftKey && KEY_DOWN_ELIGIBLE_KEY_CODES.has( keyCode );\n}\n\n/**\n * Removes the `isTyping` flag when the mouse moves in the document of the given\n * element.\n */\nexport function useMouseMoveTypingReset() {\n\tconst isTyping = useSelect(\n\t\t( select ) => select( blockEditorStore ).isTyping(),\n\t\t[]\n\t);\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! isTyping ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tlet lastClientX;\n\t\t\tlet lastClientY;\n\n\t\t\t/**\n\t\t\t * On mouse move, unset typing flag if user has moved cursor.\n\t\t\t *\n\t\t\t * @param {MouseEvent} event Mousemove event.\n\t\t\t */\n\t\t\tfunction stopTypingOnMouseMove( event ) {\n\t\t\t\tconst { clientX, clientY } = event;\n\n\t\t\t\t// We need to check that the mouse really moved because Safari\n\t\t\t\t// triggers mousemove events when shift or ctrl are pressed.\n\t\t\t\tif (\n\t\t\t\t\tlastClientX &&\n\t\t\t\t\tlastClientY &&\n\t\t\t\t\t( lastClientX !== clientX || lastClientY !== clientY )\n\t\t\t\t) {\n\t\t\t\t\tstopTyping();\n\t\t\t\t}\n\n\t\t\t\tlastClientX = clientX;\n\t\t\t\tlastClientY = clientY;\n\t\t\t}\n\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'mousemove',\n\t\t\t\tstopTypingOnMouseMove\n\t\t\t);\n\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'mousemove',\n\t\t\t\t\tstopTypingOnMouseMove\n\t\t\t\t);\n\t\t\t};\n\t\t},\n\t\t[ isTyping, stopTyping ]\n\t);\n}\n\n/**\n * Sets and removes the `isTyping` flag based on user actions:\n *\n * - Sets the flag if the user types within the given element.\n * - Removes the flag when the user selects some text, focusses a non-text\n * field, presses ESC or TAB, or moves the mouse in the document.\n */\nexport function useTypingObserver() {\n\tconst { isTyping } = useSelect( ( select ) => {\n\t\tconst { isTyping: _isTyping } = select( blockEditorStore );\n\t\treturn {\n\t\t\tisTyping: _isTyping(),\n\t\t};\n\t}, [] );\n\tconst { startTyping, stopTyping } = useDispatch( blockEditorStore );\n\n\tconst ref1 = useMouseMoveTypingReset();\n\tconst ref2 = useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t// Listeners to stop typing should only be added when typing.\n\t\t\t// Listeners to start typing should only be added when not typing.\n\t\t\tif ( isTyping ) {\n\t\t\t\tlet timerId;\n\n\t\t\t\t/**\n\t\t\t\t * Stops typing when focus transitions to a non-text field element.\n\t\t\t\t *\n\t\t\t\t * @param {FocusEvent} event Focus event.\n\t\t\t\t */\n\t\t\t\tfunction stopTypingOnNonTextField( event ) {\n\t\t\t\t\tconst { target } = event;\n\n\t\t\t\t\t// Since focus to a non-text field via arrow key will trigger\n\t\t\t\t\t// before the keydown event, wait until after current stack\n\t\t\t\t\t// before evaluating whether typing is to be stopped. Otherwise,\n\t\t\t\t\t// typing will re-start.\n\t\t\t\t\ttimerId = defaultView.setTimeout( () => {\n\t\t\t\t\t\tif ( ! isTextField( target ) ) {\n\t\t\t\t\t\t\tstopTyping();\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\t/**\n\t\t\t\t * Unsets typing flag if user presses Escape while typing flag is\n\t\t\t\t * active.\n\t\t\t\t *\n\t\t\t\t * @param {KeyboardEvent} event Keypress or keydown event to\n\t\t\t\t * interpret.\n\t\t\t\t */\n\t\t\t\tfunction stopTypingOnEscapeKey( event ) {\n\t\t\t\t\tconst { keyCode } = event;\n\n\t\t\t\t\tif ( keyCode === ESCAPE || keyCode === TAB ) {\n\t\t\t\t\t\tstopTyping();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/**\n\t\t\t\t * On selection change, unset typing flag if user has made an\n\t\t\t\t * uncollapsed (shift) selection.\n\t\t\t\t */\n\t\t\t\tfunction stopTypingOnSelectionUncollapse() {\n\t\t\t\t\tif ( ! selection.isCollapsed ) {\n\t\t\t\t\t\tstopTyping();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tnode.addEventListener( 'focus', stopTypingOnNonTextField );\n\t\t\t\tnode.addEventListener( 'keydown', stopTypingOnEscapeKey );\n\n\t\t\t\townerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tstopTypingOnSelectionUncollapse\n\t\t\t\t);\n\n\t\t\t\treturn () => {\n\t\t\t\t\tdefaultView.clearTimeout( timerId );\n\t\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t\t'focus',\n\t\t\t\t\t\tstopTypingOnNonTextField\n\t\t\t\t\t);\n\t\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t\t'keydown',\n\t\t\t\t\t\tstopTypingOnEscapeKey\n\t\t\t\t\t);\n\t\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t\t'selectionchange',\n\t\t\t\t\t\tstopTypingOnSelectionUncollapse\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Handles a keypress or keydown event to infer intention to start\n\t\t\t * typing.\n\t\t\t *\n\t\t\t * @param {KeyboardEvent} event Keypress or keydown event to interpret.\n\t\t\t */\n\t\t\tfunction startTypingInTextField( event ) {\n\t\t\t\tconst { type, target } = event;\n\n\t\t\t\t// Abort early if already typing, or key press is incurred outside a\n\t\t\t\t// text field (e.g. arrow-ing through toolbar buttons).\n\t\t\t\t// Ignore typing if outside the current DOM container\n\t\t\t\tif ( ! isTextField( target ) || ! node.contains( target ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Special-case keydown because certain keys do not emit a keypress\n\t\t\t\t// event. Conversely avoid keydown as the canonical event since\n\t\t\t\t// there are many keydown which are explicitly not targeted for\n\t\t\t\t// typing.\n\t\t\t\tif (\n\t\t\t\t\ttype === 'keydown' &&\n\t\t\t\t\t! isKeyDownEligibleForStartTyping( event )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tstartTyping();\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'keypress', startTypingInTextField );\n\t\t\tnode.addEventListener( 'keydown', startTypingInTextField );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'keypress', startTypingInTextField );\n\t\t\t\tnode.removeEventListener( 'keydown', startTypingInTextField );\n\t\t\t};\n\t\t},\n\t\t[ isTyping, startTyping, stopTyping ]\n\t);\n\n\treturn useMergeRefs( [ ref1, ref2 ] );\n}\n\nfunction ObserveTyping( { children } ) {\n\treturn <div ref={ useTypingObserver() }>{ children }</div>;\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/observe-typing/README.md\n */\nexport default ObserveTyping;\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OA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CAAC,EACzC;QACD;MACD;MAEAuB,WAAW,CAAC,CAAC;IACd;IAEAX,IAAI,CAACO,gBAAgB,CAAE,UAAU,EAAEqB,sBAAuB,CAAC;IAC3D5B,IAAI,CAACO,gBAAgB,CAAE,SAAS,EAAEqB,sBAAuB,CAAC;IAE1D,OAAO,MAAM;MACZ5B,IAAI,CAACQ,mBAAmB,CAAE,UAAU,EAAEoB,sBAAuB,CAAC;MAC9D5B,IAAI,CAACQ,mBAAmB,CAAE,SAAS,EAAEoB,sBAAuB,CAAC;IAC9D,CAAC;EACF,CAAC,EACD,CAAEnC,QAAQ,EAAEkB,WAAW,EAAEd,UAAU,CACpC,CAAC;EAED,OAAO,IAAAkC,qBAAY,EAAE,CAAEnB,IAAI,EAAEC,IAAI,CAAG,CAAC;AACtC;AAEA,SAASmB,aAAaA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACtC,oBAAO,IAAAvD,WAAA,CAAAwD,GAAA;IAAKC,GAAG,EAAG1B,iBAAiB,CAAC,CAAG;IAAAwB,QAAA,EAAGA;EAAQ,CAAO,CAAC;AAC3D;;AAEA;AACA;AACA;AAFA,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeN,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["_compose","require","_data","_dom","_keycodes","_store","_jsxRuntime","KEY_DOWN_ELIGIBLE_KEY_CODES","Set","UP","RIGHT","DOWN","LEFT","ENTER","BACKSPACE","isKeyDownEligibleForStartTyping","event","keyCode","shiftKey","has","useMouseMoveTypingReset","isTyping","useSelect","select","blockEditorStore","stopTyping","useDispatch","useRefEffect","node","ownerDocument","lastClientX","lastClientY","stopTypingOnMouseMove","clientX","clientY","addEventListener","removeEventListener","useTypingObserver","_isTyping","startTyping","ref1","ref2","defaultView","selection","getSelection","timerId","stopTypingOnNonTextField","target","setTimeout","isTextField","stopTypingOnEscapeKey","ESCAPE","TAB","stopTypingOnSelectionUncollapse","isCollapsed","clearTimeout","startTypingInTextField","type","contains","useMergeRefs","ObserveTyping","children","jsx","ref","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/observe-typing/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport {\n\tUP,\n\tRIGHT,\n\tDOWN,\n\tLEFT,\n\tENTER,\n\tBACKSPACE,\n\tESCAPE,\n\tTAB,\n} from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Set of key codes upon which typing is to be initiated on a keydown event.\n *\n * @type {Set<number>}\n */\nconst KEY_DOWN_ELIGIBLE_KEY_CODES = new Set( [\n\tUP,\n\tRIGHT,\n\tDOWN,\n\tLEFT,\n\tENTER,\n\tBACKSPACE,\n] );\n\n/**\n * Returns true if a given keydown event can be inferred as intent to start\n * typing, or false otherwise. A keydown is considered eligible if it is a\n * text navigation without shift active.\n *\n * @param {KeyboardEvent} event Keydown event to test.\n *\n * @return {boolean} Whether event is eligible to start typing.\n */\nfunction isKeyDownEligibleForStartTyping( event ) {\n\tconst { keyCode, shiftKey } = event;\n\treturn ! shiftKey && KEY_DOWN_ELIGIBLE_KEY_CODES.has( keyCode );\n}\n\n/**\n * Removes the `isTyping` flag when the mouse moves in the document of the given\n * element.\n */\nexport function useMouseMoveTypingReset() {\n\tconst isTyping = useSelect(\n\t\t( select ) => select( blockEditorStore ).isTyping(),\n\t\t[]\n\t);\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! isTyping ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tlet lastClientX;\n\t\t\tlet lastClientY;\n\n\t\t\t/**\n\t\t\t * On mouse move, unset typing flag if user has moved cursor.\n\t\t\t *\n\t\t\t * @param {MouseEvent} event Mousemove event.\n\t\t\t */\n\t\t\tfunction stopTypingOnMouseMove( event ) {\n\t\t\t\tconst { clientX, clientY } = event;\n\n\t\t\t\t// We need to check that the mouse really moved because Safari\n\t\t\t\t// triggers mousemove events when shift or ctrl are pressed.\n\t\t\t\tif (\n\t\t\t\t\tlastClientX &&\n\t\t\t\t\tlastClientY &&\n\t\t\t\t\t( lastClientX !== clientX || lastClientY !== clientY )\n\t\t\t\t) {\n\t\t\t\t\tstopTyping();\n\t\t\t\t}\n\n\t\t\t\tlastClientX = clientX;\n\t\t\t\tlastClientY = clientY;\n\t\t\t}\n\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'mousemove',\n\t\t\t\tstopTypingOnMouseMove\n\t\t\t);\n\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'mousemove',\n\t\t\t\t\tstopTypingOnMouseMove\n\t\t\t\t);\n\t\t\t};\n\t\t},\n\t\t[ isTyping, stopTyping ]\n\t);\n}\n\n/**\n * Sets and removes the `isTyping` flag based on user actions:\n *\n * - Sets the flag if the user types within the given element.\n * - Removes the flag when the user selects some text, focuses a non-text\n * field, presses ESC or TAB, or moves the mouse in the document.\n */\nexport function useTypingObserver() {\n\tconst { isTyping } = useSelect( ( select ) => {\n\t\tconst { isTyping: _isTyping } = select( blockEditorStore );\n\t\treturn {\n\t\t\tisTyping: _isTyping(),\n\t\t};\n\t}, [] );\n\tconst { startTyping, stopTyping } = useDispatch( blockEditorStore );\n\n\tconst ref1 = useMouseMoveTypingReset();\n\tconst ref2 = useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t// Listeners to stop typing should only be added when typing.\n\t\t\t// Listeners to start typing should only be added when not typing.\n\t\t\tif ( isTyping ) {\n\t\t\t\tlet timerId;\n\n\t\t\t\t/**\n\t\t\t\t * Stops typing when focus transitions to a non-text field element.\n\t\t\t\t *\n\t\t\t\t * @param {FocusEvent} event Focus event.\n\t\t\t\t */\n\t\t\t\tfunction stopTypingOnNonTextField( event ) {\n\t\t\t\t\tconst { target } = event;\n\n\t\t\t\t\t// Since focus to a non-text field via arrow key will trigger\n\t\t\t\t\t// before the keydown event, wait until after current stack\n\t\t\t\t\t// before evaluating whether typing is to be stopped. Otherwise,\n\t\t\t\t\t// typing will re-start.\n\t\t\t\t\ttimerId = defaultView.setTimeout( () => {\n\t\t\t\t\t\tif ( ! isTextField( target ) ) {\n\t\t\t\t\t\t\tstopTyping();\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\t/**\n\t\t\t\t * Unsets typing flag if user presses Escape while typing flag is\n\t\t\t\t * active.\n\t\t\t\t *\n\t\t\t\t * @param {KeyboardEvent} event Keypress or keydown event to\n\t\t\t\t * interpret.\n\t\t\t\t */\n\t\t\t\tfunction stopTypingOnEscapeKey( event ) {\n\t\t\t\t\tconst { keyCode } = event;\n\n\t\t\t\t\tif ( keyCode === ESCAPE || keyCode === TAB ) {\n\t\t\t\t\t\tstopTyping();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/**\n\t\t\t\t * On selection change, unset typing flag if user has made an\n\t\t\t\t * uncollapsed (shift) selection.\n\t\t\t\t */\n\t\t\t\tfunction stopTypingOnSelectionUncollapse() {\n\t\t\t\t\tif ( ! selection.isCollapsed ) {\n\t\t\t\t\t\tstopTyping();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tnode.addEventListener( 'focus', stopTypingOnNonTextField );\n\t\t\t\tnode.addEventListener( 'keydown', stopTypingOnEscapeKey );\n\n\t\t\t\townerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tstopTypingOnSelectionUncollapse\n\t\t\t\t);\n\n\t\t\t\treturn () => {\n\t\t\t\t\tdefaultView.clearTimeout( timerId );\n\t\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t\t'focus',\n\t\t\t\t\t\tstopTypingOnNonTextField\n\t\t\t\t\t);\n\t\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t\t'keydown',\n\t\t\t\t\t\tstopTypingOnEscapeKey\n\t\t\t\t\t);\n\t\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t\t'selectionchange',\n\t\t\t\t\t\tstopTypingOnSelectionUncollapse\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Handles a keypress or keydown event to infer intention to start\n\t\t\t * typing.\n\t\t\t *\n\t\t\t * @param {KeyboardEvent} event Keypress or keydown event to interpret.\n\t\t\t */\n\t\t\tfunction startTypingInTextField( event ) {\n\t\t\t\tconst { type, target } = event;\n\n\t\t\t\t// Abort early if already typing, or key press is incurred outside a\n\t\t\t\t// text field (e.g. arrow-ing through toolbar buttons).\n\t\t\t\t// Ignore typing if outside the current DOM container\n\t\t\t\tif ( ! isTextField( target ) || ! node.contains( target ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Special-case keydown because certain keys do not emit a keypress\n\t\t\t\t// event. Conversely avoid keydown as the canonical event since\n\t\t\t\t// there are many keydown which are explicitly not targeted for\n\t\t\t\t// typing.\n\t\t\t\tif (\n\t\t\t\t\ttype === 'keydown' &&\n\t\t\t\t\t! isKeyDownEligibleForStartTyping( event )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tstartTyping();\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'keypress', startTypingInTextField );\n\t\t\tnode.addEventListener( 'keydown', startTypingInTextField );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'keypress', startTypingInTextField );\n\t\t\t\tnode.removeEventListener( 'keydown', startTypingInTextField );\n\t\t\t};\n\t\t},\n\t\t[ isTyping, startTyping, stopTyping ]\n\t);\n\n\treturn useMergeRefs( [ ref1, ref2 ] );\n}\n\nfunction ObserveTyping( { children } ) {\n\treturn <div ref={ useTypingObserver() }>{ children }</div>;\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/observe-typing/README.md\n */\nexport default ObserveTyping;\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAcA,IAAAI,MAAA,GAAAJ,OAAA;AAAwD,IAAAK,WAAA,GAAAL,OAAA;AApBxD;AACA;AACA;;AAeA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA,GACA,MAAMM,2BAA2B,GAAG,IAAIC,GAAG,CAAE,CAC5CC,YAAE,EACFC,eAAK,EACLC,cAAI,EACJC,cAAI,EACJC,eAAK,EACLC,mBAAS,CACR,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,+BAA+BA,CAAEC,KAAK,EAAG;EACjD,MAAM;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAAGF,KAAK;EACnC,OAAO,CAAEE,QAAQ,IAAIX,2BAA2B,CAACY,GAAG,CAAEF,OAAQ,CAAC;AAChE;;AAEA;AACA;AACA;AACA;AACO,SAASG,uBAAuBA,CAAA,EAAG;EACzC,MAAMC,QAAQ,GAAG,IAAAC,eAAS,EACvBC,MAAM,IAAMA,MAAM,CAAEC,YAAiB,CAAC,CAACH,QAAQ,CAAC,CAAC,EACnD,EACD,CAAC;EACD,MAAM;IAAEI;EAAW,CAAC,GAAG,IAAAC,iBAAW,EAAEF,YAAiB,CAAC;EAEtD,OAAO,IAAAG,qBAAY,EAChBC,IAAI,IAAM;IACX,IAAK,CAAEP,QAAQ,EAAG;MACjB;IACD;IAEA,MAAM;MAAEQ;IAAc,CAAC,GAAGD,IAAI;IAC9B,IAAIE,WAAW;IACf,IAAIC,WAAW;;IAEf;AACH;AACA;AACA;AACA;IACG,SAASC,qBAAqBA,CAAEhB,KAAK,EAAG;MACvC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AW,EAAEF,MAAO,CAAC,IAAI,CAAEnB,IAAI,CAAC8B,QAAQ,CAAEX,MAAO,CAAC,EAAG;QAC3D;MACD;;MAEA;MACA;MACA;MACA;MACA,IACCU,IAAI,KAAK,SAAS,IAClB,CAAE1C,+BAA+B,CAAEC,KAAM,CAAC,EACzC;QACD;MACD;MAEAuB,WAAW,CAAC,CAAC;IACd;IAEAX,IAAI,CAACO,gBAAgB,CAAE,UAAU,EAAEqB,sBAAuB,CAAC;IAC3D5B,IAAI,CAACO,gBAAgB,CAAE,SAAS,EAAEqB,sBAAuB,CAAC;IAE1D,OAAO,MAAM;MACZ5B,IAAI,CAACQ,mBAAmB,CAAE,UAAU,EAAEoB,sBAAuB,CAAC;MAC9D5B,IAAI,CAACQ,mBAAmB,CAAE,SAAS,EAAEoB,sBAAuB,CAAC;IAC9D,CAAC;EACF,CAAC,EACD,CAAEnC,QAAQ,EAAEkB,WAAW,EAAEd,UAAU,CACpC,CAAC;EAED,OAAO,IAAAkC,qBAAY,EAAE,CAAEnB,IAAI,EAAEC,IAAI,CAAG,CAAC;AACtC;AAEA,SAASmB,aAAaA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACtC,oBAAO,IAAAvD,WAAA,CAAAwD,GAAA;IAAKC,GAAG,EAAG1B,iBAAiB,CAAC,CAAG;IAAAwB,QAAA,EAAGA;EAAQ,CAAO,CAAC;AAC3D;;AAEA;AACA;AACA;AAFA,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeN,aAAa","ignoreList":[]}
@@ -21,8 +21,6 @@ var _jsxRuntime = require("react/jsx-runtime");
21
21
  * WordPress dependencies
22
22
  */
23
23
 
24
- //eslint-disable-next-line import/no-extraneous-dependencies -- Experimental package, not published.
25
-
26
24
  /**
27
25
  * Internal dependencies
28
26
  */
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_element","_components","_uploadMedia","_withRegistryProvider","_interopRequireDefault","_useBlockSync","_store","_blockRefsProvider","_lockUnlock","_keyboardShortcuts","_useMediaUploadSettings","_jsxRuntime","noop","mediaUpload","registry","allowedTypes","additionalData","filesList","onError","onFileChange","onSuccess","onBatchSuccess","dispatch","uploadStore","addItems","files","onChange","message","ExperimentalBlockEditorProvider","exports","withRegistryProvider","props","settings","_settings","stripExperimentalSettings","mediaUploadSettings","useMediaUploadSettings","window","__experimentalMediaProcessing","useMemo","bind","__experimentalUpdateSettings","unlock","useDispatch","blockEditorStore","useEffect","__internalIsInitialized","reset","useBlockSync","children","jsxs","SlotFillProvider","passthrough","isPreviewMode","jsx","default","Register","BlockRefsProvider","MediaUploadProvider","useSubRegistry","BlockEditorProvider","_default"],"sources":["@wordpress/block-editor/src/components/provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect, useMemo } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\n//eslint-disable-next-line import/no-extraneous-dependencies -- Experimental package, not published.\nimport {\n\tMediaUploadProvider,\n\tstore as uploadStore,\n} from '@wordpress/upload-media';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport useBlockSync from './use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockRefsProvider } from './block-refs-provider';\nimport { unlock } from '../../lock-unlock';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport useMediaUploadSettings from './use-media-upload-settings';\n\n/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */\n\nconst noop = () => {};\n\n/**\n * Upload a media file when the file upload button is activated\n * or when adding a file to the editor via drag & drop.\n *\n * @param {WPDataRegistry} registry\n * @param {Object} $3 Parameters object passed to the function.\n * @param {Array} $3.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.\n * @param {Object} $3.additionalData Additional data to include in the request.\n * @param {Array<File>} $3.filesList List of files.\n * @param {Function} $3.onError Function called when an error happens.\n * @param {Function} $3.onFileChange Function called each time a file or a temporary representation of the file is available.\n * @param {Function} $3.onSuccess Function called once a file has completely finished uploading, including thumbnails.\n * @param {Function} $3.onBatchSuccess Function called once all files in a group have completely finished uploading, including thumbnails.\n */\nfunction mediaUpload(\n\tregistry,\n\t{\n\t\tallowedTypes,\n\t\tadditionalData = {},\n\t\tfilesList,\n\t\tonError = noop,\n\t\tonFileChange,\n\t\tonSuccess,\n\t\tonBatchSuccess,\n\t}\n) {\n\tvoid registry.dispatch( uploadStore ).addItems( {\n\t\tfiles: filesList,\n\t\tonChange: onFileChange,\n\t\tonSuccess,\n\t\tonBatchSuccess,\n\t\tonError: ( { message } ) => onError( message ),\n\t\tadditionalData,\n\t\tallowedTypes,\n\t} );\n}\n\nexport const ExperimentalBlockEditorProvider = withRegistryProvider(\n\t( props ) => {\n\t\tconst {\n\t\t\tsettings: _settings,\n\t\t\tregistry,\n\t\t\tstripExperimentalSettings = false,\n\t\t} = props;\n\n\t\tconst mediaUploadSettings = useMediaUploadSettings( _settings );\n\n\t\tlet settings = _settings;\n\n\t\tif ( window.__experimentalMediaProcessing && _settings.mediaUpload ) {\n\t\t\t// Create a new variable so that the original props.settings.mediaUpload is not modified.\n\t\t\tsettings = useMemo(\n\t\t\t\t() => ( {\n\t\t\t\t\t..._settings,\n\t\t\t\t\tmediaUpload: mediaUpload.bind( null, registry ),\n\t\t\t\t} ),\n\t\t\t\t[ _settings, registry ]\n\t\t\t);\n\t\t}\n\n\t\tconst { __experimentalUpdateSettings } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\t\tuseEffect( () => {\n\t\t\t__experimentalUpdateSettings(\n\t\t\t\t{\n\t\t\t\t\t...settings,\n\t\t\t\t\t__internalIsInitialized: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tstripExperimentalSettings,\n\t\t\t\t\treset: true,\n\t\t\t\t}\n\t\t\t);\n\t\t}, [\n\t\t\tsettings,\n\t\t\tstripExperimentalSettings,\n\t\t\t__experimentalUpdateSettings,\n\t\t] );\n\n\t\t// Syncs the entity provider with changes in the block-editor store.\n\t\tuseBlockSync( props );\n\n\t\tconst children = (\n\t\t\t<SlotFillProvider passthrough>\n\t\t\t\t{ ! settings?.isPreviewMode && <KeyboardShortcuts.Register /> }\n\t\t\t\t<BlockRefsProvider>{ props.children }</BlockRefsProvider>\n\t\t\t</SlotFillProvider>\n\t\t);\n\n\t\tif ( window.__experimentalMediaProcessing ) {\n\t\t\treturn (\n\t\t\t\t<MediaUploadProvider\n\t\t\t\t\tsettings={ mediaUploadSettings }\n\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</MediaUploadProvider>\n\t\t\t);\n\t\t}\n\n\t\treturn children;\n\t}\n);\n\nexport const BlockEditorProvider = ( props ) => {\n\treturn (\n\t\t<ExperimentalBlockEditorProvider { ...props } stripExperimentalSettings>\n\t\t\t{ props.children }\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n};\n\nexport default BlockEditorProvider;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AAQA,IAAAI,qBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,aAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,kBAAA,GAAAL,sBAAA,CAAAL,OAAA;AACA,IAAAW,uBAAA,GAAAN,sBAAA,CAAAL,OAAA;AAAiE,IAAAY,WAAA,GAAAZ,OAAA;AArBjE;AACA;AACA;;AAIA;;AAMA;AACA;AACA;;AASA,yEAEA,MAAMa,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC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AAK,EAAE;IACR,CACD,CAAC;EACF,CAAC,EAAE,CACFf,QAAQ,EACRE,yBAAyB,EACzBO,4BAA4B,CAC3B,CAAC;;EAEH;EACA,IAAAO,qBAAY,EAAEjB,KAAM,CAAC;EAErB,MAAMkB,QAAQ,gBACb,IAAAtC,WAAA,CAAAuC,IAAA,EAACjD,WAAA,CAAAkD,gBAAgB;IAACC,WAAW;IAAAH,QAAA,GAC1B,CAAEjB,QAAQ,EAAEqB,aAAa,iBAAI,IAAA1C,WAAA,CAAA2C,GAAA,EAAC7C,kBAAA,CAAA8C,OAAiB,CAACC,QAAQ,IAAE,CAAC,eAC7D,IAAA7C,WAAA,CAAA2C,GAAA,EAAC/C,kBAAA,CAAAkD,iBAAiB;MAAAR,QAAA,EAAGlB,KAAK,CAACkB;IAAQ,CAAqB,CAAC;EAAA,CACxC,CAClB;EAED,IAAKZ,MAAM,CAACC,6BAA6B,EAAG;IAC3C,oBACC,IAAA3B,WAAA,CAAA2C,GAAA,EAACpD,YAAA,CAAAwD,mBAAmB;MACnB1B,QAAQ,EAAGG,mBAAqB;MAChCwB,cAAc,EAAG,KAAO;MAAAV,QAAA,EAEtBA;IAAQ,CACU,CAAC;EAExB;EAEA,OAAOA,QAAQ;AAChB,CACD,CAAC;AAEM,MAAMW,mBAAmB,GAAK7B,KAAK,IAAM;EAC/C,oBACC,IAAApB,WAAA,CAAA2C,GAAA,EAAC1B,+BAA+B;IAAA,GAAMG,KAAK;IAAGG,yBAAyB;IAAAe,QAAA,EACpElB,KAAK,CAACkB;EAAQ,CACgB,CAAC;AAEpC,CAAC;AAACpB,OAAA,CAAA+B,mBAAA,GAAAA,mBAAA;AAAA,IAAAC,QAAA,GAAAhC,OAAA,CAAA0B,OAAA,GAEaK,mBAAmB","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_element","_components","_uploadMedia","_withRegistryProvider","_interopRequireDefault","_useBlockSync","_store","_blockRefsProvider","_lockUnlock","_keyboardShortcuts","_useMediaUploadSettings","_jsxRuntime","noop","mediaUpload","registry","allowedTypes","additionalData","filesList","onError","onFileChange","onSuccess","onBatchSuccess","dispatch","uploadStore","addItems","files","onChange","message","ExperimentalBlockEditorProvider","exports","withRegistryProvider","props","settings","_settings","stripExperimentalSettings","mediaUploadSettings","useMediaUploadSettings","window","__experimentalMediaProcessing","useMemo","bind","__experimentalUpdateSettings","unlock","useDispatch","blockEditorStore","useEffect","__internalIsInitialized","reset","useBlockSync","children","jsxs","SlotFillProvider","passthrough","isPreviewMode","jsx","default","Register","BlockRefsProvider","MediaUploadProvider","useSubRegistry","BlockEditorProvider","_default"],"sources":["@wordpress/block-editor/src/components/provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect, useMemo } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport {\n\tMediaUploadProvider,\n\tstore as uploadStore,\n} from '@wordpress/upload-media';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport useBlockSync from './use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockRefsProvider } from './block-refs-provider';\nimport { unlock } from '../../lock-unlock';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport useMediaUploadSettings from './use-media-upload-settings';\n\n/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */\n\nconst noop = () => {};\n\n/**\n * Upload a media file when the file upload button is activated\n * or when adding a file to the editor via drag & drop.\n *\n * @param {WPDataRegistry} registry\n * @param {Object} $3 Parameters object passed to the function.\n * @param {Array} $3.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.\n * @param {Object} $3.additionalData Additional data to include in the request.\n * @param {Array<File>} $3.filesList List of files.\n * @param {Function} $3.onError Function called when an error happens.\n * @param {Function} $3.onFileChange Function called each time a file or a temporary representation of the file is available.\n * @param {Function} $3.onSuccess Function called once a file has completely finished uploading, including thumbnails.\n * @param {Function} $3.onBatchSuccess Function called once all files in a group have completely finished uploading, including thumbnails.\n */\nfunction mediaUpload(\n\tregistry,\n\t{\n\t\tallowedTypes,\n\t\tadditionalData = {},\n\t\tfilesList,\n\t\tonError = noop,\n\t\tonFileChange,\n\t\tonSuccess,\n\t\tonBatchSuccess,\n\t}\n) {\n\tvoid registry.dispatch( uploadStore ).addItems( {\n\t\tfiles: filesList,\n\t\tonChange: onFileChange,\n\t\tonSuccess,\n\t\tonBatchSuccess,\n\t\tonError: ( { message } ) => onError( message ),\n\t\tadditionalData,\n\t\tallowedTypes,\n\t} );\n}\n\nexport const ExperimentalBlockEditorProvider = withRegistryProvider(\n\t( props ) => {\n\t\tconst {\n\t\t\tsettings: _settings,\n\t\t\tregistry,\n\t\t\tstripExperimentalSettings = false,\n\t\t} = props;\n\n\t\tconst mediaUploadSettings = useMediaUploadSettings( _settings );\n\n\t\tlet settings = _settings;\n\n\t\tif ( window.__experimentalMediaProcessing && _settings.mediaUpload ) {\n\t\t\t// Create a new variable so that the original props.settings.mediaUpload is not modified.\n\t\t\tsettings = useMemo(\n\t\t\t\t() => ( {\n\t\t\t\t\t..._settings,\n\t\t\t\t\tmediaUpload: mediaUpload.bind( null, registry ),\n\t\t\t\t} ),\n\t\t\t\t[ _settings, registry ]\n\t\t\t);\n\t\t}\n\n\t\tconst { __experimentalUpdateSettings } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\t\tuseEffect( () => {\n\t\t\t__experimentalUpdateSettings(\n\t\t\t\t{\n\t\t\t\t\t...settings,\n\t\t\t\t\t__internalIsInitialized: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tstripExperimentalSettings,\n\t\t\t\t\treset: true,\n\t\t\t\t}\n\t\t\t);\n\t\t}, [\n\t\t\tsettings,\n\t\t\tstripExperimentalSettings,\n\t\t\t__experimentalUpdateSettings,\n\t\t] );\n\n\t\t// Syncs the entity provider with changes in the block-editor store.\n\t\tuseBlockSync( props );\n\n\t\tconst children = (\n\t\t\t<SlotFillProvider passthrough>\n\t\t\t\t{ ! settings?.isPreviewMode && <KeyboardShortcuts.Register /> }\n\t\t\t\t<BlockRefsProvider>{ props.children }</BlockRefsProvider>\n\t\t\t</SlotFillProvider>\n\t\t);\n\n\t\tif ( window.__experimentalMediaProcessing ) {\n\t\t\treturn (\n\t\t\t\t<MediaUploadProvider\n\t\t\t\t\tsettings={ mediaUploadSettings }\n\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</MediaUploadProvider>\n\t\t\t);\n\t\t}\n\n\t\treturn children;\n\t}\n);\n\nexport const BlockEditorProvider = ( props ) => {\n\treturn (\n\t\t<ExperimentalBlockEditorProvider { ...props } stripExperimentalSettings>\n\t\t\t{ props.children }\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n};\n\nexport default BlockEditorProvider;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAQA,IAAAI,qBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,aAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,kBAAA,GAAAL,sBAAA,CAAAL,OAAA;AACA,IAAAW,uBAAA,GAAAN,sBAAA,CAAAL,OAAA;AAAiE,IAAAY,WAAA,GAAAZ,OAAA;AApBjE;AACA;AACA;;AASA;AACA;AACA;;AASA,yEAEA,MAAMa,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,WAAWA,CACnBC,QAAQ,EACR;EACCC,YAAY;EACZC,cAAc,GAAG,CAAC,CAAC;EACnBC,SA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BAA4B,CAC3B,CAAC;;EAEH;EACA,IAAAO,qBAAY,EAAEjB,KAAM,CAAC;EAErB,MAAMkB,QAAQ,gBACb,IAAAtC,WAAA,CAAAuC,IAAA,EAACjD,WAAA,CAAAkD,gBAAgB;IAACC,WAAW;IAAAH,QAAA,GAC1B,CAAEjB,QAAQ,EAAEqB,aAAa,iBAAI,IAAA1C,WAAA,CAAA2C,GAAA,EAAC7C,kBAAA,CAAA8C,OAAiB,CAACC,QAAQ,IAAE,CAAC,eAC7D,IAAA7C,WAAA,CAAA2C,GAAA,EAAC/C,kBAAA,CAAAkD,iBAAiB;MAAAR,QAAA,EAAGlB,KAAK,CAACkB;IAAQ,CAAqB,CAAC;EAAA,CACxC,CAClB;EAED,IAAKZ,MAAM,CAACC,6BAA6B,EAAG;IAC3C,oBACC,IAAA3B,WAAA,CAAA2C,GAAA,EAACpD,YAAA,CAAAwD,mBAAmB;MACnB1B,QAAQ,EAAGG,mBAAqB;MAChCwB,cAAc,EAAG,KAAO;MAAAV,QAAA,EAEtBA;IAAQ,CACU,CAAC;EAExB;EAEA,OAAOA,QAAQ;AAChB,CACD,CAAC;AAEM,MAAMW,mBAAmB,GAAK7B,KAAK,IAAM;EAC/C,oBACC,IAAApB,WAAA,CAAA2C,GAAA,EAAC1B,+BAA+B;IAAA,GAAMG,KAAK;IAAGG,yBAAyB;IAAAe,QAAA,EACpElB,KAAK,CAACkB;EAAQ,CACgB,CAAC;AAEpC,CAAC;AAACpB,OAAA,CAAA+B,mBAAA,GAAAA,mBAAA;AAAA,IAAAC,QAAA,GAAAhC,OAAA,CAAA0B,OAAA,GAEaK,mBAAmB","ignoreList":[]}
@@ -40,7 +40,7 @@ const noop = () => {};
40
40
  * the template part in the block editor back to the entity and vice-versa.
41
41
  *
42
42
  * Here are some of its basic functions:
43
- * - Initalizes the block-editor store for the given clientID to the blocks
43
+ * - Initializes the block-editor store for the given clientID to the blocks
44
44
  * given via props.
45
45
  * - Adds incoming changes (like undo) to the block-editor store.
46
46
  * - Adds outgoing changes (like editing content) to the controlling entity,
@@ -56,7 +56,7 @@ const noop = () => {};
56
56
  * root controller rather than an inner block
57
57
  * controller.
58
58
  * @param {Object[]} props.value The control value for the blocks. This value
59
- * is used to initalize the block-editor store
59
+ * is used to initialize the block-editor store
60
60
  * and for resetting the blocks to incoming
61
61
  * changes like undo.
62
62
  * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_data","_blocks","_store","noop","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","useRegistry","resetBlocks","resetSelection","replaceInnerBlocks","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","blockEditorStore","getBlockName","getBlocks","getSelectionStart","getSelectionEnd","select","isControlled","useSelect","areInnerBlocksControlled","pendingChangesRef","useRef","incoming","outgoing","subscribedRef","setControlledBlocks","batch","storeBlocks","map","block","cloneBlock","current","unsetControlledBlocks","onInputRef","onChangeRef","useEffect","includes","length","selectionStart","selectionEnd","initialPosition","isMountedRef","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\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst { getBlockName, getBlocks, getSelectionStart, getSelectionEnd } =\n\t\tregistry.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 pendingChangesRef = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribedRef = 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 ( subscribedRef.current ) {\n\t\t\t\t\tpendingChangesRef.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 ( subscribedRef.current ) {\n\t\t\t\tpendingChangesRef.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 ( pendingChangesRef.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\tpendingChangesRef.current.outgoing[\n\t\t\t\t\tpendingChangesRef.current.outgoing.length - 1\n\t\t\t\t] === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChangesRef.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\tpendingChangesRef.current.outgoing = [];\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}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tconst isMountedRef = useRef( false );\n\n\tuseEffect( () => {\n\t\t// On mount, controlled blocks are already set in the effect above.\n\t\tif ( ! isMountedRef.current ) {\n\t\t\tisMountedRef.current = true;\n\t\t\treturn;\n\t\t}\n\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\tpendingChangesRef.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\tsubscribedRef.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\t\t\t}\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( pendingChangesRef.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChangesRef.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\tpendingChangesRef.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\tsubscribedRef.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":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAKA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AiB,CAACW,OAAO,CAACR,QAAQ,CAACgC,IAAI,CAAEV,MAAO,CAAC;;QAEjD;QACA;QACA,MAAMW,YAAY,GAAGV,YAAY,GAC9BZ,WAAW,CAACH,OAAO,GACnBE,UAAU,CAACF,OAAO;QACrByB,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,EAAE1C,YAAiB,CAAC;IAErB,OAAO,MAAM;MACZa,aAAa,CAACO,OAAO,GAAG,KAAK;MAC7BiB,WAAW,CAAC,CAAC;IACd,CAAC;EACF,CAAC,EAAE,CAAE7C,QAAQ,EAAEP,QAAQ,CAAG,CAAC;EAE3B,IAAAuC,kBAAS,EAAE,MAAM;IAChB,OAAO,MAAM;MACZH,qBAAqB,CAAC,CAAC;IACxB,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_data","_blocks","_store","noop","useBlockSync","clientId","value","controlledBlocks","selection","controlledSelection","onChange","onInput","registry","useRegistry","resetBlocks","resetSelection","replaceInnerBlocks","setHasControlledInnerBlocks","__unstableMarkNextChangeAsNotPersistent","dispatch","blockEditorStore","getBlockName","getBlocks","getSelectionStart","getSelectionEnd","select","isControlled","useSelect","areInnerBlocksControlled","pendingChangesRef","useRef","incoming","outgoing","subscribedRef","setControlledBlocks","batch","storeBlocks","map","block","cloneBlock","current","unsetControlledBlocks","onInputRef","onChangeRef","useEffect","includes","length","selectionStart","selectionEnd","initialPosition","isMountedRef","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 * - Initializes 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 initialize 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\tsetHasControlledInnerBlocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = registry.dispatch( blockEditorStore );\n\tconst { getBlockName, getBlocks, getSelectionStart, getSelectionEnd } =\n\t\tregistry.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 pendingChangesRef = useRef( { incoming: null, outgoing: [] } );\n\tconst subscribedRef = 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 ( subscribedRef.current ) {\n\t\t\t\t\tpendingChangesRef.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 ( subscribedRef.current ) {\n\t\t\t\tpendingChangesRef.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 ( pendingChangesRef.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\tpendingChangesRef.current.outgoing[\n\t\t\t\t\tpendingChangesRef.current.outgoing.length - 1\n\t\t\t\t] === controlledBlocks\n\t\t\t) {\n\t\t\t\tpendingChangesRef.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\tpendingChangesRef.current.outgoing = [];\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}\n\t\t}\n\t}, [ controlledBlocks, clientId ] );\n\n\tconst isMountedRef = useRef( false );\n\n\tuseEffect( () => {\n\t\t// On mount, controlled blocks are already set in the effect above.\n\t\tif ( ! isMountedRef.current ) {\n\t\t\tisMountedRef.current = true;\n\t\t\treturn;\n\t\t}\n\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\tpendingChangesRef.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\tsubscribedRef.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\t\t\t}\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( pendingChangesRef.current.incoming ||\n\t\t\t\t\t__unstableIsLastBlockChangeIgnored() )\n\t\t\t) {\n\t\t\t\tpendingChangesRef.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\tpendingChangesRef.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\tsubscribedRef.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":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAGA,MAAMI,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;AACe,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,GAAG,IAAAC,iBAAW,EAAC,CAAC;EAE9B,MAAM;IACLC,WAAW;IACXC,cAAc;IACdC,kBAAkB;IAClBC,2BAA2B;IAC3BC;EACD,CAAC,GAAGN,QAAQ,CAACO,QAAQ,CAAEC,YAAiB,CAAC;EACzC,MAAM;IAAEC,YAAY;IAAEC,SAAS;IAAEC,iBAAiB;IAAEC;EAAgB,CAAC,GACpE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M;MAC/CA,MAAM,GAAGO,SAAS;MAClB,IACCC,kBAAkB,KAChBjC,iBAAiB,CAACW,OAAO,CAACT,QAAQ,IACnCsB,kCAAkC,CAAC,CAAC,CAAE,EACtC;QACDxB,iBAAiB,CAACW,OAAO,CAACT,QAAQ,GAAG,IAAI;QACzCwB,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,iBAAiB,CAACW,OAAO,CAACR,QAAQ,CAACgC,IAAI,CAAEV,MAAO,CAAC;;QAEjD;QACA;QACA,MAAMW,YAAY,GAAGV,YAAY,GAC9BZ,WAAW,CAACH,OAAO,GACnBE,UAAU,CAACF,OAAO;QACrByB,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,EAAE1C,YAAiB,CAAC;IAErB,OAAO,MAAM;MACZa,aAAa,CAACO,OAAO,GAAG,KAAK;MAC7BiB,WAAW,CAAC,CAAC;IACd,CAAC;EACF,CAAC,EAAE,CAAE7C,QAAQ,EAAEP,QAAQ,CAAG,CAAC;EAE3B,IAAAuC,kBAAS,EAAE,MAAM;IAChB,OAAO,MAAM;MACZH,qBAAqB,CAAC,CAAC;IACxB,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
@@ -105,13 +105,13 @@ var _default = props => element => {
105
105
  return;
106
106
  }
107
107
  const value = getValue();
108
- const transformed = formatTypes.reduce((accumlator, {
108
+ const transformed = formatTypes.reduce((accumulator, {
109
109
  __unstableInputRule
110
110
  }) => {
111
111
  if (__unstableInputRule) {
112
- accumlator = __unstableInputRule(accumlator);
112
+ accumulator = __unstableInputRule(accumulator);
113
113
  }
114
- return accumlator;
114
+ return accumulator;
115
115
  }, (0, _preventEventDiscovery.preventEventDiscovery)(value));
116
116
  const {
117
117
  __unstableMarkLastChangeAsPersistent,
@@ -1 +1 @@
1
- {"version":3,"names":["_richText","require","_blocks","_store","_preventEventDiscovery","_selection","findSelection","blocks","i","length","attributeKey","retrieveSelectedAttribute","attributes","toString","replace","START_OF_SELECTED_AREA","clientId","nestedSelection","innerBlocks","_default","props","element","inputRule","getValue","onReplace","selectionChange","registry","current","value","start","text","characterBefore","slice","trimmedTextBefore","trim","prefixTransforms","getBlockTransforms","filter","type","transformation","findTransform","prefix","content","toHTMLString","insert","block","transform","dispatch","blockEditorStore","__unstableMarkAutomaticChange","onInput","event","inputType","onChange","__unstableAllowPrefixTransformations","formatTypes","transformed","reduce","accumlator","__unstableInputRule","preventEventDiscovery","__unstableMarkLastChangeAsPersistent","activeFormats","addEventListener","removeEventListener","exports","default"],"sources":["@wordpress/block-editor/src/components/rich-text/event-listeners/input-rules.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { insert, toHTMLString } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { preventEventDiscovery } from '../prevent-event-discovery';\nimport {\n\tretrieveSelectedAttribute,\n\tSTART_OF_SELECTED_AREA,\n} from '../../../utils/selection';\n\nexport function findSelection( blocks ) {\n\tlet i = blocks.length;\n\n\twhile ( i-- ) {\n\t\tconst attributeKey = retrieveSelectedAttribute(\n\t\t\tblocks[ i ].attributes\n\t\t);\n\n\t\tif ( attributeKey ) {\n\t\t\tblocks[ i ].attributes[ attributeKey ] = blocks[ i ].attributes[\n\t\t\t\tattributeKey\n\t\t\t]\n\t\t\t\t// To do: refactor this to use rich text's selection instead, so\n\t\t\t\t// we no longer have to use on this hack inserting a special\n\t\t\t\t// character.\n\t\t\t\t.toString()\n\t\t\t\t.replace( START_OF_SELECTED_AREA, '' );\n\t\t\treturn [ blocks[ i ].clientId, attributeKey, 0, 0 ];\n\t\t}\n\n\t\tconst nestedSelection = findSelection( blocks[ i ].innerBlocks );\n\n\t\tif ( nestedSelection ) {\n\t\t\treturn nestedSelection;\n\t\t}\n\t}\n\n\treturn [];\n}\n\nexport default ( props ) => ( element ) => {\n\tfunction inputRule() {\n\t\tconst { getValue, onReplace, selectionChange, registry } =\n\t\t\tprops.current;\n\n\t\tif ( ! onReplace ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We must use getValue() here because value may be update\n\t\t// asynchronously.\n\t\tconst value = getValue();\n\t\tconst { start, text } = value;\n\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t// The character right before the caret must be a plain space.\n\t\tif ( characterBefore !== ' ' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t( { type } ) => type === 'prefix'\n\t\t);\n\t\tconst transformation = findTransform(\n\t\t\tprefixTransforms,\n\t\t\t( { prefix } ) => {\n\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t}\n\t\t);\n\n\t\tif ( ! transformation ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst content = toHTMLString( {\n\t\t\tvalue: insert( value, START_OF_SELECTED_AREA, 0, start ),\n\t\t} );\n\t\tconst block = transformation.transform( content );\n\n\t\tselectionChange( ...findSelection( [ block ] ) );\n\t\tonReplace( [ block ] );\n\t\tregistry.dispatch( blockEditorStore ).__unstableMarkAutomaticChange();\n\n\t\treturn true;\n\t}\n\n\tfunction onInput( event ) {\n\t\tconst { inputType, type } = event;\n\t\tconst {\n\t\t\tgetValue,\n\t\t\tonChange,\n\t\t\t__unstableAllowPrefixTransformations,\n\t\t\tformatTypes,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\t// Only run input rules when inserting text.\n\t\tif ( inputType !== 'insertText' && type !== 'compositionend' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( __unstableAllowPrefixTransformations && inputRule() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst value = getValue();\n\t\tconst transformed = formatTypes.reduce(\n\t\t\t( accumlator, { __unstableInputRule } ) => {\n\t\t\t\tif ( __unstableInputRule ) {\n\t\t\t\t\taccumlator = __unstableInputRule( accumlator );\n\t\t\t\t}\n\n\t\t\t\treturn accumlator;\n\t\t\t},\n\t\t\tpreventEventDiscovery( value )\n\t\t);\n\n\t\tconst {\n\t\t\t__unstableMarkLastChangeAsPersistent,\n\t\t\t__unstableMarkAutomaticChange,\n\t\t} = registry.dispatch( blockEditorStore );\n\n\t\tif ( transformed !== value ) {\n\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\tonChange( {\n\t\t\t\t...transformed,\n\t\t\t\tactiveFormats: value.activeFormats,\n\t\t\t} );\n\t\t\t__unstableMarkAutomaticChange();\n\t\t}\n\t}\n\n\telement.addEventListener( 'input', onInput );\n\telement.addEventListener( 'compositionend', onInput );\n\treturn () => {\n\t\telement.removeEventListener( 'input', onInput );\n\t\telement.removeEventListener( 'compositionend', onInput );\n\t};\n};\n"],"mappings":";;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAQO,SAASK,aAAaA,CAAEC,MAAM,EAAG;EACvC,IAAIC,CAAC,GAAGD,MAAM,CAACE,MAAM;EAErB,OAAQD,CAAC,EAAE,EAAG;IACb,MAAME,YAAY,GAAG,IAAAC,oCAAyB,EAC7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,mBAAmB,CAAED,UAAW,CAAC;MAC/C;MAEA,OAAOA,UAAU;IAClB,CAAC,EACD,IAAAE,4CAAqB,EAAEhC,KAAM,CAC9B,CAAC;IAED,MAAM;MACLiC,oCAAoC;MACpCZ;IACD,CAAC,GAAGvB,QAAQ,CAACqB,QAAQ,CAAEC,YAAiB,CAAC;IAEzC,IAAKQ,WAAW,KAAK5B,KAAK,EAAG;MAC5BiC,oCAAoC,CAAC,CAAC;MACtCR,QAAQ,CAAE;QACT,GAAGG,WAAW;QACdM,aAAa,EAAElC,KAAK,CAACkC;MACtB,CAAE,CAAC;MACHb,6BAA6B,CAAC,CAAC;IAChC;EACD;EAEA5B,OAAO,CAAC0C,gBAAgB,CAAE,OAAO,EAAEb,OAAQ,CAAC;EAC5C7B,OAAO,CAAC0C,gBAAgB,CAAE,gBAAgB,EAAEb,OAAQ,CAAC;EACrD,OAAO,MAAM;IACZ7B,OAAO,CAAC2C,mBAAmB,CAAE,OAAO,EAAEd,OAAQ,CAAC;IAC/C7B,OAAO,CAAC2C,mBAAmB,CAAE,gBAAgB,EAAEd,OAAQ,CAAC;EACzD,CAAC;AACF,CAAC;AAAAe,OAAA,CAAAC,OAAA,GAAA/C,QAAA","ignoreList":[]}
1
+ {"version":3,"names":["_richText","require","_blocks","_store","_preventEventDiscovery","_selection","findSelection","blocks","i","length","attributeKey","retrieveSelectedAttribute","attributes","toString","replace","START_OF_SELECTED_AREA","clientId","nestedSelection","innerBlocks","_default","props","element","inputRule","getValue","onReplace","selectionChange","registry","current","value","start","text","characterBefore","slice","trimmedTextBefore","trim","prefixTransforms","getBlockTransforms","filter","type","transformation","findTransform","prefix","content","toHTMLString","insert","block","transform","dispatch","blockEditorStore","__unstableMarkAutomaticChange","onInput","event","inputType","onChange","__unstableAllowPrefixTransformations","formatTypes","transformed","reduce","accumulator","__unstableInputRule","preventEventDiscovery","__unstableMarkLastChangeAsPersistent","activeFormats","addEventListener","removeEventListener","exports","default"],"sources":["@wordpress/block-editor/src/components/rich-text/event-listeners/input-rules.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { insert, toHTMLString } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { preventEventDiscovery } from '../prevent-event-discovery';\nimport {\n\tretrieveSelectedAttribute,\n\tSTART_OF_SELECTED_AREA,\n} from '../../../utils/selection';\n\nexport function findSelection( blocks ) {\n\tlet i = blocks.length;\n\n\twhile ( i-- ) {\n\t\tconst attributeKey = retrieveSelectedAttribute(\n\t\t\tblocks[ i ].attributes\n\t\t);\n\n\t\tif ( attributeKey ) {\n\t\t\tblocks[ i ].attributes[ attributeKey ] = blocks[ i ].attributes[\n\t\t\t\tattributeKey\n\t\t\t]\n\t\t\t\t// To do: refactor this to use rich text's selection instead, so\n\t\t\t\t// we no longer have to use on this hack inserting a special\n\t\t\t\t// character.\n\t\t\t\t.toString()\n\t\t\t\t.replace( START_OF_SELECTED_AREA, '' );\n\t\t\treturn [ blocks[ i ].clientId, attributeKey, 0, 0 ];\n\t\t}\n\n\t\tconst nestedSelection = findSelection( blocks[ i ].innerBlocks );\n\n\t\tif ( nestedSelection ) {\n\t\t\treturn nestedSelection;\n\t\t}\n\t}\n\n\treturn [];\n}\n\nexport default ( props ) => ( element ) => {\n\tfunction inputRule() {\n\t\tconst { getValue, onReplace, selectionChange, registry } =\n\t\t\tprops.current;\n\n\t\tif ( ! onReplace ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We must use getValue() here because value may be update\n\t\t// asynchronously.\n\t\tconst value = getValue();\n\t\tconst { start, text } = value;\n\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t// The character right before the caret must be a plain space.\n\t\tif ( characterBefore !== ' ' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t( { type } ) => type === 'prefix'\n\t\t);\n\t\tconst transformation = findTransform(\n\t\t\tprefixTransforms,\n\t\t\t( { prefix } ) => {\n\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t}\n\t\t);\n\n\t\tif ( ! transformation ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst content = toHTMLString( {\n\t\t\tvalue: insert( value, START_OF_SELECTED_AREA, 0, start ),\n\t\t} );\n\t\tconst block = transformation.transform( content );\n\n\t\tselectionChange( ...findSelection( [ block ] ) );\n\t\tonReplace( [ block ] );\n\t\tregistry.dispatch( blockEditorStore ).__unstableMarkAutomaticChange();\n\n\t\treturn true;\n\t}\n\n\tfunction onInput( event ) {\n\t\tconst { inputType, type } = event;\n\t\tconst {\n\t\t\tgetValue,\n\t\t\tonChange,\n\t\t\t__unstableAllowPrefixTransformations,\n\t\t\tformatTypes,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\t// Only run input rules when inserting text.\n\t\tif ( inputType !== 'insertText' && type !== 'compositionend' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( __unstableAllowPrefixTransformations && inputRule() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst value = getValue();\n\t\tconst transformed = formatTypes.reduce(\n\t\t\t( accumulator, { __unstableInputRule } ) => {\n\t\t\t\tif ( __unstableInputRule ) {\n\t\t\t\t\taccumulator = __unstableInputRule( accumulator );\n\t\t\t\t}\n\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\tpreventEventDiscovery( value )\n\t\t);\n\n\t\tconst {\n\t\t\t__unstableMarkLastChangeAsPersistent,\n\t\t\t__unstableMarkAutomaticChange,\n\t\t} = registry.dispatch( blockEditorStore );\n\n\t\tif ( transformed !== value ) {\n\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\tonChange( {\n\t\t\t\t...transformed,\n\t\t\t\tactiveFormats: value.activeFormats,\n\t\t\t} );\n\t\t\t__unstableMarkAutomaticChange();\n\t\t}\n\t}\n\n\telement.addEventListener( 'input', onInput );\n\telement.addEventListener( 'compositionend', onInput );\n\treturn () => {\n\t\telement.removeEventListener( 'input', onInput );\n\t\telement.removeEventListener( 'compositionend', onInput );\n\t};\n};\n"],"mappings":";;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAQO,SAASK,aAAaA,CAAEC,MAAM,EAAG;EACvC,IAAIC,CAAC,GAAGD,MAAM,CAACE,MAAM;EAErB,OAAQD,CAAC,EAAE,EAAG;IACb,MAAME,YAAY,GAAG,IAAAC,oCAAyB,EAC7CJ,MAAM,CAAEC,CAAC,CAAE,CAACI,UACb,CAAC;IAED,IAAKF,YAAY,EAAG;MACnBH,MAAM,CAAEC,CAAC,CAAE,CAACI,UAAU,CAAEF,YAAY,CAAE,GAAGH,MAAM,CAAEC,CAAC,CAAE,CAACI,UAAU,CAC9DF,YAAY;MAEZ;MACA;MACA;MAAA,CACCG,QAAQ,CAAC,CAAC,CACVC,OAAO,CAAEC,iCAAsB,EAAE,EAAG,CAAC;MACvC,OAAO,CAAER,MAAM,CAAEC,CAAC,CAAE,CAACQ,QAAQ,EAAEN,YAAY,EAAE,CAAC,EAAE,CAAC,CAAE;IACpD;IAEA,MAAMO,eAAe,GAAGX,aAAa,CAAEC,MAAM,CAAEC,CAAC,CAAE,CAACU,WAAY,CAAC;IAEhE,IAAKD,eAAe,EAAG;MACtB,OAAOA,eAAe;IACvB;EACD;EAEA,OAAO,EAAE;AACV;AAAC,IAAAE,QAAA,GAEgBC,KAAK,IAAQC,OAAO,IAAM;EAC1C,SAASC,SAASA,CAAA,EAAG;IACpB,MAAM;MAAEC,QAAQ;MAAEC,SAAS;MAAEC,eAAe;MAAEC;IAAS,CAAC,GACvDN,KAAK,CAACO,OAAO;IAEd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C,QAAA","ignoreList":[]}
@@ -30,7 +30,7 @@ const interactiveContentTags = new Set(['a', 'audio', 'button', 'details', 'embe
30
30
  * @param {Object} $0 Options
31
31
  * @param {string} $0.clientId Block client ID.
32
32
  * @param {string} $0.identifier Block attribute.
33
- * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.
33
+ * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formatting or not.
34
34
  * @param {Array} $0.allowedFormats Allowed formats
35
35
  */
36
36
  function useFormatTypes({
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_data","_richText","formatTypesSelector","select","richTextStore","getFormatTypes","interactiveContentTags","Set","useFormatTypes","clientId","identifier","withoutInteractiveFormatting","allowedFormats","allFormatTypes","useSelect","formatTypes","useMemo","filter","name","tagName","includes","has","keyedSelected","reduce","accumulator","type","__experimentalGetPropsForEditableTreePreparation","richTextIdentifier","blockClientId","dispatch","useDispatch","prepareHandlers","valueHandlers","changeHandlers","dependencies","forEach","__experimentalCreatePrepareEditableTree","selected","handler","__experimentalCreateOnChangeEditableValue","push","key","dispatchers","__experimentalGetPropsForEditableTreeChangeHandler"],"sources":["@wordpress/block-editor/src/components/rich-text/native/use-format-types.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as richTextStore } from '@wordpress/rich-text';\n\nfunction formatTypesSelector( select ) {\n\treturn select( richTextStore ).getFormatTypes();\n}\n\n/**\n * Set of all interactive content tags.\n *\n * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content\n */\nconst interactiveContentTags = new Set( [\n\t'a',\n\t'audio',\n\t'button',\n\t'details',\n\t'embed',\n\t'iframe',\n\t'input',\n\t'label',\n\t'select',\n\t'textarea',\n\t'video',\n] );\n\n/**\n * This hook provides RichText with the `formatTypes` and its derived props from\n * experimental format type settings.\n *\n * @param {Object} $0 Options\n * @param {string} $0.clientId Block client ID.\n * @param {string} $0.identifier Block attribute.\n * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.\n * @param {Array} $0.allowedFormats Allowed formats\n */\nexport function useFormatTypes( {\n\tclientId,\n\tidentifier,\n\twithoutInteractiveFormatting,\n\tallowedFormats,\n} ) {\n\tconst allFormatTypes = useSelect( formatTypesSelector, [] );\n\tconst formatTypes = useMemo( () => {\n\t\treturn allFormatTypes.filter( ( { name, tagName } ) => {\n\t\t\tif ( allowedFormats && ! allowedFormats.includes( name ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\twithoutInteractiveFormatting &&\n\t\t\t\tinteractiveContentTags.has( tagName )\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} );\n\t}, [ allFormatTypes, allowedFormats, interactiveContentTags ] );\n\tconst keyedSelected = useSelect(\n\t\t( select ) =>\n\t\t\tformatTypes.reduce( ( accumulator, type ) => {\n\t\t\t\tif ( type.__experimentalGetPropsForEditableTreePreparation ) {\n\t\t\t\t\taccumulator[ type.name ] =\n\t\t\t\t\t\ttype.__experimentalGetPropsForEditableTreePreparation(\n\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ formatTypes, clientId, identifier ]\n\t);\n\tconst dispatch = useDispatch();\n\tconst prepareHandlers = [];\n\tconst valueHandlers = [];\n\tconst changeHandlers = [];\n\tconst dependencies = [];\n\n\tformatTypes.forEach( ( type ) => {\n\t\tif ( type.__experimentalCreatePrepareEditableTree ) {\n\t\t\tconst selected = keyedSelected[ type.name ];\n\t\t\tconst handler = type.__experimentalCreatePrepareEditableTree(\n\t\t\t\tselected,\n\t\t\t\t{\n\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\t\tvalueHandlers.push( handler );\n\t\t\t} else {\n\t\t\t\tprepareHandlers.push( handler );\n\t\t\t}\n\n\t\t\tfor ( const key in selected ) {\n\t\t\t\tdependencies.push( selected[ key ] );\n\t\t\t}\n\t\t}\n\n\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\tlet dispatchers = {};\n\n\t\t\tif ( type.__experimentalGetPropsForEditableTreeChangeHandler ) {\n\t\t\t\tdispatchers =\n\t\t\t\t\ttype.__experimentalGetPropsForEditableTreeChangeHandler(\n\t\t\t\t\t\tdispatch,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t}\n\n\t\t\tchangeHandlers.push(\n\t\t\t\ttype.__experimentalCreateOnChangeEditableValue(\n\t\t\t\t\t{\n\t\t\t\t\t\t...( keyedSelected[ type.name ] || {} ),\n\t\t\t\t\t\t...dispatchers,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t};\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKA,SAASG,mBAAmBA,CAAEC,MAAM,EAAG;EACtC,OAAOA,MAAM,CAAEC,eAAc,CAAC,CAACC,cAAc,CAAC,CAAC;AAChD;;AAEA;AAC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AAC,EACD;QACCf,kBAAkB,EAAEjB,UAAU;QAC9BkB,aAAa,EAAEnB;MAChB,CACD,CACD,CAAC;IACF;EACD,CAAE,CAAC;EAEH,OAAO;IACNM,WAAW;IACXgB,eAAe;IACfC,aAAa;IACbC,cAAc;IACdC;EACD,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_data","_richText","formatTypesSelector","select","richTextStore","getFormatTypes","interactiveContentTags","Set","useFormatTypes","clientId","identifier","withoutInteractiveFormatting","allowedFormats","allFormatTypes","useSelect","formatTypes","useMemo","filter","name","tagName","includes","has","keyedSelected","reduce","accumulator","type","__experimentalGetPropsForEditableTreePreparation","richTextIdentifier","blockClientId","dispatch","useDispatch","prepareHandlers","valueHandlers","changeHandlers","dependencies","forEach","__experimentalCreatePrepareEditableTree","selected","handler","__experimentalCreateOnChangeEditableValue","push","key","dispatchers","__experimentalGetPropsForEditableTreeChangeHandler"],"sources":["@wordpress/block-editor/src/components/rich-text/native/use-format-types.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as richTextStore } from '@wordpress/rich-text';\n\nfunction formatTypesSelector( select ) {\n\treturn select( richTextStore ).getFormatTypes();\n}\n\n/**\n * Set of all interactive content tags.\n *\n * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content\n */\nconst interactiveContentTags = new Set( [\n\t'a',\n\t'audio',\n\t'button',\n\t'details',\n\t'embed',\n\t'iframe',\n\t'input',\n\t'label',\n\t'select',\n\t'textarea',\n\t'video',\n] );\n\n/**\n * This hook provides RichText with the `formatTypes` and its derived props from\n * experimental format type settings.\n *\n * @param {Object} $0 Options\n * @param {string} $0.clientId Block client ID.\n * @param {string} $0.identifier Block attribute.\n * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formatting or not.\n * @param {Array} $0.allowedFormats Allowed formats\n */\nexport function useFormatTypes( {\n\tclientId,\n\tidentifier,\n\twithoutInteractiveFormatting,\n\tallowedFormats,\n} ) {\n\tconst allFormatTypes = useSelect( formatTypesSelector, [] );\n\tconst formatTypes = useMemo( () => {\n\t\treturn allFormatTypes.filter( ( { name, tagName } ) => {\n\t\t\tif ( allowedFormats && ! allowedFormats.includes( name ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\twithoutInteractiveFormatting &&\n\t\t\t\tinteractiveContentTags.has( tagName )\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} );\n\t}, [ allFormatTypes, allowedFormats, interactiveContentTags ] );\n\tconst keyedSelected = useSelect(\n\t\t( select ) =>\n\t\t\tformatTypes.reduce( ( accumulator, type ) => {\n\t\t\t\tif ( type.__experimentalGetPropsForEditableTreePreparation ) {\n\t\t\t\t\taccumulator[ type.name ] =\n\t\t\t\t\t\ttype.__experimentalGetPropsForEditableTreePreparation(\n\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ formatTypes, clientId, identifier ]\n\t);\n\tconst dispatch = useDispatch();\n\tconst prepareHandlers = [];\n\tconst valueHandlers = [];\n\tconst changeHandlers = [];\n\tconst dependencies = [];\n\n\tformatTypes.forEach( ( type ) => {\n\t\tif ( type.__experimentalCreatePrepareEditableTree ) {\n\t\t\tconst selected = keyedSelected[ type.name ];\n\t\t\tconst handler = type.__experimentalCreatePrepareEditableTree(\n\t\t\t\tselected,\n\t\t\t\t{\n\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\t\tvalueHandlers.push( handler );\n\t\t\t} else {\n\t\t\t\tprepareHandlers.push( handler );\n\t\t\t}\n\n\t\t\tfor ( const key in selected ) {\n\t\t\t\tdependencies.push( selected[ key ] );\n\t\t\t}\n\t\t}\n\n\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\tlet dispatchers = {};\n\n\t\t\tif ( type.__experimentalGetPropsForEditableTreeChangeHandler ) {\n\t\t\t\tdispatchers =\n\t\t\t\t\ttype.__experimentalGetPropsForEditableTreeChangeHandler(\n\t\t\t\t\t\tdispatch,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t}\n\n\t\t\tchangeHandlers.push(\n\t\t\t\ttype.__experimentalCreateOnChangeEditableValue(\n\t\t\t\t\t{\n\t\t\t\t\t\t...( keyedSelected[ type.name ] || {} ),\n\t\t\t\t\t\t...dispatchers,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t};\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKA,SAASG,mBAAmBA,CAAEC,MAAM,EAAG;EACtC,OAAOA,MAAM,CAAEC,eAAc,CAAC,CAACC,cAAc,CAAC,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMC,sBAAsB,GAAG,IAAIC,GAAG,CAAE,CACvC,GAAG,EACH,OAAO,EACP,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,OA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