@wordpress/block-editor 8.5.2 → 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 (186) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-list/block.native.js +3 -1
  3. package/build/components/block-list/block.native.js.map +1 -1
  4. package/build/components/block-mover/button.js +4 -4
  5. package/build/components/block-mover/button.js.map +1 -1
  6. package/build/components/block-mover/index.js +39 -65
  7. package/build/components/block-mover/index.js.map +1 -1
  8. package/build/components/block-popover/inbetween.js +183 -0
  9. package/build/components/block-popover/inbetween.js.map +1 -0
  10. package/build/components/block-popover/index.js +82 -0
  11. package/build/components/block-popover/index.js.map +1 -0
  12. package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
  13. package/build/components/block-popover/use-popover-scroll.js.map +1 -0
  14. package/build/components/block-styles/index.js +1 -10
  15. package/build/components/block-styles/index.js.map +1 -1
  16. package/build/components/block-tools/back-compat.js +2 -2
  17. package/build/components/block-tools/back-compat.js.map +1 -1
  18. package/build/components/block-tools/block-selection-button.js +4 -2
  19. package/build/components/block-tools/block-selection-button.js.map +1 -1
  20. package/build/components/block-tools/index.js +5 -5
  21. package/build/components/block-tools/index.js.map +1 -1
  22. package/build/components/block-tools/insertion-point.js +14 -121
  23. package/build/components/block-tools/insertion-point.js.map +1 -1
  24. package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
  25. package/build/components/block-tools/selected-block-popover.js.map +1 -0
  26. package/build/components/duotone-control/index.js +5 -1
  27. package/build/components/duotone-control/index.js.map +1 -1
  28. package/build/components/inserter/index.native.js +30 -8
  29. package/build/components/inserter/index.native.js.map +1 -1
  30. package/build/components/rich-text/index.js +0 -5
  31. package/build/components/rich-text/index.js.map +1 -1
  32. package/build/components/rich-text/index.native.js +0 -4
  33. package/build/components/rich-text/index.native.js.map +1 -1
  34. package/build/components/use-block-display-information/index.js +3 -1
  35. package/build/components/use-block-display-information/index.js.map +1 -1
  36. package/build/hooks/border.js +468 -44
  37. package/build/hooks/border.js.map +1 -1
  38. package/build/hooks/duotone.js +66 -16
  39. package/build/hooks/duotone.js.map +1 -1
  40. package/build/hooks/index.js +8 -2
  41. package/build/hooks/index.js.map +1 -1
  42. package/build/hooks/use-border-props.js +22 -32
  43. package/build/hooks/use-border-props.js.map +1 -1
  44. package/build/index.js +7 -0
  45. package/build/index.js.map +1 -1
  46. package/build/store/actions.js +14 -2
  47. package/build/store/actions.js.map +1 -1
  48. package/build/store/reducer.js +0 -26
  49. package/build/store/reducer.js.map +1 -1
  50. package/build/store/selectors.js +9 -3
  51. package/build/store/selectors.js.map +1 -1
  52. package/build-module/components/block-list/block.native.js +3 -1
  53. package/build-module/components/block-list/block.native.js.map +1 -1
  54. package/build-module/components/block-mover/button.js +5 -5
  55. package/build-module/components/block-mover/button.js.map +1 -1
  56. package/build-module/components/block-mover/index.js +38 -63
  57. package/build-module/components/block-mover/index.js.map +1 -1
  58. package/build-module/components/block-popover/inbetween.js +165 -0
  59. package/build-module/components/block-popover/inbetween.js.map +1 -0
  60. package/build-module/components/block-popover/index.js +67 -0
  61. package/build-module/components/block-popover/index.js.map +1 -0
  62. package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  63. package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
  64. package/build-module/components/block-styles/index.js +1 -9
  65. package/build-module/components/block-styles/index.js.map +1 -1
  66. package/build-module/components/block-tools/back-compat.js +1 -1
  67. package/build-module/components/block-tools/back-compat.js.map +1 -1
  68. package/build-module/components/block-tools/block-selection-button.js +3 -2
  69. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  70. package/build-module/components/block-tools/index.js +3 -3
  71. package/build-module/components/block-tools/index.js.map +1 -1
  72. package/build-module/components/block-tools/insertion-point.js +16 -121
  73. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  74. package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
  75. package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
  76. package/build-module/components/duotone-control/index.js +4 -1
  77. package/build-module/components/duotone-control/index.js.map +1 -1
  78. package/build-module/components/inserter/index.native.js +31 -10
  79. package/build-module/components/inserter/index.native.js.map +1 -1
  80. package/build-module/components/rich-text/index.js +0 -4
  81. package/build-module/components/rich-text/index.js.map +1 -1
  82. package/build-module/components/rich-text/index.native.js +0 -4
  83. package/build-module/components/rich-text/index.native.js.map +1 -1
  84. package/build-module/components/use-block-display-information/index.js +3 -1
  85. package/build-module/components/use-block-display-information/index.js.map +1 -1
  86. package/build-module/hooks/border.js +458 -44
  87. package/build-module/hooks/border.js.map +1 -1
  88. package/build-module/hooks/duotone.js +63 -16
  89. package/build-module/hooks/duotone.js.map +1 -1
  90. package/build-module/hooks/index.js +2 -1
  91. package/build-module/hooks/index.js.map +1 -1
  92. package/build-module/hooks/use-border-props.js +21 -30
  93. package/build-module/hooks/use-border-props.js.map +1 -1
  94. package/build-module/index.js +1 -1
  95. package/build-module/index.js.map +1 -1
  96. package/build-module/store/actions.js +14 -2
  97. package/build-module/store/actions.js.map +1 -1
  98. package/build-module/store/reducer.js +0 -24
  99. package/build-module/store/reducer.js.map +1 -1
  100. package/build-module/store/selectors.js +8 -3
  101. package/build-module/store/selectors.js.map +1 -1
  102. package/build-style/style-rtl.css +111 -246
  103. package/build-style/style.css +111 -246
  104. package/package.json +28 -28
  105. package/src/components/block-list/block.native.js +2 -0
  106. package/src/components/block-mover/button.js +5 -7
  107. package/src/components/block-mover/index.js +37 -60
  108. package/src/components/block-mover/stories/index.js +110 -0
  109. package/src/components/block-mover/style.scss +48 -138
  110. package/src/components/block-popover/README.md +41 -0
  111. package/src/components/block-popover/inbetween.js +180 -0
  112. package/src/components/block-popover/index.js +73 -0
  113. package/src/components/block-popover/style.scss +24 -0
  114. package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
  115. package/src/components/block-styles/index.js +1 -12
  116. package/src/components/block-switcher/style.scss +0 -4
  117. package/src/components/block-toolbar/style.scss +0 -12
  118. package/src/components/block-tools/back-compat.js +1 -1
  119. package/src/components/block-tools/block-selection-button.js +3 -1
  120. package/src/components/block-tools/index.js +6 -4
  121. package/src/components/block-tools/insertion-point.js +19 -152
  122. package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
  123. package/src/components/block-tools/style.scss +11 -123
  124. package/src/components/border-radius-control/style.scss +5 -2
  125. package/src/components/default-block-appender/style.scss +1 -2
  126. package/src/components/duotone-control/index.js +8 -1
  127. package/src/components/gradients/README.md +29 -0
  128. package/src/components/inserter/index.native.js +60 -25
  129. package/src/components/inserter/style.native.scss +24 -3
  130. package/src/components/navigable-toolbar/README.md +16 -0
  131. package/src/components/rich-text/index.js +0 -2
  132. package/src/components/rich-text/index.native.js +0 -4
  133. package/src/components/use-block-display-information/index.js +2 -0
  134. package/src/hooks/border.js +438 -72
  135. package/src/hooks/border.scss +48 -0
  136. package/src/hooks/duotone.js +98 -62
  137. package/src/hooks/index.js +2 -1
  138. package/src/hooks/use-border-props.js +15 -32
  139. package/src/index.js +1 -0
  140. package/src/store/actions.js +14 -2
  141. package/src/store/reducer.js +0 -21
  142. package/src/store/selectors.js +12 -3
  143. package/src/store/test/actions.js +0 -18
  144. package/src/store/test/reducer.js +0 -19
  145. package/src/store/test/selectors.js +0 -19
  146. package/src/style.scss +1 -1
  147. package/build/components/block-mobile-toolbar/index.js +0 -42
  148. package/build/components/block-mobile-toolbar/index.js.map +0 -1
  149. package/build/components/block-tools/block-popover.js.map +0 -1
  150. package/build/components/block-tools/use-popover-scroll.js.map +0 -1
  151. package/build/components/list-view/appender.js +0 -93
  152. package/build/components/list-view/appender.js.map +0 -1
  153. package/build/components/list-view/list-item.js +0 -62
  154. package/build/components/list-view/list-item.js.map +0 -1
  155. package/build/components/rich-text/use-caret-in-format.js +0 -43
  156. package/build/components/rich-text/use-caret-in-format.js.map +0 -1
  157. package/build/hooks/border-color.js +0 -302
  158. package/build/hooks/border-color.js.map +0 -1
  159. package/build/hooks/border-style.js +0 -96
  160. package/build/hooks/border-style.js.map +0 -1
  161. package/build/hooks/border-width.js +0 -162
  162. package/build/hooks/border-width.js.map +0 -1
  163. package/build-module/components/block-mobile-toolbar/index.js +0 -31
  164. package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
  165. package/build-module/components/block-tools/block-popover.js.map +0 -1
  166. package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
  167. package/build-module/components/list-view/appender.js +0 -76
  168. package/build-module/components/list-view/appender.js.map +0 -1
  169. package/build-module/components/list-view/list-item.js +0 -47
  170. package/build-module/components/list-view/list-item.js.map +0 -1
  171. package/build-module/components/rich-text/use-caret-in-format.js +0 -33
  172. package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
  173. package/build-module/hooks/border-color.js +0 -276
  174. package/build-module/hooks/border-color.js.map +0 -1
  175. package/build-module/hooks/border-style.js +0 -78
  176. package/build-module/hooks/border-style.js.map +0 -1
  177. package/build-module/hooks/border-width.js +0 -143
  178. package/build-module/hooks/border-width.js.map +0 -1
  179. package/src/components/block-mobile-toolbar/index.js +0 -24
  180. package/src/components/block-mobile-toolbar/style.scss +0 -29
  181. package/src/components/list-view/appender.js +0 -82
  182. package/src/components/list-view/list-item.js +0 -59
  183. package/src/components/rich-text/use-caret-in-format.js +0 -28
  184. package/src/hooks/border-color.js +0 -315
  185. package/src/hooks/border-style.js +0 -64
  186. package/src/hooks/border-width.js +0 -139
