@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
@@ -11,11 +11,9 @@ import classnames from 'classnames';
11
11
 
12
12
  import { useState, useRef, useEffect } from '@wordpress/element';
13
13
  import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
14
- import { Popover } from '@wordpress/components';
15
14
  import { useDispatch, useSelect } from '@wordpress/data';
16
15
  import { useShortcut } from '@wordpress/keyboard-shortcuts';
17
16
  import { useViewportMatch } from '@wordpress/compose';
18
- import { getScrollContainer } from '@wordpress/dom';
19
17
  /**
20
18
  * Internal dependencies
21
19
  */
@@ -24,8 +22,7 @@ import BlockSelectionButton from './block-selection-button';
24
22
  import BlockContextualToolbar from './block-contextual-toolbar';
25
23
  import Inserter from '../inserter';
26
24
  import { store as blockEditorStore } from '../../store';
27
- import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
28
- import { usePopoverScroll } from './use-popover-scroll';
25
+ import BlockPopover from '../block-popover';
29
26
 
30
27
  function selector(select) {
31
28
  const {
@@ -33,7 +30,6 @@ function selector(select) {
33
30
  isMultiSelecting,
34
31
  hasMultiSelection,
35
32
  isTyping,
36
- isCaretWithinFormattedText,
37
33
  getSettings,
38
34
  getLastMultiSelectedBlockClientId
39
35
  } = select(blockEditorStore);
@@ -41,18 +37,15 @@ function selector(select) {
41
37
  isNavigationMode: isNavigationMode(),
42
38
  isMultiSelecting: isMultiSelecting(),
43
39
  isTyping: isTyping(),
44
- isCaretWithinFormattedText: isCaretWithinFormattedText(),
45
- hasMultiSelection: hasMultiSelection(),
46
40
  hasFixedToolbar: getSettings().hasFixedToolbar,
47
- lastClientId: getLastMultiSelectedBlockClientId()
41
+ lastClientId: hasMultiSelection() ? getLastMultiSelectedBlockClientId() : null
48
42
  };
49
43
  }
50
44
 
51
- function BlockPopover(_ref) {
45
+ function SelectedBlockPopover(_ref) {
52
46
  let {
53
47
  clientId,
54
48
  rootClientId,
55
- isValid,
56
49
  isEmptyDefaultBlock,
57
50
  capturingClientId,
58
51
  __unstablePopoverSlot,
@@ -62,8 +55,6 @@ function BlockPopover(_ref) {
62
55
  isNavigationMode,
63
56
  isMultiSelecting,
64
57
  isTyping,
65
- isCaretWithinFormattedText,
66
- hasMultiSelection,
67
58
  hasFixedToolbar,
68
59
  lastClientId
69
60
  } = useSelect(selector, []);
@@ -83,108 +74,49 @@ function BlockPopover(_ref) {
83
74
  return order[insertionPoint.index] === clientId;
84
75
  }, [clientId]);
85
76
  const isLargeViewport = useViewportMatch('medium');
86
- const [isToolbarForced, setIsToolbarForced] = useState(false);
77
+ const isToolbarForced = useRef(false);
87
78
  const [isInserterShown, setIsInserterShown] = useState(false);
88
79
  const {
89
80
  stopTyping
90
- } = useDispatch(blockEditorStore); // Controls when the side inserter on empty lines should
91
- // be shown, including writing and selection modes.
92
-
93
- const showEmptyBlockSideInserter = !isTyping && !isNavigationMode && isEmptyDefaultBlock && isValid;
81
+ } = useDispatch(blockEditorStore);
82
+ const showEmptyBlockSideInserter = !isTyping && !isNavigationMode && isEmptyDefaultBlock;
94
83
  const shouldShowBreadcrumb = isNavigationMode;
95
- const shouldShowContextualToolbar = !isNavigationMode && !hasFixedToolbar && isLargeViewport && !showEmptyBlockSideInserter && !isMultiSelecting && (!isTyping || isCaretWithinFormattedText);
84
+ const shouldShowContextualToolbar = !isNavigationMode && !hasFixedToolbar && isLargeViewport && !isMultiSelecting && !showEmptyBlockSideInserter && !isTyping;
96
85
  const canFocusHiddenToolbar = !isNavigationMode && !shouldShowContextualToolbar && !hasFixedToolbar && !isEmptyDefaultBlock;
97
86
  useShortcut('core/block-editor/focus-toolbar', () => {
98
- setIsToolbarForced(true);
87
+ isToolbarForced.current = true;
99
88
  stopTyping(true);
100
89
  }, {
101
90
  isDisabled: !canFocusHiddenToolbar
102
91
  });
103
92
  useEffect(() => {
104
- if (!shouldShowContextualToolbar) {
105
- setIsToolbarForced(false);
106
- }
107
- }, [shouldShowContextualToolbar]); // Stores the active toolbar item index so the block toolbar can return focus
93
+ isToolbarForced.current = false;
94
+ }); // Stores the active toolbar item index so the block toolbar can return focus
108
95
  // to it when re-mounting.
109
96
 
110
97
  const initialToolbarItemIndexRef = useRef();
111
- const selectedElement = useBlockElement(clientId);
112
- const lastSelectedElement = useBlockElement(lastClientId);
113
- const capturingElement = useBlockElement(capturingClientId);
114
- const popoverScrollRef = usePopoverScroll(__unstableContentRef);
115
-
116
- if (!shouldShowBreadcrumb && !shouldShowContextualToolbar && !isToolbarForced && !showEmptyBlockSideInserter) {
117
- return null;
118
- }
119
98
 
