@wordpress/block-editor 8.5.0 → 8.6.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 (274) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-alignment-control/ui.js +1 -1
  3. package/build/components/block-alignment-control/ui.js.map +1 -1
  4. package/build/components/block-content-overlay/index.js +13 -4
  5. package/build/components/block-content-overlay/index.js.map +1 -1
  6. package/build/components/block-list/block.native.js +3 -1
  7. package/build/components/block-list/block.native.js.map +1 -1
  8. package/build/components/block-lock/index.js +8 -0
  9. package/build/components/block-lock/index.js.map +1 -1
  10. package/build/components/block-lock/menu-item.js +5 -20
  11. package/build/components/block-lock/menu-item.js.map +1 -1
  12. package/build/components/block-lock/modal.js +33 -12
  13. package/build/components/block-lock/modal.js.map +1 -1
  14. package/build/components/block-lock/toolbar.js +7 -20
  15. package/build/components/block-lock/toolbar.js.map +1 -1
  16. package/build/components/block-lock/use-block-lock.js +50 -0
  17. package/build/components/block-lock/use-block-lock.js.map +1 -0
  18. package/build/components/block-mover/button.js +4 -4
  19. package/build/components/block-mover/button.js.map +1 -1
  20. package/build/components/block-mover/index.js +39 -65
  21. package/build/components/block-mover/index.js.map +1 -1
  22. package/build/components/block-pattern-setup/index.js +37 -22
  23. package/build/components/block-pattern-setup/index.js.map +1 -1
  24. package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
  25. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  26. package/build/components/block-popover/inbetween.js +183 -0
  27. package/build/components/block-popover/inbetween.js.map +1 -0
  28. package/build/components/block-popover/index.js +82 -0
  29. package/build/components/block-popover/index.js.map +1 -0
  30. package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
  31. package/build/components/block-popover/use-popover-scroll.js.map +1 -0
  32. package/build/components/block-preview/auto.js +6 -3
  33. package/build/components/block-preview/auto.js.map +1 -1
  34. package/build/components/block-preview/index.js +4 -2
  35. package/build/components/block-preview/index.js.map +1 -1
  36. package/build/components/block-styles/index.js +1 -10
  37. package/build/components/block-styles/index.js.map +1 -1
  38. package/build/components/block-switcher/index.js +7 -2
  39. package/build/components/block-switcher/index.js.map +1 -1
  40. package/build/components/block-tools/back-compat.js +2 -2
  41. package/build/components/block-tools/back-compat.js.map +1 -1
  42. package/build/components/block-tools/block-selection-button.js +4 -2
  43. package/build/components/block-tools/block-selection-button.js.map +1 -1
  44. package/build/components/block-tools/index.js +5 -5
  45. package/build/components/block-tools/index.js.map +1 -1
  46. package/build/components/block-tools/insertion-point.js +14 -121
  47. package/build/components/block-tools/insertion-point.js.map +1 -1
  48. package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
  49. package/build/components/block-tools/selected-block-popover.js.map +1 -0
  50. package/build/components/copy-handler/index.js +44 -9
  51. package/build/components/copy-handler/index.js.map +1 -1
  52. package/build/components/duotone-control/index.js +5 -1
  53. package/build/components/duotone-control/index.js.map +1 -1
  54. package/build/components/inserter/index.native.js +30 -8
  55. package/build/components/inserter/index.native.js.map +1 -1
  56. package/build/components/link-control/index.js +6 -7
  57. package/build/components/link-control/index.js.map +1 -1
  58. package/build/components/list-view/block-select-button.js +4 -10
  59. package/build/components/list-view/block-select-button.js.map +1 -1
  60. package/build/components/list-view/block.js +13 -2
  61. package/build/components/list-view/block.js.map +1 -1
  62. package/build/components/rich-text/index.js +0 -5
  63. package/build/components/rich-text/index.js.map +1 -1
  64. package/build/components/rich-text/index.native.js +0 -4
  65. package/build/components/rich-text/index.native.js.map +1 -1
  66. package/build/components/use-block-display-information/index.js +3 -1
  67. package/build/components/use-block-display-information/index.js.map +1 -1
  68. package/build/hooks/border.js +468 -44
  69. package/build/hooks/border.js.map +1 -1
  70. package/build/hooks/duotone.js +66 -16
  71. package/build/hooks/duotone.js.map +1 -1
  72. package/build/hooks/index.js +8 -2
  73. package/build/hooks/index.js.map +1 -1
  74. package/build/hooks/use-border-props.js +22 -32
  75. package/build/hooks/use-border-props.js.map +1 -1
  76. package/build/index.js +7 -0
  77. package/build/index.js.map +1 -1
  78. package/build/store/actions.js +36 -31
  79. package/build/store/actions.js.map +1 -1
  80. package/build/store/reducer.js +0 -26
  81. package/build/store/reducer.js.map +1 -1
  82. package/build/store/selectors.js +131 -6
  83. package/build/store/selectors.js.map +1 -1
  84. package/build/store/utils.js +27 -0
  85. package/build/store/utils.js.map +1 -0
  86. package/build-module/components/block-alignment-control/ui.js +2 -2
  87. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  88. package/build-module/components/block-content-overlay/index.js +13 -4
  89. package/build-module/components/block-content-overlay/index.js.map +1 -1
  90. package/build-module/components/block-list/block.native.js +3 -1
  91. package/build-module/components/block-list/block.native.js.map +1 -1
  92. package/build-module/components/block-lock/index.js +1 -0
  93. package/build-module/components/block-lock/index.js.map +1 -1
  94. package/build-module/components/block-lock/menu-item.js +4 -18
  95. package/build-module/components/block-lock/menu-item.js.map +1 -1
  96. package/build-module/components/block-lock/modal.js +31 -12
  97. package/build-module/components/block-lock/modal.js.map +1 -1
  98. package/build-module/components/block-lock/toolbar.js +6 -18
  99. package/build-module/components/block-lock/toolbar.js.map +1 -1
  100. package/build-module/components/block-lock/use-block-lock.js +41 -0
  101. package/build-module/components/block-lock/use-block-lock.js.map +1 -0
  102. package/build-module/components/block-mover/button.js +5 -5
  103. package/build-module/components/block-mover/button.js.map +1 -1
  104. package/build-module/components/block-mover/index.js +38 -63
  105. package/build-module/components/block-mover/index.js.map +1 -1
  106. package/build-module/components/block-pattern-setup/index.js +39 -24
  107. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  108. package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
  109. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  110. package/build-module/components/block-popover/inbetween.js +165 -0
  111. package/build-module/components/block-popover/inbetween.js.map +1 -0
  112. package/build-module/components/block-popover/index.js +67 -0
  113. package/build-module/components/block-popover/index.js.map +1 -0
  114. package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  115. package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
  116. package/build-module/components/block-preview/auto.js +6 -3
  117. package/build-module/components/block-preview/auto.js.map +1 -1
  118. package/build-module/components/block-preview/index.js +4 -2
  119. package/build-module/components/block-preview/index.js.map +1 -1
  120. package/build-module/components/block-styles/index.js +1 -9
  121. package/build-module/components/block-styles/index.js.map +1 -1
  122. package/build-module/components/block-switcher/index.js +7 -2
  123. package/build-module/components/block-switcher/index.js.map +1 -1
  124. package/build-module/components/block-tools/back-compat.js +1 -1
  125. package/build-module/components/block-tools/back-compat.js.map +1 -1
  126. package/build-module/components/block-tools/block-selection-button.js +3 -2
  127. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  128. package/build-module/components/block-tools/index.js +3 -3
  129. package/build-module/components/block-tools/index.js.map +1 -1
  130. package/build-module/components/block-tools/insertion-point.js +16 -121
  131. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  132. package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
  133. package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
  134. package/build-module/components/copy-handler/index.js +44 -9
  135. package/build-module/components/copy-handler/index.js.map +1 -1
  136. package/build-module/components/duotone-control/index.js +4 -1
  137. package/build-module/components/duotone-control/index.js.map +1 -1
  138. package/build-module/components/inserter/index.native.js +31 -10
  139. package/build-module/components/inserter/index.native.js.map +1 -1
  140. package/build-module/components/link-control/index.js +6 -7
  141. package/build-module/components/link-control/index.js.map +1 -1
  142. package/build-module/components/list-view/block-select-button.js +4 -9
  143. package/build-module/components/list-view/block-select-button.js.map +1 -1
  144. package/build-module/components/list-view/block.js +13 -2
  145. package/build-module/components/list-view/block.js.map +1 -1
  146. package/build-module/components/rich-text/index.js +0 -4
  147. package/build-module/components/rich-text/index.js.map +1 -1
  148. package/build-module/components/rich-text/index.native.js +0 -4
  149. package/build-module/components/rich-text/index.native.js.map +1 -1
  150. package/build-module/components/use-block-display-information/index.js +3 -1
  151. package/build-module/components/use-block-display-information/index.js.map +1 -1
  152. package/build-module/hooks/border.js +458 -44
  153. package/build-module/hooks/border.js.map +1 -1
  154. package/build-module/hooks/duotone.js +63 -16
  155. package/build-module/hooks/duotone.js.map +1 -1
  156. package/build-module/hooks/index.js +2 -1
  157. package/build-module/hooks/index.js.map +1 -1
  158. package/build-module/hooks/use-border-props.js +21 -30
  159. package/build-module/hooks/use-border-props.js.map +1 -1
  160. package/build-module/index.js +1 -1
  161. package/build-module/index.js.map +1 -1
  162. package/build-module/store/actions.js +19 -16
  163. package/build-module/store/actions.js.map +1 -1
  164. package/build-module/store/reducer.js +0 -24
  165. package/build-module/store/reducer.js.map +1 -1
  166. package/build-module/store/selectors.js +120 -5
  167. package/build-module/store/selectors.js.map +1 -1
  168. package/build-module/store/utils.js +20 -0
  169. package/build-module/store/utils.js.map +1 -0
  170. package/build-style/style-rtl.css +145 -272
  171. package/build-style/style.css +145 -272
  172. package/package.json +28 -28
  173. package/src/components/block-alignment-control/ui.js +2 -2
  174. package/src/components/block-content-overlay/index.js +19 -2
  175. package/src/components/block-list/block.native.js +2 -0
  176. package/src/components/block-lock/index.js +1 -0
  177. package/src/components/block-lock/menu-item.js +3 -23
  178. package/src/components/block-lock/modal.js +37 -13
  179. package/src/components/block-lock/style.scss +1 -2
  180. package/src/components/block-lock/toolbar.js +4 -21
  181. package/src/components/block-lock/use-block-lock.js +45 -0
  182. package/src/components/block-mover/button.js +5 -7
  183. package/src/components/block-mover/index.js +37 -60
  184. package/src/components/block-mover/stories/index.js +110 -0
  185. package/src/components/block-mover/style.scss +48 -138
  186. package/src/components/block-pattern-setup/index.js +84 -59
  187. package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
  188. package/src/components/block-pattern-setup/style.scss +32 -26
  189. package/src/components/block-popover/README.md +41 -0
  190. package/src/components/block-popover/inbetween.js +180 -0
  191. package/src/components/block-popover/index.js +73 -0
  192. package/src/components/block-popover/style.scss +24 -0
  193. package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  194. package/src/components/block-preview/auto.js +10 -1
  195. package/src/components/block-preview/index.js +2 -0
  196. package/src/components/block-styles/index.js +1 -12
  197. package/src/components/block-switcher/index.js +13 -1
  198. package/src/components/block-switcher/style.scss +4 -4
  199. package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
  200. package/src/components/block-toolbar/style.scss +0 -12
  201. package/src/components/block-tools/back-compat.js +1 -1
  202. package/src/components/block-tools/block-selection-button.js +3 -1
  203. package/src/components/block-tools/index.js +6 -4
  204. package/src/components/block-tools/insertion-point.js +19 -152
  205. package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
  206. package/src/components/block-tools/style.scss +11 -123
  207. package/src/components/border-radius-control/style.scss +5 -2
  208. package/src/components/copy-handler/index.js +52 -10
  209. package/src/components/default-block-appender/style.scss +1 -2
  210. package/src/components/duotone-control/index.js +8 -1
  211. package/src/components/gradients/README.md +29 -0
  212. package/src/components/inserter/index.native.js +60 -25
  213. package/src/components/inserter/style.native.scss +24 -3
  214. package/src/components/link-control/index.js +5 -5
  215. package/src/components/list-view/block-select-button.js +2 -10
  216. package/src/components/list-view/block.js +16 -7
  217. package/src/components/navigable-toolbar/README.md +16 -0
  218. package/src/components/rich-text/index.js +0 -2
  219. package/src/components/rich-text/index.native.js +0 -4
  220. package/src/components/use-block-display-information/index.js +2 -0
  221. package/src/hooks/border.js +438 -72
  222. package/src/hooks/border.scss +48 -0
  223. package/src/hooks/duotone.js +98 -62
  224. package/src/hooks/index.js +2 -1
  225. package/src/hooks/use-border-props.js +15 -32
  226. package/src/index.js +1 -0
  227. package/src/store/actions.js +19 -15
  228. package/src/store/reducer.js +0 -21
  229. package/src/store/selectors.js +160 -5
  230. package/src/store/test/actions.js +0 -18
  231. package/src/store/test/reducer.js +0 -19
  232. package/src/store/test/selectors.js +0 -19
  233. package/src/store/utils.js +19 -0
  234. package/src/style.scss +1 -1
  235. package/build/components/block-mobile-toolbar/index.js +0 -42
  236. package/build/components/block-mobile-toolbar/index.js.map +0 -1
  237. package/build/components/block-tools/block-popover.js.map +0 -1
  238. package/build/components/block-tools/use-popover-scroll.js.map +0 -1
  239. package/build/components/list-view/appender.js +0 -93
  240. package/build/components/list-view/appender.js.map +0 -1
  241. package/build/components/list-view/list-item.js +0 -62
  242. package/build/components/list-view/list-item.js.map +0 -1
  243. package/build/components/rich-text/use-caret-in-format.js +0 -43
  244. package/build/components/rich-text/use-caret-in-format.js.map +0 -1
  245. package/build/hooks/border-color.js +0 -302
  246. package/build/hooks/border-color.js.map +0 -1
  247. package/build/hooks/border-style.js +0 -96
  248. package/build/hooks/border-style.js.map +0 -1
  249. package/build/hooks/border-width.js +0 -162
  250. package/build/hooks/border-width.js.map +0 -1
  251. package/build-module/components/block-mobile-toolbar/index.js +0 -31
  252. package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
  253. package/build-module/components/block-tools/block-popover.js.map +0 -1
  254. package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
  255. package/build-module/components/list-view/appender.js +0 -76
  256. package/build-module/components/list-view/appender.js.map +0 -1
  257. package/build-module/components/list-view/list-item.js +0 -47
  258. package/build-module/components/list-view/list-item.js.map +0 -1
  259. package/build-module/components/rich-text/use-caret-in-format.js +0 -33
  260. package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
  261. package/build-module/hooks/border-color.js +0 -276
  262. package/build-module/hooks/border-color.js.map +0 -1
  263. package/build-module/hooks/border-style.js +0 -78
  264. package/build-module/hooks/border-style.js.map +0 -1
  265. package/build-module/hooks/border-width.js +0 -143
  266. package/build-module/hooks/border-width.js.map +0 -1
  267. package/src/components/block-mobile-toolbar/index.js +0 -24
  268. package/src/components/block-mobile-toolbar/style.scss +0 -29
  269. package/src/components/list-view/appender.js +0 -82
  270. package/src/components/list-view/list-item.js +0 -59
  271. package/src/components/rich-text/use-caret-in-format.js +0 -28
  272. package/src/hooks/border-color.js +0 -315
  273. package/src/hooks/border-style.js +0 -64
  274. package/src/hooks/border-width.js +0 -139
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/block-popover.js"],"names":["find","classnames","useState","useRef","useEffect","isUnmodifiedDefaultBlock","Popover","useDispatch","useSelect","useShortcut","useViewportMatch","getScrollContainer","BlockSelectionButton","BlockContextualToolbar","Inserter","store","blockEditorStore","__unstableUseBlockElement","useBlockElement","usePopoverScroll","selector","select","isNavigationMode","isMultiSelecting","hasMultiSelection","isTyping","isCaretWithinFormattedText","getSettings","getLastMultiSelectedBlockClientId","hasFixedToolbar","lastClientId","BlockPopover","clientId","rootClientId","isValid","isEmptyDefaultBlock","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isLargeViewport","isToolbarForced","setIsToolbarForced","isInserterShown","setIsInserterShown","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","shouldShowContextualToolbar","canFocusHiddenToolbar","isDisabled","initialToolbarItemIndexRef","selectedElement","lastSelectedElement","capturingElement","popoverScrollRef","node","anchorRef","top","bottom","onFocus","onBlur","popoverPosition","ownerDocument","stickyBoundaryElement","undefined","defaultView","frameElement","body","current","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","parentClientId","__experimentalCaptureToolbars","WrappedBlockPopover","selected"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,MAAnB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,wBAAT,QAAyC,mBAAzC;AACA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,WAAT,QA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EAAGC,iBALrB;AAMC,IAAA,qBAAqB,EAAGC,qBANzB;AAOC,IAAA,oBAAoB,EAAGC;AAPxB,IADD;AAWA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { Popover } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport Inserter from '../inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport { usePopoverScroll } from './use-popover-scroll';\n\nfunction selector( select ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\tisCaretWithinFormattedText,\n\t\tgetSettings,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\treturn {\n\t\tisNavigationMode: isNavigationMode(),\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tisTyping: isTyping(),\n\t\tisCaretWithinFormattedText: isCaretWithinFormattedText(),\n\t\thasMultiSelection: hasMultiSelection(),\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tlastClientId: getLastMultiSelectedBlockClientId(),\n\t};\n}\n\nfunction BlockPopover( {\n\tclientId,\n\trootClientId,\n\tisValid,\n\tisEmptyDefaultBlock,\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\tisTyping,\n\t\tisCaretWithinFormattedText,\n\t\thasMultiSelection,\n\t\thasFixedToolbar,\n\t\tlastClientId,\n\t} = useSelect( selector, [] );\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst [ isToolbarForced, setIsToolbarForced ] = useState( false );\n\tconst [ isInserterShown, setIsInserterShown ] = useState( false );\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\t// Controls when the side inserter on empty lines should\n\t// be shown, including writing and selection modes.\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && ! isNavigationMode && isEmptyDefaultBlock && isValid;\n\tconst shouldShowBreadcrumb = isNavigationMode;\n\tconst shouldShowContextualToolbar =\n\t\t! isNavigationMode &&\n\t\t! hasFixedToolbar &&\n\t\tisLargeViewport &&\n\t\t! showEmptyBlockSideInserter &&\n\t\t! isMultiSelecting &&\n\t\t( ! isTyping || isCaretWithinFormattedText );\n\tconst canFocusHiddenToolbar =\n\t\t! isNavigationMode &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! hasFixedToolbar &&\n\t\t! isEmptyDefaultBlock;\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tsetIsToolbarForced( true );\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tif ( ! shouldShowContextualToolbar ) {\n\t\t\tsetIsToolbarForced( false );\n\t\t}\n\t}, [ shouldShowContextualToolbar ] );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( lastClientId );\n\tconst capturingElement = useBlockElement( capturingClientId );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\n\tif (\n\t\t! shouldShowBreadcrumb &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! isToolbarForced &&\n\t\t! showEmptyBlockSideInserter\n\t) {\n\t\treturn null;\n\t}\n\n\tlet node = selectedElement;\n\n\tif ( ! node ) {\n\t\treturn null;\n\t}\n\n\tif ( capturingClientId ) {\n\t\tnode = capturingElement;\n\t}\n\n\tlet anchorRef = node;\n\n\tif ( hasMultiSelection ) {\n\t\t// Wait to render the popover until the bottom reference is available\n\t\t// as well.\n\t\tif ( ! lastSelectedElement ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tanchorRef = {\n\t\t\ttop: node,\n\t\t\tbottom: lastSelectedElement,\n\t\t};\n\t}\n\n\tfunction onFocus() {\n\t\tsetIsInserterShown( true );\n\t}\n\n\tfunction onBlur() {\n\t\tsetIsInserterShown( false );\n\t}\n\n\t// Position above the anchor, pop out towards the right, and position in the\n\t// left corner. For the side inserter, pop out towards the left, and\n\t// position in the right corner.\n\t// To do: refactor `Popover` to make this prop clearer.\n\tconst popoverPosition = showEmptyBlockSideInserter\n\t\t? 'top left right'\n\t\t: 'top right left';\n\tconst { ownerDocument } = node;\n\tconst stickyBoundaryElement = showEmptyBlockSideInserter\n\t\t? undefined\n\t\t: // The sticky boundary element should be the boundary at which the\n\t\t // the block toolbar becomes sticky when the block scolls out of view.\n\t\t // In case of an iframe, this should be the iframe boundary, otherwise\n\t\t // the scroll container.\n\t\t ownerDocument.defaultView.frameElement ||\n\t\t getScrollContainer( node ) ||\n\t\t ownerDocument.body;\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tnoArrow\n\t\t\tanimate={ false }\n\t\t\tposition={ popoverPosition }\n\t\t\tfocusOnMount={ false }\n\t\t\tanchorRef={ anchorRef }\n\t\t\tclassName={ classnames( 'block-editor-block-list__block-popover', {\n\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t} ) }\n\t\t\t__unstableStickyBoundaryElement={ stickyBoundaryElement }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\t__unstableBoundaryParent\n\t\t\t// Observe movement for block animations (especially horizontal).\n\t\t\t__unstableObserveElement={ node }\n\t\t\tshouldAnchorIncludePadding\n\t\t\t// Used to safeguard sticky position behavior against cases where it would permanently\n\t\t\t// obscure specific sections of a block.\n\t\t\t__unstableEditorCanvasWrapper={ __unstableContentRef?.current }\n\t\t>\n\t\t\t{ ( shouldShowContextualToolbar || isToolbarForced ) && (\n\t\t\t\t<div\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\t// While ideally it would be enough to capture the\n\t\t\t\t\t// bubbling focus event from the Inserter, due to the\n\t\t\t\t\t// characteristics of click focusing of `button`s in\n\t\t\t\t\t// Firefox and Safari, it is not reliable.\n\t\t\t\t\t//\n\t\t\t\t\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-block-list__block-popover-inserter',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-visible': isInserterShown,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<Inserter\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ( shouldShowContextualToolbar || isToolbarForced ) && (\n\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\tfocusOnMount={ isToolbarForced }\n\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t} }\n\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t<BlockSelectionButton\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tblockElement={ node }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t<div className=\"block-editor-block-list__empty-block-inserter\">\n\t\t\t\t\t<Inserter\n\t\t\t\t\t\tposition=\"bottom right\"\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {}, isValid } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = find(\n\t\tblockParentsClientIds,\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisValid,\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisValid,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisValid={ isValid }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/use-popover-scroll.js"],"names":["useRefEffect","usePopoverScroll","scrollableRef","node","onWheel","event","deltaX","deltaY","current","scrollBy","options","passive","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,gBAAT,CAA2BC,aAA3B,EAA2C;AACjD,SAAOF,YAAY,CAChBG,IAAF,IAAY;AACX,QAAK,CAAED,aAAP,EAAuB;AACtB;AACA;;AAED,aAASE,OAAT,CAAkBC,KAAlB,EAA0B;AACzB,YAAM;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,UAAqBF,KAA3B;AACAH,MAAAA,aAAa,CAACM,OAAd,CAAsBC,QAAtB,CAAgCH,MAAhC,EAAwCC,MAAxC;AACA,KARU,CASX;AACA;;;AACA,UAAMG,OAAO,GAAG;AAAEC,MAAAA,OAAO,EAAE;AAAX,KAAhB;AACAR,IAAAA,IAAI,CAACS,gBAAL,CAAuB,OAAvB,EAAgCR,OAAhC,EAAyCM,OAAzC;AACA,WAAO,MAAM;AACZP,MAAAA,IAAI,CAACU,mBAAL,CAA0B,OAA1B,EAAmCT,OAAnC,EAA4CM,OAA5C;AACA,KAFD;AAGA,GAjBiB,EAkBlB,CAAER,aAAF,CAlBkB,CAAnB;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Allow scrolling \"through\" popovers over the canvas. This is only called for\n * as long as the pointer is over a popover. Do not use React events because it\n * will bubble through portals.\n *\n * @param {Object} scrollableRef\n */\nexport function usePopoverScroll( scrollableRef ) {\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! scrollableRef ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction onWheel( event ) {\n\t\t\t\tconst { deltaX, deltaY } = event;\n\t\t\t\tscrollableRef.current.scrollBy( deltaX, deltaY );\n\t\t\t}\n\t\t\t// Tell the browser that we do not call event.preventDefault\n\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners\n\t\t\tconst options = { passive: true };\n\t\t\tnode.addEventListener( 'wheel', onWheel, options );\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'wheel', onWheel, options );\n\t\t\t};\n\t\t},\n\t\t[ scrollableRef ]\n\t);\n}\n"]}
@@ -1,76 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * External dependencies
5
- */
6
- import classnames from 'classnames';
7
- /**
8
- * WordPress dependencies
9
- */
10
-
11
- import { __experimentalTreeGridCell as TreeGridCell } from '@wordpress/components';
12
- import { useInstanceId } from '@wordpress/compose';
13
- import { __, sprintf } from '@wordpress/i18n';
14
- import { useSelect } from '@wordpress/data';
15
- /**
16
- * Internal dependencies
17
- */
18
-
19
- import ListViewLeaf from './leaf';
20
- import Inserter from '../inserter';
21
- import { store as blockEditorStore } from '../../store';
22
- export default function ListViewAppender(_ref) {
23
- let {
24
- parentBlockClientId,
25
- position,
26
- level,
27
- rowCount,
28
- path
29
- } = _ref;
30
- const isDragging = useSelect(select => {
31
- const {
32
- isBlockBeingDragged,
33
- isAncestorBeingDragged
34
- } = select(blockEditorStore);
35
- return isBlockBeingDragged(parentBlockClientId) || isAncestorBeingDragged(parentBlockClientId);
36
- }, [parentBlockClientId]);
37
- const instanceId = useInstanceId(ListViewAppender);
38
- const descriptionId = `list-view-appender-row__description_${instanceId}`;
39
- const appenderPositionDescription = sprintf(
40
- /* translators: 1: The numerical position of the block that will be inserted. 2: The level of nesting for the block that will be inserted. */
41
- __('Add block at position %1$d, Level %2$d'), position, level);
42
- return createElement(ListViewLeaf, {
43
- className: classnames({
44
- 'is-dragging': isDragging
45
- }),
46
- level: level,
47
- position: position,
48
- rowCount: rowCount,
49
- path: path
50
- }, createElement(TreeGridCell, {
51
- className: "block-editor-list-view-appender__cell",
52
- colSpan: "3"
53
- }, _ref2 => {
54
- let {
55
- ref,
56
- tabIndex,
57
- onFocus
58
- } = _ref2;
59
- return createElement("div", {
60
- className: "block-editor-list-view-appender__container"
61
- }, createElement(Inserter, {
62
- rootClientId: parentBlockClientId,
63
- __experimentalIsQuick: true,
64
- "aria-describedby": descriptionId,
65
- toggleProps: {
66
- ref,
67
- tabIndex,
68
- onFocus
69
- }
70
- }), createElement("div", {
71
- className: "block-editor-list-view-appender__description",
72
- id: descriptionId
73
- }, appenderPositionDescription));
74
- }));
75
- }
76
- //# sourceMappingURL=appender.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/appender.js"],"names":["classnames","__experimentalTreeGridCell","TreeGridCell","useInstanceId","__","sprintf","useSelect","ListViewLeaf","Inserter","store","blockEditorStore","ListViewAppender","parentBlockClientId","position","level","rowCount","path","isDragging","select","isBlockBeingDragged","isAncestorBeingDragged","instanceId","descriptionId","appenderPositionDescription","ref","tabIndex","onFocus"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,0BAA0B,IAAIC,YAAvC,QAA2D,uBAA3D;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,eAAe,SAASC,gBAAT,OAMX;AAAA,MANsC;AACzCC,IAAAA,mBADyC;AAEzCC,IAAAA,QAFyC;AAGzCC,IAAAA,KAHyC;AAIzCC,IAAAA,QAJyC;AAKzCC,IAAAA;AALyC,GAMtC;AACH,QAAMC,UAAU,GAAGX,SAAS,CACzBY,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,mBAAF;AAAuBC,MAAAA;AAAvB,QAAkDF,MAAM,CAC7DR,gBAD6D,CAA9D;AAIA,WACCS,mBAAmB,CAAEP,mBAAF,CAAnB,IACAQ,sBAAsB,CAAER,mBAAF,CAFvB;AAIA,GAV0B,EAW3B,CAAEA,mBAAF,CAX2B,CAA5B;AAaA,QAAMS,UAAU,GAAGlB,aAAa,CAAEQ,gBAAF,CAAhC;AACA,QAAMW,aAAa,GAAI,uCAAuCD,UAAY,EAA1E;AAEA,QAAME,2BAA2B,GAAGlB,OAAO;AAC1C;AACAD,EAAAA,EAAE,CAAE,wCAAF,CAFwC,EAG1CS,QAH0C,EAI1CC,KAJ0C,CAA3C;AAOA,SACC,cAAC,YAAD;AACC,IAAA,SAAS,EAAGd,UAAU,CAAE;AAAE,qBAAeiB;AAAjB,KAAF,CADvB;AAEC,IAAA,KAAK,EAAGH,KAFT;AAGC,IAAA,QAAQ,EAAGD,QAHZ;AAIC,IAAA,QAAQ,EAAGE,QAJZ;AAKC,IAAA,IAAI,EAAGC;AALR,KAOC,cAAC,YAAD;AACC,IAAA,SAAS,EAAC,uCADX;AAEC,IAAA,OAAO,EAAC;AAFT,KAIG;AAAA,QAAE;AAAEQ,MAAAA,GAAF;AAAOC,MAAAA,QAAP;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WACD;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,cAAC,QAAD;AACC,MAAA,YAAY,EAAGd,mBADhB;AAEC,MAAA,qBAAqB,MAFtB;AAGC,0BAAmBU,aAHpB;AAIC,MAAA,WAAW,EAAG;AAAEE,QAAAA,GAAF;AAAOC,QAAAA,QAAP;AAAiBC,QAAAA;AAAjB;AAJf,MADD,EAOC;AACC,MAAA,SAAS,EAAC,8CADX;AAEC,MAAA,EAAE,EAAGJ;AAFN,OAIGC,2BAJH,CAPD,CADC;AAAA,GAJH,CAPD,CADD;AA+BA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalTreeGridCell as TreeGridCell } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport ListViewLeaf from './leaf';\nimport Inserter from '../inserter';\nimport { store as blockEditorStore } from '../../store';\n\nexport default function ListViewAppender( {\n\tparentBlockClientId,\n\tposition,\n\tlevel,\n\trowCount,\n\tpath,\n} ) {\n\tconst isDragging = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isBlockBeingDragged, isAncestorBeingDragged } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\tisBlockBeingDragged( parentBlockClientId ) ||\n\t\t\t\tisAncestorBeingDragged( parentBlockClientId )\n\t\t\t);\n\t\t},\n\t\t[ parentBlockClientId ]\n\t);\n\tconst instanceId = useInstanceId( ListViewAppender );\n\tconst descriptionId = `list-view-appender-row__description_${ instanceId }`;\n\n\tconst appenderPositionDescription = sprintf(\n\t\t/* translators: 1: The numerical position of the block that will be inserted. 2: The level of nesting for the block that will be inserted. */\n\t\t__( 'Add block at position %1$d, Level %2$d' ),\n\t\tposition,\n\t\tlevel\n\t);\n\n\treturn (\n\t\t<ListViewLeaf\n\t\t\tclassName={ classnames( { 'is-dragging': isDragging } ) }\n\t\t\tlevel={ level }\n\t\t\tposition={ position }\n\t\t\trowCount={ rowCount }\n\t\t\tpath={ path }\n\t\t>\n\t\t\t<TreeGridCell\n\t\t\t\tclassName=\"block-editor-list-view-appender__cell\"\n\t\t\t\tcolSpan=\"3\"\n\t\t\t>\n\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t<div className=\"block-editor-list-view-appender__container\">\n\t\t\t\t\t\t<Inserter\n\t\t\t\t\t\t\trootClientId={ parentBlockClientId }\n\t\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t\t\taria-describedby={ descriptionId }\n\t\t\t\t\t\t\ttoggleProps={ { ref, tabIndex, onFocus } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"block-editor-list-view-appender__description\"\n\t\t\t\t\t\t\tid={ descriptionId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ appenderPositionDescription }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</TreeGridCell>\n\t\t</ListViewLeaf>\n\t);\n}\n"]}
@@ -1,47 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * External dependencies
5
- */
6
- import classnames from 'classnames';
7
- /**
8
- * WordPress dependencies
9
- */
10
-
11
- import { Button, VisuallyHidden } from '@wordpress/components';
12
- import { __experimentalGetBlockLabel as getBlockLabel, getBlockType } from '@wordpress/blocks';
13
- import { __ } from '@wordpress/i18n';
14
- /**
15
- * Internal dependencies
16
- */
17
-
18
- import BlockIcon from '../block-icon';
19
- export default function ListViewListItem(_ref) {
20
- let {
21
- block,
22
- onClick,
23
- isSelected,
24
- wrapperComponent: WrapperComponent,
25
- children
26
- } = _ref;
27
- const blockType = getBlockType(block.name);
28
- const blockLabel = blockType ? getBlockLabel(blockType, block.attributes) : null;
29
- return createElement("div", {
30
- className: "block-editor-list-view__list-item"
31
- }, createElement(WrapperComponent, {
32
- className: classnames('block-editor-list-view__list-item-button', {
33
- 'is-selected': isSelected
34
- }),
35
- onClick: onClick
36
- }, createElement(BlockIcon, {
37
- icon: blockType === null || blockType === void 0 ? void 0 : blockType.icon,
38
- showColors: true
39
- }), children ? children : blockLabel, isSelected && createElement(VisuallyHidden, {
40
- as: "span"
41
- }, __('(selected block)'))));
42
- }
43
- ListViewListItem.defaultProps = {
44
- onClick: () => {},
45
- wrapperComponent: props => createElement(Button, props)
46
- };
47
- //# sourceMappingURL=list-item.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/list-item.js"],"names":["classnames","Button","VisuallyHidden","__experimentalGetBlockLabel","getBlockLabel","getBlockType","__","BlockIcon","ListViewListItem","block","onClick","isSelected","wrapperComponent","WrapperComponent","children","blockType","name","blockLabel","attributes","icon","defaultProps","props"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/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, VisuallyHidden } from '@wordpress/components';\nimport {\n\t__experimentalGetBlockLabel as getBlockLabel,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\n\nexport default function ListViewListItem( {\n\tblock,\n\tonClick,\n\tisSelected,\n\twrapperComponent: WrapperComponent,\n\tchildren,\n} ) {\n\tconst blockType = getBlockType( block.name );\n\tconst blockLabel = blockType\n\t\t? getBlockLabel( blockType, block.attributes )\n\t\t: null;\n\n\treturn (\n\t\t<div className=\"block-editor-list-view__list-item\">\n\t\t\t<WrapperComponent\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view__list-item-button',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-selected': isSelected,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\tonClick={ onClick }\n\t\t\t>\n\t\t\t\t<BlockIcon icon={ blockType?.icon } showColors />\n\t\t\t\t{ children ? children : blockLabel }\n\t\t\t\t{ isSelected && (\n\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t{ __( '(selected block)' ) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t</WrapperComponent>\n\t\t</div>\n\t);\n}\n\nListViewListItem.defaultProps = {\n\tonClick: () => {},\n\twrapperComponent: ( props ) => <Button { ...props } />,\n};\n"]}
@@ -1,33 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useEffect } from '@wordpress/element';
5
- import { useDispatch, useSelect } from '@wordpress/data';
6
- /**
7
- * Internal dependencies
8
- */
9
-
10
- import { store as blockEditorStore } from '../../store';
11
- export function useCaretInFormat(_ref) {
12
- let {
13
- value
14
- } = _ref;
15
- const hasActiveFormats = value.activeFormats && !!value.activeFormats.length;
16
- const {
17
- isCaretWithinFormattedText
18
- } = useSelect(blockEditorStore);
19
- const {
20
- enterFormattedText,
21
- exitFormattedText
22
- } = useDispatch(blockEditorStore);
23
- useEffect(() => {
24
- if (hasActiveFormats) {
25
- if (!isCaretWithinFormattedText()) {
26
- enterFormattedText();
27
- }
28
- } else if (isCaretWithinFormattedText()) {
29
- exitFormattedText();
30
- }
31
- }, [hasActiveFormats]);
32
- }
33
- //# sourceMappingURL=use-caret-in-format.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-caret-in-format.js"],"names":["useEffect","useDispatch","useSelect","store","blockEditorStore","useCaretInFormat","value","hasActiveFormats","activeFormats","length","isCaretWithinFormattedText","enterFormattedText","exitFormattedText"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,OAAO,SAASC,gBAAT,OAAuC;AAAA,MAAZ;AAAEC,IAAAA;AAAF,GAAY;AAC7C,QAAMC,gBAAgB,GACrBD,KAAK,CAACE,aAAN,IAAuB,CAAC,CAAEF,KAAK,CAACE,aAAN,CAAoBC,MAD/C;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAAiCR,SAAS,CAAEE,gBAAF,CAAhD;AACA,QAAM;AAAEO,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MAA4CX,WAAW,CAC5DG,gBAD4D,CAA7D;AAGAJ,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKO,gBAAL,EAAwB;AACvB,UAAK,CAAEG,0BAA0B,EAAjC,EAAsC;AACrCC,QAAAA,kBAAkB;AAClB;AACD,KAJD,MAIO,IAAKD,0BAA0B,EAA/B,EAAoC;AAC1CE,MAAAA,iBAAiB;AACjB;AACD,GARQ,EAQN,CAAEL,gBAAF,CARM,CAAT;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport function useCaretInFormat( { value } ) {\n\tconst hasActiveFormats =\n\t\tvalue.activeFormats && !! value.activeFormats.length;\n\tconst { isCaretWithinFormattedText } = useSelect( blockEditorStore );\n\tconst { enterFormattedText, exitFormattedText } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tuseEffect( () => {\n\t\tif ( hasActiveFormats ) {\n\t\t\tif ( ! isCaretWithinFormattedText() ) {\n\t\t\t\tenterFormattedText();\n\t\t\t}\n\t\t} else if ( isCaretWithinFormattedText() ) {\n\t\t\texitFormattedText();\n\t\t}\n\t}, [ hasActiveFormats ] );\n}\n"]}
@@ -1,276 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { createElement } from "@wordpress/element";
3
-
4
- /**
5
- * External dependencies
6
- */
7
- import classnames from 'classnames';
8
- /**
9
- * WordPress dependencies
10
- */
11
-
12
- import { addFilter } from '@wordpress/hooks';
13
- import { __ } from '@wordpress/i18n';
14
- import { createHigherOrderComponent } from '@wordpress/compose';
15
- import { useEffect, useState } from '@wordpress/element';
16
- /**
17
- * Internal dependencies
18
- */
19
-
20
- import ColorGradientSettingsDropdown from '../components/colors-gradients/dropdown';
21
- import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
22
- import { getColorClassName, getColorObjectByColorValue, getColorObjectByAttributeValues } from '../components/colors';
23
- import useSetting from '../components/use-setting';
24
- import { BORDER_SUPPORT_KEY, hasBorderSupport, removeBorderAttribute } from './border';
25
- import { cleanEmptyObject, shouldSkipSerialization } from './utils'; // Defining empty array here instead of inline avoids unnecessary re-renders of
26
- // color control.
27
-
28
- const EMPTY_ARRAY = [];
29
- /**
30
- * Inspector control panel containing the border color related configuration.
31
- *
32
- * There is deliberate overlap between the colors and borders block supports
33
- * relating to border color. It can be argued the border color controls could
34
- * be included within either, or both, the colors and borders panels in the
35
- * inspector controls. If they share the same block attributes it should not
36
- * matter.
37
- *
38
- * @param {Object} props Block properties.
39
- *
40
- * @return {WPElement} Border color edit element.
41
- */
42
-
43
- export function BorderColorEdit(props) {
44
- const {
45
- attributes: {
46
- borderColor,
47
- style
48
- },
49
- setAttributes
50
- } = props;
51
- const colorGradientSettings = useMultipleOriginColorsAndGradients();
52
- const availableColors = colorGradientSettings.colors.reduce((colors, origin) => colors.concat(origin.colors), []);
53
- const {
54
- color: customBorderColor
55
- } = (style === null || style === void 0 ? void 0 : style.border) || {};
56
- const [colorValue, setColorValue] = useState(() => {
57
- var _getColorObjectByAttr;
58
-
59
- return (_getColorObjectByAttr = getColorObjectByAttributeValues(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
60
- }); // Detect changes in the color attributes and update the colorValue to keep the
61
- // UI in sync. This is necessary for situations when border controls interact with
62
- // each other: eg, setting the border width to zero causes the color and style
63
- // selections to be cleared.
64
-
65
- useEffect(() => {
66
- var _getColorObjectByAttr2;
67
-
68
- setColorValue((_getColorObjectByAttr2 = getColorObjectByAttributeValues(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color);
69
- }, [borderColor, customBorderColor, availableColors]);
70
-
71
- const onChangeColor = value => {
72
- setColorValue(value);
73
- const colorObject = getColorObjectByColorValue(availableColors, value);
74
- const newStyle = { ...style,
75
- border: { ...(style === null || style === void 0 ? void 0 : style.border),
76
- color: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value
77
- }
78
- }; // If empty slug, ensure undefined to remove attribute.
79
-
80
- const newNamedColor = colorObject !== null && colorObject !== void 0 && colorObject.slug ? colorObject.slug : undefined;
81
- setAttributes({
82
- style: cleanEmptyObject(newStyle),
83
- borderColor: newNamedColor
84
- });
85
- };
86
-
87
- const settings = [{
88
- label: __('Color'),
89
- onColorChange: onChangeColor,
90
- colorValue,
91
- clearable: false
92
- }];
93
- return createElement(ColorGradientSettingsDropdown, _extends({
94
- settings: settings,
95
- disableCustomColors: true,
96
- disableCustomGradients: true,
97
- __experimentalHasMultipleOrigins: true,
98
- __experimentalIsRenderedInSidebar: true,
99
- enableAlpha: true
100
- }, colorGradientSettings));
101
- }
102
- /**
103
- * Checks if there is a current value in the border color block support
104
- * attributes.
105
- *
106
- * @param {Object} props Block props.
107
- * @return {boolean} Whether or not the block has a border color value set.
108
- */
109
-
110
- export function hasBorderColorValue(props) {
111
- var _style$border;
112
-
113
- const {
114
- attributes: {
115
- borderColor,
116
- style
117
- }
118
- } = props;
119
- return !!borderColor || !!(style !== null && style !== void 0 && (_style$border = style.border) !== null && _style$border !== void 0 && _style$border.color);
120
- }
121
- /**
122
- * Resets the border color block support attributes. This can be used when
123
- * disabling the border color support controls for a block via a progressive
124
- * discovery panel.
125
- *
126
- * @param {Object} props Block props.
127
- * @param {Object} props.attributes Block's attributes.
128
- * @param {Object} props.setAttributes Function to set block's attributes.
129
- */
130
-
131
- export function resetBorderColor(_ref) {
132
- let {
133
- attributes = {},
134
- setAttributes
135
- } = _ref;
136
- const {
137
- style
138
- } = attributes;
139
- setAttributes({
140
- borderColor: undefined,
141
- style: removeBorderAttribute(style, 'color')
142
- });
143
- }
144
- /**
145
- * Filters registered block settings, extending attributes to include
146
- * `borderColor` if needed.
147
- *
148
- * @param {Object} settings Original block settings.
149
- *
150
- * @return {Object} Updated block settings.
151
- */
152
-
153
- function addAttributes(settings) {
154
- if (!hasBorderSupport(settings, 'color')) {
155
- return settings;
156
- } // Allow blocks to specify default value if needed.
157
-
158
-
159
- if (settings.attributes.borderColor) {
160
- return settings;
161
- } // Add new borderColor attribute to block settings.
162
-
163
-
164
- return { ...settings,
165
- attributes: { ...settings.attributes,
166
- borderColor: {
167
- type: 'string'
168
- }
169
- }
170
- };
171
- }
172
- /**
173
- * Override props assigned to save component to inject border color.
174
- *
175
- * @param {Object} props Additional props applied to save element.
176
- * @param {Object} blockType Block type definition.
177
- * @param {Object} attributes Block's attributes.
178
- *
179
- * @return {Object} Filtered props to apply to save element.
180
- */
181
-
182
-
183
- function addSaveProps(props, blockType, attributes) {
184
- var _style$border2;
185
-
186
- if (!hasBorderSupport(blockType, 'color') || shouldSkipSerialization(blockType, BORDER_SUPPORT_KEY, 'color')) {
187
- return props;
188
- }
189
-
190
- const {
191
- borderColor,
192
- style
193
- } = attributes;
194
- const borderColorClass = getColorClassName('border-color', borderColor);
195
- const newClassName = classnames(props.className, {
196
- 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border2 = style.border) === null || _style$border2 === void 0 ? void 0 : _style$border2.color),
197
- [borderColorClass]: !!borderColorClass
198
- }); // If we are clearing the last of the previous classes in `className`
199
- // set it to `undefined` to avoid rendering empty DOM attributes.
200
-
201
- props.className = newClassName ? newClassName : undefined;
202
- return props;
203
- }
204
- /**
205
- * Filters the registered block settings to apply border color styles and
206
- * classnames to the block edit wrapper.
207
- *
208
- * @param {Object} settings Original block settings.
209
- *
210
- * @return {Object} Filtered block settings.
211
- */
212
-
213
-
214
- function addEditProps(settings) {
215
- if (!hasBorderSupport(settings, 'color') || shouldSkipSerialization(settings, BORDER_SUPPORT_KEY, 'color')) {
216
- return settings;
217
- }
218
-
219
- const existingGetEditWrapperProps = settings.getEditWrapperProps;
220
-
221
- settings.getEditWrapperProps = attributes => {
222
- let props = {};
223
-
224
- if (existingGetEditWrapperProps) {
225
- props = existingGetEditWrapperProps(attributes);
226
- }
227
-
228
- return addSaveProps(props, settings, attributes);
229
- };
230
-
231
- return settings;
232
- }
233
- /**
234
- * This adds inline styles for color palette colors.
235
- * Ideally, this is not needed and themes should load their palettes on the editor.
236
- *
237
- * @param {Function} BlockListBlock Original component.
238
- *
239
- * @return {Function} Wrapped component.
240
- */
241
-
242
-
243
- export const withBorderColorPaletteStyles = createHigherOrderComponent(BlockListBlock => props => {
244
- var _getColorObjectByAttr3, _props$wrapperProps;
245
-
246
- const {
247
- name,
248
- attributes
249
- } = props;
250
- const {
251
- borderColor
252
- } = attributes;
253
- const colors = useSetting('color.palette') || EMPTY_ARRAY;
254
-
255
- if (!hasBorderSupport(name, 'color') || shouldSkipSerialization(name, BORDER_SUPPORT_KEY, 'color')) {
256
- return createElement(BlockListBlock, props);
257
- }
258
-
259
- const extraStyles = {
260
- borderColor: borderColor ? (_getColorObjectByAttr3 = getColorObjectByAttributeValues(colors, borderColor)) === null || _getColorObjectByAttr3 === void 0 ? void 0 : _getColorObjectByAttr3.color : undefined
261
- };
262
- let wrapperProps = props.wrapperProps;
263
- wrapperProps = { ...props.wrapperProps,
264
- style: { ...extraStyles,
265
- ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style)
266
- }
267
- };
268
- return createElement(BlockListBlock, _extends({}, props, {
269
- wrapperProps: wrapperProps
270
- }));
271
- });
272
- addFilter('blocks.registerBlockType', 'core/border/addAttributes', addAttributes);
273
- addFilter('blocks.getSaveContent.extraProps', 'core/border/addSaveProps', addSaveProps);
274
- addFilter('blocks.registerBlockType', 'core/border/addEditProps', addEditProps);
275
- addFilter('editor.BlockListBlock', 'core/border/with-border-color-palette-styles', withBorderColorPaletteStyles);
276
- //# sourceMappingURL=border-color.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-color.js"],"names":["classnames","addFilter","__","createHigherOrderComponent","useEffect","useState","ColorGradientSettingsDropdown","useMultipleOriginColorsAndGradients","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","useSetting","BORDER_SUPPORT_KEY","hasBorderSupport","removeBorderAttribute","cleanEmptyObject","shouldSkipSerialization","EMPTY_ARRAY","BorderColorEdit","props","attributes","borderColor","style","setAttributes","colorGradientSettings","availableColors","colors","reduce","origin","concat","color","customBorderColor","border","colorValue","setColorValue","onChangeColor","value","colorObject","newStyle","slug","undefined","newNamedColor","settings","label","onColorChange","clearable","hasBorderColorValue","resetBorderColor","addAttributes","type","addSaveProps","blockType","borderColorClass","newClassName","className","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","name","extraStyles","wrapperProps"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AAEA;AACA;AACA;;AACA,OAAOC,6BAAP,MAA0C,yCAA1C;AACA,OAAOC,mCAAP,MAAgD,yEAAhD;AACA,SACCC,iBADD,EAECC,0BAFD,EAGCC,+BAHD,QAIO,sBAJP;AAKA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SACCC,kBADD,EAECC,gBAFD,EAGCC,qBAHD,QAIO,UAJP;AAKA,SAASC,gBAAT,EAA2BC,uBAA3B,QAA0D,SAA1D,C,CAEA;AACA;;AACA,MAAMC,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,WAAF;AAAeC,MAAAA;AAAf,KADP;AAELC,IAAAA;AAFK,MAGFJ,KAHJ;AAIA,QAAMK,qBAAqB,GAAGjB,mCAAmC,EAAjE;AACA,QAAMkB,eAAe,GAAGD,qBAAqB,CAACE,MAAtB,CAA6BC,MAA7B,CACvB,CAAED,MAAF,EAAUE,MAAV,KAAsBF,MAAM,CAACG,MAAP,CAAeD,MAAM,CAACF,MAAtB,CADC,EAEvB,EAFuB,CAAxB;AAIA,QAAM;AAAEI,IAAAA,KAAK,EAAEC;AAAT,MAA+B,CAAAT,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CA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DAAG,oBAAoBxC,KAAvB;AAFM;AAFO,GAAf;AAQA,SAAO,cAAC,cAAD,eAAqBH,KAArB;AAA6B,IAAA,YAAY,EAAG2C;AAA5C,KAAP;AACA,CA7BoE,CAA/D;AAgCP7D,SAAS,CACR,0BADQ,EAER,2BAFQ,EAGR+C,aAHQ,CAAT;AAMA/C,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGRiD,YAHQ,CAAT;AAMAjD,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRsD,YAHQ,CAAT;AAMAtD,SAAS,CACR,uBADQ,EAER,8CAFQ,EAGRyD,4BAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ColorGradientSettingsDropdown from '../components/colors-gradients/dropdown';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport useSetting from '../components/use-setting';\nimport {\n\tBORDER_SUPPORT_KEY,\n\thasBorderSupport,\n\tremoveBorderAttribute,\n} from './border';\nimport { cleanEmptyObject, shouldSkipSerialization } from './utils';\n\n// Defining empty array here instead of inline avoids unnecessary re-renders of\n// color control.\nconst EMPTY_ARRAY = [];\n\n/**\n * Inspector control panel containing the border color related configuration.\n *\n * There is deliberate overlap between the colors and borders block supports\n * relating to border color. It can be argued the border color controls could\n * be included within either, or both, the colors and borders panels in the\n * inspector controls. If they share the same block attributes it should not\n * matter.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border color edit element.\n */\nexport function BorderColorEdit( props ) {\n\tconst {\n\t\tattributes: { borderColor, style },\n\t\tsetAttributes,\n\t} = props;\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\tconst availableColors = colorGradientSettings.colors.reduce(\n\t\t( colors, origin ) => colors.concat( origin.colors ),\n\t\t[]\n\t);\n\tconst { color: customBorderColor } = style?.border || {};\n\tconst [ colorValue, setColorValue ] = useState(\n\t\t() =>\n\t\t\tgetColorObjectByAttributeValues(\n\t\t\t\tavailableColors,\n\t\t\t\tborderColor,\n\t\t\t\tcustomBorderColor\n\t\t\t)?.color\n\t);\n\n\t// Detect changes in the color attributes and update the colorValue to keep the\n\t// UI in sync. This is necessary for situations when border controls interact with\n\t// each other: eg, setting the border width to zero causes the color and style\n\t// selections to be cleared.\n\tuseEffect( () => {\n\t\tsetColorValue(\n\t\t\tgetColorObjectByAttributeValues(\n\t\t\t\tavailableColors,\n\t\t\t\tborderColor,\n\t\t\t\tcustomBorderColor\n\t\t\t)?.color\n\t\t);\n\t}, [ borderColor, customBorderColor, availableColors ] );\n\n\tconst onChangeColor = ( value ) => {\n\t\tsetColorValue( value );\n\n\t\tconst colorObject = getColorObjectByColorValue(\n\t\t\tavailableColors,\n\t\t\tvalue\n\t\t);\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tcolor: colorObject?.slug ? undefined : value,\n\t\t\t},\n\t\t};\n\n\t\t// If empty slug, ensure undefined to remove attribute.\n\t\tconst newNamedColor = colorObject?.slug ? colorObject.slug : undefined;\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\tborderColor: newNamedColor,\n\t\t} );\n\t};\n\n\tconst settings = [\n\t\t{\n\t\t\tlabel: __( 'Color' ),\n\t\t\tonColorChange: onChangeColor,\n\t\t\tcolorValue,\n\t\t\tclearable: false,\n\t\t},\n\t];\n\treturn (\n\t\t<ColorGradientSettingsDropdown\n\t\t\tsettings={ settings }\n\t\t\tdisableCustomColors\n\t\t\tdisableCustomGradients\n\t\t\t__experimentalHasMultipleOrigins\n\t\t\t__experimentalIsRenderedInSidebar\n\t\t\tenableAlpha\n\t\t\t{ ...colorGradientSettings }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if there is a current value in the border color block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a border color value set.\n */\nexport function hasBorderColorValue( props ) {\n\tconst {\n\t\tattributes: { borderColor, style },\n\t} = props;\n\n\treturn !! borderColor || !! style?.border?.color;\n}\n\n/**\n * Resets the border color block support attributes. This can be used when\n * disabling the border color support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetBorderColor( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tborderColor: undefined,\n\t\tstyle: removeBorderAttribute( style, 'color' ),\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\tconst newClassName = classnames( props.className, {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor } = attributes;\n\t\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst extraStyles = {\n\t\t\tborderColor: borderColor\n\t\t\t\t? getColorObjectByAttributeValues( colors, borderColor )?.color\n\t\t\t\t: undefined,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
@@ -1,78 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * Internal dependencies
5
- */
6
- import BorderStyleControl from '../components/border-style-control';
7
- import { cleanEmptyObject } from './utils';
8
- import { removeBorderAttribute } from './border';
9
- /**
10
- * Inspector control for configuring border style property.
11
- *
12
- * @param {Object} props Block properties.
13
- *
14
- * @return {WPElement} Border style edit element.
15
- */
16
-
17
- export const BorderStyleEdit = props => {
18
- var _style$border;
19
-
20
- const {
21
- attributes: {
22
- style
23
- },
24
- setAttributes
25
- } = props;
26
-
27
- const onChange = newBorderStyle => {
28
- const newStyleAttributes = { ...style,
29
- border: { ...(style === null || style === void 0 ? void 0 : style.border),
30
- style: newBorderStyle
31
- }
32
- };
33
- setAttributes({
34
- style: cleanEmptyObject(newStyleAttributes)
35
- });
36
- };
37
-
38
- return createElement(BorderStyleControl, {
39
- value: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.style,
40
- onChange: onChange
41
- });
42
- };
43
- /**
44
- * Checks if there is a current value in the border style block support
45
- * attributes.
46
- *
47
- * @param {Object} props Block props.
48
- * @return {boolean} Whether or not the block has a border style value set.
49
- */
50
-
51
- export function hasBorderStyleValue(props) {
52
- var _props$attributes$sty, _props$attributes$sty2;
53
-
54
- return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.border) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.style);
55
- }
56
- /**
57
- * Resets the border style block support attribute. This can be used when
58
- * disabling the border style support control for a block via a progressive
59
- * discovery panel.
60
- *
61
- * @param {Object} props Block props.
62
- * @param {Object} props.attributes Block's attributes.
63
- * @param {Object} props.setAttributes Function to set block's attributes.
64
- */
65
-
66
- export function resetBorderStyle(_ref) {
67
- let {
68
- attributes = {},
69
- setAttributes
70
- } = _ref;
71
- const {
72
- style
73
- } = attributes;
74
- setAttributes({
75
- style: removeBorderAttribute(style, 'style')
76
- });
77
- }
78
- //# sourceMappingURL=border-style.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-style.js"],"names":["BorderStyleControl","cleanEmptyObject","removeBorderAttribute","BorderStyleEdit","props","attributes","style","setAttributes","onChange","newBorderStyle","newStyleAttributes","border","hasBorderStyleValue","resetBorderStyle"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,kBAAP,MAA+B,oCAA/B;AACA,SAASC,gBAAT,QAAiC,SAAjC;AACA,SAASC,qBAAT,QAAsC,UAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,eAAe,GAAKC,KAAF,IAAa;AAAA;;AAC3C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,QAAMI,QAAQ,GAAKC,cAAF,IAAsB;AACtC,UAAMC,kBAAkB,GAAG,EAC1B,GAAGJ,KADuB;AAE1BK,MAAAA,MAAM,EAAE,EACP,IAAGL,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEK,MAAV,CADO;AAEPL,QAAAA,KAAK,EAAEG;AAFA;AAFkB,KAA3B;AAQAF,IAAAA,aAAa,CAAE;AAAED,MAAAA,KAAK,EAAEL,gBAAgB,CAAES,kBAAF;AAAzB,KAAF,CAAb;AACA,GAVD;;AAYA,SACC,cAAC,kBAAD;AACC,IAAA,KAAK,EAAGJ,KAAH,aAAGA,KAAH,wCAAGA,KAAK,CAAEK,MAAV,kDAAG,cAAeL,KADxB;AAEC,IAAA,QAAQ,EAAGE;AAFZ,IADD;AAMA,CAxBM;AA0BP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,mBAAT,CAA8BR,KAA9B,EAAsC;AAAA;;AAC5C,SAAO,CAAC,2BAAEA,KAAK,CAACC,UAAN,CAAiBC,KAAnB,4EAAE,sBAAwBK,MAA1B,mDAAE,uBAAgCL,KAAlC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASO,gBAAT,OAAgE;AAAA,MAArC;AAAER,IAAAA,UAAU,GAAG,EAAf;AAAmBE,IAAAA;AAAnB,GAAqC;AACtE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AACAE,EAAAA,aAAa,CAAE;AAAED,IAAAA,KAAK,EAAEJ,qBAAqB,CAAEI,KAAF,EAAS,OAAT;AAA9B,GAAF,CAAb;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport BorderStyleControl from '../components/border-style-control';\nimport { cleanEmptyObject } from './utils';\nimport { removeBorderAttribute } from './border';\n\n/**\n * Inspector control for configuring border style property.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border style edit element.\n */\nexport const BorderStyleEdit = ( props ) => {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst onChange = ( newBorderStyle ) => {\n\t\tconst newStyleAttributes = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tstyle: newBorderStyle,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( { style: cleanEmptyObject( newStyleAttributes ) } );\n\t};\n\n\treturn (\n\t\t<BorderStyleControl\n\t\t\tvalue={ style?.border?.style }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n};\n\n/**\n * Checks if there is a current value in the border style block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a border style value set.\n */\nexport function hasBorderStyleValue( props ) {\n\treturn !! props.attributes.style?.border?.style;\n}\n\n/**\n * Resets the border style block support attribute. This can be used when\n * disabling the border style support control for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetBorderStyle( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\tsetAttributes( { style: removeBorderAttribute( style, 'style' ) } );\n}\n"]}