@@ -1,93 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = ListViewAppender;
9
-
10
- var _element = require("@wordpress/element");
11
-
12
- var _classnames = _interopRequireDefault(require("classnames"));
13
-
14
- var _components = require("@wordpress/components");
15
-
16
- var _compose = require("@wordpress/compose");
17
-
18
- var _i18n = require("@wordpress/i18n");
19
-
20
- var _data = require("@wordpress/data");
21
-
22
- var _leaf = _interopRequireDefault(require("./leaf"));
23
-
24
- var _inserter = _interopRequireDefault(require("../inserter"));
25
-
26
- var _store = require("../../store");
27
-
28
- /**
29
- * External dependencies
30
- */
31
-
32
- /**
33
- * WordPress dependencies
34
- */
35
-
36
- /**
37
- * Internal dependencies
38
- */
39
- function ListViewAppender(_ref) {
40
- let {
41
- parentBlockClientId,
42
- position,
43
- level,
44
- rowCount,
45
- path
46
- } = _ref;
47
- const isDragging = (0, _data.useSelect)(select => {
48
- const {
49
- isBlockBeingDragged,
50
- isAncestorBeingDragged
51
- } = select(_store.store);
52
- return isBlockBeingDragged(parentBlockClientId) || isAncestorBeingDragged(parentBlockClientId);
53
- }, [parentBlockClientId]);
54
- const instanceId = (0, _compose.useInstanceId)(ListViewAppender);
55
- const descriptionId = `list-view-appender-row__description_${instanceId}`;
56
- const appenderPositionDescription = (0, _i18n.sprintf)(
57
- /* translators: 1: The numerical position of the block that will be inserted. 2: The level of nesting for the block that will be inserted. */
58
- (0, _i18n.__)('Add block at position %1$d, Level %2$d'), position, level);
59
- return (0, _element.createElement)(_leaf.default, {
60
- className: (0, _classnames.default)({
61
- 'is-dragging': isDragging
62
- }),
63
- level: level,
64
- position: position,
65
- rowCount: rowCount,
66
- path: path
67
- }, (0, _element.createElement)(_components.__experimentalTreeGridCell, {
68
- className: "block-editor-list-view-appender__cell",
69
- colSpan: "3"
70
- }, _ref2 => {
71
- let {
72
- ref,
73
- tabIndex,
74
- onFocus
75
- } = _ref2;
76
- return (0, _element.createElement)("div", {
77
- className: "block-editor-list-view-appender__container"
78
- }, (0, _element.createElement)(_inserter.default, {
79
- rootClientId: parentBlockClientId,
80
- __experimentalIsQuick: true,
81
- "aria-describedby": descriptionId,
82
- toggleProps: {
83
- ref,
84
- tabIndex,
85
- onFocus
86
- }
87
- }), (0, _element.createElement)("div", {
88
- className: "block-editor-list-view-appender__description",
89
- id: descriptionId
90
- }, appenderPositionDescription));
91
- }));
92
- }
93
- //# sourceMappingURL=appender.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/appender.js"],"names":["ListViewAppender","parentBlockClientId","position","level","rowCount","path","isDragging","select","isBlockBeingDragged","isAncestorBeingDragged","blockEditorStore","instanceId","descriptionId","appenderPositionDescription","ref","tabIndex","onFocus"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAKe,SAASA,gBAAT,OAMX;AAAA,MANsC;AACzCC,IAAAA,mBADyC;AAEzCC,IAAAA,QAFyC;AAGzCC,IAAAA,KAHyC;AAIzCC,IAAAA,QAJyC;AAKzCC,IAAAA;AALyC,GAMtC;AACH,QAAMC,UAAU,GAAG,qBAChBC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,mBAAF;AAAuBC,MAAAA;AAAvB,QAAkDF,MAAM,CAC7DG,YAD6D,CAA9D;AAIA,WACCF,mBAAmB,CAAEP,mBAAF,CAAnB,IACAQ,sBAAsB,CAAER,mBAAF,CAFvB;AAIA,GAViB,EAWlB,CAAEA,mBAAF,CAXkB,CAAnB;AAaA,QAAMU,UAAU,GAAG,4BAAeX,gBAAf,CAAnB;AACA,QAAMY,aAAa,GAAI,uCAAuCD,UAAY,EAA1E;AAEA,QAAME,2BAA2B,GAAG;AACnC;AACA,gBAAI,wCAAJ,CAFmC,EAGnCX,QAHmC,EAInCC,KAJmC,CAApC;AAOA,SACC,4BAAC,aAAD;AACC,IAAA,SAAS,EAAG,yBAAY;AAAE,qBAAeG;AAAjB,KAAZ,CADb;AAEC,IAAA,KAAK,EAAGH,KAFT;AAGC,IAAA,QAAQ,EAAGD,QAHZ;AAIC,IAAA,QAAQ,EAAGE,QAJZ;AAKC,IAAA,IAAI,EAAGC;AALR,KAOC,4BAAC,sCAAD;AACC,IAAA,SAAS,EAAC,uCADX;AAEC,IAAA,OAAO,EAAC;AAFT,KAIG;AAAA,QAAE;AAAES,MAAAA,GAAF;AAAOC,MAAAA,QAAP;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WACD;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,4BAAC,iBAAD;AACC,MAAA,YAAY,EAAGf,mBADhB;AAEC,MAAA,qBAAqB,MAFtB;AAGC,0BAAmBW,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,62 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = ListViewListItem;
9
-
10
- var _element = require("@wordpress/element");
11
-
12
- var _classnames = _interopRequireDefault(require("classnames"));
13
-
14
- var _components = require("@wordpress/components");
15
-
16
- var _blocks = require("@wordpress/blocks");
17
-
18
- var _i18n = require("@wordpress/i18n");
19
-
20
- var _blockIcon = _interopRequireDefault(require("../block-icon"));
21
-
22
- /**
23
- * External dependencies
24
- */
25
-
26
- /**
27
- * WordPress dependencies
28
- */
29
-
30
- /**
31
- * Internal dependencies
32
- */
33
- function ListViewListItem(_ref) {
34
- let {
35
- block,
36
- onClick,
37
- isSelected,
38
- wrapperComponent: WrapperComponent,
39
- children
40
- } = _ref;
41
- const blockType = (0, _blocks.getBlockType)(block.name);
42
- const blockLabel = blockType ? (0, _blocks.__experimentalGetBlockLabel)(blockType, block.attributes) : null;
43
- return (0, _element.createElement)("div", {
44
- className: "block-editor-list-view__list-item"
45
- }, (0, _element.createElement)(WrapperComponent, {
46
- className: (0, _classnames.default)('block-editor-list-view__list-item-button', {
47
- 'is-selected': isSelected
48
- }),
49
- onClick: onClick
50
- }, (0, _element.createElement)(_blockIcon.default, {
51
- icon: blockType === null || blockType === void 0 ? void 0 : blockType.icon,
52
- showColors: true
53
- }), children ? children : blockLabel, isSelected && (0, _element.createElement)(_components.VisuallyHidden, {
54
- as: "span"
55
- }, (0, _i18n.__)('(selected block)'))));
56
- }
57
-
58
- ListViewListItem.defaultProps = {
59
- onClick: () => {},
60
- wrapperComponent: props => (0, _element.createElement)(_components.Button, props)
61
- };
62
- //# sourceMappingURL=list-item.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/list-item.js"],"names":["ListViewListItem","block","onClick","isSelected","wrapperComponent","WrapperComponent","children","blockType","name","blockLabel","attributes","icon","defaultProps","props"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAIA;;AAKA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AAGe,SAASA,gBAAT,OAMX;AAAA,MANsC;AACzCC,IAAAA,KADyC;AAEzCC,IAAAA,OAFyC;AAGzCC,IAAAA,UAHyC;AAIzCC,IAAAA,gBAAgB,EAAEC,gBAJuB;AAKzCC,IAAAA;AALyC,GAMtC;AACH,QAAMC,SAAS,GAAG,0BAAcN,KAAK,CAACO,IAApB,CAAlB;AACA,QAAMC,UAAU,GAAGF,SAAS,GACzB,yCAAeA,SAAf,EAA0BN,KAAK,CAACS,UAAhC,CADyB,GAEzB,IAFH;AAIA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAG,yBACX,0CADW,EAEX;AACC,qBAAeP;AADhB,KAFW,CADb;AAOC,IAAA,OAAO,EAAGD;AAPX,KASC,4BAAC,kBAAD;AAAW,IAAA,IAAI,EAAGK,SAAH,aAAGA,SAAH,uBAAGA,SAAS,CAAEI,IAA7B;AAAoC,IAAA,UAAU;AAA9C,IATD,EAUGL,QAAQ,GAAGA,QAAH,GAAcG,UAVzB,EAWGN,UAAU,IACX,4BAAC,0BAAD;AAAgB,IAAA,EAAE,EAAC;AAAnB,KACG,cAAI,kBAAJ,CADH,CAZF,CADD,CADD;AAqBA;;AAEDH,gBAAgB,CAACY,YAAjB,GAAgC;AAC/BV,EAAAA,OAAO,EAAE,MAAM,CAAE,CADc;AAE/BE,EAAAA,gBAAgB,EAAIS,KAAF,IAAa,4BAAC,kBAAD,EAAaA,KAAb;AAFA,CAAhC","sourcesContent":["/**\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,43 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useCaretInFormat = useCaretInFormat;
7
-
8
- var _element = require("@wordpress/element");
9
-
10
- var _data = require("@wordpress/data");
11
-
12
- var _store = require("../../store");
13
-
14
- /**
15
- * WordPress dependencies
16
- */
17
-
18
- /**
19
- * Internal dependencies
20
- */
21
- function useCaretInFormat(_ref) {
22
- let {
23
- value
24
- } = _ref;
25
- const hasActiveFormats = value.activeFormats && !!value.activeFormats.length;
26
- const {
27
- isCaretWithinFormattedText
28
- } = (0, _data.useSelect)(_store.store);
29
- const {
30
- enterFormattedText,
31
- exitFormattedText
32
- } = (0, _data.useDispatch)(_store.store);
33
- (0, _element.useEffect)(() => {
34
- if (hasActiveFormats) {
35
- if (!isCaretWithinFormattedText()) {
36
- enterFormattedText();
37
- }
38
- } else if (isCaretWithinFormattedText()) {
39
- exitFormattedText();
40
- }
41
- }, [hasActiveFormats]);
42
- }
43
- //# 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":["useCaretInFormat","value","hasActiveFormats","activeFormats","length","isCaretWithinFormattedText","blockEditorStore","enterFormattedText","exitFormattedText"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGO,SAASA,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,MAAiC,qBAAWC,YAAX,CAAvC;AACA,QAAM;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MAA4C,uBACjDF,YADiD,CAAlD;AAGA,0BAAW,MAAM;AAChB,QAAKJ,gBAAL,EAAwB;AACvB,UAAK,CAAEG,0BAA0B,EAAjC,EAAsC;AACrCE,QAAAA,kBAAkB;AAClB;AACD,KAJD,MAIO,IAAKF,0BAA0B,EAA/B,EAAoC;AAC1CG,MAAAA,iBAAiB;AACjB;AACD,GARD,EAQG,CAAEN,gBAAF,CARH;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,302 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.BorderColorEdit = BorderColorEdit;
9
- exports.hasBorderColorValue = hasBorderColorValue;
10
- exports.resetBorderColor = resetBorderColor;
11
- exports.withBorderColorPaletteStyles = void 0;
12
-
13
- var _element = require("@wordpress/element");
14
-
15
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
16
-
17
- var _classnames = _interopRequireDefault(require("classnames"));
18
-
19
- var _hooks = require("@wordpress/hooks");
20
-
21
- var _i18n = require("@wordpress/i18n");
22
-
23
- var _compose = require("@wordpress/compose");
24
-
25
- var _dropdown = _interopRequireDefault(require("../components/colors-gradients/dropdown"));
26
-
27
- var _useMultipleOriginColorsAndGradients = _interopRequireDefault(require("../components/colors-gradients/use-multiple-origin-colors-and-gradients"));
28
-
29
- var _colors = require("../components/colors");
30
-
31
- var _useSetting = _interopRequireDefault(require("../components/use-setting"));
32
-
33
- var _border = require("./border");
34
-
35
- var _utils = require("./utils");
36
-
37
- /**
38
- * External dependencies
39
- */
40
-
41
- /**
42
- * WordPress dependencies
43
- */
44
-
45
- /**
46
- * Internal dependencies
47
- */
48
- // Defining empty array here instead of inline avoids unnecessary re-renders of
49
- // color control.
50
- const EMPTY_ARRAY = [];
51
- /**
52
- * Inspector control panel containing the border color related configuration.
53
- *
54
- * There is deliberate overlap between the colors and borders block supports
55
- * relating to border color. It can be argued the border color controls could
56
- * be included within either, or both, the colors and borders panels in the
57
- * inspector controls. If they share the same block attributes it should not
58
- * matter.
59
- *
60
- * @param {Object} props Block properties.
61
- *
62
- * @return {WPElement} Border color edit element.
63
- */
64
-
65
- function BorderColorEdit(props) {
66
- const {
67
- attributes: {
68
- borderColor,
69
- style
70
- },
71
- setAttributes
72
- } = props;
73
- const colorGradientSettings = (0, _useMultipleOriginColorsAndGradients.default)();
74
- const availableColors = colorGradientSettings.colors.reduce((colors, origin) => colors.concat(origin.colors), []);
75
- const {
76
- color: customBorderColor
77
- } = (style === null || style === void 0 ? void 0 : style.border) || {};
78
- const [colorValue, setColorValue] = (0, _element.useState)(() => {
79
- var _getColorObjectByAttr;
80
-
81
- return (_getColorObjectByAttr = (0, _colors.getColorObjectByAttributeValues)(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
82
- }); // Detect changes in the color attributes and update the colorValue to keep the
83
- // UI in sync. This is necessary for situations when border controls interact with
84
- // each other: eg, setting the border width to zero causes the color and style
85
- // selections to be cleared.
86
-
87
- (0, _element.useEffect)(() => {
88
- var _getColorObjectByAttr2;
89
-
90
- setColorValue((_getColorObjectByAttr2 = (0, _colors.getColorObjectByAttributeValues)(availableColors, borderColor, customBorderColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color);
91
- }, [borderColor, customBorderColor, availableColors]);
92
-
93
- const onChangeColor = value => {
94
- setColorValue(value);
95
- const colorObject = (0, _colors.getColorObjectByColorValue)(availableColors, value);
96
- const newStyle = { ...style,
97
- border: { ...(style === null || style === void 0 ? void 0 : style.border),
98
- color: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value
99
- }
100
- }; // If empty slug, ensure undefined to remove attribute.
101
-
102
- const newNamedColor = colorObject !== null && colorObject !== void 0 && colorObject.slug ? colorObject.slug : undefined;
103
- setAttributes({
104
- style: (0, _utils.cleanEmptyObject)(newStyle),
105
- borderColor: newNamedColor
106
- });
107
- };
108
-
109
- const settings = [{
110
- label: (0, _i18n.__)('Color'),
111
- onColorChange: onChangeColor,
112
- colorValue,
113
- clearable: false
114
- }];
115
- return (0, _element.createElement)(_dropdown.default, (0, _extends2.default)({
116
- settings: settings,
117
- disableCustomColors: true,
118
- disableCustomGradients: true,
119
- __experimentalHasMultipleOrigins: true,
120
- __experimentalIsRenderedInSidebar: true,
121
- enableAlpha: true
122
- }, colorGradientSettings));
123
- }
124
- /**
125
- * Checks if there is a current value in the border color block support
126
- * attributes.
127
- *
128
- * @param {Object} props Block props.
129
- * @return {boolean} Whether or not the block has a border color value set.
130
- */
131
-
132
-
133
- function hasBorderColorValue(props) {
134
- var _style$border;
135
-
136
- const {
137
- attributes: {
138
- borderColor,
139
- style
140
- }
141
- } = props;
142
- return !!borderColor || !!(style !== null && style !== void 0 && (_style$border = style.border) !== null && _style$border !== void 0 && _style$border.color);
143
- }
144
- /**
145
- * Resets the border color block support attributes. This can be used when
146
- * disabling the border color support controls for a block via a progressive
147
- * discovery panel.
148
- *
149
- * @param {Object} props Block props.
150
- * @param {Object} props.attributes Block's attributes.
151
- * @param {Object} props.setAttributes Function to set block's attributes.
152
- */
153
-
154
-
155
- function resetBorderColor(_ref) {
156
- let {
157
- attributes = {},
158
- setAttributes
159
- } = _ref;
160
- const {
161
- style
162
- } = attributes;
163
- setAttributes({
164
- borderColor: undefined,
165
- style: (0, _border.removeBorderAttribute)(style, 'color')
166
- });
167
- }
168
- /**
169
- * Filters registered block settings, extending attributes to include
170
- * `borderColor` if needed.
171
- *
172
- * @param {Object} settings Original block settings.
173
- *
174
- * @return {Object} Updated block settings.
175
- */
176
-
177
-
178
- function addAttributes(settings) {
179
- if (!(0, _border.hasBorderSupport)(settings, 'color')) {
180
- return settings;
181
- } // Allow blocks to specify default value if needed.
182
-
183
-
184
- if (settings.attributes.borderColor) {
185
- return settings;
186
- } // Add new borderColor attribute to block settings.
187
-
188
-
189
- return { ...settings,
190
- attributes: { ...settings.attributes,
191
- borderColor: {
192
- type: 'string'
193
- }
194
- }
195
- };
196
- }
197
- /**
198
- * Override props assigned to save component to inject border color.
199
- *
200
- * @param {Object} props Additional props applied to save element.
201
- * @param {Object} blockType Block type definition.
202
- * @param {Object} attributes Block's attributes.
203
- *
204
- * @return {Object} Filtered props to apply to save element.
205
- */
206
-
207
-
208
- function addSaveProps(props, blockType, attributes) {
209
- var _style$border2;
210
-
211
- if (!(0, _border.hasBorderSupport)(blockType, 'color') || (0, _utils.shouldSkipSerialization)(blockType, _border.BORDER_SUPPORT_KEY, 'color')) {
212
- return props;
213
- }
214
-
215
- const {
216
- borderColor,
217
- style
218
- } = attributes;
219
- const borderColorClass = (0, _colors.getColorClassName)('border-color', borderColor);
220
- const newClassName = (0, _classnames.default)(props.className, {
221
- '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),
222
- [borderColorClass]: !!borderColorClass
223
- }); // If we are clearing the last of the previous classes in `className`
224
- // set it to `undefined` to avoid rendering empty DOM attributes.
225
-
226
- props.className = newClassName ? newClassName : undefined;
227
- return props;
228
- }
229
- /**
230
- * Filters the registered block settings to apply border color styles and
231
- * classnames to the block edit wrapper.
232
- *
233
- * @param {Object} settings Original block settings.
234
- *
235
- * @return {Object} Filtered block settings.
236
- */
237
-
238
-
239
- function addEditProps(settings) {
240
- if (!(0, _border.hasBorderSupport)(settings, 'color') || (0, _utils.shouldSkipSerialization)(settings, _border.BORDER_SUPPORT_KEY, 'color')) {
241
- return settings;
242
- }
243
-
244
- const existingGetEditWrapperProps = settings.getEditWrapperProps;
245
-
246
- settings.getEditWrapperProps = attributes => {
247
- let props = {};
248
-
249
- if (existingGetEditWrapperProps) {
250
- props = existingGetEditWrapperProps(attributes);
251
- }
252
-
253
- return addSaveProps(props, settings, attributes);
254
- };
255
-
256
- return settings;
257
- }
258
- /**
259
- * This adds inline styles for color palette colors.
260
- * Ideally, this is not needed and themes should load their palettes on the editor.
261
- *
262
- * @param {Function} BlockListBlock Original component.
263
- *
264
- * @return {Function} Wrapped component.
265
- */
266
-
267
-
268
- const withBorderColorPaletteStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock => props => {
269
- var _getColorObjectByAttr3, _props$wrapperProps;
270
-
271
- const {
272
- name,
273
- attributes
274
- } = props;
275
- const {
276
- borderColor
277
- } = attributes;
278
- const colors = (0, _useSetting.default)('color.palette') || EMPTY_ARRAY;
279
-
280
- if (!(0, _border.hasBorderSupport)(name, 'color') || (0, _utils.shouldSkipSerialization)(name, _border.BORDER_SUPPORT_KEY, 'color')) {
281
- return (0, _element.createElement)(BlockListBlock, props);
282
- }
283
-
284
- const extraStyles = {
285
- borderColor: borderColor ? (_getColorObjectByAttr3 = (0, _colors.getColorObjectByAttributeValues)(colors, borderColor)) === null || _getColorObjectByAttr3 === void 0 ? void 0 : _getColorObjectByAttr3.color : undefined
286
- };
287
- let wrapperProps = props.wrapperProps;
288
- wrapperProps = { ...props.wrapperProps,
289
- style: { ...extraStyles,
290
- ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style)
291
- }
292
- };
293
- return (0, _element.createElement)(BlockListBlock, (0, _extends2.default)({}, props, {
294
- wrapperProps: wrapperProps
295
- }));
296
- });
297
- exports.withBorderColorPaletteStyles = withBorderColorPaletteStyles;
298
- (0, _hooks.addFilter)('blocks.registerBlockType', 'core/border/addAttributes', addAttributes);
299
- (0, _hooks.addFilter)('blocks.getSaveContent.extraProps', 'core/border/addSaveProps', addSaveProps);
300
- (0, _hooks.addFilter)('blocks.registerBlockType', 'core/border/addEditProps', addEditProps);
301
- (0, _hooks.addFilter)('editor.BlockListBlock', 'core/border/with-border-color-palette-styles', withBorderColorPaletteStyles);
302
- //# sourceMappingURL=border-color.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-color.js"],"names":["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","BORDER_SUPPORT_KEY","borderColorClass","newClassName","className","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","name","extraStyles","wrapperProps"],"mappings":";;;;;;;;;;;;AAWA;;;;AARA;;AAKA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AAKA;;AA7BA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAgBA;AACA;AACA,MAAMA,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AACA;;AAED,QAAM2C,WAAW,GAAG;AACnBzC,IAAAA,WAAW,EAAEA,WAAW,6BACrB,6CAAiCK,MAAjC,EAAyCL,WAAzC,CADqB,2DACrB,uBAAwDS,KADnC,GAErBU;AAHgB,GAApB;AAMA,MAAIuB,YAAY,GAAG5C,KAAK,CAAC4C,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAG5C,KAAK,CAAC4C,YADK;AAEdzC,IAAAA,KAAK,EAAE,EACN,GAAGwC,WADG;AAEN,iCAAG3C,KAAK,CAAC4C,YAAT,wDAAG,oBAAoBzC,KAAvB;AAFM;AAFO,GAAf;AAQA,SAAO,4BAAC,cAAD,6BAAqBH,KAArB;AAA6B,IAAA,YAAY,EAAG4C;AAA5C,KAAP;AACA,CA7B0C,CAArC;;AAgCP,sBACC,0BADD,EAEC,2BAFD,EAGCf,aAHD;AAMA,sBACC,kCADD,EAEC,0BAFD,EAGCE,YAHD;AAMA,sBACC,0BADD,EAEC,0BAFD,EAGCM,YAHD;AAMA,sBACC,uBADD,EAEC,8CAFD,EAGCG,4BAHD","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,96 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.BorderStyleEdit = void 0;
9
- exports.hasBorderStyleValue = hasBorderStyleValue;
10
- exports.resetBorderStyle = resetBorderStyle;
11
-
12
- var _element = require("@wordpress/element");
13
-
14
- var _borderStyleControl = _interopRequireDefault(require("../components/border-style-control"));
15
-
16
- var _utils = require("./utils");
17
-
18
- var _border = require("./border");
19
-
20
- /**
21
- * Internal dependencies
22
- */
23
-
24
- /**
25
- * Inspector control for configuring border style property.
26
- *
27
- * @param {Object} props Block properties.
28
- *
29
- * @return {WPElement} Border style edit element.
30
- */
31
- const BorderStyleEdit = props => {
32
- var _style$border;
33
-
34
- const {
35
- attributes: {
36
- style
37
- },
38
- setAttributes
39
- } = props;
40
-
41
- const onChange = newBorderStyle => {
42
- const newStyleAttributes = { ...style,
43
- border: { ...(style === null || style === void 0 ? void 0 : style.border),
44
- style: newBorderStyle
45
- }
46
- };
47
- setAttributes({
48
- style: (0, _utils.cleanEmptyObject)(newStyleAttributes)
49
- });
50
- };
51
-
52
- return (0, _element.createElement)(_borderStyleControl.default, {
53
- value: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.style,
54
- onChange: onChange
55
- });
56
- };
57
- /**
58
- * Checks if there is a current value in the border style block support
59
- * attributes.
60
- *
61
- * @param {Object} props Block props.
62
- * @return {boolean} Whether or not the block has a border style value set.
63
- */
64
-
65
-
66
- exports.BorderStyleEdit = BorderStyleEdit;
67
-
68
- function hasBorderStyleValue(props) {
69
- var _props$attributes$sty, _props$attributes$sty2;
70
-
71
- 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);
72
- }
73
- /**
74
- * Resets the border style block support attribute. This can be used when
75
- * disabling the border style support control for a block via a progressive
76
- * discovery panel.
77
- *
78
- * @param {Object} props Block props.
79
- * @param {Object} props.attributes Block's attributes.
80
- * @param {Object} props.setAttributes Function to set block's attributes.
81
- */
82
-
83
-
84
- function resetBorderStyle(_ref) {
85
- let {
86
- attributes = {},
87
- setAttributes
88
- } = _ref;
89
- const {
90
- style
91
- } = attributes;
92
- setAttributes({
93
- style: (0, _border.removeBorderAttribute)(style, 'style')
94
- });
95
- }
96
- //# sourceMappingURL=border-style.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-style.js"],"names":["BorderStyleEdit","props","attributes","style","setAttributes","onChange","newBorderStyle","newStyleAttributes","border","hasBorder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B;AAAT,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"]}