120
- let node = selectedElement;
121
-
122
- if (!node) {
99
+ if (!shouldShowBreadcrumb && !shouldShowContextualToolbar) {
123
100
  return null;
124
101
  }
125
102
 
126
- if (capturingClientId) {
127
- node = capturingElement;
128
- }
129
-
130
- let anchorRef = node;
131
-
132
- if (hasMultiSelection) {
133
- // Wait to render the popover until the bottom reference is available
134
- // as well.
135
- if (!lastSelectedElement) {
136
- return null;
137
- }
138
-
139
- anchorRef = {
140
- top: node,
141
- bottom: lastSelectedElement
142
- };
143
- }
144
-
145
103
  function onFocus() {
146
104
  setIsInserterShown(true);
147
105
  }
148
106
 
149
107
  function onBlur() {
150
108
  setIsInserterShown(false);
151
- } // Position above the anchor, pop out towards the right, and position in the
152
- // left corner. For the side inserter, pop out towards the left, and
153
- // position in the right corner.
154
- // To do: refactor `Popover` to make this prop clearer.
155
-
109
+ }
156
110
 
157
- const popoverPosition = showEmptyBlockSideInserter ? 'top left right' : 'top right left';
158
- const {
159
- ownerDocument
160
- } = node;
161
- const stickyBoundaryElement = showEmptyBlockSideInserter ? undefined : // The sticky boundary element should be the boundary at which the
162
- // the block toolbar becomes sticky when the block scolls out of view.
163
- // In case of an iframe, this should be the iframe boundary, otherwise
164
- // the scroll container.
165
- ownerDocument.defaultView.frameElement || getScrollContainer(node) || ownerDocument.body;
166
- return createElement(Popover, {
167
- ref: popoverScrollRef,
168
- noArrow: true,
169
- animate: false,
170
- position: popoverPosition,
171
- focusOnMount: false,
172
- anchorRef: anchorRef,
111
+ return createElement(BlockPopover, {
112
+ clientId: capturingClientId || clientId,
113
+ bottomClientId: lastClientId,
173
114
  className: classnames('block-editor-block-list__block-popover', {
174
115
  'is-insertion-point-visible': isInsertionPointVisible
175
116
  }),
176
- __unstableStickyBoundaryElement: stickyBoundaryElement // Render in the old slot if needed for backward compatibility,
177
- // otherwise render in place (not in the the default popover slot).
178
- ,
179
- __unstableSlotName: __unstablePopoverSlot || null,
180
- __unstableBoundaryParent: true // Observe movement for block animations (especially horizontal).
181
- ,
182
- __unstableObserveElement: node,
183
- shouldAnchorIncludePadding: true // Used to safeguard sticky position behavior against cases where it would permanently
184
- // obscure specific sections of a block.
185
- ,
186
- __unstableEditorCanvasWrapper: __unstableContentRef === null || __unstableContentRef === void 0 ? void 0 : __unstableContentRef.current
187
- }, (shouldShowContextualToolbar || isToolbarForced) && createElement("div", {
117
+ __unstablePopoverSlot: __unstablePopoverSlot,
118
+ __unstableContentRef: __unstableContentRef
119
+ }, shouldShowContextualToolbar && createElement("div", {
188
120
  onFocus: onFocus,
189
121
  onBlur: onBlur // While ideally it would be enough to capture the
190
122
  // bubbling focus event from the Inserter, due to the
@@ -201,10 +133,10 @@ function BlockPopover(_ref) {
201
133
  clientId: clientId,
202
134
  rootClientId: rootClientId,
203
135
  __experimentalIsQuick: true
204
- })), (shouldShowContextualToolbar || isToolbarForced) && createElement(BlockContextualToolbar // If the toolbar is being shown because of being forced
136
+ })), shouldShowContextualToolbar && createElement(BlockContextualToolbar // If the toolbar is being shown because of being forced
205
137
  // it should focus the toolbar right after the mount.
206
138
  , {
207
- focusOnMount: isToolbarForced,
139
+ focusOnMount: isToolbarForced.current,
208
140
  __experimentalInitialIndex: initialToolbarItemIndexRef.current,
209
141
  __experimentalOnIndexChange: index => {
210
142
  initialToolbarItemIndexRef.current = index;
@@ -214,16 +146,8 @@ function BlockPopover(_ref) {
214
146
  key: clientId
215
147
  }), shouldShowBreadcrumb && createElement(BlockSelectionButton, {
216
148
  clientId: clientId,
217
- rootClientId: rootClientId,
218
- blockElement: node
219
- }), showEmptyBlockSideInserter && createElement("div", {
220
- className: "block-editor-block-list__empty-block-inserter"
221
- }, createElement(Inserter, {
222
- position: "bottom right",
223
- rootClientId: rootClientId,
224
- clientId: clientId,
225
- __experimentalIsQuick: true
226
- })));
149
+ rootClientId: rootClientId
150
+ }));
227
151
  }
228
152
 
