@wordpress/block-editor 10.0.9 → 10.0.10
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 +4 -0
- package/README.md +0 -1
- package/build/components/block-tools/selected-block-popover.js +23 -3
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +56 -24
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/inner-blocks/index.js +6 -2
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +23 -4
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +56 -24
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +6 -2
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-style/style-rtl.css +12 -1
- package/build-style/style.css +12 -1
- package/package.json +3 -3
- package/src/components/block-popover/style.scss +1 -1
- package/src/components/block-tools/selected-block-popover.js +74 -33
- package/src/components/block-tools/style.scss +9 -0
- package/src/components/default-block-appender/style.scss +1 -0
- package/src/components/font-sizes/fluid-utils.js +77 -29
- package/src/components/font-sizes/test/fluid-utils.js +5 -5
- package/src/components/inner-blocks/index.js +6 -3
- package/src/hooks/test/use-typography-props.js +1 -1
|
@@ -8,7 +8,7 @@ const DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';
|
|
|
8
8
|
const DEFAULT_MINIMUM_VIEWPORT_WIDTH = '768px';
|
|
9
9
|
const DEFAULT_SCALE_FACTOR = 1;
|
|
10
10
|
const DEFAULT_MINIMUM_FONT_SIZE_FACTOR = 0.75;
|
|
11
|
-
const
|
|
11
|
+
const DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';
|
|
12
12
|
/**
|
|
13
13
|
* Computes a fluid font-size value that uses clamp(). A minimum and maxinmum
|
|
14
14
|
* font size OR a single font size can be specified.
|
|
@@ -38,7 +38,6 @@ const DEFAULT_MAXIMUM_FONT_SIZE_FACTOR = 1.5;
|
|
|
38
38
|
* @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.
|
|
39
39
|
* @param {?number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.
|
|
40
40
|
* @param {?number} args.minimumFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.
|
|
41
|
-
* @param {?number} args.maximumFontSizeFactor How much to scale defaultFontSize by to derive maximumFontSize. Optional.
|
|
42
41
|
*
|
|
43
42
|
* @return {string|null} A font-size value using clamp().
|
|
44
43
|
*/
|
|
@@ -52,48 +51,71 @@ export function getComputedFluidTypographyValue(_ref) {
|
|
|
52
51
|
maximumViewPortWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,
|
|
53
52
|
scaleFactor = DEFAULT_SCALE_FACTOR,
|
|
54
53
|
minimumFontSizeFactor = DEFAULT_MINIMUM_FONT_SIZE_FACTOR,
|
|
55
|
-
|
|
54
|
+
minimumFontSizeLimit = DEFAULT_MINIMUM_FONT_SIZE_LIMIT
|
|
56
55
|
} = _ref;
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
/*
|
|
58
|
+
* Calculates missing minimumFontSize and maximumFontSize from
|
|
59
|
+
* defaultFontSize if provided.
|
|
60
|
+
*/
|
|
61
|
+
if (fontSize) {
|
|
62
|
+
// Parses default font size.
|
|
62
63
|
const fontSizeParsed = getTypographyValueAndUnit(fontSize); // Protect against invalid units.
|
|
63
64
|
|
|
64
65
|
if (!(fontSizeParsed !== null && fontSizeParsed !== void 0 && fontSizeParsed.unit)) {
|
|
65
66
|
return null;
|
|
66
|
-
} //
|
|
67
|
+
} // Parses the minimum font size limit, so we can perform checks using it.
|
|
67
68
|
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
} //
|
|
70
|
+
const minimumFontSizeLimitParsed = getTypographyValueAndUnit(minimumFontSizeLimit, {
|
|
71
|
+
coerceTo: fontSizeParsed.unit
|
|
72
|
+
}); // Don't enforce minimum font size if a font size has explicitly set a min and max value.
|
|
73
|
+
|
|
74
|
+
if (!!(minimumFontSizeLimitParsed !== null && minimumFontSizeLimitParsed !== void 0 && minimumFontSizeLimitParsed.value) && !minimumFontSize && !maximumFontSize) {
|
|
75
|
+
/*
|
|
76
|
+
* If a minimum size was not passed to this function
|
|
77
|
+
* and the user-defined font size is lower than $minimum_font_size_limit,
|
|
78
|
+
* do not calculate a fluid value.
|
|
79
|
+
*/
|
|
80
|
+
if ((fontSizeParsed === null || fontSizeParsed === void 0 ? void 0 : fontSizeParsed.value) <= (minimumFontSizeLimitParsed === null || minimumFontSizeLimitParsed === void 0 ? void 0 : minimumFontSizeLimitParsed.value)) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
} // If no fluid max font size is available use the incoming value.
|
|
72
84
|
|
|
73
85
|
|
|
74
86
|
if (!maximumFontSize) {
|
|
75
|
-
maximumFontSize = fontSizeParsed.value
|
|
87
|
+
maximumFontSize = `${fontSizeParsed.value}${fontSizeParsed.unit}`;
|
|
76
88
|
}
|
|
77
|
-
|
|
89
|
+
/*
|
|
90
|
+
* If no minimumFontSize is provided, create one using
|
|
91
|
+
* the given font size multiplied by the min font size scale factor.
|
|
92
|
+
*/
|
|
78
93
|
|
|
79
94
|
|
|
80
|
-
|
|
81
|
-
|
|
95
|
+
if (!minimumFontSize) {
|
|
96
|
+
const calculatedMinimumFontSize = roundToPrecision(fontSizeParsed.value * minimumFontSizeFactor, 3); // Only use calculated min font size if it's > $minimum_font_size_limit value.
|
|
97
|
+
|
|
98
|
+
if (!!(minimumFontSizeLimitParsed !== null && minimumFontSizeLimitParsed !== void 0 && minimumFontSizeLimitParsed.value) && calculatedMinimumFontSize < (minimumFontSizeLimitParsed === null || minimumFontSizeLimitParsed === void 0 ? void 0 : minimumFontSizeLimitParsed.value)) {
|
|
99
|
+
minimumFontSize = `${minimumFontSizeLimitParsed.value}${minimumFontSizeLimitParsed.unit}`;
|
|
100
|
+
} else {
|
|
101
|
+
minimumFontSize = `${calculatedMinimumFontSize}${fontSizeParsed.unit}`;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
82
104
|
} // Grab the minimum font size and normalize it in order to use the value for calculations.
|
|
83
105
|
|
|
84
106
|
|
|
85
107
|
const minimumFontSizeParsed = getTypographyValueAndUnit(minimumFontSize); // We get a 'preferred' unit to keep units consistent when calculating,
|
|
86
108
|
// otherwise the result will not be accurate.
|
|
87
109
|
|
|
88
|
-
const fontSizeUnit = (minimumFontSizeParsed === null || minimumFontSizeParsed === void 0 ? void 0 : minimumFontSizeParsed.unit) || 'rem'; //
|
|
110
|
+
const fontSizeUnit = (minimumFontSizeParsed === null || minimumFontSizeParsed === void 0 ? void 0 : minimumFontSizeParsed.unit) || 'rem'; // Grabs the maximum font size and normalize it in order to use the value for calculations.
|
|
89
111
|
|
|
90
112
|
const maximumFontSizeParsed = getTypographyValueAndUnit(maximumFontSize, {
|
|
91
113
|
coerceTo: fontSizeUnit
|
|
92
|
-
}); //
|
|
114
|
+
}); // Checks for mandatory min and max sizes, and protects against unsupported units.
|
|
93
115
|
|
|
94
116
|
if (!minimumFontSizeParsed || !maximumFontSizeParsed) {
|
|
95
117
|
return null;
|
|
96
|
-
} //
|
|
118
|
+
} // Uses rem for accessible fluid target font scaling.
|
|
97
119
|
|
|
98
120
|
|
|
99
121
|
const minimumFontSizeRem = getTypographyValueAndUnit(minimumFontSize, {
|
|
@@ -114,10 +136,9 @@ export function getComputedFluidTypographyValue(_ref) {
|
|
|
114
136
|
|
|
115
137
|
|
|
116
138
|
const minViewPortWidthOffsetValue = roundToPrecision(minumumViewPortWidthParsed.value / 100, 3);
|
|
117
|
-
const viewPortWidthOffset = minViewPortWidthOffsetValue + fontSizeUnit;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const linearFactorScaled = linearFactor * scaleFactor;
|
|
139
|
+
const viewPortWidthOffset = roundToPrecision(minViewPortWidthOffsetValue, 3) + fontSizeUnit;
|
|
140
|
+
const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / (maximumViewPortWidthParsed.value - minumumViewPortWidthParsed.value));
|
|
141
|
+
const linearFactorScaled = roundToPrecision((linearFactor || 1) * scaleFactor, 3);
|
|
121
142
|
const fluidTargetFontSize = `${minimumFontSizeRem.value}${minimumFontSizeRem.unit} + ((1vw - ${viewPortWidthOffset}) * ${linearFactorScaled})`;
|
|
122
143
|
return `clamp(${minimumFontSize}, ${fluidTargetFontSize}, ${maximumFontSize})`;
|
|
123
144
|
}
|
|
@@ -174,9 +195,19 @@ export function getTypographyValueAndUnit(rawValue) {
|
|
|
174
195
|
returnValue = returnValue / rootSizeValue;
|
|
175
196
|
unit = coerceTo;
|
|
176
197
|
}
|
|
198
|
+
/*
|
|
199
|
+
* No calculation is required if swapping between em and rem yet,
|
|
200
|
+
* since we assume a root size value. Later we might like to differentiate between
|
|
201
|
+
* :root font size (rem) and parent element font size (em) relativity.
|
|
202
|
+
*/
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
if (('em' === coerceTo || 'rem' === coerceTo) && ('em' === unit || 'rem' === unit)) {
|
|
206
|
+
unit = coerceTo;
|
|
207
|
+
}
|
|
177
208
|
|
|
178
209
|
return {
|
|
179
|
-
value: returnValue,
|
|
210
|
+
value: roundToPrecision(returnValue, 3),
|
|
180
211
|
unit
|
|
181
212
|
};
|
|
182
213
|
}
|
|
@@ -192,6 +223,7 @@ export function getTypographyValueAndUnit(rawValue) {
|
|
|
192
223
|
|
|
193
224
|
export function roundToPrecision(value) {
|
|
194
225
|
let digits = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
|
|
195
|
-
|
|
226
|
+
const base = Math.pow(10, digits);
|
|
227
|
+
return Number.isFinite(value) ? parseFloat(Math.round(value * base) / base) : undefined;
|
|
196
228
|
}
|
|
197
229
|
//# sourceMappingURL=fluid-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/font-sizes/fluid-utils.js"],"names":["DEFAULT_MAXIMUM_VIEWPORT_WIDTH","DEFAULT_MINIMUM_VIEWPORT_WIDTH","DEFAULT_SCALE_FACTOR","DEFAULT_MINIMUM_FONT_SIZE_FACTOR","DEFAULT_MAXIMUM_FONT_SIZE_FACTOR","getComputedFluidTypographyValue","minimumFontSize","maximumFontSize","fontSize","minimumViewPortWidth","maximumViewPortWidth","scaleFactor","minimumFontSizeFactor","maximumFontSizeFactor","fontSizeParsed","getTypographyValueAndUnit","unit","value","minimumFontSizeParsed","fontSizeUnit","maximumFontSizeParsed","coerceTo","minimumFontSizeRem","maximumViewPortWidthParsed","minumumViewPortWidthParsed","minViewPortWidthOffsetValue","roundToPrecision","viewPortWidthOffset","linearFactor","linearFactorScaled","fluidTargetFontSize","rawValue","options","isFinite","rootSizeValue","acceptableUnits","acceptableUnitsGroup","join","regexUnits","RegExp","matches","match","length","returnValue","parseFloat","digits","Number","toFixed","undefined"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA;AACA,MAAMA,8BAA8B,GAAG,QAAvC;AACA,MAAMC,8BAA8B,GAAG,OAAvC;AACA,MAAMC,oBAAoB,GAAG,CAA7B;AACA,MAAMC,gCAAgC,GAAG,IAAzC;AACA,MAAMC,gCAAgC,GAAG,GAAzC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,+BAAT,OASH;AAAA,MAT6C;AAChDC,IAAAA,eADgD;AAEhDC,IAAAA,eAFgD;AAGhDC,IAAAA,QAHgD;AAIhDC,IAAAA,oBAAoB,GAAGR,8BAJyB;AAKhDS,IAAAA,oBAAoB,GAAGV,8BALyB;AAMhDW,IAAAA,WAA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J,IAAAA,KAAK,EAAE0B,WADD;AAEN3B,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASU,gBAAT,CAA2BT,KAA3B,EAA+C;AAAA,MAAb4B,MAAa,uEAAJ,CAAI;AACrD,SAAOC,MAAM,CAACb,QAAP,CAAiBhB,KAAjB,IACJ2B,UAAU,CAAE3B,KAAK,CAAC8B,OAAN,CAAeF,MAAf,CAAF,CADN,GAEJG,SAFH;AAGA","sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n// Defaults.\nconst DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';\nconst DEFAULT_MINIMUM_VIEWPORT_WIDTH = '768px';\nconst DEFAULT_SCALE_FACTOR = 1;\nconst DEFAULT_MINIMUM_FONT_SIZE_FACTOR = 0.75;\nconst DEFAULT_MAXIMUM_FONT_SIZE_FACTOR = 1.5;\n\n/**\n * Computes a fluid font-size value that uses clamp(). A minimum and maxinmum\n * font size OR a single font size can be specified.\n *\n * If a single font size is specified, it is scaled up and down by\n * minimumFontSizeFactor and maximumFontSizeFactor to arrive at the minimum and\n * maximum sizes.\n *\n * @example\n * ```js\n * // Calculate fluid font-size value from a minimum and maximum value.\n * const fontSize = getComputedFluidTypographyValue( {\n * minimumFontSize: '20px',\n * maximumFontSize: '45px'\n * } );\n * // Calculate fluid font-size value from a single font size.\n * const fontSize = getComputedFluidTypographyValue( {\n * fontSize: '30px',\n * } );\n * ```\n *\n * @param {Object} args\n * @param {?string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.\n * @param {?string} args.maximumViewPortWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.\n * @param {string|number} [args.fontSize] Size to derive maximumFontSize and minimumFontSize from, if necessary. Optional if minimumFontSize and maximumFontSize are specified.\n * @param {?string} args.maximumFontSize Maximum font size for any clamp() calculation. Optional.\n * @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.\n * @param {?number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.\n * @param {?number} args.minimumFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.\n * @param {?number} args.maximumFontSizeFactor How much to scale defaultFontSize by to derive maximumFontSize. Optional.\n *\n * @return {string|null} A font-size value using clamp().\n */\nexport function getComputedFluidTypographyValue( {\n\tminimumFontSize,\n\tmaximumFontSize,\n\tfontSize,\n\tminimumViewPortWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,\n\tmaximumViewPortWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,\n\tscaleFactor = DEFAULT_SCALE_FACTOR,\n\tminimumFontSizeFactor = DEFAULT_MINIMUM_FONT_SIZE_FACTOR,\n\tmaximumFontSizeFactor = DEFAULT_MAXIMUM_FONT_SIZE_FACTOR,\n} ) {\n\t// Calculate missing minimumFontSize and maximumFontSize from\n\t// defaultFontSize if provided.\n\tif ( fontSize && ( ! minimumFontSize || ! maximumFontSize ) ) {\n\t\t// Parse default font size.\n\t\tconst fontSizeParsed = getTypographyValueAndUnit( fontSize );\n\n\t\t// Protect against invalid units.\n\t\tif ( ! fontSizeParsed?.unit ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// If no minimumFontSize is provided, derive using min scale factor.\n\t\tif ( ! minimumFontSize ) {\n\t\t\tminimumFontSize =\n\t\t\t\tfontSizeParsed.value * minimumFontSizeFactor +\n\t\t\t\tfontSizeParsed.unit;\n\t\t}\n\n\t\t// If no maximumFontSize is provided, derive using max scale factor.\n\t\tif ( ! maximumFontSize ) {\n\t\t\tmaximumFontSize =\n\t\t\t\tfontSizeParsed.value * maximumFontSizeFactor +\n\t\t\t\tfontSizeParsed.unit;\n\t\t}\n\t}\n\n\t// Return early if one of the provided inputs is not provided.\n\tif ( ! minimumFontSize || ! maximumFontSize ) {\n\t\treturn null;\n\t}\n\n\t// Grab the minimum font size and normalize it in order to use the value for calculations.\n\tconst minimumFontSizeParsed = getTypographyValueAndUnit( minimumFontSize );\n\n\t// We get a 'preferred' unit to keep units consistent when calculating,\n\t// otherwise the result will not be accurate.\n\tconst fontSizeUnit = minimumFontSizeParsed?.unit || 'rem';\n\n\t// Grab the maximum font size and normalize it in order to use the value for calculations.\n\tconst maximumFontSizeParsed = getTypographyValueAndUnit( maximumFontSize, {\n\t\tcoerceTo: fontSizeUnit,\n\t} );\n\n\t// Protect against unsupported units.\n\tif ( ! minimumFontSizeParsed || ! maximumFontSizeParsed ) {\n\t\treturn null;\n\t}\n\n\t// Use rem for accessible fluid target font scaling.\n\tconst minimumFontSizeRem = getTypographyValueAndUnit( minimumFontSize, {\n\t\tcoerceTo: 'rem',\n\t} );\n\n\t// Viewport widths defined for fluid typography. Normalize units\n\tconst maximumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tmaximumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\tconst minumumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tminimumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\n\t// Protect against unsupported units.\n\tif (\n\t\t! maximumViewPortWidthParsed ||\n\t\t! minumumViewPortWidthParsed ||\n\t\t! minimumFontSizeRem\n\t) {\n\t\treturn null;\n\t}\n\n\t// Build CSS rule.\n\t// Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.\n\tconst minViewPortWidthOffsetValue = roundToPrecision(\n\t\tminumumViewPortWidthParsed.value / 100,\n\t\t3\n\t);\n\n\tconst viewPortWidthOffset = minViewPortWidthOffsetValue + fontSizeUnit;\n\tlet linearFactor =\n\t\t100 *\n\t\t( ( maximumFontSizeParsed.value - minimumFontSizeParsed.value ) /\n\t\t\t( maximumViewPortWidthParsed.value -\n\t\t\t\tminumumViewPortWidthParsed.value ) );\n\tlinearFactor = roundToPrecision( linearFactor, 3 ) || 1;\n\tconst linearFactorScaled = linearFactor * scaleFactor;\n\tconst fluidTargetFontSize = `${ minimumFontSizeRem.value }${ minimumFontSizeRem.unit } + ((1vw - ${ viewPortWidthOffset }) * ${ linearFactorScaled })`;\n\n\treturn `clamp(${ minimumFontSize }, ${ fluidTargetFontSize }, ${ maximumFontSize })`;\n}\n\n/**\n * Internal method that checks a string for a unit and value and returns an array consisting of `'value'` and `'unit'`, e.g., [ '42', 'rem' ].\n * A raw font size of `value + unit` is expected. If the value is an integer, it will convert to `value + 'px'`.\n *\n * @param {string|number} rawValue Raw size value from theme.json.\n * @param {Object|undefined} options Calculation options.\n *\n * @return {{ unit: string, value: number }|null} An object consisting of `'value'` and `'unit'` properties.\n */\nexport function getTypographyValueAndUnit( rawValue, options = {} ) {\n\tif ( typeof rawValue !== 'string' && typeof rawValue !== 'number' ) {\n\t\treturn null;\n\t}\n\n\t// Converts numeric values to pixel values by default.\n\tif ( isFinite( rawValue ) ) {\n\t\trawValue = `${ rawValue }px`;\n\t}\n\n\tconst { coerceTo, rootSizeValue, acceptableUnits } = {\n\t\tcoerceTo: '',\n\t\t// Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( \"html\" ) ).fontSize`.\n\t\trootSizeValue: 16,\n\t\tacceptableUnits: [ 'rem', 'px', 'em' ],\n\t\t...options,\n\t};\n\n\tconst acceptableUnitsGroup = acceptableUnits?.join( '|' );\n\tconst regexUnits = new RegExp(\n\t\t`^(\\\\d*\\\\.?\\\\d+)(${ acceptableUnitsGroup }){1,1}$`\n\t);\n\n\tconst matches = rawValue.match( regexUnits );\n\n\t// We need a number value and a unit.\n\tif ( ! matches || matches.length < 3 ) {\n\t\treturn null;\n\t}\n\n\tlet [ , value, unit ] = matches;\n\n\tlet returnValue = parseFloat( value );\n\n\tif ( 'px' === coerceTo && ( 'em' === unit || 'rem' === unit ) ) {\n\t\treturnValue = returnValue * rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\tif ( 'px' === unit && ( 'em' === coerceTo || 'rem' === coerceTo ) ) {\n\t\treturnValue = returnValue / rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\treturn {\n\t\tvalue: returnValue,\n\t\tunit,\n\t};\n}\n\n/**\n * Returns a value rounded to defined precision.\n * Returns `undefined` if the value is not a valid finite number.\n *\n * @param {number} value Raw value.\n * @param {number} digits The number of digits to appear after the decimal point\n *\n * @return {number|undefined} Value rounded to standard precision.\n */\nexport function roundToPrecision( value, digits = 3 ) {\n\treturn Number.isFinite( value )\n\t\t? parseFloat( value.toFixed( digits ) )\n\t\t: undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/font-sizes/fluid-utils.js"],"names":["DEFAULT_MAXIMUM_VIEWPORT_WIDTH","DEFAULT_MINIMUM_VIEWPORT_WIDTH","DEFAULT_SCALE_FACTOR","DEFAULT_MINIMUM_FONT_SIZE_FACTOR","DEFAULT_MINIMUM_FONT_SIZE_LIMIT","getComputedFluidTypographyValue","minimumFontSize","maximumFontSize","fontSize","minimumViewPortWidth","maximumViewPortWidth","scaleFactor","minimumFontSizeFactor","minimumFontSizeLimit","fontSizeParsed","getTypographyValueAndUnit","unit","minimumFontSizeLimitParsed","coerceTo","value","calculatedMinimumFontSize","roundToPrecision","minimumFontSizeParsed","fontSizeUnit","maximumFontSizeParsed","minimumFontSizeRem","maximumViewPortWidthParsed","minumumViewPortWidthParsed","minViewPortWidthOffsetValue","viewPortWidthOffset","linearFactor","linearFactorScaled","fluidTargetFontSize","rawValue","options","isFinite","rootSizeValue","acceptableUnits","acceptableUnitsGroup","join","regexUnits","RegExp","matches","match","length","returnValue","parseFloat","digits","base","Math","pow","Number","round","undefined"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA;AACA,MAAMA,8BAA8B,GAAG,QAAvC;AACA,MAAMC,8BAA8B,GAAG,OAAvC;AACA,MAAMC,oBAAoB,GAAG,CAA7B;AACA,MAAMC,gCAAgC,GAAG,IAAzC;AACA,MAAMC,+BAA+B,GAAG,MAA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IAAI,GAAGE,QAAP;AACA;;AAED,SAAO;AACNC,IAAAA,KAAK,EAAEE,gBAAgB,CAAEwB,WAAF,EAAe,CAAf,CADjB;AAEN7B,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,gBAAT,CAA2BF,KAA3B,EAA+C;AAAA,MAAb4B,MAAa,uEAAJ,CAAI;AACrD,QAAMC,IAAI,GAAGC,IAAI,CAACC,GAAL,CAAU,EAAV,EAAcH,MAAd,CAAb;AACA,SAAOI,MAAM,CAAChB,QAAP,CAAiBhB,KAAjB,IACJ2B,UAAU,CAAEG,IAAI,CAACG,KAAL,CAAYjC,KAAK,GAAG6B,IAApB,IAA6BA,IAA/B,CADN,GAEJK,SAFH;AAGA","sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n// Defaults.\nconst DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';\nconst DEFAULT_MINIMUM_VIEWPORT_WIDTH = '768px';\nconst DEFAULT_SCALE_FACTOR = 1;\nconst DEFAULT_MINIMUM_FONT_SIZE_FACTOR = 0.75;\nconst DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';\n\n/**\n * Computes a fluid font-size value that uses clamp(). A minimum and maxinmum\n * font size OR a single font size can be specified.\n *\n * If a single font size is specified, it is scaled up and down by\n * minimumFontSizeFactor and maximumFontSizeFactor to arrive at the minimum and\n * maximum sizes.\n *\n * @example\n * ```js\n * // Calculate fluid font-size value from a minimum and maximum value.\n * const fontSize = getComputedFluidTypographyValue( {\n * minimumFontSize: '20px',\n * maximumFontSize: '45px'\n * } );\n * // Calculate fluid font-size value from a single font size.\n * const fontSize = getComputedFluidTypographyValue( {\n * fontSize: '30px',\n * } );\n * ```\n *\n * @param {Object} args\n * @param {?string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.\n * @param {?string} args.maximumViewPortWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.\n * @param {string|number} [args.fontSize] Size to derive maximumFontSize and minimumFontSize from, if necessary. Optional if minimumFontSize and maximumFontSize are specified.\n * @param {?string} args.maximumFontSize Maximum font size for any clamp() calculation. Optional.\n * @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.\n * @param {?number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.\n * @param {?number} args.minimumFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.\n *\n * @return {string|null} A font-size value using clamp().\n */\nexport function getComputedFluidTypographyValue( {\n\tminimumFontSize,\n\tmaximumFontSize,\n\tfontSize,\n\tminimumViewPortWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,\n\tmaximumViewPortWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,\n\tscaleFactor = DEFAULT_SCALE_FACTOR,\n\tminimumFontSizeFactor = DEFAULT_MINIMUM_FONT_SIZE_FACTOR,\n\tminimumFontSizeLimit = DEFAULT_MINIMUM_FONT_SIZE_LIMIT,\n} ) {\n\t/*\n\t * Calculates missing minimumFontSize and maximumFontSize from\n\t * defaultFontSize if provided.\n\t */\n\tif ( fontSize ) {\n\t\t// Parses default font size.\n\t\tconst fontSizeParsed = getTypographyValueAndUnit( fontSize );\n\n\t\t// Protect against invalid units.\n\t\tif ( ! fontSizeParsed?.unit ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Parses the minimum font size limit, so we can perform checks using it.\n\t\tconst minimumFontSizeLimitParsed = getTypographyValueAndUnit(\n\t\t\tminimumFontSizeLimit,\n\t\t\t{\n\t\t\t\tcoerceTo: fontSizeParsed.unit,\n\t\t\t}\n\t\t);\n\n\t\t// Don't enforce minimum font size if a font size has explicitly set a min and max value.\n\t\tif (\n\t\t\t!! minimumFontSizeLimitParsed?.value &&\n\t\t\t! minimumFontSize &&\n\t\t\t! maximumFontSize\n\t\t) {\n\t\t\t/*\n\t\t\t * If a minimum size was not passed to this function\n\t\t\t * and the user-defined font size is lower than $minimum_font_size_limit,\n\t\t\t * do not calculate a fluid value.\n\t\t\t */\n\t\t\tif ( fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\t// If no fluid max font size is available use the incoming value.\n\t\tif ( ! maximumFontSize ) {\n\t\t\tmaximumFontSize = `${ fontSizeParsed.value }${ fontSizeParsed.unit }`;\n\t\t}\n\n\t\t/*\n\t\t * If no minimumFontSize is provided, create one using\n\t\t * the given font size multiplied by the min font size scale factor.\n\t\t */\n\t\tif ( ! minimumFontSize ) {\n\t\t\tconst calculatedMinimumFontSize = roundToPrecision(\n\t\t\t\tfontSizeParsed.value * minimumFontSizeFactor,\n\t\t\t\t3\n\t\t\t);\n\n\t\t\t// Only use calculated min font size if it's > $minimum_font_size_limit value.\n\t\t\tif (\n\t\t\t\t!! minimumFontSizeLimitParsed?.value &&\n\t\t\t\tcalculatedMinimumFontSize < minimumFontSizeLimitParsed?.value\n\t\t\t) {\n\t\t\t\tminimumFontSize = `${ minimumFontSizeLimitParsed.value }${ minimumFontSizeLimitParsed.unit }`;\n\t\t\t} else {\n\t\t\t\tminimumFontSize = `${ calculatedMinimumFontSize }${ fontSizeParsed.unit }`;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Grab the minimum font size and normalize it in order to use the value for calculations.\n\tconst minimumFontSizeParsed = getTypographyValueAndUnit( minimumFontSize );\n\n\t// We get a 'preferred' unit to keep units consistent when calculating,\n\t// otherwise the result will not be accurate.\n\tconst fontSizeUnit = minimumFontSizeParsed?.unit || 'rem';\n\n\t// Grabs the maximum font size and normalize it in order to use the value for calculations.\n\tconst maximumFontSizeParsed = getTypographyValueAndUnit( maximumFontSize, {\n\t\tcoerceTo: fontSizeUnit,\n\t} );\n\n\t// Checks for mandatory min and max sizes, and protects against unsupported units.\n\tif ( ! minimumFontSizeParsed || ! maximumFontSizeParsed ) {\n\t\treturn null;\n\t}\n\n\t// Uses rem for accessible fluid target font scaling.\n\tconst minimumFontSizeRem = getTypographyValueAndUnit( minimumFontSize, {\n\t\tcoerceTo: 'rem',\n\t} );\n\n\t// Viewport widths defined for fluid typography. Normalize units\n\tconst maximumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tmaximumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\tconst minumumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tminimumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\n\t// Protect against unsupported units.\n\tif (\n\t\t! maximumViewPortWidthParsed ||\n\t\t! minumumViewPortWidthParsed ||\n\t\t! minimumFontSizeRem\n\t) {\n\t\treturn null;\n\t}\n\n\t// Build CSS rule.\n\t// Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.\n\tconst minViewPortWidthOffsetValue = roundToPrecision(\n\t\tminumumViewPortWidthParsed.value / 100,\n\t\t3\n\t);\n\n\tconst viewPortWidthOffset =\n\t\troundToPrecision( minViewPortWidthOffsetValue, 3 ) + fontSizeUnit;\n\tconst linearFactor =\n\t\t100 *\n\t\t( ( maximumFontSizeParsed.value - minimumFontSizeParsed.value ) /\n\t\t\t( maximumViewPortWidthParsed.value -\n\t\t\t\tminumumViewPortWidthParsed.value ) );\n\tconst linearFactorScaled = roundToPrecision(\n\t\t( linearFactor || 1 ) * scaleFactor,\n\t\t3\n\t);\n\tconst fluidTargetFontSize = `${ minimumFontSizeRem.value }${ minimumFontSizeRem.unit } + ((1vw - ${ viewPortWidthOffset }) * ${ linearFactorScaled })`;\n\n\treturn `clamp(${ minimumFontSize }, ${ fluidTargetFontSize }, ${ maximumFontSize })`;\n}\n\n/**\n * Internal method that checks a string for a unit and value and returns an array consisting of `'value'` and `'unit'`, e.g., [ '42', 'rem' ].\n * A raw font size of `value + unit` is expected. If the value is an integer, it will convert to `value + 'px'`.\n *\n * @param {string|number} rawValue Raw size value from theme.json.\n * @param {Object|undefined} options Calculation options.\n *\n * @return {{ unit: string, value: number }|null} An object consisting of `'value'` and `'unit'` properties.\n */\nexport function getTypographyValueAndUnit( rawValue, options = {} ) {\n\tif ( typeof rawValue !== 'string' && typeof rawValue !== 'number' ) {\n\t\treturn null;\n\t}\n\n\t// Converts numeric values to pixel values by default.\n\tif ( isFinite( rawValue ) ) {\n\t\trawValue = `${ rawValue }px`;\n\t}\n\n\tconst { coerceTo, rootSizeValue, acceptableUnits } = {\n\t\tcoerceTo: '',\n\t\t// Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( \"html\" ) ).fontSize`.\n\t\trootSizeValue: 16,\n\t\tacceptableUnits: [ 'rem', 'px', 'em' ],\n\t\t...options,\n\t};\n\n\tconst acceptableUnitsGroup = acceptableUnits?.join( '|' );\n\tconst regexUnits = new RegExp(\n\t\t`^(\\\\d*\\\\.?\\\\d+)(${ acceptableUnitsGroup }){1,1}$`\n\t);\n\n\tconst matches = rawValue.match( regexUnits );\n\n\t// We need a number value and a unit.\n\tif ( ! matches || matches.length < 3 ) {\n\t\treturn null;\n\t}\n\n\tlet [ , value, unit ] = matches;\n\n\tlet returnValue = parseFloat( value );\n\n\tif ( 'px' === coerceTo && ( 'em' === unit || 'rem' === unit ) ) {\n\t\treturnValue = returnValue * rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\tif ( 'px' === unit && ( 'em' === coerceTo || 'rem' === coerceTo ) ) {\n\t\treturnValue = returnValue / rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\t/*\n\t * No calculation is required if swapping between em and rem yet,\n\t * since we assume a root size value. Later we might like to differentiate between\n\t * :root font size (rem) and parent element font size (em) relativity.\n\t */\n\tif (\n\t\t( 'em' === coerceTo || 'rem' === coerceTo ) &&\n\t\t( 'em' === unit || 'rem' === unit )\n\t) {\n\t\tunit = coerceTo;\n\t}\n\n\treturn {\n\t\tvalue: roundToPrecision( returnValue, 3 ),\n\t\tunit,\n\t};\n}\n\n/**\n * Returns a value rounded to defined precision.\n * Returns `undefined` if the value is not a valid finite number.\n *\n * @param {number} value Raw value.\n * @param {number} digits The number of digits to appear after the decimal point\n *\n * @return {number|undefined} Value rounded to standard precision.\n */\nexport function roundToPrecision( value, digits = 3 ) {\n\tconst base = Math.pow( 10, digits );\n\treturn Number.isFinite( value )\n\t\t? parseFloat( Math.round( value * base ) / base )\n\t\t: undefined;\n}\n"]}
|
|
@@ -128,6 +128,9 @@ const ForwardedInnerBlocks = forwardRef((props, ref) => {
|
|
|
128
128
|
export function useInnerBlocksProps() {
|
|
129
129
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
130
130
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
131
|
+
const {
|
|
132
|
+
__unstableDisableDropZone
|
|
133
|
+
} = options;
|
|
131
134
|
const {
|
|
132
135
|
clientId
|
|
133
136
|
} = useBlockEditContext();
|
|
@@ -153,9 +156,10 @@ export function useInnerBlocksProps() {
|
|
|
153
156
|
hasOverlay: blockName !== 'core/template' && !isBlockSelected(clientId) && !hasSelectedInnerBlock(clientId, true) && enableClickThrough
|
|
154
157
|
};
|
|
155
158
|
}, [clientId, isSmallScreen]);
|
|
156
|
-
const
|
|
159
|
+
const blockDropZoneRef = useBlockDropZone({
|
|
157
160
|
rootClientId: clientId
|
|
158
|
-
})
|
|
161
|
+
});
|
|
162
|
+
const ref = useMergeRefs([props.ref, __unstableDisableDropZone ? null : blockDropZoneRef]);
|
|
159
163
|
const innerBlocksProps = {
|
|
160
164
|
__experimentalCaptureToolbars,
|
|
161
165
|
...options
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"names":["classnames","useViewportMatch","useMergeRefs","forwardRef","useSelect","getBlockType","store","blocksStore","__unstableGetInnerBlocksProps","getInnerBlocksProps","ButtonBlockAppender","DefaultBlockAppender","useNestedSettingsUpdate","useInnerBlockTemplateSync","getBlockContext","BlockListItems","BlockContextProvider","useBlockEditContext","useBlockSync","blockEditorStore","useBlockDropZone","UncontrolledInnerBlocks","props","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","__experimentalLayout","context","select","block","getBlock","blockType","name","providesContext","attributes","ControlledInnerBlocks","ForwardedInnerBlocks","ref","innerBlocksProps","useInnerBlocksProps","options","isSmallScreen","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","hasBlockSupport","rootClientId","InnerBlocks","value","onChange","className","children","save","Content"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,YAA3B,QAA+C,oBAA/C;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,YADD,EAECC,KAAK,IAAIC,WAFV,EAGCC,6BAA6B,IAAIC,mBAHlC,QAIO,mBAJP;AAMA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,SAASC,cAAT,QAA+B,eAA/B;AACA,SAASC,oBAAT,QAAqC,kBAArC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,OAAOC,YAAP,MAAyB,4BAAzB;AACA,SAASZ,KAAK,IAAIa,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,gBAAP,MAA6B,wBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,uBAAT,CAAkCC,KAAlC,EAA0C;AACzC,QAAM;AACLC,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OAArB,GAA+B,MAAMlB,mBAAmB,CAACiB,IAApB,GAA2BD,QAAhE;AAEA;AACA;AACA;;;AACA,eAAenB,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockType,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport getBlockContext from './get-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\t__experimentalLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\t__experimentalLayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst context = useSelect(\n\t\t( select ) => {\n\t\t\tconst block = select( blockEditorStore ).getBlock( clientId );\n\n\t\t\t// This check is here to avoid the Redux zombie bug where a child subscription\n\t\t\t// is called before a parent, causing potential JS errors when the child has been removed.\n\t\t\tif ( ! block ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst blockType = getBlockType( block.name );\n\n\t\t\tif ( ! blockType || ! blockType.providesContext ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn getBlockContext( block.attributes, blockType );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t<BlockListItems\n\t\t\t\trootClientId={ clientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\t\t__experimentalLayout={ __experimentalLayout }\n\t\t\t\twrapperRef={ wrapperRef }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t</BlockContextProvider>\n\t);\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst { clientId } = useBlockEditContext();\n\tconst isSmallScreen = useViewportMatch( 'medium', '<' );\n\tconst { __experimentalCaptureToolbars, hasOverlay } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough =\n\t\t\t\t__unstableGetEditorMode() === 'navigation' || isSmallScreen;\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: select(\n\t\t\t\t\tblocksStore\n\t\t\t\t).hasBlockSupport(\n\t\t\t\t\tblockName,\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasOverlay:\n\t\t\t\t\tblockName !== 'core/template' &&\n\t\t\t\t\t! isBlockSelected( clientId ) &&\n\t\t\t\t\t! hasSelectedInnerBlock( clientId, true ) &&\n\t\t\t\t\tenableClickThrough,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSmallScreen ]\n\t);\n\n\tconst ref = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseBlockDropZone( {\n\t\t\trootClientId: clientId,\n\t\t} ),\n\t] );\n\n\tconst innerBlocksProps = {\n\t\t__experimentalCaptureToolbars,\n\t\t...options,\n\t};\n\tconst InnerBlocks =\n\t\tinnerBlocksProps.value && innerBlocksProps.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-list__layout',\n\t\t\t{\n\t\t\t\t'has-overlay': hasOverlay,\n\t\t\t}\n\t\t),\n\t\tchildren: clientId ? (\n\t\t\t<InnerBlocks { ...innerBlocksProps } clientId={ clientId } />\n\t\t) : (\n\t\t\t<BlockListItems { ...options } />\n\t\t),\n\t};\n}\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\n// Expose default appender placeholders as components.\nForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport default ForwardedInnerBlocks;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"names":["classnames","useViewportMatch","useMergeRefs","forwardRef","useSelect","getBlockType","store","blocksStore","__unstableGetInnerBlocksProps","getInnerBlocksProps","ButtonBlockAppender","DefaultBlockAppender","useNestedSettingsUpdate","useInnerBlockTemplateSync","getBlockContext","BlockListItems","BlockContextProvider","useBlockEditContext","useBlockSync","blockEditorStore","useBlockDropZone","UncontrolledInnerBlocks","props","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","__experimentalLayout","context","select","block","getBlock","blockType","name","providesContext","attributes","ControlledInnerBlocks","ForwardedInnerBlocks","ref","innerBlocksProps","useInnerBlocksProps","options","__unstableDisableDropZone","isSmallScreen","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","hasBlockSupport","blockDropZoneRef","rootClientId","InnerBlocks","value","onChange","className","children","save","Content"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,YAA3B,QAA+C,oBAA/C;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,YADD,EAECC,KAAK,IAAIC,WAFV,EAGCC,6BAA6B,IAAIC,mBAHlC,QAIO,mBAJP;AAMA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,SAASC,cAAT,QAA+B,eAA/B;AACA,SAASC,oBAAT,QAAqC,kBAArC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,OAAOC,YAAP,MAAyB,4BAAzB;AACA,SAASZ,KAAK,IAAIa,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,gBAAP,MAA6B,wBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,uBAAT,CAAkCC,KAAlC,EAA0C;AACzC,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,aAFK;AAGLC,IAAAA,0BAHK;AAILC,IAAAA,0BAJK;AAKLC,IAAAA,QALK;AAMLC,IAAAA,YANK;AAOLC,IAAAA,UAPK;AAQLC,IAAAA,8BARK;AASLC,IAAAA,6BAA6B,EAAEC,eAT1B;AAULC,IAAAA,6BAVK;AAWLC,IAAAA,cAXK;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ies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockType,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport getBlockContext from './get-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\t__experimentalLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\t__experimentalLayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst context = useSelect(\n\t\t( select ) => {\n\t\t\tconst block = select( blockEditorStore ).getBlock( clientId );\n\n\t\t\t// This check is here to avoid the Redux zombie bug where a child subscription\n\t\t\t// is called before a parent, causing potential JS errors when the child has been removed.\n\t\t\tif ( ! block ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst blockType = getBlockType( block.name );\n\n\t\t\tif ( ! blockType || ! blockType.providesContext ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn getBlockContext( block.attributes, blockType );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t<BlockListItems\n\t\t\t\trootClientId={ clientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\t\t__experimentalLayout={ __experimentalLayout }\n\t\t\t\twrapperRef={ wrapperRef }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t</BlockContextProvider>\n\t);\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst { __unstableDisableDropZone } = options;\n\tconst { clientId } = useBlockEditContext();\n\tconst isSmallScreen = useViewportMatch( 'medium', '<' );\n\tconst { __experimentalCaptureToolbars, hasOverlay } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough =\n\t\t\t\t__unstableGetEditorMode() === 'navigation' || isSmallScreen;\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: select(\n\t\t\t\t\tblocksStore\n\t\t\t\t).hasBlockSupport(\n\t\t\t\t\tblockName,\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasOverlay:\n\t\t\t\t\tblockName !== 'core/template' &&\n\t\t\t\t\t! isBlockSelected( clientId ) &&\n\t\t\t\t\t! hasSelectedInnerBlock( clientId, true ) &&\n\t\t\t\t\tenableClickThrough,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSmallScreen ]\n\t);\n\n\tconst blockDropZoneRef = useBlockDropZone( {\n\t\trootClientId: clientId,\n\t} );\n\n\tconst ref = useMergeRefs( [\n\t\tprops.ref,\n\t\t__unstableDisableDropZone ? null : blockDropZoneRef,\n\t] );\n\n\tconst innerBlocksProps = {\n\t\t__experimentalCaptureToolbars,\n\t\t...options,\n\t};\n\tconst InnerBlocks =\n\t\tinnerBlocksProps.value && innerBlocksProps.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-list__layout',\n\t\t\t{\n\t\t\t\t'has-overlay': hasOverlay,\n\t\t\t}\n\t\t),\n\t\tchildren: clientId ? (\n\t\t\t<InnerBlocks { ...innerBlocksProps } clientId={ clientId } />\n\t\t) : (\n\t\t\t<BlockListItems { ...options } />\n\t\t),\n\t};\n}\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\n// Expose default appender placeholders as components.\nForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport default ForwardedInnerBlocks;\n"]}
|
|
@@ -531,6 +531,14 @@
|
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
533
|
|
|
534
|
+
.block-editor-block-list__block-side-inserter-popover .components-popover__content > div {
|
|
535
|
+
pointer-events: none;
|
|
536
|
+
}
|
|
537
|
+
.block-editor-block-list__block-side-inserter-popover .components-popover__content > div > * {
|
|
538
|
+
pointer-events: all;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
.block-editor-block-list__empty-block-inserter .block-editor-inserter__toggle.components-button.has-icon,
|
|
534
542
|
.block-editor-default-block-appender .block-editor-inserter__toggle.components-button.has-icon,
|
|
535
543
|
.block-editor-block-list__insertion-point-inserter .block-editor-inserter__toggle.components-button.has-icon {
|
|
536
544
|
background: #1e1e1e;
|
|
@@ -540,6 +548,7 @@
|
|
|
540
548
|
min-width: 24px;
|
|
541
549
|
height: 24px;
|
|
542
550
|
}
|
|
551
|
+
.block-editor-block-list__empty-block-inserter .block-editor-inserter__toggle.components-button.has-icon:hover,
|
|
543
552
|
.block-editor-default-block-appender .block-editor-inserter__toggle.components-button.has-icon:hover,
|
|
544
553
|
.block-editor-block-list__insertion-point-inserter .block-editor-inserter__toggle.components-button.has-icon:hover {
|
|
545
554
|
color: #fff;
|
|
@@ -1119,7 +1128,7 @@
|
|
|
1119
1128
|
box-shadow: none;
|
|
1120
1129
|
overflow-y: visible;
|
|
1121
1130
|
}
|
|
1122
|
-
.components-popover.block-editor-block-popover:not(.block-editor-block-popover__inbetween) .components-popover__content * {
|
|
1131
|
+
.components-popover.block-editor-block-popover:not(.block-editor-block-popover__inbetween, .block-editor-block-list__block-side-inserter-popover) .components-popover__content * {
|
|
1123
1132
|
pointer-events: all;
|
|
1124
1133
|
}
|
|
1125
1134
|
|
|
@@ -1851,12 +1860,14 @@
|
|
|
1851
1860
|
display: none;
|
|
1852
1861
|
}
|
|
1853
1862
|
|
|
1863
|
+
.block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter,
|
|
1854
1864
|
.block-editor-default-block-appender .block-editor-inserter {
|
|
1855
1865
|
position: absolute;
|
|
1856
1866
|
top: 0;
|
|
1857
1867
|
left: 0;
|
|
1858
1868
|
line-height: 0;
|
|
1859
1869
|
}
|
|
1870
|
+
.block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter:disabled,
|
|
1860
1871
|
.block-editor-default-block-appender .block-editor-inserter:disabled {
|
|
1861
1872
|
display: none;
|
|
1862
1873
|
}
|
package/build-style/style.css
CHANGED
|
@@ -531,6 +531,14 @@
|
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
533
|
|
|
534
|
+
.block-editor-block-list__block-side-inserter-popover .components-popover__content > div {
|
|
535
|
+
pointer-events: none;
|
|
536
|
+
}
|
|
537
|
+
.block-editor-block-list__block-side-inserter-popover .components-popover__content > div > * {
|
|
538
|
+
pointer-events: all;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
.block-editor-block-list__empty-block-inserter .block-editor-inserter__toggle.components-button.has-icon,
|
|
534
542
|
.block-editor-default-block-appender .block-editor-inserter__toggle.components-button.has-icon,
|
|
535
543
|
.block-editor-block-list__insertion-point-inserter .block-editor-inserter__toggle.components-button.has-icon {
|
|
536
544
|
background: #1e1e1e;
|
|
@@ -540,6 +548,7 @@
|
|
|
540
548
|
min-width: 24px;
|
|
541
549
|
height: 24px;
|
|
542
550
|
}
|
|
551
|
+
.block-editor-block-list__empty-block-inserter .block-editor-inserter__toggle.components-button.has-icon:hover,
|
|
543
552
|
.block-editor-default-block-appender .block-editor-inserter__toggle.components-button.has-icon:hover,
|
|
544
553
|
.block-editor-block-list__insertion-point-inserter .block-editor-inserter__toggle.components-button.has-icon:hover {
|
|
545
554
|
color: #fff;
|
|
@@ -1119,7 +1128,7 @@
|
|
|
1119
1128
|
box-shadow: none;
|
|
1120
1129
|
overflow-y: visible;
|
|
1121
1130
|
}
|
|
1122
|
-
.components-popover.block-editor-block-popover:not(.block-editor-block-popover__inbetween) .components-popover__content * {
|
|
1131
|
+
.components-popover.block-editor-block-popover:not(.block-editor-block-popover__inbetween, .block-editor-block-list__block-side-inserter-popover) .components-popover__content * {
|
|
1123
1132
|
pointer-events: all;
|
|
1124
1133
|
}
|
|
1125
1134
|
|
|
@@ -1851,12 +1860,14 @@
|
|
|
1851
1860
|
display: none;
|
|
1852
1861
|
}
|
|
1853
1862
|
|
|
1863
|
+
.block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter,
|
|
1854
1864
|
.block-editor-default-block-appender .block-editor-inserter {
|
|
1855
1865
|
position: absolute;
|
|
1856
1866
|
top: 0;
|
|
1857
1867
|
right: 0;
|
|
1858
1868
|
line-height: 0;
|
|
1859
1869
|
}
|
|
1870
|
+
.block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter:disabled,
|
|
1860
1871
|
.block-editor-default-block-appender .block-editor-inserter:disabled {
|
|
1861
1872
|
display: none;
|
|
1862
1873
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.10",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@wordpress/api-fetch": "^6.14.1",
|
|
38
38
|
"@wordpress/blob": "^3.17.1",
|
|
39
39
|
"@wordpress/blocks": "^11.16.4",
|
|
40
|
-
"@wordpress/components": "^21.0.
|
|
40
|
+
"@wordpress/components": "^21.0.7",
|
|
41
41
|
"@wordpress/compose": "^5.15.2",
|
|
42
42
|
"@wordpress/data": "^7.1.3",
|
|
43
43
|
"@wordpress/date": "^4.17.1",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "6566f5fe9ece6ad5ae550349d3b1f0944a011040"
|
|
82
82
|
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Enable pointer events for the toolbar's content.
|
|
24
|
-
&:not(.block-editor-block-popover__inbetween) .components-popover__content {
|
|
24
|
+
&:not(.block-editor-block-popover__inbetween, .block-editor-block-list__block-side-inserter-popover) .components-popover__content {
|
|
25
25
|
* {
|
|
26
26
|
pointer-events: all;
|
|
27
27
|
}
|
|
@@ -21,6 +21,7 @@ import BlockContextualToolbar from './block-contextual-toolbar';
|
|
|
21
21
|
import { store as blockEditorStore } from '../../store';
|
|
22
22
|
import BlockPopover from '../block-popover';
|
|
23
23
|
import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
|
|
24
|
+
import Inserter from '../inserter';
|
|
24
25
|
|
|
25
26
|
function selector( select ) {
|
|
26
27
|
const {
|
|
@@ -120,45 +121,85 @@ function SelectedBlockPopover( {
|
|
|
120
121
|
clientId,
|
|
121
122
|
} );
|
|
122
123
|
|
|
123
|
-
if (
|
|
124
|
+
if (
|
|
125
|
+
! shouldShowBreadcrumb &&
|
|
126
|
+
! shouldShowContextualToolbar &&
|
|
127
|
+
! showEmptyBlockSideInserter
|
|
128
|
+
) {
|
|
124
129
|
return null;
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
return (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
133
|
+
<>
|
|
134
|
+
{ showEmptyBlockSideInserter && (
|
|
135
|
+
<BlockPopover
|
|
136
|
+
clientId={ capturingClientId || clientId }
|
|
137
|
+
__unstableCoverTarget
|
|
138
|
+
bottomClientId={ lastClientId }
|
|
139
|
+
className={ classnames(
|
|
140
|
+
'block-editor-block-list__block-side-inserter-popover',
|
|
141
|
+
{
|
|
142
|
+
'is-insertion-point-visible':
|
|
143
|
+
isInsertionPointVisible,
|
|
144
|
+
}
|
|
145
|
+
) }
|
|
146
|
+
__unstablePopoverSlot={ __unstablePopoverSlot }
|
|
147
|
+
__unstableContentRef={ __unstableContentRef }
|
|
148
|
+
resize={ false }
|
|
149
|
+
shift={ false }
|
|
150
|
+
{ ...popoverProps }
|
|
151
|
+
>
|
|
152
|
+
<div className="block-editor-block-list__empty-block-inserter">
|
|
153
|
+
<Inserter
|
|
154
|
+
position="bottom right"
|
|
155
|
+
rootClientId={ rootClientId }
|
|
156
|
+
clientId={ clientId }
|
|
157
|
+
__experimentalIsQuick
|
|
158
|
+
/>
|
|
159
|
+
</div>
|
|
160
|
+
</BlockPopover>
|
|
154
161
|
) }
|
|
155
|
-
{ shouldShowBreadcrumb && (
|
|
156
|
-
<
|
|
157
|
-
clientId={ clientId }
|
|
158
|
-
|
|
159
|
-
|
|
162
|
+
{ ( shouldShowBreadcrumb || shouldShowContextualToolbar ) && (
|
|
163
|
+
<BlockPopover
|
|
164
|
+
clientId={ capturingClientId || clientId }
|
|
165
|
+
bottomClientId={ lastClientId }
|
|
166
|
+
className={ classnames(
|
|
167
|
+
'block-editor-block-list__block-popover',
|
|
168
|
+
{
|
|
169
|
+
'is-insertion-point-visible':
|
|
170
|
+
isInsertionPointVisible,
|
|
171
|
+
}
|
|
172
|
+
) }
|
|
173
|
+
__unstablePopoverSlot={ __unstablePopoverSlot }
|
|
174
|
+
__unstableContentRef={ __unstableContentRef }
|
|
175
|
+
resize={ false }
|
|
176
|
+
{ ...popoverProps }
|
|
177
|
+
>
|
|
178
|
+
{ shouldShowContextualToolbar && (
|
|
179
|
+
<BlockContextualToolbar
|
|
180
|
+
// If the toolbar is being shown because of being forced
|
|
181
|
+
// it should focus the toolbar right after the mount.
|
|
182
|
+
focusOnMount={ isToolbarForced.current }
|
|
183
|
+
__experimentalInitialIndex={
|
|
184
|
+
initialToolbarItemIndexRef.current
|
|
185
|
+
}
|
|
186
|
+
__experimentalOnIndexChange={ ( index ) => {
|
|
187
|
+
initialToolbarItemIndexRef.current = index;
|
|
188
|
+
} }
|
|
189
|
+
// Resets the index whenever the active block changes so
|
|
190
|
+
// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
|
|
191
|
+
key={ clientId }
|
|
192
|
+
/>
|
|
193
|
+
) }
|
|
194
|
+
{ shouldShowBreadcrumb && (
|
|
195
|
+
<BlockSelectionButton
|
|
196
|
+
clientId={ clientId }
|
|
197
|
+
rootClientId={ rootClientId }
|
|
198
|
+
/>
|
|
199
|
+
) }
|
|
200
|
+
</BlockPopover>
|
|
160
201
|
) }
|
|
161
|
-
|
|
202
|
+
</>
|
|
162
203
|
);
|
|
163
204
|
}
|
|
164
205
|
|
|
@@ -42,7 +42,16 @@
|
|
|
42
42
|
left: calc(50% - #{$button-size-small * 0.5});
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
.block-editor-block-list__block-side-inserter-popover .components-popover__content > div {
|
|
46
|
+
pointer-events: none;
|
|
47
|
+
|
|
48
|
+
> * {
|
|
49
|
+
pointer-events: all;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
45
53
|
// Sibling inserter / "inbetweenserter".
|
|
54
|
+
.block-editor-block-list__empty-block-inserter,
|
|
46
55
|
.block-editor-default-block-appender,
|
|
47
56
|
.block-editor-block-list__insertion-point-inserter {
|
|
48
57
|
.block-editor-inserter__toggle.components-button.has-icon {
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
|
|
35
35
|
// The black plus that shows up on the right side of an empty paragraph block, or the initial appender
|
|
36
36
|
// that exists only on empty documents.
|
|
37
|
+
.block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter,
|
|
37
38
|
.block-editor-default-block-appender .block-editor-inserter {
|
|
38
39
|
position: absolute;
|
|
39
40
|
top: 0;
|