@wordpress/block-editor 12.3.10 → 12.3.12
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/build/components/block-list/index.js +2 -4
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +4 -2
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/editor-styles/index.js +2 -2
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/global-styles/hooks.js +2 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +6 -2
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter-list-item/index.js +1 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +6 -1
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/rich-text/format-edit.js +57 -28
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +11 -18
- package/build/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +2 -2
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build-module/components/block-list/index.js +2 -3
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +4 -2
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/editor-styles/index.js +2 -2
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +2 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +7 -3
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +1 -1
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +6 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +51 -26
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +13 -18
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +2 -2
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-style/style-rtl.css +9 -1
- package/build-style/style.css +9 -1
- package/package.json +6 -6
- package/src/components/block-list/index.js +3 -6
- package/src/components/block-tools/block-contextual-toolbar.js +43 -35
- package/src/components/block-tools/style.scss +12 -3
- package/src/components/editor-styles/index.js +2 -2
- package/src/components/global-styles/hooks.js +2 -1
- package/src/components/inserter/hooks/use-block-types-state.js +15 -6
- package/src/components/inserter-list-item/index.js +3 -1
- package/src/components/list-view/use-list-view-drop-zone.js +5 -1
- package/src/components/rich-text/format-edit.js +62 -38
- package/src/components/rich-text/get-rich-text-values.js +22 -28
- package/src/components/spacing-sizes-control/test/utils.js +9 -1
- package/src/components/spacing-sizes-control/utils.js +2 -2
- package/src/private-apis.js +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/get-rich-text-values.js"],"names":["RawHTML","StrictMode","Fragment","getSaveElement","__unstableGetBlockProps","getBlockProps","InnerBlocks","Content","addValuesForElement","element","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/get-rich-text-values.js"],"names":["RawHTML","StrictMode","Fragment","getSaveElement","__unstableGetBlockProps","getBlockProps","InnerBlocks","Content","addValuesForElement","element","values","innerBlocks","undefined","Array","isArray","addValuesForElements","type","props","children","addValuesForBlocks","push","value","el","prototype","render","args","i","length","blocks","name","attributes","saveElement","getRichTextValues","skipFilters"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,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M,GAAG,EAAf;AACAS,EAAAA,kBAAkB,CAAET,MAAF,EAAUkB,MAAV,CAAlB;AACAvB,EAAAA,aAAa,CAAC4B,WAAd,GAA4B,KAA5B;AACA,SAAOvB,MAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { RawHTML, StrictMode, Fragment } from '@wordpress/element';\nimport {\n\tgetSaveElement,\n\t__unstableGetBlockProps as getBlockProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport InnerBlocks from '../inner-blocks';\nimport { Content } from './content';\n\n/*\n * This function is similar to `@wordpress/element`'s `renderToString` function,\n * except that it does not render the elements to a string, but instead collects\n * the values of all rich text `Content` elements.\n */\nfunction addValuesForElement( element, values, innerBlocks ) {\n\tif ( null === element || undefined === element || false === element ) {\n\t\treturn;\n\t}\n\n\tif ( Array.isArray( element ) ) {\n\t\treturn addValuesForElements( element, values, innerBlocks );\n\t}\n\n\tswitch ( typeof element ) {\n\t\tcase 'string':\n\t\tcase 'number':\n\t\t\treturn;\n\t}\n\n\tconst { type, props } = element;\n\n\tswitch ( type ) {\n\t\tcase StrictMode:\n\t\tcase Fragment:\n\t\t\treturn addValuesForElements( props.children, values, innerBlocks );\n\t\tcase RawHTML:\n\t\t\treturn;\n\t\tcase InnerBlocks.Content:\n\t\t\treturn addValuesForBlocks( values, innerBlocks );\n\t\tcase Content:\n\t\t\tvalues.push( props.value );\n\t\t\treturn;\n\t}\n\n\tswitch ( typeof type ) {\n\t\tcase 'string':\n\t\t\tif ( typeof props.children !== 'undefined' ) {\n\t\t\t\treturn addValuesForElements(\n\t\t\t\t\tprops.children,\n\t\t\t\t\tvalues,\n\t\t\t\t\tinnerBlocks\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\tcase 'function':\n\t\t\tconst el =\n\t\t\t\ttype.prototype && typeof type.prototype.render === 'function'\n\t\t\t\t\t? new type( props ).render()\n\t\t\t\t\t: type( props );\n\t\t\treturn addValuesForElement( el, values, innerBlocks );\n\t}\n}\n\nfunction addValuesForElements( children, ...args ) {\n\tchildren = Array.isArray( children ) ? children : [ children ];\n\n\tfor ( let i = 0; i < children.length; i++ ) {\n\t\taddValuesForElement( children[ i ], ...args );\n\t}\n}\n\nfunction addValuesForBlocks( values, blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tconst { name, attributes, innerBlocks } = blocks[ i ];\n\t\tconst saveElement = getSaveElement(\n\t\t\tname,\n\t\t\tattributes,\n\t\t\t// Instead of letting save elements use `useInnerBlocksProps.save`,\n\t\t\t// force them to use InnerBlocks.Content instead so we can intercept\n\t\t\t// a single component.\n\t\t\t<InnerBlocks.Content />\n\t\t);\n\t\taddValuesForElement( saveElement, values, innerBlocks );\n\t}\n}\n\nexport function getRichTextValues( blocks = [] ) {\n\tgetBlockProps.skipFilters = true;\n\tconst values = [];\n\taddValuesForBlocks( values, blocks );\n\tgetBlockProps.skipFilters = false;\n\treturn values;\n}\n"]}
|
|
@@ -85,8 +85,8 @@ export function getCustomValueFromPreset(value, spacingSizes) {
|
|
|
85
85
|
*/
|
|
86
86
|
|
|
87
87
|
export function getPresetValueFromCustomValue(value, spacingSizes) {
|
|
88
|
-
// Return value as-is if it is already a preset;
|
|
89
|
-
if (isValueSpacingPreset(value) || value === '0') {
|
|
88
|
+
// Return value as-is if it is undefined or is already a preset, or '0';
|
|
89
|
+
if (!value || isValueSpacingPreset(value) || value === '0') {
|
|
90
90
|
return value;
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/utils.js"],"names":["__","sidesAll","sidesAxial","sidesBottom","sidesHorizontal","sidesLeft","sidesRight","sidesTop","sidesVertical","ALL_SIDES","DEFAULT_VALUES","top","undefined","right","bottom","left","ICONS","custom","axial","horizontal","vertical","LABELS","default","mixed","VIEWS","isValueSpacingPreset","value","includes","getCustomValueFromPreset","spacingSizes","slug","getSpacingPresetSlug","spacingSize","find","size","String","getPresetValueFromCustomValue","spacingMatch","getSpacingPresetCssVar","match","getSliderValueFromPreset","presetValue","parseFloat","sliderValue","findIndex","NaN","mode","arr","sort","a","b","filter","v","length","pop","getAllRawValue","values","Object","isValuesMixed","sides","Set","isValuesDefined","hasAxisSupport","axis","hasHorizontalSupport","hasVerticalSupport","getSupportedMenuItems","menuItems","label","icon","numberOfIndividualSides","forEach","side","hasBalancedSidesSupport","counts","getInitialView","sideValues","Boolean","hasMatchingAxialValues","hasNoValuesAndBalancedSides","entries","some","key"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SACCC,QADD,EAECC,UAFD,EAGCC,WAHD,EAICC,eAJD,EAKCC,SALD,EAMCC,UAND,EAOCC,QAPD,EAQCC,aARD,QASO,kBATP;AAWA,OAAO,MAAMC,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,CAAlB;AAEP,OAAO,MAAMC,cAAc,GAAG;AAC7BC,EAAAA,GAAG,EAAEC,SADwB;AAE7BC,EAAAA,KAAK,EAAED,SAFsB;AAG7BE,EAAAA,MAAM,EAAEF,SAHqB;AAI7BG,EAAAA,IAAI,EAAEH;AAJuB,CAAvB;AAOP,OAAO,MAAMI,KAAK,GAAG;AACpBC,EAAAA,MAAM,EAAEhB,QADY;AAEpBiB,EAAAA,KAAK,EAAEhB,UAFa;AAGpBiB,EAAAA,UAAU,EAAEf,eAHQ;AAIpBgB,EAAAA,QAAQ,EAAEZ,aAJU;AAKpBG,EAAAA,GAAG,EAAEJ,QALe;AAMpBM,EAAAA,KAAK,EAAEP,UANa;AAOpBQ,EAAAA,MAAM,EAAEX,WAPY;AAQpBY,EAAAA,IAAI,EAAEV;AARc,CAAd;AAWP,OAAO,MAAMgB,MAAM,GAAG;AACrBC,EAAAA,OAAO,EAAEtB,EAAE,CAAE,iBAAF,CADU;AAErBW,EAAAA,GAAG,EAAEX,EAAE,CAAE,KAAF,C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AR,IAAkBC,IAAI,KAAKF,KAA3B,KAAsC,CAAC,CAAEF,GAAH,IAAU,CAAC,CAAEI,IAAnD,CADD;AAEA,QAAMgE,2BAA2B,GAChC,CAAEH,UAAU,CAACvB,MAAb,IAAuBoB,uBAAuB,CAAEd,KAAF,CAD/C;;AAGA,MACCG,cAAc,CAAEH,KAAF,CAAd,KACEmB,sBAAsB,IAAIC,2BAD5B,CADD,EAGE;AACD,WAAOvD,KAAK,CAACN,KAAb;AACA,GAlBmD,CAoBpD;AACA;;;AACA,MAAK0D,UAAU,CAACvB,MAAX,KAAsB,CAA3B,EAA+B;AAC9B,QAAImB,IAAJ;AAEAf,IAAAA,MAAM,CAACuB,OAAP,CAAgBxB,MAAhB,EAAyByB,IAAzB,CAA+B,CAAE,CAAEC,GAAF,EAAOxD,KAAP,CAAF,KAAsB;AACpD8C,MAAAA,IAAI,GAAGU,GAAP;AACA,aAAOxD,KAAK,KAAKd,SAAjB;AACA,KAHD;AAKA,WAAO4D,IAAP;AACA,GA/BmD,CAiCpD;;;AACA,MAAKb,KAAK,EAAEN,MAAP,KAAkB,CAAlB,IAAuB,CAAEuB,UAAU,CAACvB,MAAzC,EAAkD;AACjD,WAAOM,KAAK,CAAE,CAAF,CAAZ;AACA,GApCmD,CAsCpD;;;AACA,SAAOnC,KAAK,CAACP,MAAb;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tsidesAll,\n\tsidesAxial,\n\tsidesBottom,\n\tsidesHorizontal,\n\tsidesLeft,\n\tsidesRight,\n\tsidesTop,\n\tsidesVertical,\n} from '@wordpress/icons';\n\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\n\nexport const DEFAULT_VALUES = {\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nexport const ICONS = {\n\tcustom: sidesAll,\n\taxial: sidesAxial,\n\thorizontal: sidesHorizontal,\n\tvertical: sidesVertical,\n\ttop: sidesTop,\n\tright: sidesRight,\n\tbottom: sidesBottom,\n\tleft: sidesLeft,\n};\n\nexport const LABELS = {\n\tdefault: __( 'Spacing control' ),\n\ttop: __( 'Top' ),\n\tbottom: __( 'Bottom' ),\n\tleft: __( 'Left' ),\n\tright: __( 'Right' ),\n\tmixed: __( 'Mixed' ),\n\tvertical: __( 'Vertical' ),\n\thorizontal: __( 'Horizontal' ),\n\taxial: __( 'Horizontal & vertical' ),\n\tcustom: __( 'Custom' ),\n};\n\nexport const VIEWS = {\n\taxial: 'axial',\n\ttop: 'top',\n\tright: 'right',\n\tbottom: 'bottom',\n\tleft: 'left',\n\tcustom: 'custom',\n};\n\n/**\n * Checks is given value is a spacing preset.\n *\n * @param {string} value Value to check\n *\n * @return {boolean} Return true if value is string in format var:preset|spacing|.\n */\nexport function isValueSpacingPreset( value ) {\n\tif ( ! value?.includes ) {\n\t\treturn false;\n\t}\n\treturn value === '0' || value.includes( 'var:preset|spacing|' );\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} Mapping of the spacing preset to its equivalent custom value.\n */\nexport function getCustomValueFromPreset( value, spacingSizes ) {\n\tif ( ! isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst slug = getSpacingPresetSlug( value );\n\tconst spacingSize = spacingSizes.find(\n\t\t( size ) => String( size.slug ) === slug\n\t);\n\n\treturn spacingSize?.size;\n}\n\n/**\n * Converts a custom value to preset value if one can be found.\n *\n * Returns value as-is if no match is found.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} The preset value if it can be found.\n */\nexport function getPresetValueFromCustomValue( value, spacingSizes ) {\n\t// Return value as-is if it is already a preset;\n\tif ( isValueSpacingPreset( value ) || value === '0' ) {\n\t\treturn value;\n\t}\n\n\tconst spacingMatch = spacingSizes.find(\n\t\t( size ) => String( size.size ) === String( value )\n\t);\n\n\tif ( spacingMatch?.slug ) {\n\t\treturn `var:preset|spacing|${ spacingMatch.slug }`;\n\t}\n\n\treturn value;\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert.\n *\n * @return {string | undefined} CSS var string for given spacing preset value.\n */\nexport function getSpacingPresetCssVar( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--spacing--${ slug[ 1 ] })`;\n}\n\n/**\n * Returns the slug section of the given spacing preset string.\n *\n * @param {string} value Value to extract slug from.\n *\n * @return {string|undefined} The int value of the slug from given spacing preset.\n */\nexport function getSpacingPresetSlug( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tif ( value === '0' || value === 'default' ) {\n\t\treturn value;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\treturn slug ? slug[ 1 ] : undefined;\n}\n\n/**\n * Converts spacing preset value into a Range component value .\n *\n * @param {string} presetValue Value to convert to Range value.\n * @param {Array} spacingSizes Array of current spacing preset value objects.\n *\n * @return {number} The int value for use in Range control.\n */\nexport function getSliderValueFromPreset( presetValue, spacingSizes ) {\n\tif ( presetValue === undefined ) {\n\t\treturn 0;\n\t}\n\tconst slug =\n\t\tparseFloat( presetValue, 10 ) === 0\n\t\t\t? '0'\n\t\t\t: getSpacingPresetSlug( presetValue );\n\tconst sliderValue = spacingSizes.findIndex( ( spacingSize ) => {\n\t\treturn String( spacingSize.slug ) === slug;\n\t} );\n\n\t// Returning NaN rather than undefined as undefined makes range control thumb sit in center\n\treturn sliderValue !== -1 ? sliderValue : NaN;\n}\n\n/**\n * Gets an items with the most occurrence within an array\n * https://stackoverflow.com/a/20762713\n *\n * @param {Array<any>} arr Array of items to check.\n * @return {any} The item with the most occurrences.\n */\nfunction mode( arr ) {\n\treturn arr\n\t\t.sort(\n\t\t\t( a, b ) =>\n\t\t\t\tarr.filter( ( v ) => v === a ).length -\n\t\t\t\tarr.filter( ( v ) => v === b ).length\n\t\t)\n\t\t.pop();\n}\n\n/**\n * Gets the 'all' input value from values data.\n *\n * @param {Object} values Box spacing values\n *\n * @return {string} The most common value from all sides of box.\n */\nexport function getAllRawValue( values = {} ) {\n\treturn mode( Object.values( values ) );\n}\n\n/**\n * Checks to determine if values are mixed.\n *\n * @param {Object} values Box values.\n * @param {Array} sides Sides that values relate to.\n *\n * @return {boolean} Whether values are mixed.\n */\nexport function isValuesMixed( values = {}, sides = ALL_SIDES ) {\n\treturn (\n\t\t( Object.values( values ).length >= 1 &&\n\t\t\tObject.values( values ).length < sides.length ) ||\n\t\tnew Set( Object.values( values ) ).size > 1\n\t);\n}\n\n/**\n * Checks to determine if values are defined.\n *\n * @param {Object} values Box values.\n *\n * @return {boolean} Whether values are defined.\n */\nexport function isValuesDefined( values ) {\n\tif ( values === undefined || values === null ) {\n\t\treturn false;\n\t}\n\treturn Object.values( values ).filter( ( value ) => !! value ).length > 0;\n}\n\n/**\n * Determines whether a particular axis has support. If no axis is\n * specified, this function checks if either axis is supported.\n *\n * @param {Array} sides Supported sides.\n * @param {string} axis Which axis to check.\n *\n * @return {boolean} Whether there is support for the specified axis or both axes.\n */\nexport function hasAxisSupport( sides, axis ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn false;\n\t}\n\n\tconst hasHorizontalSupport =\n\t\tsides.includes( 'horizontal' ) ||\n\t\t( sides.includes( 'left' ) && sides.includes( 'right' ) );\n\n\tconst hasVerticalSupport =\n\t\tsides.includes( 'vertical' ) ||\n\t\t( sides.includes( 'top' ) && sides.includes( 'bottom' ) );\n\n\tif ( axis === 'horizontal' ) {\n\t\treturn hasHorizontalSupport;\n\t}\n\n\tif ( axis === 'vertical' ) {\n\t\treturn hasVerticalSupport;\n\t}\n\n\treturn hasHorizontalSupport || hasVerticalSupport;\n}\n\n/**\n * Determines which menu options should be included in the SidePicker.\n *\n * @param {Array} sides Supported sides.\n *\n * @return {Object} Menu options with each option containing label & icon.\n */\nexport function getSupportedMenuItems( sides ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn {};\n\t}\n\n\tconst menuItems = {};\n\n\t// Determine the primary \"side\" menu options.\n\tconst hasHorizontalSupport = hasAxisSupport( sides, 'horizontal' );\n\tconst hasVerticalSupport = hasAxisSupport( sides, 'vertical' );\n\n\tif ( hasHorizontalSupport && hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.axial, icon: ICONS.axial };\n\t} else if ( hasHorizontalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.horizontal, icon: ICONS.horizontal };\n\t} else if ( hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.vertical, icon: ICONS.vertical };\n\t}\n\n\t// Track whether we have any individual sides so we can omit the custom\n\t// option if required.\n\tlet numberOfIndividualSides = 0;\n\n\tALL_SIDES.forEach( ( side ) => {\n\t\tif ( sides.includes( side ) ) {\n\t\t\tnumberOfIndividualSides += 1;\n\t\t\tmenuItems[ side ] = {\n\t\t\t\tlabel: LABELS[ side ],\n\t\t\t\ticon: ICONS[ side ],\n\t\t\t};\n\t\t}\n\t} );\n\n\t// Add custom item if there are enough sides to warrant a separated view.\n\tif ( numberOfIndividualSides > 1 ) {\n\t\tmenuItems.custom = { label: LABELS.custom, icon: ICONS.custom };\n\t}\n\n\treturn menuItems;\n}\n\n/**\n * Checks if the supported sides are balanced for each axis.\n * - Horizontal - both left and right sides are supported.\n * - Vertical - both top and bottom are supported.\n *\n * @param {Array} sides The supported sides which may be axes as well.\n *\n * @return {boolean} Whether or not the supported sides are balanced.\n */\nexport function hasBalancedSidesSupport( sides = [] ) {\n\tconst counts = { top: 0, right: 0, bottom: 0, left: 0 };\n\tsides.forEach( ( side ) => ( counts[ side ] += 1 ) );\n\n\treturn (\n\t\t( counts.top + counts.bottom ) % 2 === 0 &&\n\t\t( counts.left + counts.right ) % 2 === 0\n\t);\n}\n\n/**\n * Determines which view the SpacingSizesControl should default to on its\n * first render; Axial, Custom, or Single side.\n *\n * @param {Object} values Current side values.\n * @param {Array} sides Supported sides.\n *\n * @return {string} View to display.\n */\nexport function getInitialView( values = {}, sides ) {\n\tconst { top, right, bottom, left } = values;\n\tconst sideValues = [ top, right, bottom, left ].filter( Boolean );\n\n\t// Axial ( Horizontal & vertical ).\n\t// - Has axial side support\n\t// - Has axial side values which match\n\t// - Has no values and the supported sides are balanced\n\tconst hasMatchingAxialValues =\n\t\ttop === bottom && left === right && ( !! top || !! left );\n\tconst hasNoValuesAndBalancedSides =\n\t\t! sideValues.length && hasBalancedSidesSupport( sides );\n\n\tif (\n\t\thasAxisSupport( sides ) &&\n\t\t( hasMatchingAxialValues || hasNoValuesAndBalancedSides )\n\t) {\n\t\treturn VIEWS.axial;\n\t}\n\n\t// Single side.\n\t// - Ensure the side returned is the first side that has a value.\n\tif ( sideValues.length === 1 ) {\n\t\tlet side;\n\n\t\tObject.entries( values ).some( ( [ key, value ] ) => {\n\t\t\tside = key;\n\t\t\treturn value !== undefined;\n\t\t} );\n\n\t\treturn side;\n\t}\n\n\t// Only single side supported and no value defined.\n\tif ( sides?.length === 1 && ! sideValues.length ) {\n\t\treturn sides[ 0 ];\n\t}\n\n\t// Default to the Custom (separated sides) view.\n\treturn VIEWS.custom;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/utils.js"],"names":["__","sidesAll","sidesAxial","sidesBottom","sidesHorizontal","sidesLeft","sidesRight","sidesTop","sidesVertical","ALL_SIDES","DEFAULT_VALUES","top","undefined","right","bottom","left","ICONS","custom","axial","horizontal","vertical","LABELS","default","mixed","VIEWS","isValueSpacingPreset","value","includes","getCustomValueFromPreset","spacingSizes","slug","getSpacingPresetSlug","spacingSize","find","size","String","getPresetValueFromCustomValue","spacingMatch","getSpacingPresetCssVar","match","getSliderValueFromPreset","presetValue","parseFloat","sliderValue","findIndex","NaN","mode","arr","sort","a","b","filter","v","length","pop","getAllRawValue","values","Object","isValuesMixed","sides","Set","isValuesDefined","hasAxisSupport","axis","hasHorizontalSupport","hasVerticalSupport","getSupportedMenuItems","menuItems","label","icon","numberOfIndividualSides","forEach","side","hasBalancedSidesSupport","counts","getInitialView","sideValues","Boolean","hasMatchingAxialValues","hasNoValuesAndBalancedSides","entries","some","key"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SACCC,QADD,EAECC,UAFD,EAGCC,WAHD,EAICC,eAJD,EAKCC,SALD,EAMCC,UAND,EAOCC,QAPD,EAQCC,aARD,QASO,kBATP;AAWA,OAAO,MAAMC,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,CAAlB;AAEP,OAAO,MAAMC,cAAc,GAAG;AAC7BC,EAAAA,GAAG,EAAEC,SADwB;AAE7BC,EAAAA,KAAK,EAAED,SAFsB;AAG7BE,EAAAA,MAAM,EAAEF,SAHqB;AAI7BG,EAAAA,IAAI,EAAEH;AAJuB,CAAvB;AAOP,OAAO,MAAMI,KAAK,GAAG;AACpBC,EAAAA,MAAM,EAAEhB,QADY;AAEpBiB,EAAAA,KAAK,EAAEhB,UAFa;AAGpBiB,EAAAA,UAAU,EAAEf,eAHQ;AAIpBgB,EAAAA,QAAQ,EAAEZ,aAJU;AAKpBG,EAAAA,GAAG,EAAEJ,QALe;AAMpBM,EAAAA,KAAK,EAAEP,UANa;AAOpBQ,EAAAA,MAAM,EAAEX,WAPY;AAQpBY,EAAAA,IAAI,EAAEV;AARc,CAAd;AAWP,OAAO,MAAMgB,MAAM,GAAG;AACrBC,EAAAA,OAAO,EAAEtB,EAAE,CAAE,iBAAF,CADU;AAErBW,EAAAA,GAAG,EAAEX,EAAE,CAAE,KAAF,CAFc;AAGrBc,EAAAA,MAAM,EAAEd,EAAE,CAAE,QAAF,CAHW;AAIrBe,EAAAA,IAAI,EAAEf,EAAE,CAAE,MAAF,CAJa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AAEA,QAAMgE,2BAA2B,GAChC,CAAEH,UAAU,CAACvB,MAAb,IAAuBoB,uBAAuB,CAAEd,KAAF,CAD/C;;AAGA,MACCG,cAAc,CAAEH,KAAF,CAAd,KACEmB,sBAAsB,IAAIC,2BAD5B,CADD,EAGE;AACD,WAAOvD,KAAK,CAACN,KAAb;AACA,GAlBmD,CAoBpD;AACA;;;AACA,MAAK0D,UAAU,CAACvB,MAAX,KAAsB,CAA3B,EAA+B;AAC9B,QAAImB,IAAJ;AAEAf,IAAAA,MAAM,CAACuB,OAAP,CAAgBxB,MAAhB,EAAyByB,IAAzB,CAA+B,CAAE,CAAEC,GAAF,EAAOxD,KAAP,CAAF,KAAsB;AACpD8C,MAAAA,IAAI,GAAGU,GAAP;AACA,aAAOxD,KAAK,KAAKd,SAAjB;AACA,KAHD;AAKA,WAAO4D,IAAP;AACA,GA/BmD,CAiCpD;;;AACA,MAAKb,KAAK,EAAEN,MAAP,KAAkB,CAAlB,IAAuB,CAAEuB,UAAU,CAACvB,MAAzC,EAAkD;AACjD,WAAOM,KAAK,CAAE,CAAF,CAAZ;AACA,GApCmD,CAsCpD;;;AACA,SAAOnC,KAAK,CAACP,MAAb;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tsidesAll,\n\tsidesAxial,\n\tsidesBottom,\n\tsidesHorizontal,\n\tsidesLeft,\n\tsidesRight,\n\tsidesTop,\n\tsidesVertical,\n} from '@wordpress/icons';\n\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\n\nexport const DEFAULT_VALUES = {\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nexport const ICONS = {\n\tcustom: sidesAll,\n\taxial: sidesAxial,\n\thorizontal: sidesHorizontal,\n\tvertical: sidesVertical,\n\ttop: sidesTop,\n\tright: sidesRight,\n\tbottom: sidesBottom,\n\tleft: sidesLeft,\n};\n\nexport const LABELS = {\n\tdefault: __( 'Spacing control' ),\n\ttop: __( 'Top' ),\n\tbottom: __( 'Bottom' ),\n\tleft: __( 'Left' ),\n\tright: __( 'Right' ),\n\tmixed: __( 'Mixed' ),\n\tvertical: __( 'Vertical' ),\n\thorizontal: __( 'Horizontal' ),\n\taxial: __( 'Horizontal & vertical' ),\n\tcustom: __( 'Custom' ),\n};\n\nexport const VIEWS = {\n\taxial: 'axial',\n\ttop: 'top',\n\tright: 'right',\n\tbottom: 'bottom',\n\tleft: 'left',\n\tcustom: 'custom',\n};\n\n/**\n * Checks is given value is a spacing preset.\n *\n * @param {string} value Value to check\n *\n * @return {boolean} Return true if value is string in format var:preset|spacing|.\n */\nexport function isValueSpacingPreset( value ) {\n\tif ( ! value?.includes ) {\n\t\treturn false;\n\t}\n\treturn value === '0' || value.includes( 'var:preset|spacing|' );\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} Mapping of the spacing preset to its equivalent custom value.\n */\nexport function getCustomValueFromPreset( value, spacingSizes ) {\n\tif ( ! isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst slug = getSpacingPresetSlug( value );\n\tconst spacingSize = spacingSizes.find(\n\t\t( size ) => String( size.slug ) === slug\n\t);\n\n\treturn spacingSize?.size;\n}\n\n/**\n * Converts a custom value to preset value if one can be found.\n *\n * Returns value as-is if no match is found.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} The preset value if it can be found.\n */\nexport function getPresetValueFromCustomValue( value, spacingSizes ) {\n\t// Return value as-is if it is undefined or is already a preset, or '0';\n\tif ( ! value || isValueSpacingPreset( value ) || value === '0' ) {\n\t\treturn value;\n\t}\n\n\tconst spacingMatch = spacingSizes.find(\n\t\t( size ) => String( size.size ) === String( value )\n\t);\n\n\tif ( spacingMatch?.slug ) {\n\t\treturn `var:preset|spacing|${ spacingMatch.slug }`;\n\t}\n\n\treturn value;\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert.\n *\n * @return {string | undefined} CSS var string for given spacing preset value.\n */\nexport function getSpacingPresetCssVar( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--spacing--${ slug[ 1 ] })`;\n}\n\n/**\n * Returns the slug section of the given spacing preset string.\n *\n * @param {string} value Value to extract slug from.\n *\n * @return {string|undefined} The int value of the slug from given spacing preset.\n */\nexport function getSpacingPresetSlug( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tif ( value === '0' || value === 'default' ) {\n\t\treturn value;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\treturn slug ? slug[ 1 ] : undefined;\n}\n\n/**\n * Converts spacing preset value into a Range component value .\n *\n * @param {string} presetValue Value to convert to Range value.\n * @param {Array} spacingSizes Array of current spacing preset value objects.\n *\n * @return {number} The int value for use in Range control.\n */\nexport function getSliderValueFromPreset( presetValue, spacingSizes ) {\n\tif ( presetValue === undefined ) {\n\t\treturn 0;\n\t}\n\tconst slug =\n\t\tparseFloat( presetValue, 10 ) === 0\n\t\t\t? '0'\n\t\t\t: getSpacingPresetSlug( presetValue );\n\tconst sliderValue = spacingSizes.findIndex( ( spacingSize ) => {\n\t\treturn String( spacingSize.slug ) === slug;\n\t} );\n\n\t// Returning NaN rather than undefined as undefined makes range control thumb sit in center\n\treturn sliderValue !== -1 ? sliderValue : NaN;\n}\n\n/**\n * Gets an items with the most occurrence within an array\n * https://stackoverflow.com/a/20762713\n *\n * @param {Array<any>} arr Array of items to check.\n * @return {any} The item with the most occurrences.\n */\nfunction mode( arr ) {\n\treturn arr\n\t\t.sort(\n\t\t\t( a, b ) =>\n\t\t\t\tarr.filter( ( v ) => v === a ).length -\n\t\t\t\tarr.filter( ( v ) => v === b ).length\n\t\t)\n\t\t.pop();\n}\n\n/**\n * Gets the 'all' input value from values data.\n *\n * @param {Object} values Box spacing values\n *\n * @return {string} The most common value from all sides of box.\n */\nexport function getAllRawValue( values = {} ) {\n\treturn mode( Object.values( values ) );\n}\n\n/**\n * Checks to determine if values are mixed.\n *\n * @param {Object} values Box values.\n * @param {Array} sides Sides that values relate to.\n *\n * @return {boolean} Whether values are mixed.\n */\nexport function isValuesMixed( values = {}, sides = ALL_SIDES ) {\n\treturn (\n\t\t( Object.values( values ).length >= 1 &&\n\t\t\tObject.values( values ).length < sides.length ) ||\n\t\tnew Set( Object.values( values ) ).size > 1\n\t);\n}\n\n/**\n * Checks to determine if values are defined.\n *\n * @param {Object} values Box values.\n *\n * @return {boolean} Whether values are defined.\n */\nexport function isValuesDefined( values ) {\n\tif ( values === undefined || values === null ) {\n\t\treturn false;\n\t}\n\treturn Object.values( values ).filter( ( value ) => !! value ).length > 0;\n}\n\n/**\n * Determines whether a particular axis has support. If no axis is\n * specified, this function checks if either axis is supported.\n *\n * @param {Array} sides Supported sides.\n * @param {string} axis Which axis to check.\n *\n * @return {boolean} Whether there is support for the specified axis or both axes.\n */\nexport function hasAxisSupport( sides, axis ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn false;\n\t}\n\n\tconst hasHorizontalSupport =\n\t\tsides.includes( 'horizontal' ) ||\n\t\t( sides.includes( 'left' ) && sides.includes( 'right' ) );\n\n\tconst hasVerticalSupport =\n\t\tsides.includes( 'vertical' ) ||\n\t\t( sides.includes( 'top' ) && sides.includes( 'bottom' ) );\n\n\tif ( axis === 'horizontal' ) {\n\t\treturn hasHorizontalSupport;\n\t}\n\n\tif ( axis === 'vertical' ) {\n\t\treturn hasVerticalSupport;\n\t}\n\n\treturn hasHorizontalSupport || hasVerticalSupport;\n}\n\n/**\n * Determines which menu options should be included in the SidePicker.\n *\n * @param {Array} sides Supported sides.\n *\n * @return {Object} Menu options with each option containing label & icon.\n */\nexport function getSupportedMenuItems( sides ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn {};\n\t}\n\n\tconst menuItems = {};\n\n\t// Determine the primary \"side\" menu options.\n\tconst hasHorizontalSupport = hasAxisSupport( sides, 'horizontal' );\n\tconst hasVerticalSupport = hasAxisSupport( sides, 'vertical' );\n\n\tif ( hasHorizontalSupport && hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.axial, icon: ICONS.axial };\n\t} else if ( hasHorizontalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.horizontal, icon: ICONS.horizontal };\n\t} else if ( hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.vertical, icon: ICONS.vertical };\n\t}\n\n\t// Track whether we have any individual sides so we can omit the custom\n\t// option if required.\n\tlet numberOfIndividualSides = 0;\n\n\tALL_SIDES.forEach( ( side ) => {\n\t\tif ( sides.includes( side ) ) {\n\t\t\tnumberOfIndividualSides += 1;\n\t\t\tmenuItems[ side ] = {\n\t\t\t\tlabel: LABELS[ side ],\n\t\t\t\ticon: ICONS[ side ],\n\t\t\t};\n\t\t}\n\t} );\n\n\t// Add custom item if there are enough sides to warrant a separated view.\n\tif ( numberOfIndividualSides > 1 ) {\n\t\tmenuItems.custom = { label: LABELS.custom, icon: ICONS.custom };\n\t}\n\n\treturn menuItems;\n}\n\n/**\n * Checks if the supported sides are balanced for each axis.\n * - Horizontal - both left and right sides are supported.\n * - Vertical - both top and bottom are supported.\n *\n * @param {Array} sides The supported sides which may be axes as well.\n *\n * @return {boolean} Whether or not the supported sides are balanced.\n */\nexport function hasBalancedSidesSupport( sides = [] ) {\n\tconst counts = { top: 0, right: 0, bottom: 0, left: 0 };\n\tsides.forEach( ( side ) => ( counts[ side ] += 1 ) );\n\n\treturn (\n\t\t( counts.top + counts.bottom ) % 2 === 0 &&\n\t\t( counts.left + counts.right ) % 2 === 0\n\t);\n}\n\n/**\n * Determines which view the SpacingSizesControl should default to on its\n * first render; Axial, Custom, or Single side.\n *\n * @param {Object} values Current side values.\n * @param {Array} sides Supported sides.\n *\n * @return {string} View to display.\n */\nexport function getInitialView( values = {}, sides ) {\n\tconst { top, right, bottom, left } = values;\n\tconst sideValues = [ top, right, bottom, left ].filter( Boolean );\n\n\t// Axial ( Horizontal & vertical ).\n\t// - Has axial side support\n\t// - Has axial side values which match\n\t// - Has no values and the supported sides are balanced\n\tconst hasMatchingAxialValues =\n\t\ttop === bottom && left === right && ( !! top || !! left );\n\tconst hasNoValuesAndBalancedSides =\n\t\t! sideValues.length && hasBalancedSidesSupport( sides );\n\n\tif (\n\t\thasAxisSupport( sides ) &&\n\t\t( hasMatchingAxialValues || hasNoValuesAndBalancedSides )\n\t) {\n\t\treturn VIEWS.axial;\n\t}\n\n\t// Single side.\n\t// - Ensure the side returned is the first side that has a value.\n\tif ( sideValues.length === 1 ) {\n\t\tlet side;\n\n\t\tObject.entries( values ).some( ( [ key, value ] ) => {\n\t\t\tside = key;\n\t\t\treturn value !== undefined;\n\t\t} );\n\n\t\treturn side;\n\t}\n\n\t// Only single side supported and no value defined.\n\tif ( sides?.length === 1 && ! sideValues.length ) {\n\t\treturn sides[ 0 ];\n\t}\n\n\t// Default to the Custom (separated sides) view.\n\treturn VIEWS.custom;\n}\n"]}
|
|
@@ -19,6 +19,7 @@ import { useLayoutClasses, useLayoutStyles } from './hooks';
|
|
|
19
19
|
import DimensionsTool from './components/dimensions-tool';
|
|
20
20
|
import ResolutionTool from './components/resolution-tool';
|
|
21
21
|
import { default as ReusableBlocksRenameHint, useReusableBlocksRenameHint } from './components/inserter/reusable-block-rename-hint';
|
|
22
|
+
import { usesContextKey } from './components/rich-text/format-edit';
|
|
22
23
|
/**
|
|
23
24
|
* Private @wordpress/block-editor APIs.
|
|
24
25
|
*/
|
|
@@ -42,6 +43,7 @@ lock(privateApis, { ...globalStyles,
|
|
|
42
43
|
DimensionsTool,
|
|
43
44
|
ResolutionTool,
|
|
44
45
|
ReusableBlocksRenameHint,
|
|
45
|
-
useReusableBlocksRenameHint
|
|
46
|
+
useReusableBlocksRenameHint,
|
|
47
|
+
usesContextKey
|
|
46
48
|
});
|
|
47
49
|
//# sourceMappingURL=private-apis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/private-apis.js"],"names":["globalStyles","ExperimentalBlockEditorProvider","lock","getRichTextValues","ResizableBoxPopover","ComposedPrivateInserter","PrivateInserter","PrivateListView","BlockInfo","useShouldContextualToolbarShow","cleanEmptyObject","useBlockEditingMode","BlockQuickNavigation","LayoutStyle","BlockRemovalWarningModal","useLayoutClasses","useLayoutStyles","DimensionsTool","ResolutionTool","default","ReusableBlocksRenameHint","useReusableBlocksRenameHint","privateApis"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,KAAKA,YAAZ,MAA8B,4BAA9B;AACA,SAASC,+BAAT,QAAgD,uBAAhD;AACA,SAASC,IAAT,QAAqB,eAArB;AACA,SAASC,iBAAT,QAAkC,6CAAlC;AACA,OAAOC,mBAAP,MAAgC,oCAAhC;AACA,SAASC,uBAAuB,IAAIC,eAApC,QAA2D,uBAA3D;AACA,SAASC,eAAT,QAAgC,wBAAhC;AACA,OAAOC,SAAP,MAAsB,mCAAtB;AACA,SAASC,8BAAT,QAA+C,4CAA/C;AACA,SAASC,gBAAT,QAAiC,eAAjC;AACA,SAASC,mBAAT,QAAoC,iCAApC;AACA,OAAOC,oBAAP,MAAiC,qCAAjC;AACA,SAASC,WAAT,QAA4B,gCAA5B;AACA,SAASC,wBAAT,QAAyC,0CAAzC;AACA,SAASC,gBAAT,EAA2BC,eAA3B,QAAkD,SAAlD;AACA,OAAOC,cAAP,MAA2B,8BAA3B;AACA,OAAOC,cAAP,MAA2B,8BAA3B;AACA,SACCC,OAAO,IAAIC,wBADZ,EAECC,2BAFD,QAGO,kDAHP;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/private-apis.js"],"names":["globalStyles","ExperimentalBlockEditorProvider","lock","getRichTextValues","ResizableBoxPopover","ComposedPrivateInserter","PrivateInserter","PrivateListView","BlockInfo","useShouldContextualToolbarShow","cleanEmptyObject","useBlockEditingMode","BlockQuickNavigation","LayoutStyle","BlockRemovalWarningModal","useLayoutClasses","useLayoutStyles","DimensionsTool","ResolutionTool","default","ReusableBlocksRenameHint","useReusableBlocksRenameHint","usesContextKey","privateApis"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,KAAKA,YAAZ,MAA8B,4BAA9B;AACA,SAASC,+BAAT,QAAgD,uBAAhD;AACA,SAASC,IAAT,QAAqB,eAArB;AACA,SAASC,iBAAT,QAAkC,6CAAlC;AACA,OAAOC,mBAAP,MAAgC,oCAAhC;AACA,SAASC,uBAAuB,IAAIC,eAApC,QAA2D,uBAA3D;AACA,SAASC,eAAT,QAAgC,wBAAhC;AACA,OAAOC,SAAP,MAAsB,mCAAtB;AACA,SAASC,8BAAT,QAA+C,4CAA/C;AACA,SAASC,gBAAT,QAAiC,eAAjC;AACA,SAASC,mBAAT,QAAoC,iCAApC;AACA,OAAOC,oBAAP,MAAiC,qCAAjC;AACA,SAASC,WAAT,QAA4B,gCAA5B;AACA,SAASC,wBAAT,QAAyC,0CAAzC;AACA,SAASC,gBAAT,EAA2BC,eAA3B,QAAkD,SAAlD;AACA,OAAOC,cAAP,MAA2B,8BAA3B;AACA,OAAOC,cAAP,MAA2B,8BAA3B;AACA,SACCC,OAAO,IAAIC,wBADZ,EAECC,2BAFD,QAGO,kDAHP;AAIA,SAASC,cAAT,QAA+B,oCAA/B;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAG,EAApB;AACPrB,IAAI,CAAEqB,WAAF,EAAe,EAClB,GAAGvB,YADe;AAElBC,EAAAA,+BAFkB;AAGlBE,EAAAA,iBAHkB;AAIlBG,EAAAA,eAJkB;AAKlBC,EAAAA,eALkB;AAMlBH,EAAAA,mBANkB;AAOlBI,EAAAA,SAPkB;AAQlBC,EAAAA,8BARkB;AASlBC,EAAAA,gBATkB;AAUlBC,EAAAA,mBAVkB;AAWlBC,EAAAA,oBAXkB;AAYlBC,EAAAA,WAZkB;AAalBC,EAAAA,wBAbkB;AAclBC,EAAAA,gBAdkB;AAelBC,EAAAA,eAfkB;AAgBlBC,EAAAA,cAhBkB;AAiBlBC,EAAAA,cAjBkB;AAkBlBE,EAAAA,wBAlBkB;AAmBlBC,EAAAA,2BAnBkB;AAoBlBC,EAAAA;AApBkB,CAAf,CAAJ","sourcesContent":["/**\n * Internal dependencies\n */\nimport * as globalStyles from './components/global-styles';\nimport { ExperimentalBlockEditorProvider } from './components/provider';\nimport { lock } from './lock-unlock';\nimport { getRichTextValues } from './components/rich-text/get-rich-text-values';\nimport ResizableBoxPopover from './components/resizable-box-popover';\nimport { ComposedPrivateInserter as PrivateInserter } from './components/inserter';\nimport { PrivateListView } from './components/list-view';\nimport BlockInfo from './components/block-info-slot-fill';\nimport { useShouldContextualToolbarShow } from './utils/use-should-contextual-toolbar-show';\nimport { cleanEmptyObject } from './hooks/utils';\nimport { useBlockEditingMode } from './components/block-editing-mode';\nimport BlockQuickNavigation from './components/block-quick-navigation';\nimport { LayoutStyle } from './components/block-list/layout';\nimport { BlockRemovalWarningModal } from './components/block-removal-warning-modal';\nimport { useLayoutClasses, useLayoutStyles } from './hooks';\nimport DimensionsTool from './components/dimensions-tool';\nimport ResolutionTool from './components/resolution-tool';\nimport {\n\tdefault as ReusableBlocksRenameHint,\n\tuseReusableBlocksRenameHint,\n} from './components/inserter/reusable-block-rename-hint';\nimport { usesContextKey } from './components/rich-text/format-edit';\n\n/**\n * Private @wordpress/block-editor APIs.\n */\nexport const privateApis = {};\nlock( privateApis, {\n\t...globalStyles,\n\tExperimentalBlockEditorProvider,\n\tgetRichTextValues,\n\tPrivateInserter,\n\tPrivateListView,\n\tResizableBoxPopover,\n\tBlockInfo,\n\tuseShouldContextualToolbarShow,\n\tcleanEmptyObject,\n\tuseBlockEditingMode,\n\tBlockQuickNavigation,\n\tLayoutStyle,\n\tBlockRemovalWarningModal,\n\tuseLayoutClasses,\n\tuseLayoutStyles,\n\tDimensionsTool,\n\tResolutionTool,\n\tReusableBlocksRenameHint,\n\tuseReusableBlocksRenameHint,\n\tusesContextKey,\n} );\n"]}
|
|
@@ -331,6 +331,14 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
|
|
|
331
331
|
.block-editor-block-contextual-toolbar:has(.block-editor-block-toolbar:empty) {
|
|
332
332
|
display: none;
|
|
333
333
|
}
|
|
334
|
+
.block-editor-block-contextual-toolbar.is-collapsed::after {
|
|
335
|
+
content: "";
|
|
336
|
+
position: absolute;
|
|
337
|
+
right: 100%;
|
|
338
|
+
width: 48px;
|
|
339
|
+
height: 100%;
|
|
340
|
+
background: linear-gradient(to left, #fff, transparent);
|
|
341
|
+
}
|
|
334
342
|
@media (min-width: 782px) {
|
|
335
343
|
.block-editor-block-contextual-toolbar.is-fixed {
|
|
336
344
|
margin-right: 180px;
|
|
@@ -475,7 +483,7 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
|
|
|
475
483
|
width: auto;
|
|
476
484
|
}
|
|
477
485
|
.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
|
|
478
|
-
width: calc(100% -
|
|
486
|
+
width: calc(100% - 280px - 256px);
|
|
479
487
|
}
|
|
480
488
|
}
|
|
481
489
|
|
package/build-style/style.css
CHANGED
|
@@ -331,6 +331,14 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
|
|
|
331
331
|
.block-editor-block-contextual-toolbar:has(.block-editor-block-toolbar:empty) {
|
|
332
332
|
display: none;
|
|
333
333
|
}
|
|
334
|
+
.block-editor-block-contextual-toolbar.is-collapsed::after {
|
|
335
|
+
content: "";
|
|
336
|
+
position: absolute;
|
|
337
|
+
left: 100%;
|
|
338
|
+
width: 48px;
|
|
339
|
+
height: 100%;
|
|
340
|
+
background: linear-gradient(to right, #fff, transparent);
|
|
341
|
+
}
|
|
334
342
|
@media (min-width: 782px) {
|
|
335
343
|
.block-editor-block-contextual-toolbar.is-fixed {
|
|
336
344
|
margin-left: 180px;
|
|
@@ -475,7 +483,7 @@ body.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
|
|
|
475
483
|
width: auto;
|
|
476
484
|
}
|
|
477
485
|
.is-fullscreen-mode .block-editor-block-contextual-toolbar.is-fixed {
|
|
478
|
-
width: calc(100% -
|
|
486
|
+
width: calc(100% - 280px - 256px);
|
|
479
487
|
}
|
|
480
488
|
}
|
|
481
489
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "12.3.
|
|
3
|
+
"version": "12.3.12",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@wordpress/a11y": "^3.35.1",
|
|
38
38
|
"@wordpress/api-fetch": "^6.32.1",
|
|
39
39
|
"@wordpress/blob": "^3.35.1",
|
|
40
|
-
"@wordpress/blocks": "^12.12.
|
|
41
|
-
"@wordpress/components": "^25.1.
|
|
40
|
+
"@wordpress/blocks": "^12.12.7",
|
|
41
|
+
"@wordpress/components": "^25.1.10",
|
|
42
42
|
"@wordpress/compose": "^6.12.2",
|
|
43
43
|
"@wordpress/data": "^9.5.5",
|
|
44
44
|
"@wordpress/date": "^4.35.1",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"@wordpress/keyboard-shortcuts": "^4.12.5",
|
|
55
55
|
"@wordpress/keycodes": "^3.35.1",
|
|
56
56
|
"@wordpress/notices": "^4.3.5",
|
|
57
|
-
"@wordpress/preferences": "^3.12.
|
|
57
|
+
"@wordpress/preferences": "^3.12.10",
|
|
58
58
|
"@wordpress/private-apis": "^0.17.2",
|
|
59
|
-
"@wordpress/rich-text": "^6.12.
|
|
59
|
+
"@wordpress/rich-text": "^6.12.7",
|
|
60
60
|
"@wordpress/shortcode": "^3.35.1",
|
|
61
61
|
"@wordpress/style-engine": "^1.18.1",
|
|
62
62
|
"@wordpress/token-list": "^2.35.1",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "53cd9574a54a643c73e76fe1abaa8d1be489f8f7"
|
|
89
89
|
}
|
|
@@ -33,7 +33,6 @@ import { useInBetweenInserter } from './use-in-between-inserter';
|
|
|
33
33
|
import { store as blockEditorStore } from '../../store';
|
|
34
34
|
import { usePreParsePatterns } from '../../utils/pre-parse-patterns';
|
|
35
35
|
import { LayoutProvider, defaultLayout } from './layout';
|
|
36
|
-
import BlockToolsBackCompat from '../block-tools/back-compat';
|
|
37
36
|
import { useBlockSelectionClearer } from '../block-selection-clearer';
|
|
38
37
|
import { useInnerBlocksProps } from '../inner-blocks';
|
|
39
38
|
import {
|
|
@@ -127,11 +126,9 @@ function Root( { className, ...settings } ) {
|
|
|
127
126
|
export default function BlockList( settings ) {
|
|
128
127
|
usePreParsePatterns();
|
|
129
128
|
return (
|
|
130
|
-
<
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
</BlockEditContextProvider>
|
|
134
|
-
</BlockToolsBackCompat>
|
|
129
|
+
<BlockEditContextProvider value={ DEFAULT_BLOCK_EDIT_CONTEXT }>
|
|
130
|
+
<Root { ...settings } />
|
|
131
|
+
</BlockEditContextProvider>
|
|
135
132
|
);
|
|
136
133
|
}
|
|
137
134
|
|
|
@@ -32,48 +32,56 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
|
|
|
32
32
|
const toolbarButtonRef = useRef();
|
|
33
33
|
|
|
34
34
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
const {
|
|
36
|
+
blockType,
|
|
37
|
+
hasParents,
|
|
38
|
+
showParentSelector,
|
|
39
|
+
selectedBlockClientId,
|
|
40
|
+
isContentOnly,
|
|
41
|
+
} = useSelect( ( select ) => {
|
|
42
|
+
const {
|
|
43
|
+
getBlockName,
|
|
44
|
+
getBlockParents,
|
|
45
|
+
getSelectedBlockClientIds,
|
|
46
|
+
getBlockEditingMode,
|
|
47
|
+
} = unlock( select( blockEditorStore ) );
|
|
48
|
+
const { getBlockType } = select( blocksStore );
|
|
49
|
+
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
50
|
+
const _selectedBlockClientId = selectedBlockClientIds[ 0 ];
|
|
51
|
+
const parents = getBlockParents( _selectedBlockClientId );
|
|
52
|
+
const firstParentClientId = parents[ parents.length - 1 ];
|
|
53
|
+
const parentBlockName = getBlockName( firstParentClientId );
|
|
54
|
+
const parentBlockType = getBlockType( parentBlockName );
|
|
50
55
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
return {
|
|
57
|
+
selectedBlockClientId: _selectedBlockClientId,
|
|
58
|
+
blockType:
|
|
59
|
+
_selectedBlockClientId &&
|
|
60
|
+
getBlockType( getBlockName( _selectedBlockClientId ) ),
|
|
61
|
+
hasParents: parents.length,
|
|
62
|
+
isContentOnly:
|
|
63
|
+
getBlockEditingMode( _selectedBlockClientId ) === 'contentOnly',
|
|
64
|
+
showParentSelector:
|
|
65
|
+
parentBlockType &&
|
|
66
|
+
getBlockEditingMode( firstParentClientId ) === 'default' &&
|
|
67
|
+
hasBlockSupport(
|
|
68
|
+
parentBlockType,
|
|
69
|
+
'__experimentalParentSelector',
|
|
70
|
+
true
|
|
71
|
+
) &&
|
|
72
|
+
selectedBlockClientIds.length <= 1 &&
|
|
73
|
+
getBlockEditingMode( _selectedBlockClientId ) === 'default',
|
|
74
|
+
};
|
|
75
|
+
}, [] );
|
|
69
76
|
|
|
70
77
|
useEffect( () => {
|
|
71
78
|
setIsCollapsed( false );
|
|
72
79
|
}, [ selectedBlockClientId ] );
|
|
73
80
|
|
|
74
81
|
if (
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
isContentOnly ||
|
|
83
|
+
( blockType &&
|
|
84
|
+
! hasBlockSupport( blockType, '__experimentalToolbar', true ) )
|
|
77
85
|
) {
|
|
78
86
|
return null;
|
|
79
87
|
}
|
|
@@ -125,9 +125,18 @@
|
|
|
125
125
|
display: none;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
// Add a scrim to the right of the collapsed button.
|
|
129
|
+
&.is-collapsed::after {
|
|
130
|
+
content: "";
|
|
131
|
+
position: absolute;
|
|
132
|
+
left: 100%;
|
|
133
|
+
width: $grid-unit-60;
|
|
134
|
+
height: 100%;
|
|
135
|
+
background: linear-gradient(to right, $white, transparent);
|
|
136
|
+
}
|
|
137
|
+
|
|
128
138
|
// on desktop and tablet viewports the toolbar is fixed
|
|
129
139
|
// on top of interface header
|
|
130
|
-
|
|
131
140
|
@include break-medium() {
|
|
132
141
|
&.is-fixed {
|
|
133
142
|
|
|
@@ -308,7 +317,7 @@
|
|
|
308
317
|
}
|
|
309
318
|
}
|
|
310
319
|
|
|
311
|
-
// on tablet
|
|
320
|
+
// on tablet viewports the toolbar is fixed
|
|
312
321
|
// on top of interface header and covers the whole header
|
|
313
322
|
// except for the inserter on the left
|
|
314
323
|
@include break-medium() {
|
|
@@ -328,7 +337,7 @@
|
|
|
328
337
|
// in full screen mode we need to account for
|
|
329
338
|
// the combined with of the tools at the right of the header and the margin left
|
|
330
339
|
// of the toolbar which includes four buttons
|
|
331
|
-
width: calc(100% -
|
|
340
|
+
width: calc(100% - 280px - #{4 * $grid-unit-80});
|
|
332
341
|
}
|
|
333
342
|
}
|
|
334
343
|
}
|
|
@@ -43,13 +43,13 @@ function useDarkThemeBodyClassName( styles ) {
|
|
|
43
43
|
body.appendChild( tempCanvas );
|
|
44
44
|
|
|
45
45
|
backgroundColor = defaultView
|
|
46
|
-
|
|
46
|
+
?.getComputedStyle( tempCanvas, null )
|
|
47
47
|
.getPropertyValue( 'background-color' );
|
|
48
48
|
|
|
49
49
|
body.removeChild( tempCanvas );
|
|
50
50
|
} else {
|
|
51
51
|
backgroundColor = defaultView
|
|
52
|
-
|
|
52
|
+
?.getComputedStyle( canvas, null )
|
|
53
53
|
.getPropertyValue( 'background-color' );
|
|
54
54
|
}
|
|
55
55
|
const colordBackgroundColor = colord( backgroundColor );
|
|
@@ -331,7 +331,8 @@ export function useSettingsForBlockElement(
|
|
|
331
331
|
const sides = Array.isArray( supports?.spacing?.[ key ] )
|
|
332
332
|
? supports?.spacing?.[ key ]
|
|
333
333
|
: supports?.spacing?.[ key ]?.sides;
|
|
334
|
-
if
|
|
334
|
+
// Check if spacing type is supported before adding sides.
|
|
335
|
+
if ( sides?.length && updatedSettings.spacing?.[ key ] ) {
|
|
335
336
|
updatedSettings.spacing = {
|
|
336
337
|
...updatedSettings.spacing,
|
|
337
338
|
[ key ]: {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
createBlock,
|
|
6
6
|
createBlocksFromInnerBlocksTemplate,
|
|
7
7
|
store as blocksStore,
|
|
8
|
+
parse,
|
|
8
9
|
} from '@wordpress/blocks';
|
|
9
10
|
import { useSelect } from '@wordpress/data';
|
|
10
11
|
import { useCallback } from '@wordpress/element';
|
|
@@ -37,12 +38,20 @@ const useBlockTypesState = ( rootClientId, onInsert ) => {
|
|
|
37
38
|
);
|
|
38
39
|
|
|
39
40
|
const onSelectItem = useCallback(
|
|
40
|
-
(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
(
|
|
42
|
+
{ name, initialAttributes, innerBlocks, syncStatus, content },
|
|
43
|
+
shouldFocusBlock
|
|
44
|
+
) => {
|
|
45
|
+
const insertedBlock =
|
|
46
|
+
syncStatus === 'unsynced'
|
|
47
|
+
? parse( content, {
|
|
48
|
+
__unstableSkipMigrationLogs: true,
|
|
49
|
+
} )
|
|
50
|
+
: createBlock(
|
|
51
|
+
name,
|
|
52
|
+
initialAttributes,
|
|
53
|
+
createBlocksFromInnerBlocksTemplate( innerBlocks )
|
|
54
|
+
);
|
|
46
55
|
|
|
47
56
|
onInsert( insertedBlock, undefined, shouldFocusBlock );
|
|
48
57
|
},
|
|
@@ -49,7 +49,9 @@ function InserterListItem( {
|
|
|
49
49
|
];
|
|
50
50
|
}, [ item.name, item.initialAttributes, item.initialAttributes ] );
|
|
51
51
|
|
|
52
|
-
const isSynced =
|
|
52
|
+
const isSynced =
|
|
53
|
+
( isReusableBlock( item ) && item.syncStatus !== 'unsynced' ) ||
|
|
54
|
+
isTemplatePart( item );
|
|
53
55
|
|
|
54
56
|
return (
|
|
55
57
|
<InserterDraggableBlocks
|
|
@@ -489,7 +489,11 @@ export default function useListViewDropZone( { dropZoneElement } ) {
|
|
|
489
489
|
|
|
490
490
|
const ref = useDropZone( {
|
|
491
491
|
dropZoneElement,
|
|
492
|
-
onDrop
|
|
492
|
+
onDrop( event ) {
|
|
493
|
+
if ( target ) {
|
|
494
|
+
onBlockDrop( event );
|
|
495
|
+
}
|
|
496
|
+
},
|
|
493
497
|
onDragLeave() {
|
|
494
498
|
throttled.cancel();
|
|
495
499
|
setTarget( null );
|
|
@@ -2,43 +2,67 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { getActiveFormat, getActiveObject } from '@wordpress/rich-text';
|
|
5
|
+
import { useContext, useMemo } from '@wordpress/element';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import BlockContext from '../block-context';
|
|
11
|
+
|
|
12
|
+
const DEFAULT_BLOCK_CONTEXT = {};
|
|
13
|
+
|
|
14
|
+
export const usesContextKey = Symbol( 'usesContext' );
|
|
15
|
+
|
|
16
|
+
function Edit( { onChange, onFocus, value, forwardedRef, settings } ) {
|
|
17
|
+
const {
|
|
18
|
+
name,
|
|
19
|
+
edit: EditFunction,
|
|
20
|
+
[ usesContextKey ]: usesContext,
|
|
21
|
+
} = settings;
|
|
22
|
+
|
|
23
|
+
const blockContext = useContext( BlockContext );
|
|
24
|
+
|
|
25
|
+
// Assign context values using the block type's declared context needs.
|
|
26
|
+
const context = useMemo( () => {
|
|
27
|
+
return usesContext
|
|
28
|
+
? Object.fromEntries(
|
|
29
|
+
Object.entries( blockContext ).filter( ( [ key ] ) =>
|
|
30
|
+
usesContext.includes( key )
|
|
31
|
+
)
|
|
32
|
+
)
|
|
33
|
+
: DEFAULT_BLOCK_CONTEXT;
|
|
34
|
+
}, [ usesContext, blockContext ] );
|
|
35
|
+
|
|
36
|
+
if ( ! EditFunction ) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const activeFormat = getActiveFormat( value, name );
|
|
41
|
+
const isActive = activeFormat !== undefined;
|
|
42
|
+
const activeObject = getActiveObject( value );
|
|
43
|
+
const isObjectActive =
|
|
44
|
+
activeObject !== undefined && activeObject.type === name;
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<EditFunction
|
|
48
|
+
key={ name }
|
|
49
|
+
isActive={ isActive }
|
|
50
|
+
activeAttributes={ isActive ? activeFormat.attributes || {} : {} }
|
|
51
|
+
isObjectActive={ isObjectActive }
|
|
52
|
+
activeObjectAttributes={
|
|
53
|
+
isObjectActive ? activeObject.attributes || {} : {}
|
|
54
|
+
}
|
|
55
|
+
value={ value }
|
|
56
|
+
onChange={ onChange }
|
|
57
|
+
onFocus={ onFocus }
|
|
58
|
+
contentRef={ forwardedRef }
|
|
59
|
+
context={ context }
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default function FormatEdit( { formatTypes, ...props } ) {
|
|
65
|
+
return formatTypes.map( ( settings ) => (
|
|
66
|
+
<Edit settings={ settings } { ...props } key={ settings.name } />
|
|
67
|
+
) );
|
|
44
68
|
}
|