229
153
  function wrapperSelector(select) {
@@ -243,8 +167,7 @@ function wrapperSelector(select) {
243
167
 
244
168
  const {
245
169
  name,
246
- attributes = {},
247
- isValid
170
+ attributes = {}
248
171
  } = getBlock(clientId) || {};
249
172
  const blockParentsClientIds = getBlockParents(clientId); // Get Block List Settings for all ancestors of the current Block clientId.
250
173
 
@@ -260,7 +183,6 @@ function wrapperSelector(select) {
260
183
  clientId,
261
184
  rootClientId: getBlockRootClientId(clientId),
262
185
  name,
263
- isValid,
264
186
  isEmptyDefaultBlock: name && isUnmodifiedDefaultBlock({
265
187
  name,
266
188
  attributes
@@ -284,7 +206,6 @@ export default function WrappedBlockPopover(_ref2) {
284
206
  clientId,
285
207
  rootClientId,
286
208
  name,
287
- isValid,
288
209
  isEmptyDefaultBlock,
289
210
  capturingClientId
290
211
  } = selected;
@@ -293,14 +214,13 @@ export default function WrappedBlockPopover(_ref2) {
293
214
  return null;
294
215
  }
295
216
 
296
- return createElement(BlockPopover, {
217
+ return createElement(SelectedBlockPopover, {
297
218
  clientId: clientId,
298
219
  rootClientId: rootClientId,
299
- isValid: isValid,
300
220
  isEmptyDefaultBlock: isEmptyDefaultBlock,
301
221
  capturingClientId: capturingClientId,
302
222
  __unstablePopoverSlot: __unstablePopoverSlot,
303
223
  __unstableContentRef: __unstableContentRef
304
224
  });
305
225
  }
306
- //# sourceMappingURL=block-popover.js.map
226
+ //# sourceMappingURL=selected-block-popover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-popover.js"],"names":["find","classnames","useState","useRef","useEffect","isUnmodifiedDefaultBlock","useDispatch","useSelect","useShortcut","useViewportMatch","BlockSelectionButton","BlockContextualToolbar","Inserter","store","blockEditorStore","BlockPopover","selector","select","isNavigationMode","isMultiSelecting","hasMultiSelection","isTyping","getSettings","getLastMultiSelectedBlockClientId","hasFixedToolbar","lastClientId","SelectedBlockPopover","clientId","rootClientId","isEmptyDefaultBlock","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isLargeViewport","isToolbarForced","isInserterShown","setIsInserterShown","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","shouldShowContextualToolbar","canFocusHiddenToolbar","current","isDisabled","initialToolbarItemIndexRef","onFocus","onBlur","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,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,WAAT,QAA4B,+BAA5B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,sBAAP,MAAmC,4BAAnC;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,YAAP,MAAyB,kBAAzB;;AAEA,SAASC,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,QAAM;AACLC,IAAAA,gBADK;AAELC,IAAAA,gBAFK;AAG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C,YAFhB;AAGC,IAAA,mBAAmB,EAAGC,mBAHvB;AAIC,IAAA,iBAAiB,EAAGC,iBAJrB;AAKC,IAAA,qBAAqB,EAAGC,qBALzB;AAMC,IAAA,oBAAoB,EAAGC;AANxB,IADD;AAUA","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 { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\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 BlockPopover from '../block-popover';\n\nfunction selector( select ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\thasMultiSelection,\n\t\tisTyping,\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\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tlastClientId: hasMultiSelection()\n\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t: null,\n\t};\n}\n\nfunction SelectedBlockPopover( {\n\tclientId,\n\trootClientId,\n\tisEmptyDefaultBlock,\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\tisTyping,\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 = useRef( false );\n\tconst [ isInserterShown, setIsInserterShown ] = useState( false );\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && ! isNavigationMode && isEmptyDefaultBlock;\n\tconst shouldShowBreadcrumb = isNavigationMode;\n\tconst shouldShowContextualToolbar =\n\t\t! isNavigationMode &&\n\t\t! hasFixedToolbar &&\n\t\tisLargeViewport &&\n\t\t! isMultiSelecting &&\n\t\t! showEmptyBlockSideInserter &&\n\t\t! isTyping;\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\tisToolbarForced.current = 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\tisToolbarForced.current = false;\n\t} );\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\tif ( ! shouldShowBreadcrumb && ! shouldShowContextualToolbar ) {\n\t\treturn null;\n\t}\n\n\tfunction onFocus() {\n\t\tsetIsInserterShown( true );\n\t}\n\n\tfunction onBlur() {\n\t\tsetIsInserterShown( false );\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ capturingClientId || clientId }\n\t\t\tbottomClientId={ lastClientId }\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__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t>\n\t\t\t{ shouldShowContextualToolbar && (\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 && (\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.current }\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/>\n\t\t\t) }\n\t\t</BlockPopover>\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 = {} } = 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\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\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SelectedBlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\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"]}
@@ -53,12 +53,18 @@ export function useClipboardHandler() {
53
53
  getBlocksByClientId,
54
54
  getSelectedBlockClientIds,
55
55
  hasMultiSelection,
56
- getSettings
56
+ getSettings,
57
+ __unstableIsFullySelected,
58
+ __unstableIsSelectionCollapsed,
59
+ __unstableIsSelectionMergeable,
60
+ __unstableGetSelectedBlocksWithPartialSelection
57
61
  } = useSelect(blockEditorStore);
58
62
  const {
59
63
  flashBlock,
60
64
  removeBlocks,
61
- replaceBlocks
65
+ replaceBlocks,
66
+ __unstableDeleteSelection,
67
+ __unstableExpandSelection
62
68
  } = useDispatch(blockEditorStore);
63
69
  const notifyCopy = useNotifyCopy();
64
70
  return useRefEffect(node => {
@@ -93,20 +99,49 @@ export function useClipboardHandler() {
93
99
  const eventDefaultPrevented = event.defaultPrevented;
94
100
  event.preventDefault();
95
101
 
102
+ const isSelectionMergeable = __unstableIsSelectionMergeable();
103
+
104
+ const shouldHandleWholeBlocks = __unstableIsSelectionCollapsed() || __unstableIsFullySelected();
105
+
106
+ const expandSelectionIsNeeded = !shouldHandleWholeBlocks && !isSelectionMergeable;
107
+
96
108
  if (event.type === 'copy' || event.type === 'cut') {
97
109
  if (selectedBlockClientIds.length === 1) {
98
110
  flashBlock(selectedBlockClientIds[0]);
99
- }
111
+ } // If we have a partial selection that is not mergeable, just
112
+ // expand the selection to the whole blocks.
113
+
100
114
 
101
- notifyCopy(event.type, selectedBlockClientIds);
102
- const blocks = getBlocksByClientId(selectedBlockClientIds);
103
- const serialized = serialize(blocks);
104
- event.clipboardData.setData('text/plain', serialized);
105
- event.clipboardData.setData('text/html', serialized);
115
+ if (expandSelectionIsNeeded) {
116
+ __unstableExpandSelection();
117
+ } else {
118
+ notifyCopy(event.type, selectedBlockClientIds);
119
+ let blocks; // Check if we have partial selection.
120
+
121
+ if (shouldHandleWholeBlocks) {
122
+ blocks = getBlocksByClientId(selectedBlockClientIds);
123
+ } else {
124
+ const [head, tail] = __unstableGetSelectedBlocksWithPartialSelection();
125
+
126
+ const inBetweenBlocks = getBlocksByClientId(selectedBlockClientIds.slice(1, selectedBlockClientIds.length - 1));
127
+ blocks = [head, ...inBetweenBlocks, tail];
128
+ }
129
+
130
+ const serialized = serialize(blocks);
131
+ event.clipboardData.setData('text/plain', serialized);
132
+ event.clipboardData.setData('text/html', serialized);
133
+ }
106
134
  }
107
135
 
108
136
  if (event.type === 'cut') {
109
- removeBlocks(selectedBlockClientIds);
137
+ // We need to also check if at the start we needed to
138
+ // expand the selection, as in this point we might have
139
+ // programmatically fully selected the blocks above.
140
+ if (shouldHandleWholeBlocks && !expandSelectionIsNeeded) {
141
+ removeBlocks(selectedBlockClientIds);
142
+ } else {
143
+ __unstableDeleteSelection();
144
+ }
110
145
  } else if (event.type === 'paste') {
111
146
  if (eventDefaultPrevented) {
112
147
  // This was likely already handled in rich-text/use-paste-handler.js.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/copy-handler/index.js"],"names":["useCallback","serialize","pasteHandler","store","blocksStore","documentHasSelection","documentHasUncollapsedSelection","useDispatch","useSelect","__","_n","sprintf","noticesStore","useRefEffect","getPasteEventData","blockEditorStore","useNotifyCopy","getBlockName","getBlockType","createSuccessNotice","eventType","selectedBlockClientIds","notice","length","clientId","title","type","useClipboardHandler","getBlocksByClientId","getSelectedBlockClientIds","hasMultiSelection","getSettings","flashBlock","removeBlocks","replaceBlocks","notifyCopy","node","handler","event","target","ownerDocument","hasSelection","contains","activeElement","eventDefaultPrevented","defaultPrevented","preventDefault","blocks","serialized","clipboardData","setData","__experimentalCanUserUseUnfilteredHTML","canUserUseUnfilteredHTML","plainText","html","HTML","mode","addEventListener","removeEventListener","CopyHandler","children"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,oBAA5B;AACA,SACCC,SADD,EAECC,YAFD,EAGCC,KAAK,IAAIC,WAHV,QAIO,mBAJP;AAKA,SACCC,oBADD,EAECC,+BAFD,QAGO,gBAHP;AAIA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASR,KAAK,IAAIS,YAAlB,QAAsC,oBAAtC;AACA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,SAASX,KAAK,IAAIY,gBAAlB,QAA0C,aAA1C;AAEA,OAAO,SAASC,aAAT,GAAyB;AAC/B,QAAM;AAAEC,IAAAA;AAAF,MAAmBT,SAAS,CAAEO,gBAAF,CAAlC;AACA,QAAM;AAAEG,IAAAA;AAAF,MAAmBV,SAAS,CAAEJ,WAAF,CAAlC;AACA,QAAM;AAAEe,IAAAA;AAAF,MAA0BZ,WAAW,CAAEK,YAAF,CAA3C;AAEA,SAAOZ,WAAW,CAAE,CAAEoB,SAAF,EAAaC,sBAAb,KAAyC;AAC5D,QAAIC,MAAM,GAAG,EAAb;;AACA,QAAKD,sBAAsB,CAACE,MAAvB,KAAkC,CAAvC,EAA2C;AAAA;;AAC1C,YAAMC,QAAQ,GAAGH,sBAAsB,CAAE,CAAF,CAAvC;AACA,YAAMI,KAAK,oBAAGP,YAAY,CAAED,YAAY,CAAEO,QAAF,CAAd,CAAf,kDAAG,cAA0CC,KAAxD;AACAH,MAAAA,MAAM,GACLF,SAAS,KAAK,MAAd,GACGT,OAAO,E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*/\nimport { useCallback } from '@wordpress/element';\nimport {\n\tserialize,\n\tpasteHandler,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport {\n\tdocumentHasSelection,\n\tdocumentHasUncollapsedSelection,\n} from '@wordpress/dom';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getPasteEventData } from '../../utils/pasting';\nimport { store as blockEditorStore } from '../../store';\n\nexport function useNotifyCopy() {\n\tconst { getBlockName } = useSelect( blockEditorStore );\n\tconst { getBlockType } = useSelect( blocksStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\treturn useCallback( ( eventType, selectedBlockClientIds ) => {\n\t\tlet notice = '';\n\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\tconst clientId = selectedBlockClientIds[ 0 ];\n\t\t\tconst title = getBlockType( getBlockName( clientId ) )?.title;\n\t\t\tnotice =\n\t\t\t\teventType === 'copy'\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// Translators: Name of the block being copied, e.g. \"Paragraph\".\n\t\t\t\t\t\t\t__( 'Copied \"%s\" to clipboard.' ),\n\t\t\t\t\t\t\ttitle\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// Translators: Name of the block being cut, e.g. \"Paragraph\".\n\t\t\t\t\t\t\t__( 'Moved \"%s\" to clipboard.' ),\n\t\t\t\t\t\t\ttitle\n\t\t\t\t\t );\n\t\t} else {\n\t\t\tnotice =\n\t\t\t\teventType === 'copy'\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// Translators: %d: Number of blocks being copied.\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'Copied %d block to clipboard.',\n\t\t\t\t\t\t\t\t'Copied %d blocks to clipboard.',\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// Translators: %d: Number of blocks being cut.\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'Moved %d block to clipboard.',\n\t\t\t\t\t\t\t\t'Moved %d blocks to clipboard.',\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t );\n\t\t}\n\t\tcreateSuccessNotice( notice, {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t}, [] );\n}\n\nexport function useClipboardHandler() {\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSettings,\n\t} = useSelect( blockEditorStore );\n\tconst { flashBlock, removeBlocks, replaceBlocks } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst notifyCopy = useNotifyCopy();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction handler( event ) {\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\n\t\t\tif ( selectedBlockClientIds.length === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Always handle multiple selected blocks.\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tconst { target } = event;\n\t\t\t\tconst { ownerDocument } = target;\n\t\t\t\t// If copying, only consider actual text selection as selection.\n\t\t\t\t// Otherwise, any focus on an input field is considered.\n\t\t\t\tconst hasSelection =\n\t\t\t\t\tevent.type === 'copy' || event.type === 'cut'\n\t\t\t\t\t\t? documentHasUncollapsedSelection( ownerDocument )\n\t\t\t\t\t\t: documentHasSelection( ownerDocument );\n\n\t\t\t\t// Let native copy behaviour take over in input fields.\n\t\t\t\tif ( hasSelection ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! node.contains( event.target.ownerDocument.activeElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst eventDefaultPrevented = event.defaultPrevented;\n\t\t\tevent.preventDefault();\n\n\t\t\tif ( event.type === 'copy' || event.type === 'cut' ) {\n\t\t\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\t\t\tflashBlock( selectedBlockClientIds[ 0 ] );\n\t\t\t\t}\n\t\t\t\tnotifyCopy( event.type, selectedBlockClientIds );\n\t\t\t\tconst blocks = getBlocksByClientId( selectedBlockClientIds );\n\t\t\t\tconst serialized = serialize( blocks );\n\n\t\t\t\tevent.clipboardData.setData( 'text/plain', serialized );\n\t\t\t\tevent.clipboardData.setData( 'text/html', serialized );\n\t\t\t}\n\n\t\t\tif ( event.type === 'cut' ) {\n\t\t\t\tremoveBlocks( selectedBlockClientIds );\n\t\t\t} else if ( event.type === 'paste' ) {\n\t\t\t\tif ( eventDefaultPrevented ) {\n\t\t\t\t\t// This was likely already handled in rich-text/use-paste-handler.js.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst {\n\t\t\t\t\t__experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML,\n\t\t\t\t} = getSettings();\n\t\t\t\tconst { plainText, html } = getPasteEventData( event );\n\t\t\t\tconst blocks = pasteHandler( {\n\t\t\t\t\tHTML: html,\n\t\t\t\t\tplainText,\n\t\t\t\t\tmode: 'BLOCKS',\n\t\t\t\t\tcanUserUseUnfilteredHTML,\n\t\t\t\t} );\n\n\t\t\t\treplaceBlocks(\n\t\t\t\t\tselectedBlockClientIds,\n\t\t\t\t\tblocks,\n\t\t\t\t\tblocks.length - 1,\n\t\t\t\t\t-1\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tnode.ownerDocument.addEventListener( 'copy', handler );\n\t\tnode.ownerDocument.addEventListener( 'cut', handler );\n\t\tnode.ownerDocument.addEventListener( 'paste', handler );\n\n\t\treturn () => {\n\t\t\tnode.ownerDocument.removeEventListener( 'copy', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'cut', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'paste', handler );\n\t\t};\n\t}, [] );\n}\n\nfunction CopyHandler( { children } ) {\n\treturn <div ref={ useClipboardHandler() }>{ children }</div>;\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/copy-handler/README.md\n */\nexport default CopyHandler;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/copy-handler/index.js"],"names":["useCallback","serialize","pasteHandler","store","blocksStore","documentHasSelection","documentHasUncollapsedSelection","useDispatch","useSelect","__","_n","sprintf","noticesStore","useRefEffect","getPasteEventData","blockEditorStore","useNotifyCopy","getBlockName","getBlockType","createSuccessNotice","eventType","selectedBlockClientIds","notice","length","clientId","title","type","useClipboardHandler","getBlocksByClientId","getSelectedBlockClientIds","hasMultiSelection","getSettings","__unstableIsFullySelected","__unstableIsSelectionCollapsed","__unstableIsSelectionMergeable","__unstableGetSelectedBlocksWithPartialSelection","flashBlock","removeBlocks","replaceBlocks","__unstableDeleteSelection","__unstableExpandSelection","notifyCopy","node","handler","event","target","ownerDocument","hasSelection","contains","activeElement","eventDefaultPrevented","defaultPrevented","preventDefault","isSelectionMergeable","shouldHandleWholeBlocks","expandSelectionIsNeeded","blocks","head","tail","inBetweenBlocks","slice","serialized","clipboardData","setData","__experimentalCanUserUseUnfilteredHTML","canUserUseUnfilteredHTML","plainText","html","HTML","mode","addEventListener","removeEventListener","CopyHandler","children"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,oBAA5B;AACA,SACCC,SADD,EAECC,YAFD,EAGCC,KAAK,IAAIC,WAHV,QAIO,mBAJP;AAKA,SACCC,oBADD,EAECC,+BAFD,QAGO,gBAHP;AAIA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAAS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ACI,aAAL,CAAmByB,mBAAnB,CAAwC,KAAxC,EAA+C5B,OAA/C;AACAD,MAAAA,IAAI,CAACI,aAAL,CAAmByB,mBAAnB,CAAwC,OAAxC,EAAiD5B,OAAjD;AACA,KAJD;AAKA,GAlHkB,EAkHhB,EAlHgB,CAAnB;AAmHA;;AAED,SAAS6B,WAAT,OAAqC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACpC,SAAO;AAAK,IAAA,GAAG,EAAG9C,mBAAmB;AAA9B,KAAqC8C,QAArC,CAAP;AACA;AAED;AACA;AACA;;;AACA,eAAeD,WAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tserialize,\n\tpasteHandler,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport {\n\tdocumentHasSelection,\n\tdocumentHasUncollapsedSelection,\n} from '@wordpress/dom';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getPasteEventData } from '../../utils/pasting';\nimport { store as blockEditorStore } from '../../store';\n\nexport function useNotifyCopy() {\n\tconst { getBlockName } = useSelect( blockEditorStore );\n\tconst { getBlockType } = useSelect( blocksStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\treturn useCallback( ( eventType, selectedBlockClientIds ) => {\n\t\tlet notice = '';\n\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\tconst clientId = selectedBlockClientIds[ 0 ];\n\t\t\tconst title = getBlockType( getBlockName( clientId ) )?.title;\n\t\t\tnotice =\n\t\t\t\teventType === 'copy'\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// Translators: Name of the block being copied, e.g. \"Paragraph\".\n\t\t\t\t\t\t\t__( 'Copied \"%s\" to clipboard.' ),\n\t\t\t\t\t\t\ttitle\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// Translators: Name of the block being cut, e.g. \"Paragraph\".\n\t\t\t\t\t\t\t__( 'Moved \"%s\" to clipboard.' ),\n\t\t\t\t\t\t\ttitle\n\t\t\t\t\t );\n\t\t} else {\n\t\t\tnotice =\n\t\t\t\teventType === 'copy'\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// Translators: %d: Number of blocks being copied.\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'Copied %d block to clipboard.',\n\t\t\t\t\t\t\t\t'Copied %d blocks to clipboard.',\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// Translators: %d: Number of blocks being cut.\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'Moved %d block to clipboard.',\n\t\t\t\t\t\t\t\t'Moved %d blocks to clipboard.',\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tselectedBlockClientIds.length\n\t\t\t\t\t );\n\t\t}\n\t\tcreateSuccessNotice( notice, {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t}, [] );\n}\n\nexport function useClipboardHandler() {\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSettings,\n\t\t__unstableIsFullySelected,\n\t\t__unstableIsSelectionCollapsed,\n\t\t__unstableIsSelectionMergeable,\n\t\t__unstableGetSelectedBlocksWithPartialSelection,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tflashBlock,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t} = useDispatch( blockEditorStore );\n\tconst notifyCopy = useNotifyCopy();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction handler( event ) {\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\n\t\t\tif ( selectedBlockClientIds.length === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Always handle multiple selected blocks.\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tconst { target } = event;\n\t\t\t\tconst { ownerDocument } = target;\n\t\t\t\t// If copying, only consider actual text selection as selection.\n\t\t\t\t// Otherwise, any focus on an input field is considered.\n\t\t\t\tconst hasSelection =\n\t\t\t\t\tevent.type === 'copy' || event.type === 'cut'\n\t\t\t\t\t\t? documentHasUncollapsedSelection( ownerDocument )\n\t\t\t\t\t\t: documentHasSelection( ownerDocument );\n\n\t\t\t\t// Let native copy behaviour take over in input fields.\n\t\t\t\tif ( hasSelection ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! node.contains( event.target.ownerDocument.activeElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst eventDefaultPrevented = event.defaultPrevented;\n\t\t\tevent.preventDefault();\n\n\t\t\tconst isSelectionMergeable = __unstableIsSelectionMergeable();\n\t\t\tconst shouldHandleWholeBlocks =\n\t\t\t\t__unstableIsSelectionCollapsed() || __unstableIsFullySelected();\n\t\t\tconst expandSelectionIsNeeded =\n\t\t\t\t! shouldHandleWholeBlocks && ! isSelectionMergeable;\n\t\t\tif ( event.type === 'copy' || event.type === 'cut' ) {\n\t\t\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\t\t\tflashBlock( selectedBlockClientIds[ 0 ] );\n\t\t\t\t}\n\t\t\t\t// If we have a partial selection that is not mergeable, just\n\t\t\t\t// expand the selection to the whole blocks.\n\t\t\t\tif ( expandSelectionIsNeeded ) {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t} else {\n\t\t\t\t\tnotifyCopy( event.type, selectedBlockClientIds );\n\t\t\t\t\tlet blocks;\n\t\t\t\t\t// Check if we have partial selection.\n\t\t\t\t\tif ( shouldHandleWholeBlocks ) {\n\t\t\t\t\t\tblocks = getBlocksByClientId( selectedBlockClientIds );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst [\n\t\t\t\t\t\t\thead,\n\t\t\t\t\t\t\ttail,\n\t\t\t\t\t\t] = __unstableGetSelectedBlocksWithPartialSelection();\n\t\t\t\t\t\tconst inBetweenBlocks = getBlocksByClientId(\n\t\t\t\t\t\t\tselectedBlockClientIds.slice(\n\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length - 1\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tblocks = [ head, ...inBetweenBlocks, tail ];\n\t\t\t\t\t}\n\t\t\t\t\tconst serialized = serialize( blocks );\n\n\t\t\t\t\tevent.clipboardData.setData( 'text/plain', serialized );\n\t\t\t\t\tevent.clipboardData.setData( 'text/html', serialized );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( event.type === 'cut' ) {\n\t\t\t\t// We need to also check if at the start we needed to\n\t\t\t\t// expand the selection, as in this point we might have\n\t\t\t\t// programmatically fully selected the blocks above.\n\t\t\t\tif ( shouldHandleWholeBlocks && ! expandSelectionIsNeeded ) {\n\t\t\t\t\tremoveBlocks( selectedBlockClientIds );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableDeleteSelection();\n\t\t\t\t}\n\t\t\t} else if ( event.type === 'paste' ) {\n\t\t\t\tif ( eventDefaultPrevented ) {\n\t\t\t\t\t// This was likely already handled in rich-text/use-paste-handler.js.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst {\n\t\t\t\t\t__experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML,\n\t\t\t\t} = getSettings();\n\t\t\t\tconst { plainText, html } = getPasteEventData( event );\n\t\t\t\tconst blocks = pasteHandler( {\n\t\t\t\t\tHTML: html,\n\t\t\t\t\tplainText,\n\t\t\t\t\tmode: 'BLOCKS',\n\t\t\t\t\tcanUserUseUnfilteredHTML,\n\t\t\t\t} );\n\n\t\t\t\treplaceBlocks(\n\t\t\t\t\tselectedBlockClientIds,\n\t\t\t\t\tblocks,\n\t\t\t\t\tblocks.length - 1,\n\t\t\t\t\t-1\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tnode.ownerDocument.addEventListener( 'copy', handler );\n\t\tnode.ownerDocument.addEventListener( 'cut', handler );\n\t\tnode.ownerDocument.addEventListener( 'paste', handler );\n\n\t\treturn () => {\n\t\t\tnode.ownerDocument.removeEventListener( 'copy', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'cut', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'paste', handler );\n\t\t};\n\t}, [] );\n}\n\nfunction CopyHandler( { children } ) {\n\treturn <div ref={ useClipboardHandler() }>{ children }</div>;\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/copy-handler/README.md\n */\nexport default CopyHandler;\n"]}
@@ -6,6 +6,7 @@ import { createElement } from "@wordpress/element";
6
6
  import { Dropdown, DuotonePicker, DuotoneSwatch, MenuGroup, ToolbarButton } from '@wordpress/components';
7
7
  import { __ } from '@wordpress/i18n';
8
8
  import { DOWN } from '@wordpress/keycodes';
9
+ import { Icon, filter } from '@wordpress/icons';
9
10
 
10
11
  function DuotoneControl(_ref) {
11
12
  let {
@@ -42,8 +43,10 @@ function DuotoneControl(_ref) {
42
43
  "aria-expanded": isOpen,
43
44
  onKeyDown: openOnArrowDown,
44
45
  label: __('Apply duotone filter'),
45
- icon: createElement(DuotoneSwatch, {
46
+ icon: value ? createElement(DuotoneSwatch, {
46
47
  values: value
48
+ }) : createElement(Icon, {
49
+ icon: filter
47
50
  })
48
51
  });
49
52
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/duotone-control/index.js"],"names":["Dropdown","DuotonePicker","DuotoneSwatch","MenuGroup","ToolbarButton","__","DOWN","DuotoneControl","colorPalette","duotonePalette","disableCustomColors","disableCustomDuotone","value","onChange","className","headerTitle","isAlternate","isOpen","onToggle","openOnArrowDown","event","keyCode","preventDefault"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,QADD,EAECC,aAFD,EAGCC,aAHD,EAICC,SAJD,EAKCC,aALD,QAMO,uBANP;AAOA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,IAAT,QAAqB,qBAArB;;AAEA,SAASC,cAAT,OAOI;AAAA,MAPqB;AACxBC,IAAAA,YADwB;AAExBC,IAAAA,cAFwB;AAGxBC,IAAAA,mBAHwB;AAIxBC,IAAAA,oBAJwB;AAKxBC,IAAAA,KALwB;AAMxBC,IAAAA;AANwB,GAOrB;AACH,SACC,cAAC,QAAD;AACC,IAAA,YAAY,EAAG;AACdC,MAAAA,SAAS,EAAE,uCADG;AAEdC,MAAAA,WAAW,EAAEV,EAAE,CAAE,SAAF,CAFD;AAGdW,MAAAA,WAAW,EAAE;AAHC,KADhB;AAMC,IAAA,YAAY,EAAG,SAA4B;AAAA,UAA1B;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAA0B;;AAC1C,YAAMC,eAAe,GAAKC,KAAF,IAAa;AACpC,YAAK,CAAEH,MAAF,IAAYG,KAAK,CAACC,OAAN,KAAkBf,IAAnC,EAA0C;AACzCc,UAAAA,KAAK,CAACE,cAAN;AACAJ,UAAAA,QAAQ;AACR;AACD,OALD;;AAMA,aACC,cAAC,aAAD;AACC,QAAA,WAAW,MADZ;AAEC,QAAA,OAAO,EAAGA,QAFX;AAGC,yBAAc,MAHf;AAIC,yBAAgBD,MAJjB;AAKC,QAAA,SAAS,EAAGE,eALb;AAMC,QAAA,KAAK,EAAGd,EAAE,CAAE,sBAAF,CANX;AAOC,QAAA,IAAI,EAAG,cAAC,aAAD;AAAe,UAAA,MAAM,EAAGO;AAAxB;AAPR,QADD;AAWA,KAxBF;AAyBC,IAAA,aAAa,EAAG,MACf,cAAC,SAAD;AAAW,MAAA,KAAK,EAAGP,EAAE,CAAE,SAAF;AAArB,OACC;AAAK,MAAA,SAAS,EAAC;AAAf,OACGA,EAAE,CACH,oEADG,CADL,CADD,EAMC,cAAC,aAAD;AACC,MAAA,YAAY,EAAGG,YADhB;AAEC,MAAA,cAAc,EAAGC,cAFlB;AAGC,MAAA,mBAAmB,EAAGC,mBAHvB;AAIC,MAAA,oBAAoB,EAAGC,oBAJxB;AAKC,MAAA,KAAK,EAAGC,KALT;AAMC,MAAA,QAAQ,EAAGC;AANZ,MAND;AA1BF,IADD;AA6CA;;AAED,eAAeN,cAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tDropdown,\n\tDuotonePicker,\n\tDuotoneSwatch,\n\tMenuGroup,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { DOWN } from '@wordpress/keycodes';\n\nfunction DuotoneControl( {\n\tcolorPalette,\n\tduotonePalette,\n\tdisableCustomColors,\n\tdisableCustomDuotone,\n\tvalue,\n\tonChange,\n} ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ {\n\t\t\t\tclassName: 'block-editor-duotone-control__popover',\n\t\t\t\theaderTitle: __( 'Duotone' ),\n\t\t\t\tisAlternate: true,\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => {\n\t\t\t\tconst openOnArrowDown = ( event ) => {\n\t\t\t\t\tif ( ! isOpen && event.keyCode === DOWN ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tonToggle();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\treturn (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t\t\tlabel={ __( 'Apply duotone filter' ) }\n\t\t\t\t\t\ticon={ <DuotoneSwatch values={ value } /> }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} }\n\t\t\trenderContent={ () => (\n\t\t\t\t<MenuGroup label={ __( 'Duotone' ) }>\n\t\t\t\t\t<div className=\"block-editor-duotone-control__description\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Create a two-tone color effect without losing your original image.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t\t<DuotonePicker\n\t\t\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default DuotoneControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/duotone-control/index.js"],"names":["Dropdown","DuotonePicker","DuotoneSwatch","MenuGroup","ToolbarButton","__","DOWN","Icon","filter","DuotoneControl","colorPalette","duotonePalette","disableCustomColors","disableCustomDuotone","value","onChange","className","headerTitle","isAlternate","isOpen","onToggle","openOnArrowDown","event","keyCode","preventDefault"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,QADD,EAECC,aAFD,EAGCC,aAHD,EAICC,SAJD,EAKCC,aALD,QAMO,uBANP;AAOA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,IAAT,QAAqB,qBAArB;AACA,SAASC,IAAT,EAAeC,MAAf,QAA6B,kBAA7B;;AAEA,SAASC,cAAT,OAOI;AAAA,MAPqB;AACxBC,IAAAA,YADwB;AAExBC,IAAAA,cAFwB;AAGxBC,IAAAA,mBAHwB;AAIxBC,IAAAA,oBAJwB;AAKxBC,IAAAA,KALwB;AAMxBC,IAAAA;AANwB,GAOrB;AACH,SACC,cAAC,QAAD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\nimport {\n\tDropdown,\n\tDuotonePicker,\n\tDuotoneSwatch,\n\tMenuGroup,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { DOWN } from '@wordpress/keycodes';\nimport { Icon, filter } from '@wordpress/icons';\n\nfunction DuotoneControl( {\n\tcolorPalette,\n\tduotonePalette,\n\tdisableCustomColors,\n\tdisableCustomDuotone,\n\tvalue,\n\tonChange,\n} ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ {\n\t\t\t\tclassName: 'block-editor-duotone-control__popover',\n\t\t\t\theaderTitle: __( 'Duotone' ),\n\t\t\t\tisAlternate: true,\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => {\n\t\t\t\tconst openOnArrowDown = ( event ) => {\n\t\t\t\t\tif ( ! isOpen && event.keyCode === DOWN ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tonToggle();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\treturn (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t\t\tlabel={ __( 'Apply duotone filter' ) }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\tvalue ? (\n\t\t\t\t\t\t\t\t<DuotoneSwatch values={ value } />\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Icon icon={ filter } />\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} }\n\t\t\trenderContent={ () => (\n\t\t\t\t<MenuGroup label={ __( 'Duotone' ) }>\n\t\t\t\t\t<div className=\"block-editor-duotone-control__description\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Create a two-tone color effect without losing your original image.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t\t<DuotonePicker\n\t\t\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default DuotoneControl;\n"]}
@@ -1,9 +1,10 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import { createElement, Fragment } from "@wordpress/element";
2
3
 
3
4
  /**
4
5
  * External dependencies
5
6
  */
6
- import { AccessibilityInfo, Platform } from 'react-native';
7
+ import { AccessibilityInfo, Platform, Text } from 'react-native';
7
8
  import { delay } from 'lodash';
8
9
  /**
9
10
  * WordPress dependencies
@@ -15,7 +16,7 @@ import { Component } from '@wordpress/element';
15
16
  import { withDispatch, withSelect } from '@wordpress/data';
16
17
  import { compose, withPreferredColorScheme } from '@wordpress/compose';
17
18
  import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
18
- import { Icon, plusCircle, plusCircleFilled, insertAfter, insertBefore } from '@wordpress/icons';
19
+ import { Icon, plus, plusCircle, plusCircleFilled, insertAfter, insertBefore } from '@wordpress/icons';
19
20
  import { setBlockTypeImpressions } from '@wordpress/react-native-bridge';
20
21
  /**
21
22
  * Internal dependencies
@@ -32,14 +33,30 @@ const defaultRenderToggle = _ref => {
32
33
  onToggle,
33
34
  disabled,
34
35
  style,
35
- onLongPress
36
+ containerStyle,
37
+ onLongPress,
38
+ useExpandedMode
36
39
  } = _ref;
37
- return createElement(ToolbarButton, {
40
+ // The "expanded mode" refers to the editor's appearance when no blocks
41
+ // are currently selected. The "add block" button has a separate style
42
+ // for the "expanded mode", which are added via the below "expandedModeViewProps"
43
+ // and "expandedModeViewText" variables.
44
+ const expandedModeViewProps = useExpandedMode && {
45
+ icon: createElement(Icon, {
46
+ icon: plus,
47
+ style: style
48
+ }),
49
+ customContainerStyles: containerStyle,
50
+ fixedRatio: false
51
+ };
52
+ const expandedModeViewText = createElement(Text, {
53
+ style: styles['inserter-menu__add-block-button-text']
54
+ }, __('Add Blocks'));
55
+ return createElement(ToolbarButton, _extends({
38
56
  title: _x('Add block', 'Generic label for block inserter button'),
39
57
  icon: createElement(Icon, {
40
58
  icon: plusCircleFilled,
41
- style: style,
42
- color: style.color
59
+ style: style
43
60
  }),
44
61
  onClick: onToggle,
45
62
  extraProps: {
@@ -50,7 +67,7 @@ const defaultRenderToggle = _ref => {
50
67
  onLongPress
51
68
  },
52
69
  isDisabled: disabled
53
- });
70
+ }, expandedModeViewProps), useExpandedMode && expandedModeViewText);
54
71
  };
55
72
 
56
73
  export class Inserter extends Component {
@@ -211,14 +228,16 @@ export class Inserter extends Component {
211
228
  disabled,
212
229
  renderToggle = defaultRenderToggle,
213
230
  getStylesFromColorScheme,
214
- showSeparator
231
+ showSeparator,
232
+ useExpandedMode
215
233
  } = this.props;
216
234
 
217
235
  if (showSeparator && isOpen) {
218
236
  return createElement(BlockInsertionPoint, null);
219
237
  }
220
238
 
221
- const style = getStylesFromColorScheme(styles.addBlockButton, styles.addBlockButtonDark);
239
+ const style = useExpandedMode ? styles['inserter-menu__add-block-button-icon--expanded'] : getStylesFromColorScheme(styles['inserter-menu__add-block-button-icon'], styles['inserter-menu__add-block-button-icon--dark']);
240
+ const containerStyle = getStylesFromColorScheme(styles['inserter-menu__add-block-button'], styles['inserter-menu__add-block-button--dark']);
222
241
 
223
242
  const onPress = () => {
224
243
  this.setState({
@@ -247,7 +266,9 @@ export class Inserter extends Component {
247
266
  isOpen,
248
267
  disabled,
249
268
  style,
250
- onLongPress
269
+ containerStyle,
270
+ onLongPress,
271
+ useExpandedMode
251
272
  }), createElement(Picker, {
252
273
  ref: instance => this.picker = instance,
253
274
  options: this.getInsertionOptions(),