@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.
- package/CHANGELOG.md +2 -0
- package/build/components/block-list/block.native.js +3 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-mover/button.js +4 -4
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +39 -65
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-popover/inbetween.js +183 -0
- package/build/components/block-popover/inbetween.js.map +1 -0
- package/build/components/block-popover/index.js +82 -0
- package/build/components/block-popover/index.js.map +1 -0
- package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
- package/build/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build/components/block-styles/index.js +1 -10
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +4 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +5 -5
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +14 -121
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
- package/build/components/block-tools/selected-block-popover.js.map +1 -0
- package/build/components/duotone-control/index.js +5 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/inserter/index.native.js +30 -8
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/rich-text/index.js +0 -5
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/use-block-display-information/index.js +3 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/border.js +468 -44
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/duotone.js +66 -16
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +8 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use-border-props.js +22 -32
- package/build/hooks/use-border-props.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +14 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +0 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +9 -3
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-list/block.native.js +3 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-mover/button.js +5 -5
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +38 -63
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +165 -0
- package/build-module/components/block-popover/inbetween.js.map +1 -0
- package/build-module/components/block-popover/index.js +67 -0
- package/build-module/components/block-popover/index.js.map +1 -0
- package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build-module/components/block-styles/index.js +1 -9
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +3 -3
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +16 -121
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
- package/build-module/components/duotone-control/index.js +4 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +31 -10
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -4
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +3 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/hooks/border.js +458 -44
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/duotone.js +63 -16
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/use-border-props.js +21 -30
- package/build-module/hooks/use-border-props.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +14 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +0 -24
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +8 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +111 -246
- package/build-style/style.css +111 -246
- package/package.json +28 -28
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-mover/button.js +5 -7
- package/src/components/block-mover/index.js +37 -60
- package/src/components/block-mover/stories/index.js +110 -0
- package/src/components/block-mover/style.scss +48 -138
- package/src/components/block-popover/README.md +41 -0
- package/src/components/block-popover/inbetween.js +180 -0
- package/src/components/block-popover/index.js +73 -0
- package/src/components/block-popover/style.scss +24 -0
- package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/src/components/block-styles/index.js +1 -12
- package/src/components/block-switcher/style.scss +0 -4
- package/src/components/block-toolbar/style.scss +0 -12
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-selection-button.js +3 -1
- package/src/components/block-tools/index.js +6 -4
- package/src/components/block-tools/insertion-point.js +19 -152
- package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
- package/src/components/block-tools/style.scss +11 -123
- package/src/components/border-radius-control/style.scss +5 -2
- package/src/components/default-block-appender/style.scss +1 -2
- package/src/components/duotone-control/index.js +8 -1
- package/src/components/gradients/README.md +29 -0
- package/src/components/inserter/index.native.js +60 -25
- package/src/components/inserter/style.native.scss +24 -3
- package/src/components/navigable-toolbar/README.md +16 -0
- package/src/components/rich-text/index.js +0 -2
- package/src/components/rich-text/index.native.js +0 -4
- package/src/components/use-block-display-information/index.js +2 -0
- package/src/hooks/border.js +438 -72
- package/src/hooks/border.scss +48 -0
- package/src/hooks/duotone.js +98 -62
- package/src/hooks/index.js +2 -1
- package/src/hooks/use-border-props.js +15 -32
- package/src/index.js +1 -0
- package/src/store/actions.js +14 -2
- package/src/store/reducer.js +0 -21
- package/src/store/selectors.js +12 -3
- package/src/store/test/actions.js +0 -18
- package/src/store/test/reducer.js +0 -19
- package/src/store/test/selectors.js +0 -19
- package/src/style.scss +1 -1
- package/build/components/block-mobile-toolbar/index.js +0 -42
- package/build/components/block-mobile-toolbar/index.js.map +0 -1
- package/build/components/block-tools/block-popover.js.map +0 -1
- package/build/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build/components/list-view/appender.js +0 -93
- package/build/components/list-view/appender.js.map +0 -1
- package/build/components/list-view/list-item.js +0 -62
- package/build/components/list-view/list-item.js.map +0 -1
- package/build/components/rich-text/use-caret-in-format.js +0 -43
- package/build/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build/hooks/border-color.js +0 -302
- package/build/hooks/border-color.js.map +0 -1
- package/build/hooks/border-style.js +0 -96
- package/build/hooks/border-style.js.map +0 -1
- package/build/hooks/border-width.js +0 -162
- package/build/hooks/border-width.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.js +0 -31
- package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
- package/build-module/components/block-tools/block-popover.js.map +0 -1
- package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build-module/components/list-view/appender.js +0 -76
- package/build-module/components/list-view/appender.js.map +0 -1
- package/build-module/components/list-view/list-item.js +0 -47
- package/build-module/components/list-view/list-item.js.map +0 -1
- package/build-module/components/rich-text/use-caret-in-format.js +0 -33
- package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build-module/hooks/border-color.js +0 -276
- package/build-module/hooks/border-color.js.map +0 -1
- package/build-module/hooks/border-style.js +0 -78
- package/build-module/hooks/border-style.js.map +0 -1
- package/build-module/hooks/border-width.js +0 -143
- package/build-module/hooks/border-width.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.js +0 -24
- package/src/components/block-mobile-toolbar/style.scss +0 -29
- package/src/components/list-view/appender.js +0 -82
- package/src/components/list-view/list-item.js +0 -59
- package/src/components/rich-text/use-caret-in-format.js +0 -28
- package/src/hooks/border-color.js +0 -315
- package/src/hooks/border-style.js +0 -64
- package/src/hooks/border-width.js +0 -139
package/src/hooks/border.scss
CHANGED
|
@@ -3,3 +3,51 @@
|
|
|
3
3
|
grid-column: span 1;
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
+
|
|
7
|
+
.block-editor__border-box-control__popover,
|
|
8
|
+
.block-editor__border-box-control__popover-top,
|
|
9
|
+
.block-editor__border-box-control__popover-right,
|
|
10
|
+
.block-editor__border-box-control__popover-bottom,
|
|
11
|
+
.block-editor__border-box-control__popover-left {
|
|
12
|
+
.components-popover__content {
|
|
13
|
+
width: 282px;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
$split-border-control-offset: 55px;
|
|
18
|
+
|
|
19
|
+
@include break-medium() {
|
|
20
|
+
.block-editor__border-box-control__popover,
|
|
21
|
+
.block-editor__border-box-control__popover-left {
|
|
22
|
+
.components-popover__content {
|
|
23
|
+
margin-right: #{ $grid-unit-50 + $grid-unit-15 } !important;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.block-editor__border-box-control__popover-top,
|
|
28
|
+
.block-editor__border-box-control__popover-bottom {
|
|
29
|
+
.components-popover__content {
|
|
30
|
+
margin-right: #{ $grid-unit-50 + $grid-unit-15 + $split-border-control-offset } !important;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.block-editor__border-box-control__popover-right {
|
|
35
|
+
.components-popover__content {
|
|
36
|
+
margin-right: #{ $grid-unit-50 + $grid-unit-15 + ( $split-border-control-offset * 2 )} !important;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.block-editor__border-box-control__popover,
|
|
41
|
+
.block-editor__border-box-control__popover-top,
|
|
42
|
+
.block-editor__border-box-control__popover-right,
|
|
43
|
+
.block-editor__border-box-control__popover-bottom,
|
|
44
|
+
.block-editor__border-box-control__popover-left {
|
|
45
|
+
&.is-from-top .components-popover__content {
|
|
46
|
+
margin-top: #{ -($grid-unit-50 + $grid-unit-15) } !important;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&.is-from-bottom .components-popover__content {
|
|
50
|
+
margin-bottom: #{ -($grid-unit-50 + $grid-unit-15) } !important;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
package/src/hooks/duotone.js
CHANGED
|
@@ -60,82 +60,109 @@ export function getValuesFromColors( colors = [] ) {
|
|
|
60
60
|
*/
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* Stylesheet for rendering the duotone filter.
|
|
64
64
|
*
|
|
65
65
|
* @param {Object} props Duotone props.
|
|
66
66
|
* @param {string} props.selector Selector to apply the filter to.
|
|
67
67
|
* @param {string} props.id Unique id for this duotone filter.
|
|
68
|
-
* @param {Values} props.values R, G, B, and A values to filter with.
|
|
69
68
|
*
|
|
70
69
|
* @return {WPElement} Duotone element.
|
|
71
70
|
*/
|
|
72
|
-
function
|
|
73
|
-
const
|
|
71
|
+
function DuotoneStylesheet( { selector, id } ) {
|
|
72
|
+
const css = `
|
|
74
73
|
${ selector } {
|
|
75
74
|
filter: url( #${ id } );
|
|
76
75
|
}
|
|
77
76
|
`;
|
|
77
|
+
return <style>{ css }</style>;
|
|
78
|
+
}
|
|
78
79
|
|
|
80
|
+
/**
|
|
81
|
+
* SVG for rendering the duotone filter.
|
|
82
|
+
*
|
|
83
|
+
* @param {Object} props Duotone props.
|
|
84
|
+
* @param {string} props.id Unique id for this duotone filter.
|
|
85
|
+
* @param {Values} props.values R, G, B, and A values to filter with.
|
|
86
|
+
*
|
|
87
|
+
* @return {WPElement} Duotone element.
|
|
88
|
+
*/
|
|
89
|
+
function DuotoneFilter( { id, values } ) {
|
|
79
90
|
return (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
>
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
91
|
+
<SVG
|
|
92
|
+
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
93
|
+
viewBox="0 0 0 0"
|
|
94
|
+
width="0"
|
|
95
|
+
height="0"
|
|
96
|
+
focusable="false"
|
|
97
|
+
role="none"
|
|
98
|
+
style={ {
|
|
99
|
+
visibility: 'hidden',
|
|
100
|
+
position: 'absolute',
|
|
101
|
+
left: '-9999px',
|
|
102
|
+
overflow: 'hidden',
|
|
103
|
+
} }
|
|
104
|
+
>
|
|
105
|
+
<defs>
|
|
106
|
+
<filter id={ id }>
|
|
107
|
+
<feColorMatrix
|
|
108
|
+
// Use sRGB instead of linearRGB so transparency looks correct.
|
|
109
|
+
colorInterpolationFilters="sRGB"
|
|
110
|
+
type="matrix"
|
|
111
|
+
// Use perceptual brightness to convert to grayscale.
|
|
112
|
+
values="
|
|
113
|
+
.299 .587 .114 0 0
|
|
114
|
+
.299 .587 .114 0 0
|
|
115
|
+
.299 .587 .114 0 0
|
|
116
|
+
.299 .587 .114 0 0
|
|
117
|
+
"
|
|
118
|
+
/>
|
|
119
|
+
<feComponentTransfer
|
|
120
|
+
// Use sRGB instead of linearRGB to be consistent with how CSS gradients work.
|
|
121
|
+
colorInterpolationFilters="sRGB"
|
|
122
|
+
>
|
|
123
|
+
<feFuncR
|
|
124
|
+
type="table"
|
|
125
|
+
tableValues={ values.r.join( ' ' ) }
|
|
126
|
+
/>
|
|
127
|
+
<feFuncG
|
|
128
|
+
type="table"
|
|
129
|
+
tableValues={ values.g.join( ' ' ) }
|
|
130
|
+
/>
|
|
131
|
+
<feFuncB
|
|
132
|
+
type="table"
|
|
133
|
+
tableValues={ values.b.join( ' ' ) }
|
|
108
134
|
/>
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
>
|
|
113
|
-
<feFuncR
|
|
114
|
-
type="table"
|
|
115
|
-
tableValues={ values.r.join( ' ' ) }
|
|
116
|
-
/>
|
|
117
|
-
<feFuncG
|
|
118
|
-
type="table"
|
|
119
|
-
tableValues={ values.g.join( ' ' ) }
|
|
120
|
-
/>
|
|
121
|
-
<feFuncB
|
|
122
|
-
type="table"
|
|
123
|
-
tableValues={ values.b.join( ' ' ) }
|
|
124
|
-
/>
|
|
125
|
-
<feFuncA
|
|
126
|
-
type="table"
|
|
127
|
-
tableValues={ values.a.join( ' ' ) }
|
|
128
|
-
/>
|
|
129
|
-
</feComponentTransfer>
|
|
130
|
-
<feComposite
|
|
131
|
-
// Re-mask the image with the original transparency since the feColorMatrix above loses that information.
|
|
132
|
-
in2="SourceGraphic"
|
|
133
|
-
operator="in"
|
|
135
|
+
<feFuncA
|
|
136
|
+
type="table"
|
|
137
|
+
tableValues={ values.a.join( ' ' ) }
|
|
134
138
|
/>
|
|
135
|
-
</
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
+
</feComponentTransfer>
|
|
140
|
+
<feComposite
|
|
141
|
+
// Re-mask the image with the original transparency since the feColorMatrix above loses that information.
|
|
142
|
+
in2="SourceGraphic"
|
|
143
|
+
operator="in"
|
|
144
|
+
/>
|
|
145
|
+
</filter>
|
|
146
|
+
</defs>
|
|
147
|
+
</SVG>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* SVG and stylesheet needed for rendering the duotone filter.
|
|
153
|
+
*
|
|
154
|
+
* @param {Object} props Duotone props.
|
|
155
|
+
* @param {string} props.selector Selector to apply the filter to.
|
|
156
|
+
* @param {string} props.id Unique id for this duotone filter.
|
|
157
|
+
* @param {Values} props.values R, G, B, and A values to filter with.
|
|
158
|
+
*
|
|
159
|
+
* @return {WPElement} Duotone element.
|
|
160
|
+
*/
|
|
161
|
+
function InlineDuotone( { selector, id, values } ) {
|
|
162
|
+
return (
|
|
163
|
+
<>
|
|
164
|
+
<DuotoneFilter id={ id } values={ values } />
|
|
165
|
+
<DuotoneStylesheet id={ id } selector={ selector } />
|
|
139
166
|
</>
|
|
140
167
|
);
|
|
141
168
|
}
|
|
@@ -321,7 +348,7 @@ const withDuotoneStyles = createHigherOrderComponent(
|
|
|
321
348
|
<>
|
|
322
349
|
{ element &&
|
|
323
350
|
createPortal(
|
|
324
|
-
<
|
|
351
|
+
<InlineDuotone
|
|
325
352
|
selector={ selectorsGroup }
|
|
326
353
|
id={ id }
|
|
327
354
|
values={ getValuesFromColors( values ) }
|
|
@@ -335,6 +362,15 @@ const withDuotoneStyles = createHigherOrderComponent(
|
|
|
335
362
|
'withDuotoneStyles'
|
|
336
363
|
);
|
|
337
364
|
|
|
365
|
+
export function PresetDuotoneFilter( { preset } ) {
|
|
366
|
+
return (
|
|
367
|
+
<DuotoneFilter
|
|
368
|
+
id={ `wp-duotone-${ preset.slug }` }
|
|
369
|
+
values={ getValuesFromColors( preset.colors ) }
|
|
370
|
+
/>
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
338
374
|
addFilter(
|
|
339
375
|
'blocks.registerBlockType',
|
|
340
376
|
'core/editor/duotone/add-attributes',
|
package/src/hooks/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import './style';
|
|
|
11
11
|
import './color';
|
|
12
12
|
import './duotone';
|
|
13
13
|
import './font-size';
|
|
14
|
-
import './border
|
|
14
|
+
import './border';
|
|
15
15
|
import './layout';
|
|
16
16
|
|
|
17
17
|
export { useCustomSides } from './dimensions';
|
|
@@ -19,3 +19,4 @@ export { getBorderClassesAndStyles, useBorderProps } from './use-border-props';
|
|
|
19
19
|
export { getColorClassesAndStyles, useColorProps } from './use-color-props';
|
|
20
20
|
export { getSpacingClassesAndStyles } from './use-spacing-props';
|
|
21
21
|
export { useCachedTruthy } from './use-cached-truthy';
|
|
22
|
+
export { PresetDuotoneFilter } from './duotone';
|
|
@@ -1,46 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Internal dependencies
|
|
8
3
|
*/
|
|
9
4
|
import { getInlineStyles } from './style';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
getColorObjectByAttributeValues,
|
|
13
|
-
} from '../components/colors';
|
|
14
|
-
import useSetting from '../components/use-setting';
|
|
5
|
+
import { getBorderClasses, getMultiOriginColor } from './border';
|
|
6
|
+
import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
|
|
15
7
|
|
|
16
8
|
// This utility is intended to assist where the serialization of the border
|
|
17
9
|
// block support is being skipped for a block but the border related CSS classes
|
|
18
10
|
// & styles still need to be generated so they can be applied to inner elements.
|
|
19
11
|
|
|
20
|
-
const EMPTY_ARRAY = [];
|
|
21
|
-
|
|
22
12
|
/**
|
|
23
13
|
* Provides the CSS class names and inline styles for a block's border support
|
|
24
14
|
* attributes.
|
|
25
15
|
*
|
|
26
|
-
* @param {Object} attributes
|
|
27
|
-
* @param {string} attributes.borderColor Selected named border color.
|
|
28
|
-
* @param {Object} attributes.style Block's styles attribute.
|
|
29
|
-
*
|
|
16
|
+
* @param {Object} attributes Block attributes.
|
|
30
17
|
* @return {Object} Border block support derived CSS classes & styles.
|
|
31
18
|
*/
|
|
32
|
-
export function getBorderClassesAndStyles(
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const className = classnames( {
|
|
37
|
-
[ borderClass ]: !! borderClass,
|
|
38
|
-
'has-border-color': borderColor || style?.border?.color,
|
|
39
|
-
} );
|
|
19
|
+
export function getBorderClassesAndStyles( attributes ) {
|
|
20
|
+
const border = attributes.style?.border || {};
|
|
21
|
+
const className = getBorderClasses( attributes );
|
|
40
22
|
|
|
41
23
|
return {
|
|
42
24
|
className: className || undefined,
|
|
43
|
-
style: getInlineStyles( { border
|
|
25
|
+
style: getInlineStyles( { border } ),
|
|
44
26
|
};
|
|
45
27
|
}
|
|
46
28
|
|
|
@@ -56,16 +38,17 @@ export function getBorderClassesAndStyles( { borderColor, style } ) {
|
|
|
56
38
|
* @return {Object} ClassName & style props from border block support.
|
|
57
39
|
*/
|
|
58
40
|
export function useBorderProps( attributes ) {
|
|
59
|
-
const colors =
|
|
41
|
+
const { colors } = useMultipleOriginColorsAndGradients();
|
|
60
42
|
const borderProps = getBorderClassesAndStyles( attributes );
|
|
43
|
+
const { borderColor } = attributes;
|
|
61
44
|
|
|
62
|
-
// Force inline
|
|
63
|
-
// color stylesheets in the editor.
|
|
64
|
-
if (
|
|
65
|
-
const borderColorObject =
|
|
45
|
+
// Force inline styles to apply named border colors when themes do not load
|
|
46
|
+
// their color stylesheets in the editor.
|
|
47
|
+
if ( borderColor ) {
|
|
48
|
+
const borderColorObject = getMultiOriginColor( {
|
|
66
49
|
colors,
|
|
67
|
-
|
|
68
|
-
);
|
|
50
|
+
namedColor: borderColor,
|
|
51
|
+
} );
|
|
69
52
|
|
|
70
53
|
borderProps.style.borderColor = borderColorObject.color;
|
|
71
54
|
}
|
package/src/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import './hooks';
|
|
5
5
|
export {
|
|
6
|
+
PresetDuotoneFilter as __unstablePresetDuotoneFilter,
|
|
6
7
|
getBorderClassesAndStyles as __experimentalGetBorderClassesAndStyles,
|
|
7
8
|
useBorderProps as __experimentalUseBorderProps,
|
|
8
9
|
getColorClassesAndStyles as __experimentalGetColorClassesAndStyles,
|
package/src/store/actions.js
CHANGED
|
@@ -1261,22 +1261,34 @@ export function stopDraggingBlocks() {
|
|
|
1261
1261
|
/**
|
|
1262
1262
|
* Returns an action object used in signalling that the caret has entered formatted text.
|
|
1263
1263
|
*
|
|
1264
|
+
* @deprecated
|
|
1265
|
+
*
|
|
1264
1266
|
* @return {Object} Action object.
|
|
1265
1267
|
*/
|
|
1266
1268
|
export function enterFormattedText() {
|
|
1269
|
+
deprecated( 'wp.data.dispatch( "core/block-editor" ).enterFormattedText', {
|
|
1270
|
+
since: '6.1',
|
|
1271
|
+
version: '6.3',
|
|
1272
|
+
} );
|
|
1267
1273
|
return {
|
|
1268
|
-
type: '
|
|
1274
|
+
type: 'DO_NOTHING',
|
|
1269
1275
|
};
|
|
1270
1276
|
}
|
|
1271
1277
|
|
|
1272
1278
|
/**
|
|
1273
1279
|
* Returns an action object used in signalling that the user caret has exited formatted text.
|
|
1274
1280
|
*
|
|
1281
|
+
* @deprecated
|
|
1282
|
+
*
|
|
1275
1283
|
* @return {Object} Action object.
|
|
1276
1284
|
*/
|
|
1277
1285
|
export function exitFormattedText() {
|
|
1286
|
+
deprecated( 'wp.data.dispatch( "core/block-editor" ).exitFormattedText', {
|
|
1287
|
+
since: '6.1',
|
|
1288
|
+
version: '6.3',
|
|
1289
|
+
} );
|
|
1278
1290
|
return {
|
|
1279
|
-
type: '
|
|
1291
|
+
type: 'DO_NOTHING',
|
|
1280
1292
|
};
|
|
1281
1293
|
}
|
|
1282
1294
|
|
package/src/store/reducer.js
CHANGED
|
@@ -1181,26 +1181,6 @@ export function draggedBlocks( state = [], action ) {
|
|
|
1181
1181
|
return state;
|
|
1182
1182
|
}
|
|
1183
1183
|
|
|
1184
|
-
/**
|
|
1185
|
-
* Reducer returning whether the caret is within formatted text.
|
|
1186
|
-
*
|
|
1187
|
-
* @param {boolean} state Current state.
|
|
1188
|
-
* @param {Object} action Dispatched action.
|
|
1189
|
-
*
|
|
1190
|
-
* @return {boolean} Updated state.
|
|
1191
|
-
*/
|
|
1192
|
-
export function isCaretWithinFormattedText( state = false, action ) {
|
|
1193
|
-
switch ( action.type ) {
|
|
1194
|
-
case 'ENTER_FORMATTED_TEXT':
|
|
1195
|
-
return true;
|
|
1196
|
-
|
|
1197
|
-
case 'EXIT_FORMATTED_TEXT':
|
|
1198
|
-
return false;
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
return state;
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
1184
|
/**
|
|
1205
1185
|
* Internal helper reducer for selectionStart and selectionEnd. Can hold a block
|
|
1206
1186
|
* selection, represented by an object with property clientId.
|
|
@@ -1765,7 +1745,6 @@ export default combineReducers( {
|
|
|
1765
1745
|
blocks,
|
|
1766
1746
|
isTyping,
|
|
1767
1747
|
draggedBlocks,
|
|
1768
|
-
isCaretWithinFormattedText,
|
|
1769
1748
|
selection,
|
|
1770
1749
|
isMultiSelecting,
|
|
1771
1750
|
isSelectionEnabled,
|
package/src/store/selectors.js
CHANGED
|
@@ -34,6 +34,7 @@ import { applyFilters } from '@wordpress/hooks';
|
|
|
34
34
|
import { symbol } from '@wordpress/icons';
|
|
35
35
|
import { __ } from '@wordpress/i18n';
|
|
36
36
|
import { create, remove, toHTMLString } from '@wordpress/rich-text';
|
|
37
|
+
import deprecated from '@wordpress/deprecated';
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Internal dependencies
|
|
@@ -1344,12 +1345,20 @@ export function isAncestorBeingDragged( state, clientId ) {
|
|
|
1344
1345
|
/**
|
|
1345
1346
|
* Returns true if the caret is within formatted text, or false otherwise.
|
|
1346
1347
|
*
|
|
1347
|
-
* @
|
|
1348
|
+
* @deprecated
|
|
1348
1349
|
*
|
|
1349
1350
|
* @return {boolean} Whether the caret is within formatted text.
|
|
1350
1351
|
*/
|
|
1351
|
-
export function isCaretWithinFormattedText(
|
|
1352
|
-
|
|
1352
|
+
export function isCaretWithinFormattedText() {
|
|
1353
|
+
deprecated(
|
|
1354
|
+
'wp.data.select( "core/block-editor" ).isCaretWithinFormattedText',
|
|
1355
|
+
{
|
|
1356
|
+
since: '6.1',
|
|
1357
|
+
version: '6.3',
|
|
1358
|
+
}
|
|
1359
|
+
);
|
|
1360
|
+
|
|
1361
|
+
return false;
|
|
1353
1362
|
}
|
|
1354
1363
|
|
|
1355
1364
|
/**
|
|
@@ -26,8 +26,6 @@ import { STORE_NAME as blockEditorStoreName } from '../../store/constants';
|
|
|
26
26
|
|
|
27
27
|
const {
|
|
28
28
|
clearSelectedBlock,
|
|
29
|
-
enterFormattedText,
|
|
30
|
-
exitFormattedText,
|
|
31
29
|
hideInsertionPoint,
|
|
32
30
|
insertBlock,
|
|
33
31
|
insertBlocks,
|
|
@@ -819,22 +817,6 @@ describe( 'actions', () => {
|
|
|
819
817
|
} );
|
|
820
818
|
} );
|
|
821
819
|
|
|
822
|
-
describe( 'enterFormattedText', () => {
|
|
823
|
-
it( 'should return the ENTER_FORMATTED_TEXT action', () => {
|
|
824
|
-
expect( enterFormattedText() ).toEqual( {
|
|
825
|
-
type: 'ENTER_FORMATTED_TEXT',
|
|
826
|
-
} );
|
|
827
|
-
} );
|
|
828
|
-
} );
|
|
829
|
-
|
|
830
|
-
describe( 'exitFormattedText', () => {
|
|
831
|
-
it( 'should return the EXIT_FORMATTED_TEXT action', () => {
|
|
832
|
-
expect( exitFormattedText() ).toEqual( {
|
|
833
|
-
type: 'EXIT_FORMATTED_TEXT',
|
|
834
|
-
} );
|
|
835
|
-
} );
|
|
836
|
-
} );
|
|
837
|
-
|
|
838
820
|
describe( 'toggleSelection', () => {
|
|
839
821
|
it( 'should return the TOGGLE_SELECTION action with default value for isSelectionEnabled = true', () => {
|
|
840
822
|
expect( toggleSelection() ).toEqual( {
|
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
blocks,
|
|
23
23
|
isTyping,
|
|
24
24
|
draggedBlocks,
|
|
25
|
-
isCaretWithinFormattedText,
|
|
26
25
|
selection,
|
|
27
26
|
initialPosition,
|
|
28
27
|
isMultiSelecting,
|
|
@@ -2160,24 +2159,6 @@ describe( 'state', () => {
|
|
|
2160
2159
|
} );
|
|
2161
2160
|
} );
|
|
2162
2161
|
|
|
2163
|
-
describe( 'isCaretWithinFormattedText()', () => {
|
|
2164
|
-
it( 'should set the flag to true', () => {
|
|
2165
|
-
const state = isCaretWithinFormattedText( false, {
|
|
2166
|
-
type: 'ENTER_FORMATTED_TEXT',
|
|
2167
|
-
} );
|
|
2168
|
-
|
|
2169
|
-
expect( state ).toBe( true );
|
|
2170
|
-
} );
|
|
2171
|
-
|
|
2172
|
-
it( 'should set the flag to false', () => {
|
|
2173
|
-
const state = isCaretWithinFormattedText( true, {
|
|
2174
|
-
type: 'EXIT_FORMATTED_TEXT',
|
|
2175
|
-
} );
|
|
2176
|
-
|
|
2177
|
-
expect( state ).toBe( false );
|
|
2178
|
-
} );
|
|
2179
|
-
} );
|
|
2180
|
-
|
|
2181
2162
|
describe( 'initialPosition()', () => {
|
|
2182
2163
|
it( 'should return with block clientId as selected', () => {
|
|
2183
2164
|
const state = initialPosition( undefined, {
|
|
@@ -54,7 +54,6 @@ const {
|
|
|
54
54
|
getDraggedBlockClientIds,
|
|
55
55
|
isBlockBeingDragged,
|
|
56
56
|
isAncestorBeingDragged,
|
|
57
|
-
isCaretWithinFormattedText,
|
|
58
57
|
getBlockInsertionPoint,
|
|
59
58
|
isBlockInsertionPointVisible,
|
|
60
59
|
isSelectionEnabled,
|
|
@@ -2056,24 +2055,6 @@ describe( 'selectors', () => {
|
|
|
2056
2055
|
} );
|
|
2057
2056
|
} );
|
|
2058
2057
|
|
|
2059
|
-
describe( 'isCaretWithinFormattedText', () => {
|
|
2060
|
-
it( 'returns true if the isCaretWithinFormattedText state is also true', () => {
|
|
2061
|
-
const state = {
|
|
2062
|
-
isCaretWithinFormattedText: true,
|
|
2063
|
-
};
|
|
2064
|
-
|
|
2065
|
-
expect( isCaretWithinFormattedText( state ) ).toBe( true );
|
|
2066
|
-
} );
|
|
2067
|
-
|
|
2068
|
-
it( 'returns false if the isCaretWithinFormattedText state is also false', () => {
|
|
2069
|
-
const state = {
|
|
2070
|
-
isCaretWithinFormattedText: false,
|
|
2071
|
-
};
|
|
2072
|
-
|
|
2073
|
-
expect( isCaretWithinFormattedText( state ) ).toBe( false );
|
|
2074
|
-
} );
|
|
2075
|
-
} );
|
|
2076
|
-
|
|
2077
2058
|
describe( 'isSelectionEnabled', () => {
|
|
2078
2059
|
it( 'should return true if selection is enable', () => {
|
|
2079
2060
|
const state = {
|
package/src/style.scss
CHANGED
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
@import "./components/block-compare/style.scss";
|
|
13
13
|
@import "./components/block-content-overlay/style.scss";
|
|
14
14
|
@import "./components/block-draggable/style.scss";
|
|
15
|
-
@import "./components/block-mobile-toolbar/style.scss";
|
|
16
15
|
@import "./components/block-mover/style.scss";
|
|
17
16
|
@import "./components/block-navigation/style.scss";
|
|
18
17
|
@import "./components/block-parent-selector/style.scss";
|
|
19
18
|
@import "./components/block-patterns-list/style.scss";
|
|
19
|
+
@import "./components/block-popover/style.scss";
|
|
20
20
|
@import "./components/block-preview/style.scss";
|
|
21
21
|
@import "./components/block-settings-menu/style.scss";
|
|
22
22
|
@import "./components/block-styles/style.scss";
|
|
@@ -1,42 +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 = void 0;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _compose = require("@wordpress/compose");
|
|
13
|
-
|
|
14
|
-
var _blockMover = _interopRequireDefault(require("../block-mover"));
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Internal dependencies
|
|
22
|
-
*/
|
|
23
|
-
function BlockMobileToolbar(_ref) {
|
|
24
|
-
let {
|
|
25
|
-
clientId
|
|
26
|
-
} = _ref;
|
|
27
|
-
const isMobile = (0, _compose.useViewportMatch)('small', '<');
|
|
28
|
-
|
|
29
|
-
if (!isMobile) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return (0, _element.createElement)("div", {
|
|
34
|
-
className: "block-editor-block-mobile-toolbar"
|
|
35
|
-
}, (0, _element.createElement)(_blockMover.default, {
|
|
36
|
-
clientIds: [clientId]
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
var _default = BlockMobileToolbar;
|
|
41
|
-
exports.default = _default;
|
|
42
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-mobile-toolbar/index.js"],"names":["BlockMobileToolbar","clientId","isMobile"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGA,SAASA,kBAAT,OAA4C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AAC3C,QAAMC,QAAQ,GAAG,+BAAkB,OAAlB,EAA2B,GAA3B,CAAjB;;AACA,MAAK,CAAEA,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,mBAAD;AAAY,IAAA,SAAS,EAAG,CAAED,QAAF;AAAxB,IADD,CADD;AAKA;;eAEcD,kB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockMover from '../block-mover';\n\nfunction BlockMobileToolbar( { clientId } ) {\n\tconst isMobile = useViewportMatch( 'small', '<' );\n\tif ( ! isMobile ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-editor-block-mobile-toolbar\">\n\t\t\t<BlockMover clientIds={ [ clientId ] } />\n\t\t</div>\n\t);\n}\n\nexport default BlockMobileToolbar;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/block-popover.js"],"names":["selector","select","isNavigationMode","isMultiSelecting","hasMultiSelection","isTyping","isCaretWithinFormattedText","getSettings","getLastMultiSelectedBlockClientId","blockEditorStore","hasFixedToolbar","lastClientId","BlockPopover","clientId","rootClientId","isValid","isEmptyDefaultBlock","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isLargeViewport","isToolbarForced","setIsToolbarForced","isInserterShown","setIsInserterShown","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","shouldShowContextualToolbar","canFocusHiddenToolbar","isDisabled","initialToolbarItemIndexRef","selectedElement","lastSelectedElement","capturingElement","popoverScrollRef","node","anchorRef","top","bottom","onFocus","onBlur","popoverPosition","ownerDocument","stickyBoundaryElement","undefined","defaultView","frameElement","body","current","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","parentClientId","__experimentalCaptureToolbars","WrappedBlockPopover","selected"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAzBA;AACA;AACA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AAA,IAHM;AAINjD,IAAAA,OAJM;AAKNC,IAAAA,mBAAmB,EAClBgD,IAAI,IAAI,sCAA0B;AAAEA,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAA1B,CANH;AAONhD,IAAAA;AAPM,GAAP;AASA;;AAEc,SAASqD,mBAAT,QAGX;AAAA,MAHyC;AAC5CpD,IAAAA,qBAD4C;AAE5CC,IAAAA;AAF4C,GAGzC;AACH,QAAMoD,QAAQ,GAAG,qBAAWd,eAAX,EAA4B,EAA5B,CAAjB;;AAEA,MAAK,CAAEc,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAM;AACL1D,IAAAA,QADK;AAELC,IAAAA,YAFK;AAGLkD,IAAAA,IAHK;AAILjD,IAAAA,OAJK;AAKLC,IAAAA,mBALK;AAMLC,IAAAA;AANK,MAOFsD,QAPJ;;AASA,MAAK,CAAEP,IAAP,EAAc;AACb,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,YAAD;AACC,IAAA,QAAQ,EAAGnD,QADZ;AAEC,IAAA,YAAY,EAAGC,YAFhB;AAGC,IAAA,OAAO,EAAGC,OAHX;AAIC,IAAA,mBAAmB,EAAGC,mBAJvB;AAKC,IAAA,iBAAiB,EAAGC,iBALrB;AAMC,IAAA,qBAAqB,EAAGC,qBANzB;AAOC,IAAA,oBAAoB,EAAGC;AAPxB,IADD;AAWA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { Popover } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport Inserter from '../inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport { usePopoverScroll } from './use-popover-scroll';\n\nfunction selector( select ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\tisCaretWithinFormattedText,\n\t\tgetSettings,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\treturn {\n\t\tisNavigationMode: isNavigationMode(),\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tisTyping: isTyping(),\n\t\tisCaretWithinFormattedText: isCaretWithinFormattedText(),\n\t\thasMultiSelection: hasMultiSelection(),\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tlastClientId: getLastMultiSelectedBlockClientId(),\n\t};\n}\n\nfunction BlockPopover( {\n\tclientId,\n\trootClientId,\n\tisValid,\n\tisEmptyDefaultBlock,\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\tisTyping,\n\t\tisCaretWithinFormattedText,\n\t\thasMultiSelection,\n\t\thasFixedToolbar,\n\t\tlastClientId,\n\t} = useSelect( selector, [] );\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst [ isToolbarForced, setIsToolbarForced ] = useState( false );\n\tconst [ isInserterShown, setIsInserterShown ] = useState( false );\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\t// Controls when the side inserter on empty lines should\n\t// be shown, including writing and selection modes.\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && ! isNavigationMode && isEmptyDefaultBlock && isValid;\n\tconst shouldShowBreadcrumb = isNavigationMode;\n\tconst shouldShowContextualToolbar =\n\t\t! isNavigationMode &&\n\t\t! hasFixedToolbar &&\n\t\tisLargeViewport &&\n\t\t! showEmptyBlockSideInserter &&\n\t\t! isMultiSelecting &&\n\t\t( ! isTyping || isCaretWithinFormattedText );\n\tconst canFocusHiddenToolbar =\n\t\t! isNavigationMode &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! hasFixedToolbar &&\n\t\t! isEmptyDefaultBlock;\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tsetIsToolbarForced( true );\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tif ( ! shouldShowContextualToolbar ) {\n\t\t\tsetIsToolbarForced( false );\n\t\t}\n\t}, [ shouldShowContextualToolbar ] );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( lastClientId );\n\tconst capturingElement = useBlockElement( capturingClientId );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\n\tif (\n\t\t! shouldShowBreadcrumb &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! isToolbarForced &&\n\t\t! showEmptyBlockSideInserter\n\t) {\n\t\treturn null;\n\t}\n\n\tlet node = selectedElement;\n\n\tif ( ! node ) {\n\t\treturn null;\n\t}\n\n\tif ( capturingClientId ) {\n\t\tnode = capturingElement;\n\t}\n\n\tlet anchorRef = node;\n\n\tif ( hasMultiSelection ) {\n\t\t// Wait to render the popover until the bottom reference is available\n\t\t// as well.\n\t\tif ( ! lastSelectedElement ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tanchorRef = {\n\t\t\ttop: node,\n\t\t\tbottom: lastSelectedElement,\n\t\t};\n\t}\n\n\tfunction onFocus() {\n\t\tsetIsInserterShown( true );\n\t}\n\n\tfunction onBlur() {\n\t\tsetIsInserterShown( false );\n\t}\n\n\t// Position above the anchor, pop out towards the right, and position in the\n\t// left corner. For the side inserter, pop out towards the left, and\n\t// position in the right corner.\n\t// To do: refactor `Popover` to make this prop clearer.\n\tconst popoverPosition = showEmptyBlockSideInserter\n\t\t? 'top left right'\n\t\t: 'top right left';\n\tconst { ownerDocument } = node;\n\tconst stickyBoundaryElement = showEmptyBlockSideInserter\n\t\t? undefined\n\t\t: // The sticky boundary element should be the boundary at which the\n\t\t // the block toolbar becomes sticky when the block scolls out of view.\n\t\t // In case of an iframe, this should be the iframe boundary, otherwise\n\t\t // the scroll container.\n\t\t ownerDocument.defaultView.frameElement ||\n\t\t getScrollContainer( node ) ||\n\t\t ownerDocument.body;\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tnoArrow\n\t\t\tanimate={ false }\n\t\t\tposition={ popoverPosition }\n\t\t\tfocusOnMount={ false }\n\t\t\tanchorRef={ anchorRef }\n\t\t\tclassName={ classnames( 'block-editor-block-list__block-popover', {\n\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t} ) }\n\t\t\t__unstableStickyBoundaryElement={ stickyBoundaryElement }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\t__unstableBoundaryParent\n\t\t\t// Observe movement for block animations (especially horizontal).\n\t\t\t__unstableObserveElement={ node }\n\t\t\tshouldAnchorIncludePadding\n\t\t\t// Used to safeguard sticky position behavior against cases where it would permanently\n\t\t\t// obscure specific sections of a block.\n\t\t\t__unstableEditorCanvasWrapper={ __unstableContentRef?.current }\n\t\t>\n\t\t\t{ ( shouldShowContextualToolbar || isToolbarForced ) && (\n\t\t\t\t<div\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\t// While ideally it would be enough to capture the\n\t\t\t\t\t// bubbling focus event from the Inserter, due to the\n\t\t\t\t\t// characteristics of click focusing of `button`s in\n\t\t\t\t\t// Firefox and Safari, it is not reliable.\n\t\t\t\t\t//\n\t\t\t\t\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-block-list__block-popover-inserter',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-visible': isInserterShown,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<Inserter\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ( shouldShowContextualToolbar || isToolbarForced ) && (\n\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\tfocusOnMount={ isToolbarForced }\n\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t} }\n\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t<BlockSelectionButton\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tblockElement={ node }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t<div className=\"block-editor-block-list__empty-block-inserter\">\n\t\t\t\t\t<Inserter\n\t\t\t\t\t\tposition=\"bottom right\"\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {}, isValid } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = find(\n\t\tblockParentsClientIds,\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisValid,\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisValid,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisValid={ isValid }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/use-popover-scroll.js"],"names":["usePopoverScroll","scrollableRef","node","onWheel","event","deltaX","deltaY","current","scrollBy","options","passive","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA2BC,aAA3B,EAA2C;AACjD,SAAO,2BACJC,IAAF,IAAY;AACX,QAAK,CAAED,aAAP,EAAuB;AACtB;AACA;;AAED,aAASE,OAAT,CAAkBC,KAAlB,EAA0B;AACzB,YAAM;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,UAAqBF,KAA3B;AACAH,MAAAA,aAAa,CAACM,OAAd,CAAsBC,QAAtB,CAAgCH,MAAhC,EAAwCC,MAAxC;AACA,KARU,CASX;AACA;;;AACA,UAAMG,OAAO,GAAG;AAAEC,MAAAA,OAAO,EAAE;AAAX,KAAhB;AACAR,IAAAA,IAAI,CAACS,gBAAL,CAAuB,OAAvB,EAAgCR,OAAhC,EAAyCM,OAAzC;AACA,WAAO,MAAM;AACZP,MAAAA,IAAI,CAACU,mBAAL,CAA0B,OAA1B,EAAmCT,OAAnC,EAA4CM,OAA5C;AACA,KAFD;AAGA,GAjBK,EAkBN,CAAER,aAAF,CAlBM,CAAP;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Allow scrolling \"through\" popovers over the canvas. This is only called for\n * as long as the pointer is over a popover. Do not use React events because it\n * will bubble through portals.\n *\n * @param {Object} scrollableRef\n */\nexport function usePopoverScroll( scrollableRef ) {\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! scrollableRef ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction onWheel( event ) {\n\t\t\t\tconst { deltaX, deltaY } = event;\n\t\t\t\tscrollableRef.current.scrollBy( deltaX, deltaY );\n\t\t\t}\n\t\t\t// Tell the browser that we do not call event.preventDefault\n\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners\n\t\t\tconst options = { passive: true };\n\t\t\tnode.addEventListener( 'wheel', onWheel, options );\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'wheel', onWheel, options );\n\t\t\t};\n\t\t},\n\t\t[ scrollableRef ]\n\t);\n}\n"]}
|