@wordpress/block-editor 15.6.1-next.36001005c.0 → 15.6.2
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/background-image-control/index.js +2 -2
- package/build/components/background-image-control/index.js.map +2 -2
- package/build/components/block-list/block.js +3 -3
- package/build/components/block-list/block.js.map +2 -2
- package/build/components/block-list/index.js +2 -2
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +0 -1
- package/build/components/block-quick-navigation/index.js.map +2 -2
- package/build/components/global-styles/border-panel.js +1 -2
- package/build/components/global-styles/border-panel.js.map +2 -2
- package/build/components/global-styles/color-panel.js +1 -2
- package/build/components/global-styles/color-panel.js.map +2 -2
- package/build/components/global-styles/dimensions-panel.js +2 -3
- package/build/components/global-styles/dimensions-panel.js.map +2 -2
- package/build/components/global-styles/filters-panel.js +1 -2
- package/build/components/global-styles/filters-panel.js.map +2 -2
- package/build/components/global-styles/get-block-css-selector.js +78 -0
- package/build/components/global-styles/get-block-css-selector.js.map +7 -0
- package/build/components/global-styles/hooks.js +95 -23
- package/build/components/global-styles/hooks.js.map +2 -2
- package/build/components/global-styles/index.js +14 -0
- package/build/components/global-styles/index.js.map +2 -2
- package/build/components/global-styles/typography-panel.js +19 -3
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/global-styles/typography-utils.js +49 -2
- package/build/components/global-styles/typography-utils.js.map +2 -2
- package/build/components/global-styles/use-global-styles-output.js +998 -0
- package/build/components/global-styles/use-global-styles-output.js.map +7 -0
- package/build/components/global-styles/utils.js +377 -0
- package/build/components/global-styles/utils.js.map +2 -2
- package/build/components/rich-text/index.js +8 -7
- package/build/components/rich-text/index.js.map +2 -2
- package/build/hooks/allowed-blocks.js +50 -1
- package/build/hooks/allowed-blocks.js.map +2 -2
- package/build/hooks/block-bindings.js +111 -170
- package/build/hooks/block-bindings.js.map +2 -2
- package/build/hooks/block-style-variation.js +10 -6
- package/build/hooks/block-style-variation.js.map +2 -2
- package/build/hooks/custom-class-name.js +1 -1
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/duotone.js +3 -3
- package/build/hooks/duotone.js.map +2 -2
- package/build/hooks/fit-text.js +33 -20
- package/build/hooks/fit-text.js.map +2 -2
- package/build/hooks/font-size.js +6 -5
- package/build/hooks/font-size.js.map +2 -2
- package/build/hooks/metadata.js +48 -2
- package/build/hooks/metadata.js.map +2 -2
- package/build/hooks/typography.js +11 -4
- package/build/hooks/typography.js.map +3 -3
- package/build/hooks/use-typography-props.js +2 -2
- package/build/hooks/use-typography-props.js.map +2 -2
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/selectors.js +38 -13
- package/build/store/selectors.js.map +2 -2
- package/build/store/utils.js +2 -1
- package/build/store/utils.js.map +2 -2
- package/build/utils/fit-text-utils.js +4 -4
- package/build/utils/fit-text-utils.js.map +2 -2
- package/build-module/components/background-image-control/index.js +1 -1
- package/build-module/components/background-image-control/index.js.map +2 -2
- package/build-module/components/block-list/block.js +3 -3
- package/build-module/components/block-list/block.js.map +2 -2
- package/build-module/components/block-list/index.js +2 -2
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +0 -1
- package/build-module/components/block-quick-navigation/index.js.map +2 -2
- package/build-module/components/global-styles/border-panel.js +1 -2
- package/build-module/components/global-styles/border-panel.js.map +2 -2
- package/build-module/components/global-styles/color-panel.js +1 -2
- package/build-module/components/global-styles/color-panel.js.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.js +1 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
- package/build-module/components/global-styles/filters-panel.js +1 -2
- package/build-module/components/global-styles/filters-panel.js.map +2 -2
- package/build-module/components/global-styles/get-block-css-selector.js +54 -0
- package/build-module/components/global-styles/get-block-css-selector.js.map +7 -0
- package/build-module/components/global-styles/hooks.js +95 -27
- package/build-module/components/global-styles/hooks.js.map +2 -2
- package/build-module/components/global-styles/index.js +14 -0
- package/build-module/components/global-styles/index.js.map +2 -2
- package/build-module/components/global-styles/typography-panel.js +19 -3
- package/build-module/components/global-styles/typography-panel.js.map +2 -2
- package/build-module/components/global-styles/typography-utils.js +49 -1
- package/build-module/components/global-styles/typography-utils.js.map +2 -2
- package/build-module/components/global-styles/use-global-styles-output.js +979 -0
- package/build-module/components/global-styles/use-global-styles-output.js.map +7 -0
- package/build-module/components/global-styles/utils.js +364 -0
- package/build-module/components/global-styles/utils.js.map +2 -2
- package/build-module/components/rich-text/index.js +8 -7
- package/build-module/components/rich-text/index.js.map +2 -2
- package/build-module/hooks/allowed-blocks.js +49 -1
- package/build-module/hooks/allowed-blocks.js.map +2 -2
- package/build-module/hooks/block-bindings.js +112 -172
- package/build-module/hooks/block-bindings.js.map +2 -2
- package/build-module/hooks/block-style-variation.js +12 -4
- package/build-module/hooks/block-style-variation.js.map +2 -2
- package/build-module/hooks/custom-class-name.js +1 -1
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/duotone.js +3 -3
- package/build-module/hooks/duotone.js.map +2 -2
- package/build-module/hooks/fit-text.js +34 -21
- package/build-module/hooks/fit-text.js.map +2 -2
- package/build-module/hooks/font-size.js +5 -4
- package/build-module/hooks/font-size.js.map +2 -2
- package/build-module/hooks/metadata.js +46 -1
- package/build-module/hooks/metadata.js.map +2 -2
- package/build-module/hooks/typography.js +11 -4
- package/build-module/hooks/typography.js.map +3 -3
- package/build-module/hooks/use-typography-props.js +1 -1
- package/build-module/hooks/use-typography-props.js.map +2 -2
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/selectors.js +39 -14
- package/build-module/store/selectors.js.map +2 -2
- package/build-module/store/utils.js +3 -2
- package/build-module/store/utils.js.map +2 -2
- package/build-module/utils/fit-text-utils.js +4 -4
- package/build-module/utils/fit-text-utils.js.map +2 -2
- package/build-style/style-rtl.css +6 -10
- package/build-style/style.css +6 -10
- package/package.json +35 -36
- package/src/components/background-image-control/index.js +1 -1
- package/src/components/block-card/style.scss +1 -1
- package/src/components/block-list/block.js +1 -1
- package/src/components/block-list/index.js +2 -2
- package/src/components/block-navigation/style.scss +1 -1
- package/src/components/block-quick-navigation/index.js +0 -1
- package/src/components/block-switcher/style.scss +1 -1
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/global-styles/border-panel.js +1 -2
- package/src/components/global-styles/color-panel.js +1 -2
- package/src/components/global-styles/color-panel.native.js +1 -1
- package/src/components/global-styles/dimensions-panel.js +1 -2
- package/src/components/global-styles/filters-panel.js +1 -2
- package/src/components/global-styles/get-block-css-selector.js +114 -0
- package/src/components/global-styles/hooks.js +108 -29
- package/src/components/global-styles/index.js +8 -0
- package/src/components/global-styles/test/typography-utils.js +806 -0
- package/src/components/global-styles/test/use-global-styles-output.js +1131 -0
- package/src/components/global-styles/test/utils.js +442 -1
- package/src/components/global-styles/typography-panel.js +27 -3
- package/src/components/global-styles/typography-utils.js +133 -0
- package/src/components/global-styles/use-global-styles-output.js +1487 -0
- package/src/components/global-styles/utils.js +537 -0
- package/src/components/inserter/style.scss +2 -2
- package/src/components/multi-selection-inspector/style.scss +1 -1
- package/src/components/rich-text/index.js +8 -14
- package/src/hooks/allowed-blocks.js +89 -1
- package/src/hooks/block-bindings.js +79 -153
- package/src/hooks/block-style-variation.js +12 -4
- package/src/hooks/custom-class-name.js +1 -1
- package/src/hooks/duotone.js +3 -3
- package/src/hooks/fit-text.js +39 -30
- package/src/hooks/font-size.js +8 -4
- package/src/hooks/metadata.js +89 -0
- package/src/hooks/test/allowed-blocks.js +278 -0
- package/src/hooks/test/metadata.js +316 -0
- package/src/hooks/typography.js +15 -4
- package/src/hooks/use-typography-props.js +1 -1
- package/src/store/private-selectors.js +2 -2
- package/src/store/selectors.js +59 -21
- package/src/store/test/selectors.js +1 -1
- package/src/store/utils.js +2 -1
- package/src/style.scss +0 -1
- package/src/utils/fit-text-utils.js +4 -16
- package/tsconfig.json +0 -1
- package/src/components/block-quick-navigation/style.scss +0 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/global-styles/utils.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\n\nexport function useToolsPanelDropdownMenuProps() {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn ! isMobile\n\t\t? {\n\t\t\t\tpopoverProps: {\n\t\t\t\t\tplacement: 'left-start',\n\t\t\t\t\t// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)\n\t\t\t\t\toffset: 259,\n\t\t\t\t},\n\t\t }\n\t\t: {};\n}\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nexport function scopeSelector( scope, selector ) {\n\tif ( ! scope || ! selector ) {\n\t\treturn selector;\n\t}\n\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n\n/**\n * Compares global style variations according to their styles and settings properties.\n *\n * @example\n * ```js\n * const globalStyles = { styles: { typography: { fontSize: '10px' } }, settings: {} };\n * const variation = { styles: { typography: { fontSize: '10000px' } }, settings: {} };\n * const isEqual = areGlobalStyleConfigsEqual( globalStyles, variation );\n * // false\n * ```\n *\n * @param {Object} original A global styles object.\n * @param {Object} variation A global styles object.\n *\n * @return {boolean} Whether `original` and `variation` match.\n */\nexport function areGlobalStyleConfigsEqual( original, variation ) {\n\tif ( typeof original !== 'object' || typeof variation !== 'object' ) {\n\t\treturn original === variation;\n\t}\n\treturn (\n\t\tfastDeepEqual( original?.styles, variation?.styles ) &&\n\t\tfastDeepEqual( original?.settings, variation?.settings )\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAA0B;AAK1B,qBAAiC;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { getCSSValueFromRawStyle } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport { getTypographyFontSizeValue } from './typography-utils';\nimport { getValueFromObjectPath } from '../../utils/object';\n\n/* Supporting data. */\nexport const ROOT_BLOCK_SELECTOR = 'body';\nexport const ROOT_CSS_PROPERTIES_SELECTOR = ':root';\n\nexport const PRESET_METADATA = [\n\t{\n\t\tpath: [ 'color', 'palette' ],\n\t\tvalueKey: 'color',\n\t\tcssVarInfix: 'color',\n\t\tclasses: [\n\t\t\t{ classSuffix: 'color', propertyName: 'color' },\n\t\t\t{\n\t\t\t\tclassSuffix: 'background-color',\n\t\t\t\tpropertyName: 'background-color',\n\t\t\t},\n\t\t\t{\n\t\t\t\tclassSuffix: 'border-color',\n\t\t\t\tpropertyName: 'border-color',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tpath: [ 'color', 'gradients' ],\n\t\tvalueKey: 'gradient',\n\t\tcssVarInfix: 'gradient',\n\t\tclasses: [\n\t\t\t{\n\t\t\t\tclassSuffix: 'gradient-background',\n\t\t\t\tpropertyName: 'background',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tpath: [ 'color', 'duotone' ],\n\t\tvalueKey: 'colors',\n\t\tcssVarInfix: 'duotone',\n\t\tvalueFunc: ( { slug } ) => `url( '#wp-duotone-${ slug }' )`,\n\t\tclasses: [],\n\t},\n\t{\n\t\tpath: [ 'shadow', 'presets' ],\n\t\tvalueKey: 'shadow',\n\t\tcssVarInfix: 'shadow',\n\t\tclasses: [],\n\t},\n\t{\n\t\tpath: [ 'typography', 'fontSizes' ],\n\t\tvalueFunc: ( preset, settings ) =>\n\t\t\tgetTypographyFontSizeValue( preset, settings ),\n\t\tvalueKey: 'size',\n\t\tcssVarInfix: 'font-size',\n\t\tclasses: [ { classSuffix: 'font-size', propertyName: 'font-size' } ],\n\t},\n\t{\n\t\tpath: [ 'typography', 'fontFamilies' ],\n\t\tvalueKey: 'fontFamily',\n\t\tcssVarInfix: 'font-family',\n\t\tclasses: [\n\t\t\t{ classSuffix: 'font-family', propertyName: 'font-family' },\n\t\t],\n\t},\n\t{\n\t\tpath: [ 'spacing', 'spacingSizes' ],\n\t\tvalueKey: 'size',\n\t\tcssVarInfix: 'spacing',\n\t\tclasses: [],\n\t},\n\t{\n\t\tpath: [ 'border', 'radiusSizes' ],\n\t\tvalueKey: 'size',\n\t\tcssVarInfix: 'border-radius',\n\t\tclasses: [],\n\t},\n];\n\nexport const STYLE_PATH_TO_CSS_VAR_INFIX = {\n\t'color.background': 'color',\n\t'color.text': 'color',\n\t'filter.duotone': 'duotone',\n\t'elements.link.color.text': 'color',\n\t'elements.link.:hover.color.text': 'color',\n\t'elements.link.typography.fontFamily': 'font-family',\n\t'elements.link.typography.fontSize': 'font-size',\n\t'elements.button.color.text': 'color',\n\t'elements.button.color.background': 'color',\n\t'elements.caption.color.text': 'color',\n\t'elements.button.typography.fontFamily': 'font-family',\n\t'elements.button.typography.fontSize': 'font-size',\n\t'elements.heading.color': 'color',\n\t'elements.heading.color.background': 'color',\n\t'elements.heading.typography.fontFamily': 'font-family',\n\t'elements.heading.gradient': 'gradient',\n\t'elements.heading.color.gradient': 'gradient',\n\t'elements.h1.color': 'color',\n\t'elements.h1.color.background': 'color',\n\t'elements.h1.typography.fontFamily': 'font-family',\n\t'elements.h1.color.gradient': 'gradient',\n\t'elements.h2.color': 'color',\n\t'elements.h2.color.background': 'color',\n\t'elements.h2.typography.fontFamily': 'font-family',\n\t'elements.h2.color.gradient': 'gradient',\n\t'elements.h3.color': 'color',\n\t'elements.h3.color.background': 'color',\n\t'elements.h3.typography.fontFamily': 'font-family',\n\t'elements.h3.color.gradient': 'gradient',\n\t'elements.h4.color': 'color',\n\t'elements.h4.color.background': 'color',\n\t'elements.h4.typography.fontFamily': 'font-family',\n\t'elements.h4.color.gradient': 'gradient',\n\t'elements.h5.color': 'color',\n\t'elements.h5.color.background': 'color',\n\t'elements.h5.typography.fontFamily': 'font-family',\n\t'elements.h5.color.gradient': 'gradient',\n\t'elements.h6.color': 'color',\n\t'elements.h6.color.background': 'color',\n\t'elements.h6.typography.fontFamily': 'font-family',\n\t'elements.h6.color.gradient': 'gradient',\n\t'color.gradient': 'gradient',\n\tshadow: 'shadow',\n\t'typography.fontSize': 'font-size',\n\t'typography.fontFamily': 'font-family',\n};\n\n// A static list of block attributes that store global style preset slugs.\nexport const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {\n\t'color.background': 'backgroundColor',\n\t'color.text': 'textColor',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'fontSize',\n\t'typography.fontFamily': 'fontFamily',\n};\n\nexport function useToolsPanelDropdownMenuProps() {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn ! isMobile\n\t\t? {\n\t\t\t\tpopoverProps: {\n\t\t\t\t\tplacement: 'left-start',\n\t\t\t\t\t// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)\n\t\t\t\t\toffset: 259,\n\t\t\t\t},\n\t\t }\n\t\t: {};\n}\n\nfunction findInPresetsBy(\n\tfeatures,\n\tblockName,\n\tpresetPath,\n\tpresetProperty,\n\tpresetValueValue\n) {\n\t// Block presets take priority above root level presets.\n\tconst orderedPresetsByOrigin = [\n\t\tgetValueFromObjectPath( features, [\n\t\t\t'blocks',\n\t\t\tblockName,\n\t\t\t...presetPath,\n\t\t] ),\n\t\tgetValueFromObjectPath( features, presetPath ),\n\t];\n\n\tfor ( const presetByOrigin of orderedPresetsByOrigin ) {\n\t\tif ( presetByOrigin ) {\n\t\t\t// Preset origins ordered by priority.\n\t\t\tconst origins = [ 'custom', 'theme', 'default' ];\n\t\t\tfor ( const origin of origins ) {\n\t\t\t\tconst presets = presetByOrigin[ origin ];\n\t\t\t\tif ( presets ) {\n\t\t\t\t\tconst presetObject = presets.find(\n\t\t\t\t\t\t( preset ) =>\n\t\t\t\t\t\t\tpreset[ presetProperty ] === presetValueValue\n\t\t\t\t\t);\n\t\t\t\t\tif ( presetObject ) {\n\t\t\t\t\t\tif ( presetProperty === 'slug' ) {\n\t\t\t\t\t\t\treturn presetObject;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.\n\t\t\t\t\t\tconst highestPresetObjectWithSameSlug = findInPresetsBy(\n\t\t\t\t\t\t\tfeatures,\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tpresetPath,\n\t\t\t\t\t\t\t'slug',\n\t\t\t\t\t\t\tpresetObject.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thighestPresetObjectWithSameSlug[\n\t\t\t\t\t\t\t\tpresetProperty\n\t\t\t\t\t\t\t] === presetObject[ presetProperty ]\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn presetObject;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function getPresetVariableFromValue(\n\tfeatures,\n\tblockName,\n\tvariableStylePath,\n\tpresetPropertyValue\n) {\n\tif ( ! presetPropertyValue ) {\n\t\treturn presetPropertyValue;\n\t}\n\n\tconst cssVarInfix = STYLE_PATH_TO_CSS_VAR_INFIX[ variableStylePath ];\n\n\tconst metadata = PRESET_METADATA.find(\n\t\t( data ) => data.cssVarInfix === cssVarInfix\n\t);\n\n\tif ( ! metadata ) {\n\t\t// The property doesn't have preset data\n\t\t// so the value should be returned as it is.\n\t\treturn presetPropertyValue;\n\t}\n\tconst { valueKey, path } = metadata;\n\n\tconst presetObject = findInPresetsBy(\n\t\tfeatures,\n\t\tblockName,\n\t\tpath,\n\t\tvalueKey,\n\t\tpresetPropertyValue\n\t);\n\n\tif ( ! presetObject ) {\n\t\t// Value wasn't found in the presets,\n\t\t// so it must be a custom value.\n\t\treturn presetPropertyValue;\n\t}\n\n\treturn `var:preset|${ cssVarInfix }|${ presetObject.slug }`;\n}\n\nfunction getValueFromPresetVariable(\n\tfeatures,\n\tblockName,\n\tvariable,\n\t[ presetType, slug ]\n) {\n\tconst metadata = PRESET_METADATA.find(\n\t\t( data ) => data.cssVarInfix === presetType\n\t);\n\tif ( ! metadata ) {\n\t\treturn variable;\n\t}\n\n\tconst presetObject = findInPresetsBy(\n\t\tfeatures.settings,\n\t\tblockName,\n\t\tmetadata.path,\n\t\t'slug',\n\t\tslug\n\t);\n\n\tif ( presetObject ) {\n\t\tconst { valueKey } = metadata;\n\t\tconst result = presetObject[ valueKey ];\n\t\treturn getValueFromVariable( features, blockName, result );\n\t}\n\n\treturn variable;\n}\n\nfunction getValueFromCustomVariable( features, blockName, variable, path ) {\n\tconst result =\n\t\tgetValueFromObjectPath( features.settings, [\n\t\t\t'blocks',\n\t\t\tblockName,\n\t\t\t'custom',\n\t\t\t...path,\n\t\t] ) ??\n\t\tgetValueFromObjectPath( features.settings, [ 'custom', ...path ] );\n\tif ( ! result ) {\n\t\treturn variable;\n\t}\n\t// A variable may reference another variable so we need recursion until we find the value.\n\treturn getValueFromVariable( features, blockName, result );\n}\n\n/**\n * Attempts to fetch the value of a theme.json CSS variable.\n *\n * @param {Object} features GlobalStylesContext config, e.g., user, base or merged. Represents the theme.json tree.\n * @param {string} blockName The name of a block as represented in the styles property. E.g., 'root' for root-level, and 'core/${blockName}' for blocks.\n * @param {string|*} variable An incoming style value. A CSS var value is expected, but it could be any value.\n * @return {string|*|{ref}} The value of the CSS var, if found. If not found, the passed variable argument.\n */\nexport function getValueFromVariable( features, blockName, variable ) {\n\tif ( ! variable || typeof variable !== 'string' ) {\n\t\tif ( typeof variable?.ref === 'string' ) {\n\t\t\tvariable = getValueFromObjectPath( features, variable.ref );\n\t\t\t// Presence of another ref indicates a reference to another dynamic value.\n\t\t\t// Pointing to another dynamic value is not supported.\n\t\t\tif ( ! variable || !! variable?.ref ) {\n\t\t\t\treturn variable;\n\t\t\t}\n\t\t} else {\n\t\t\treturn variable;\n\t\t}\n\t}\n\tconst USER_VALUE_PREFIX = 'var:';\n\tconst THEME_VALUE_PREFIX = 'var(--wp--';\n\tconst THEME_VALUE_SUFFIX = ')';\n\n\tlet parsedVar;\n\n\tif ( variable.startsWith( USER_VALUE_PREFIX ) ) {\n\t\tparsedVar = variable.slice( USER_VALUE_PREFIX.length ).split( '|' );\n\t} else if (\n\t\tvariable.startsWith( THEME_VALUE_PREFIX ) &&\n\t\tvariable.endsWith( THEME_VALUE_SUFFIX )\n\t) {\n\t\tparsedVar = variable\n\t\t\t.slice( THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length )\n\t\t\t.split( '--' );\n\t} else {\n\t\t// We don't know how to parse the value: either is raw of uses complex CSS such as `calc(1px * var(--wp--variable) )`\n\t\treturn variable;\n\t}\n\n\tconst [ type, ...path ] = parsedVar;\n\tif ( type === 'preset' ) {\n\t\treturn getValueFromPresetVariable(\n\t\t\tfeatures,\n\t\t\tblockName,\n\t\t\tvariable,\n\t\t\tpath\n\t\t);\n\t}\n\tif ( type === 'custom' ) {\n\t\treturn getValueFromCustomVariable(\n\t\t\tfeatures,\n\t\t\tblockName,\n\t\t\tvariable,\n\t\t\tpath\n\t\t);\n\t}\n\treturn variable;\n}\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nexport function scopeSelector( scope, selector ) {\n\tif ( ! scope || ! selector ) {\n\t\treturn selector;\n\t}\n\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n\n/**\n * Scopes a collection of selectors for features and subfeatures.\n *\n * @example\n * ```js\n * const scope = '.custom-scope';\n * const selectors = {\n * color: '.wp-my-block p',\n * typography: { fontSize: '.wp-my-block caption' },\n * };\n * const result = scopeFeatureSelector( scope, selectors );\n * // result is {\n * // color: '.custom-scope .wp-my-block p',\n * // typography: { fonSize: '.custom-scope .wp-my-block caption' },\n * // }\n * ```\n *\n * @param {string} scope Selector to scope collection of selectors with.\n * @param {Object} selectors Collection of feature selectors e.g.\n *\n * @return {Object|undefined} Scoped collection of feature selectors.\n */\nexport function scopeFeatureSelectors( scope, selectors ) {\n\tif ( ! scope || ! selectors ) {\n\t\treturn;\n\t}\n\n\tconst featureSelectors = {};\n\n\tObject.entries( selectors ).forEach( ( [ feature, selector ] ) => {\n\t\tif ( typeof selector === 'string' ) {\n\t\t\tfeatureSelectors[ feature ] = scopeSelector( scope, selector );\n\t\t}\n\n\t\tif ( typeof selector === 'object' ) {\n\t\t\tfeatureSelectors[ feature ] = {};\n\n\t\t\tObject.entries( selector ).forEach(\n\t\t\t\t( [ subfeature, subfeatureSelector ] ) => {\n\t\t\t\t\tfeatureSelectors[ feature ][ subfeature ] = scopeSelector(\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tsubfeatureSelector\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn featureSelectors;\n}\n\n/**\n * Appends a sub-selector to an existing one.\n *\n * Given the compounded `selector` \"h1, h2, h3\"\n * and the `toAppend` selector \".some-class\" the result will be\n * \"h1.some-class, h2.some-class, h3.some-class\".\n *\n * @param {string} selector Original selector.\n * @param {string} toAppend Selector to append.\n *\n * @return {string} The new selector.\n */\nexport function appendToSelector( selector, toAppend ) {\n\tif ( ! selector.includes( ',' ) ) {\n\t\treturn selector + toAppend;\n\t}\n\tconst selectors = selector.split( ',' );\n\tconst newSelectors = selectors.map( ( sel ) => sel + toAppend );\n\treturn newSelectors.join( ',' );\n}\n\n/**\n * Compares global style variations according to their styles and settings properties.\n *\n * @example\n * ```js\n * const globalStyles = { styles: { typography: { fontSize: '10px' } }, settings: {} };\n * const variation = { styles: { typography: { fontSize: '10000px' } }, settings: {} };\n * const isEqual = areGlobalStyleConfigsEqual( globalStyles, variation );\n * // false\n * ```\n *\n * @param {Object} original A global styles object.\n * @param {Object} variation A global styles object.\n *\n * @return {boolean} Whether `original` and `variation` match.\n */\nexport function areGlobalStyleConfigsEqual( original, variation ) {\n\tif ( typeof original !== 'object' || typeof variation !== 'object' ) {\n\t\treturn original === variation;\n\t}\n\treturn (\n\t\tfastDeepEqual( original?.styles, variation?.styles ) &&\n\t\tfastDeepEqual( original?.settings, variation?.settings )\n\t);\n}\n\n/**\n * Generates the selector for a block style variation by creating the\n * appropriate CSS class and adding it to the ancestor portion of the block's\n * selector.\n *\n * For example, take the Button block which has a compound selector:\n * `.wp-block-button .wp-block-button__link`. With a variation named 'custom',\n * the class `.is-style-custom` should be added to the `.wp-block-button`\n * ancestor only.\n *\n * This function will take into account comma separated and complex selectors.\n *\n * @param {string} variation Name for the variation.\n * @param {string} blockSelector CSS selector for the block.\n *\n * @return {string} CSS selector for the block style variation.\n */\nexport function getBlockStyleVariationSelector( variation, blockSelector ) {\n\tconst variationClass = `.is-style-${ variation }`;\n\n\tif ( ! blockSelector ) {\n\t\treturn variationClass;\n\t}\n\n\tconst ancestorRegex = /((?::\\([^)]+\\))?\\s*)([^\\s:]+)/;\n\tconst addVariationClass = ( _match, group1, group2 ) => {\n\t\treturn group1 + group2 + variationClass;\n\t};\n\n\tconst result = blockSelector\n\t\t.split( ',' )\n\t\t.map( ( part ) => part.replace( ancestorRegex, addVariationClass ) );\n\n\treturn result.join( ',' );\n}\n\n/**\n * Looks up a theme file URI based on a relative path.\n *\n * @param {string} file A relative path.\n * @param {Array<Object>} themeFileURIs A collection of absolute theme file URIs and their corresponding file paths.\n * @return {string} A resolved theme file URI, if one is found in the themeFileURIs collection.\n */\nexport function getResolvedThemeFilePath( file, themeFileURIs ) {\n\tif ( ! file || ! themeFileURIs || ! Array.isArray( themeFileURIs ) ) {\n\t\treturn file;\n\t}\n\n\tconst uri = themeFileURIs.find(\n\t\t( themeFileUri ) => themeFileUri?.name === file\n\t);\n\n\tif ( ! uri?.href ) {\n\t\treturn file;\n\t}\n\n\treturn uri?.href;\n}\n\n/**\n * Resolves ref values in theme JSON.\n *\n * @param {Object|string} ruleValue A block style value that may contain a reference to a theme.json value.\n * @param {Object} tree A theme.json object.\n * @return {*} The resolved value or incoming ruleValue.\n */\nexport function getResolvedRefValue( ruleValue, tree ) {\n\tif ( ! ruleValue || ! tree ) {\n\t\treturn ruleValue;\n\t}\n\n\t/*\n\t * Where the rule value is an object with a 'ref' property pointing\n\t * to a path, this converts that path into the value at that path.\n\t * For example: { \"ref\": \"style.color.background\" } => \"#fff\".\n\t */\n\tif ( typeof ruleValue !== 'string' && ruleValue?.ref ) {\n\t\tconst resolvedRuleValue = getCSSValueFromRawStyle(\n\t\t\tgetValueFromObjectPath( tree, ruleValue.ref )\n\t\t);\n\n\t\t/*\n\t\t * Presence of another ref indicates a reference to another dynamic value.\n\t\t * Pointing to another dynamic value is not supported.\n\t\t */\n\t\tif ( resolvedRuleValue?.ref ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif ( resolvedRuleValue === undefined ) {\n\t\t\treturn ruleValue;\n\t\t}\n\n\t\treturn resolvedRuleValue;\n\t}\n\treturn ruleValue;\n}\n\n/**\n * Resolves ref and relative path values in theme JSON.\n *\n * @param {Object|string} ruleValue A block style value that may contain a reference to a theme.json value.\n * @param {Object} tree A theme.json object.\n * @return {*} The resolved value or incoming ruleValue.\n */\nexport function getResolvedValue( ruleValue, tree ) {\n\tif ( ! ruleValue || ! tree ) {\n\t\treturn ruleValue;\n\t}\n\n\t// Resolve ref values.\n\tconst resolvedValue = getResolvedRefValue( ruleValue, tree );\n\n\t// Resolve relative paths.\n\tif ( resolvedValue?.url ) {\n\t\tresolvedValue.url = getResolvedThemeFilePath(\n\t\t\tresolvedValue.url,\n\t\t\ttree?._links?.[ 'wp:theme-file' ]\n\t\t);\n\t}\n\n\treturn resolvedValue;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAA0B;AAK1B,qBAAiC;AACjC,0BAAwC;AAKxC,8BAA2C;AAC3C,oBAAuC;AAGhC,MAAM,sBAAsB;AAC5B,MAAM,+BAA+B;AAErC,MAAM,kBAAkB;AAAA,EAC9B;AAAA,IACC,MAAM,CAAE,SAAS,SAAU;AAAA,IAC3B,UAAU;AAAA,IACV,aAAa;AAAA,IACb,SAAS;AAAA,MACR,EAAE,aAAa,SAAS,cAAc,QAAQ;AAAA,MAC9C;AAAA,QACC,aAAa;AAAA,QACb,cAAc;AAAA,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,YAAY,WAAW,KAAM;AACtD,UAAM,wBAAoB;AAAA,UACzB,sCAAwB,MAAM,UAAU,GAAI;AAAA,IAC7C;AAMA,QAAK,mBAAmB,KAAM;AAC7B,aAAO;AAAA,IACR;AAEA,QAAK,sBAAsB,QAAY;AACtC,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR;AACA,SAAO;AACR;AASO,SAAS,iBAAkB,WAAW,MAAO;AACnD,MAAK,CAAE,aAAa,CAAE,MAAO;AAC5B,WAAO;AAAA,EACR;AAGA,QAAM,gBAAgB,oBAAqB,WAAW,IAAK;AAG3D,MAAK,eAAe,KAAM;AACzB,kBAAc,MAAM;AAAA,MACnB,cAAc;AAAA,MACd,MAAM,SAAU,eAAgB;AAAA,IACjC;AAAA,EACD;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": ["fastDeepEqual"]
|
|
7
7
|
}
|
|
@@ -62,6 +62,7 @@ var import_utils = require("./utils");
|
|
|
62
62
|
var import_content = require("./content");
|
|
63
63
|
var import_with_deprecations = require("./with-deprecations");
|
|
64
64
|
var import_block_context = __toESM(require("../block-context"));
|
|
65
|
+
var import_private_block_context = require("../block-list/private-block-context");
|
|
65
66
|
var import_shortcut = require("./shortcut");
|
|
66
67
|
var import_toolbar_button = require("./toolbar-button");
|
|
67
68
|
var import_input_event = require("./input-event");
|
|
@@ -130,9 +131,10 @@ function RichTextWrapper({
|
|
|
130
131
|
const instanceId = (0, import_compose.useInstanceId)(RichTextWrapper);
|
|
131
132
|
const anchorRef = (0, import_element.useRef)();
|
|
132
133
|
const context = (0, import_block_edit.useBlockEditContext)();
|
|
133
|
-
const { clientId, isSelected: isBlockSelected
|
|
134
|
+
const { clientId, isSelected: isBlockSelected } = context;
|
|
134
135
|
const blockBindings = context[import_context.blockBindingsKey];
|
|
135
136
|
const blockContext = (0, import_element.useContext)(import_block_context.default);
|
|
137
|
+
const { bindableAttributes } = (0, import_element.useContext)(import_private_block_context.PrivateBlockContext);
|
|
136
138
|
const registry = (0, import_data.useRegistry)();
|
|
137
139
|
const selector = (select) => {
|
|
138
140
|
if (!isBlockSelected) {
|
|
@@ -163,8 +165,7 @@ function RichTextWrapper({
|
|
|
163
165
|
]);
|
|
164
166
|
const { disableBoundBlock, bindingsPlaceholder, bindingsLabel } = (0, import_data.useSelect)(
|
|
165
167
|
(select) => {
|
|
166
|
-
|
|
167
|
-
if (!blockBindings?.[identifier] || !(blockName in __experimentalBlockBindingsSupportedAttributes)) {
|
|
168
|
+
if (!blockBindings?.[identifier] || !bindableAttributes) {
|
|
168
169
|
return {};
|
|
169
170
|
}
|
|
170
171
|
const relatedBinding = blockBindings[identifier];
|
|
@@ -193,12 +194,12 @@ function RichTextWrapper({
|
|
|
193
194
|
const { getBlockAttributes } = select(import_store.store);
|
|
194
195
|
const blockAttributes = getBlockAttributes(clientId);
|
|
195
196
|
let clientSideFieldLabel = null;
|
|
196
|
-
if (blockBindingsSource?.
|
|
197
|
-
const
|
|
197
|
+
if (blockBindingsSource?.getFieldsList) {
|
|
198
|
+
const fieldsItems = blockBindingsSource.getFieldsList({
|
|
198
199
|
select,
|
|
199
200
|
context: blockBindingsContext
|
|
200
201
|
});
|
|
201
|
-
clientSideFieldLabel =
|
|
202
|
+
clientSideFieldLabel = fieldsItems?.find(
|
|
202
203
|
(item) => (0, import_es6.default)(item.args, relatedBinding?.args)
|
|
203
204
|
)?.label;
|
|
204
205
|
}
|
|
@@ -222,7 +223,7 @@ function RichTextWrapper({
|
|
|
222
223
|
[
|
|
223
224
|
blockBindings,
|
|
224
225
|
identifier,
|
|
225
|
-
|
|
226
|
+
bindableAttributes,
|
|
226
227
|
adjustedValue,
|
|
227
228
|
clientId,
|
|
228
229
|
blockContext
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/rich-text/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n\tcreateContext,\n\tuseContext,\n} from '@wordpress/element';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { useMergeRefs, useInstanceId } from '@wordpress/compose';\nimport {\n\t__unstableUseRichText as useRichText,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport { Popover } from '@wordpress/components';\nimport { getBlockBindingsSource } from '@wordpress/blocks';\nimport deprecated from '@wordpress/deprecated';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditorAutocompleteProps } from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport { blockBindingsKey, isPreviewModeKey } from '../block-edit/context';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { store as blockEditorStore } from '../../store';\nimport { useMarkPersistent } from './use-mark-persistent';\nimport { useFormatTypes } from './use-format-types';\nimport { useEventListeners } from './event-listeners';\nimport FormatEdit from './format-edit';\nimport { getAllowedFormats } from './utils';\nimport { Content, valueToHTMLString } from './content';\nimport { withDeprecations } from './with-deprecations';\nimport BlockContext from '../block-context';\n\nexport const keyboardShortcutContext = createContext();\nkeyboardShortcutContext.displayName = 'keyboardShortcutContext';\n\nexport const inputEventContext = createContext();\ninputEventContext.displayName = 'inputEventContext';\n\nconst instanceIdKey = Symbol( 'instanceId' );\n\n/**\n * Removes props used for the native version of RichText so that they are not\n * passed to the DOM element and log warnings.\n *\n * @param {Object} props Props to filter.\n *\n * @return {Object} Filtered props.\n */\nfunction removeNativeProps( props ) {\n\tconst {\n\t\t__unstableMobileNoFocusOnMount,\n\t\tdeleteEnter,\n\t\tplaceholderTextColor,\n\t\ttextAlign,\n\t\tselectionColor,\n\t\ttagsToEliminate,\n\t\tdisableEditingMenu,\n\t\tfontSize,\n\t\tfontFamily,\n\t\tfontWeight,\n\t\tfontStyle,\n\t\tminWidth,\n\t\tmaxWidth,\n\t\tdisableSuggestions,\n\t\tdisableAutocorrection,\n\t\t...restProps\n\t} = props;\n\treturn restProps;\n}\n\nexport function RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName = 'div',\n\t\tvalue: adjustedValue = '',\n\t\tonChange: adjustedOnChange,\n\t\tisSelected: originalIsSelected,\n\t\tmultiline,\n\t\tinlineToolbar,\n\t\twrapperClassName,\n\t\tautocompleters,\n\t\tonReplace,\n\t\tplaceholder,\n\t\tallowedFormats,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitAtDoubleLineEnd: onSplitAtDoubleLineEnd,\n\t\tidentifier,\n\t\tpreserveWhiteSpace,\n\t\t__unstablePastePlainText: pastePlainText,\n\t\t__unstableEmbedURLOnPaste,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tdisableLineBreaks,\n\t\t__unstableAllowPrefixTransformations,\n\t\treadOnly,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tprops = removeNativeProps( props );\n\n\tif ( onSplit ) {\n\t\tdeprecated( 'wp.blockEditor.RichText onSplit prop', {\n\t\t\tsince: '6.4',\n\t\t\talternative: 'block.json support key: \"splitting\"',\n\t\t} );\n\t}\n\n\tconst instanceId = useInstanceId( RichTextWrapper );\n\tconst anchorRef = useRef();\n\tconst context = useBlockEditContext();\n\tconst { clientId, isSelected: isBlockSelected, name: blockName } = context;\n\tconst blockBindings = context[ blockBindingsKey ];\n\tconst blockContext = useContext( BlockContext );\n\tconst registry = useRegistry();\n\tconst selector = ( select ) => {\n\t\t// Avoid subscribing to the block editor store if the block is not\n\t\t// selected.\n\t\tif ( ! isBlockSelected ) {\n\t\t\treturn { isSelected: false };\n\t\t}\n\n\t\tconst { getSelectionStart, getSelectionEnd, getBlockEditingMode } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\n\t\tlet isSelected;\n\n\t\tif ( originalIsSelected === undefined ) {\n\t\t\tisSelected =\n\t\t\t\tselectionStart.clientId === clientId &&\n\t\t\t\tselectionEnd.clientId === clientId &&\n\t\t\t\t( identifier\n\t\t\t\t\t? selectionStart.attributeKey === identifier\n\t\t\t\t\t: selectionStart[ instanceIdKey ] === instanceId );\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\treturn {\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t\tisContentOnly: getBlockEditingMode( clientId ) === 'contentOnly',\n\t\t};\n\t};\n\tconst { selectionStart, selectionEnd, isSelected, isContentOnly } =\n\t\tuseSelect( selector, [\n\t\t\tclientId,\n\t\t\tidentifier,\n\t\t\tinstanceId,\n\t\t\toriginalIsSelected,\n\t\t\tisBlockSelected,\n\t\t] );\n\n\tconst { disableBoundBlock, bindingsPlaceholder, bindingsLabel } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { __experimentalBlockBindingsSupportedAttributes } =\n\t\t\t\tselect( blockEditorStore ).getSettings();\n\n\t\t\tif (\n\t\t\t\t! blockBindings?.[ identifier ] ||\n\t\t\t\t! (\n\t\t\t\t\tblockName in __experimentalBlockBindingsSupportedAttributes\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst relatedBinding = blockBindings[ identifier ];\n\t\t\tconst blockBindingsSource = getBlockBindingsSource(\n\t\t\t\trelatedBinding.source\n\t\t\t);\n\t\t\tconst blockBindingsContext = {};\n\t\t\tif ( blockBindingsSource?.usesContext?.length ) {\n\t\t\t\tfor ( const key of blockBindingsSource.usesContext ) {\n\t\t\t\t\tblockBindingsContext[ key ] = blockContext[ key ];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst _disableBoundBlock =\n\t\t\t\t! blockBindingsSource?.canUserEditValue?.( {\n\t\t\t\t\tselect,\n\t\t\t\t\tcontext: blockBindingsContext,\n\t\t\t\t\targs: relatedBinding.args,\n\t\t\t\t} );\n\n\t\t\t// Don't modify placeholders if value is not empty.\n\t\t\tif ( adjustedValue.length > 0 ) {\n\t\t\t\treturn {\n\t\t\t\t\tdisableBoundBlock: _disableBoundBlock,\n\t\t\t\t\t// Null values will make them fall back to the default behavior.\n\t\t\t\t\tbindingsPlaceholder: null,\n\t\t\t\t\tbindingsLabel: null,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { getBlockAttributes } = select( blockEditorStore );\n\t\t\tconst blockAttributes = getBlockAttributes( clientId );\n\t\t\tlet clientSideFieldLabel = null;\n\t\t\tif ( blockBindingsSource?.editorUI ) {\n\t\t\t\tconst editorUIResult = blockBindingsSource.editorUI( {\n\t\t\t\t\tselect,\n\t\t\t\t\tcontext: blockBindingsContext,\n\t\t\t\t} );\n\t\t\t\tclientSideFieldLabel = editorUIResult.data?.find( ( item ) =>\n\t\t\t\t\tfastDeepEqual( item.args, relatedBinding?.args )\n\t\t\t\t)?.label;\n\t\t\t}\n\n\t\t\tconst bindingKey =\n\t\t\t\tclientSideFieldLabel ?? blockBindingsSource?.label;\n\n\t\t\tconst _bindingsPlaceholder = _disableBoundBlock\n\t\t\t\t? bindingKey\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: connected field label or source label */\n\t\t\t\t\t\t__( 'Add %s' ),\n\t\t\t\t\t\tbindingKey\n\t\t\t\t );\n\t\t\tconst _bindingsLabel = _disableBoundBlock\n\t\t\t\t? relatedBinding?.args?.key || blockBindingsSource?.label\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: source label or key */\n\t\t\t\t\t\t__( 'Empty %s; start writing to edit its value' ),\n\t\t\t\t\t\trelatedBinding?.args?.key || blockBindingsSource?.label\n\t\t\t\t );\n\n\t\t\treturn {\n\t\t\t\tdisableBoundBlock: _disableBoundBlock,\n\t\t\t\tbindingsPlaceholder:\n\t\t\t\t\tblockAttributes?.placeholder || _bindingsPlaceholder,\n\t\t\t\tbindingsLabel: _bindingsLabel,\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tblockBindings,\n\t\t\tidentifier,\n\t\t\tblockName,\n\t\t\tadjustedValue,\n\t\t\tclientId,\n\t\t\tblockContext,\n\t\t]\n\t);\n\tconst isInsidePatternOverrides = !! blockContext?.[ 'pattern/overrides' ];\n\tconst hasOverrideEnabled =\n\t\tblockBindings?.__default?.source === 'core/pattern-overrides';\n\n\tconst shouldDisableForPattern =\n\t\tisInsidePatternOverrides && ! hasOverrideEnabled;\n\n\tconst shouldDisableEditing =\n\t\treadOnly || disableBoundBlock || shouldDisableForPattern;\n\n\tconst { getSelectionStart, getSelectionEnd, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tconst selection = {};\n\t\t\tconst unset = start === undefined && end === undefined;\n\n\t\t\tconst baseSelection = {\n\t\t\t\tclientId,\n\t\t\t\t[ identifier ? 'attributeKey' : instanceIdKey ]: identifier\n\t\t\t\t\t? identifier\n\t\t\t\t\t: instanceId,\n\t\t\t};\n\n\t\t\tif ( typeof start === 'number' || unset ) {\n\t\t\t\t// If we are only setting the start (or the end below), which\n\t\t\t\t// means a partial selection, and we're not updating a selection\n\t\t\t\t// with the same client ID, abort. This means the selected block\n\t\t\t\t// is a parent block.\n\t\t\t\tif (\n\t\t\t\t\tend === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionEnd().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.start = {\n\t\t\t\t\t...baseSelection,\n\t\t\t\t\toffset: start,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( typeof end === 'number' || unset ) {\n\t\t\t\tif (\n\t\t\t\t\tstart === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionStart().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.end = {\n\t\t\t\t\t...baseSelection,\n\t\t\t\t\toffset: end,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionChange( selection );\n\t\t},\n\t\t[\n\t\t\tclientId,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetSelectionEnd,\n\t\t\tgetSelectionStart,\n\t\t\tidentifier,\n\t\t\tinstanceId,\n\t\t\tselectionChange,\n\t\t]\n\t);\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t\twithoutInteractiveFormatting,\n\t\tdisableNoneEssentialFormatting: isContentOnly,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tgetValue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: adjustedValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tadjustedOnChange( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tonSelectionChange,\n\t\tplaceholder: bindingsPlaceholder || placeholder,\n\t\t__unstableIsSelected: isSelected,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tpreserveWhiteSpace,\n\t\t__unstableDependencies: [ ...dependencies, tagName ],\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\tconst autocompleteProps = useBlockEditorAutocompleteProps( {\n\t\tonReplace,\n\t\tcompleters: autocompleters,\n\t\trecord: value,\n\t\tonChange,\n\t} );\n\n\tuseMarkPersistent( { html: adjustedValue, value } );\n\n\tconst keyboardShortcuts = useRef( new Set() );\n\tconst inputEvents = useRef( new Set() );\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst TagName = tagName;\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<Popover.__unstableSlotNameProvider value=\"__unstable-block-tools-after\">\n\t\t\t\t\t\t\t{ children &&\n\t\t\t\t\t\t\t\tchildren( { value, onChange, onFocus } ) }\n\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover.__unstableSlotNameProvider>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t{ isSelected && hasFormats && (\n\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\teditableContentElement={ anchorRef.current }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<TagName\n\t\t\t\t// Overridable props.\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline={ ! disableLineBreaks }\n\t\t\t\taria-readonly={ shouldDisableEditing }\n\t\t\t\t{ ...props }\n\t\t\t\t// Unset draggable (coming from block props) for contentEditable\n\t\t\t\t// elements because it will interfere with multi block selection\n\t\t\t\t// when the contentEditable and draggable elements are the same\n\t\t\t\t// element.\n\t\t\t\tdraggable={ undefined }\n\t\t\t\taria-label={\n\t\t\t\t\tbindingsLabel || props[ 'aria-label' ] || placeholder\n\t\t\t\t}\n\t\t\t\t{ ...autocompleteProps }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t// Rich text ref must be first because its focus listener\n\t\t\t\t\t// must be set up before any other ref calls .focus() on\n\t\t\t\t\t// mount.\n\t\t\t\t\trichTextRef,\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tautocompleteProps.ref,\n\t\t\t\t\tprops.ref,\n\t\t\t\t\tuseEventListeners( {\n\t\t\t\t\t\tregistry,\n\t\t\t\t\t\tgetValue,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tselectionChange,\n\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\tdisableFormats,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\ttagName,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\t\t\tpastePlainText,\n\t\t\t\t\t\tonMerge,\n\t\t\t\t\t\tonRemove,\n\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\tdisableLineBreaks,\n\t\t\t\t\t\tonSplitAtEnd,\n\t\t\t\t\t\tonSplitAtDoubleLineEnd,\n\t\t\t\t\t\tkeyboardShortcuts,\n\t\t\t\t\t\tinputEvents,\n\t\t\t\t\t} ),\n\t\t\t\t\tanchorRef,\n\t\t\t\t] ) }\n\t\t\t\tcontentEditable={ ! shouldDisableEditing }\n\t\t\t\tsuppressContentEditableWarning\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-editor-rich-text__editable',\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'rich-text'\n\t\t\t\t) }\n\t\t\t\t// Setting tabIndex to 0 is unnecessary, the element is already\n\t\t\t\t// focusable because it's contentEditable. This also fixes a\n\t\t\t\t// Safari bug where it's not possible to Shift+Click multi\n\t\t\t\t// select blocks when Shift Clicking into an element with\n\t\t\t\t// tabIndex because Safari will focus the element. However,\n\t\t\t\t// Safari will correctly ignore nested contentEditable elements.\n\t\t\t\ttabIndex={\n\t\t\t\t\tprops.tabIndex === 0 && ! shouldDisableEditing\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: props.tabIndex\n\t\t\t\t}\n\t\t\t\tdata-wp-block-attribute-key={ identifier }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\n// This is the private API for the RichText component.\n// It allows access to all props, not just the public ones.\nexport const PrivateRichText = withDeprecations(\n\tforwardRef( RichTextWrapper )\n);\n\nPrivateRichText.Content = Content;\nPrivateRichText.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\n// This is the public API for the RichText component.\n// We wrap the PrivateRichText component to hide some props from the public API.\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md\n */\nconst PublicForwardedRichTextContainer = forwardRef( ( props, ref ) => {\n\tconst context = useBlockEditContext();\n\tconst isPreviewMode = context[ isPreviewModeKey ];\n\n\tif ( isPreviewMode ) {\n\t\t// Remove all non-content props.\n\t\tconst {\n\t\t\tchildren,\n\t\t\ttagName: Tag = 'div',\n\t\t\tvalue,\n\t\t\tonChange,\n\t\t\tisSelected,\n\t\t\tmultiline,\n\t\t\tinlineToolbar,\n\t\t\twrapperClassName,\n\t\t\tautocompleters,\n\t\t\tonReplace,\n\t\t\tplaceholder,\n\t\t\tallowedFormats,\n\t\t\twithoutInteractiveFormatting,\n\t\t\tonRemove,\n\t\t\tonMerge,\n\t\t\tonSplit,\n\t\t\t__unstableOnSplitAtEnd,\n\t\t\t__unstableOnSplitAtDoubleLineEnd,\n\t\t\tidentifier,\n\t\t\tpreserveWhiteSpace,\n\t\t\t__unstablePastePlainText,\n\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t__unstableDisableFormats,\n\t\t\tdisableLineBreaks,\n\t\t\t__unstableAllowPrefixTransformations,\n\t\t\treadOnly,\n\t\t\t...contentProps\n\t\t} = removeNativeProps( props );\n\t\treturn (\n\t\t\t<Tag\n\t\t\t\t{ ...contentProps }\n\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t__html: valueToHTMLString( value, multiline ),\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn <PrivateRichText ref={ ref } { ...props } readOnly={ false } />;\n} );\n\nPublicForwardedRichTextContainer.Content = Content;\nPublicForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\nexport default PublicForwardedRichTextContainer;\nexport { RichTextShortcut } from './shortcut';\nexport { RichTextToolbarButton } from './toolbar-button';\nexport { __unstableRichTextInputEvent } from './input-event';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n\tcreateContext,\n\tuseContext,\n} from '@wordpress/element';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { useMergeRefs, useInstanceId } from '@wordpress/compose';\nimport {\n\t__unstableUseRichText as useRichText,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport { Popover } from '@wordpress/components';\nimport { getBlockBindingsSource } from '@wordpress/blocks';\nimport deprecated from '@wordpress/deprecated';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditorAutocompleteProps } from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport { blockBindingsKey, isPreviewModeKey } from '../block-edit/context';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { store as blockEditorStore } from '../../store';\nimport { useMarkPersistent } from './use-mark-persistent';\nimport { useFormatTypes } from './use-format-types';\nimport { useEventListeners } from './event-listeners';\nimport FormatEdit from './format-edit';\nimport { getAllowedFormats } from './utils';\nimport { Content, valueToHTMLString } from './content';\nimport { withDeprecations } from './with-deprecations';\nimport BlockContext from '../block-context';\nimport { PrivateBlockContext } from '../block-list/private-block-context';\n\nexport const keyboardShortcutContext = createContext();\nkeyboardShortcutContext.displayName = 'keyboardShortcutContext';\n\nexport const inputEventContext = createContext();\ninputEventContext.displayName = 'inputEventContext';\n\nconst instanceIdKey = Symbol( 'instanceId' );\n\n/**\n * Removes props used for the native version of RichText so that they are not\n * passed to the DOM element and log warnings.\n *\n * @param {Object} props Props to filter.\n *\n * @return {Object} Filtered props.\n */\nfunction removeNativeProps( props ) {\n\tconst {\n\t\t__unstableMobileNoFocusOnMount,\n\t\tdeleteEnter,\n\t\tplaceholderTextColor,\n\t\ttextAlign,\n\t\tselectionColor,\n\t\ttagsToEliminate,\n\t\tdisableEditingMenu,\n\t\tfontSize,\n\t\tfontFamily,\n\t\tfontWeight,\n\t\tfontStyle,\n\t\tminWidth,\n\t\tmaxWidth,\n\t\tdisableSuggestions,\n\t\tdisableAutocorrection,\n\t\t...restProps\n\t} = props;\n\treturn restProps;\n}\n\nexport function RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName = 'div',\n\t\tvalue: adjustedValue = '',\n\t\tonChange: adjustedOnChange,\n\t\tisSelected: originalIsSelected,\n\t\tmultiline,\n\t\tinlineToolbar,\n\t\twrapperClassName,\n\t\tautocompleters,\n\t\tonReplace,\n\t\tplaceholder,\n\t\tallowedFormats,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitAtDoubleLineEnd: onSplitAtDoubleLineEnd,\n\t\tidentifier,\n\t\tpreserveWhiteSpace,\n\t\t__unstablePastePlainText: pastePlainText,\n\t\t__unstableEmbedURLOnPaste,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tdisableLineBreaks,\n\t\t__unstableAllowPrefixTransformations,\n\t\treadOnly,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tprops = removeNativeProps( props );\n\n\tif ( onSplit ) {\n\t\tdeprecated( 'wp.blockEditor.RichText onSplit prop', {\n\t\t\tsince: '6.4',\n\t\t\talternative: 'block.json support key: \"splitting\"',\n\t\t} );\n\t}\n\n\tconst instanceId = useInstanceId( RichTextWrapper );\n\tconst anchorRef = useRef();\n\tconst context = useBlockEditContext();\n\tconst { clientId, isSelected: isBlockSelected } = context;\n\tconst blockBindings = context[ blockBindingsKey ];\n\tconst blockContext = useContext( BlockContext );\n\tconst { bindableAttributes } = useContext( PrivateBlockContext );\n\tconst registry = useRegistry();\n\tconst selector = ( select ) => {\n\t\t// Avoid subscribing to the block editor store if the block is not\n\t\t// selected.\n\t\tif ( ! isBlockSelected ) {\n\t\t\treturn { isSelected: false };\n\t\t}\n\n\t\tconst { getSelectionStart, getSelectionEnd, getBlockEditingMode } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\n\t\tlet isSelected;\n\n\t\tif ( originalIsSelected === undefined ) {\n\t\t\tisSelected =\n\t\t\t\tselectionStart.clientId === clientId &&\n\t\t\t\tselectionEnd.clientId === clientId &&\n\t\t\t\t( identifier\n\t\t\t\t\t? selectionStart.attributeKey === identifier\n\t\t\t\t\t: selectionStart[ instanceIdKey ] === instanceId );\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\treturn {\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t\tisContentOnly: getBlockEditingMode( clientId ) === 'contentOnly',\n\t\t};\n\t};\n\tconst { selectionStart, selectionEnd, isSelected, isContentOnly } =\n\t\tuseSelect( selector, [\n\t\t\tclientId,\n\t\t\tidentifier,\n\t\t\tinstanceId,\n\t\t\toriginalIsSelected,\n\t\t\tisBlockSelected,\n\t\t] );\n\n\tconst { disableBoundBlock, bindingsPlaceholder, bindingsLabel } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! blockBindings?.[ identifier ] || ! bindableAttributes ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst relatedBinding = blockBindings[ identifier ];\n\t\t\tconst blockBindingsSource = getBlockBindingsSource(\n\t\t\t\trelatedBinding.source\n\t\t\t);\n\t\t\tconst blockBindingsContext = {};\n\t\t\tif ( blockBindingsSource?.usesContext?.length ) {\n\t\t\t\tfor ( const key of blockBindingsSource.usesContext ) {\n\t\t\t\t\tblockBindingsContext[ key ] = blockContext[ key ];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst _disableBoundBlock =\n\t\t\t\t! blockBindingsSource?.canUserEditValue?.( {\n\t\t\t\t\tselect,\n\t\t\t\t\tcontext: blockBindingsContext,\n\t\t\t\t\targs: relatedBinding.args,\n\t\t\t\t} );\n\n\t\t\t// Don't modify placeholders if value is not empty.\n\t\t\tif ( adjustedValue.length > 0 ) {\n\t\t\t\treturn {\n\t\t\t\t\tdisableBoundBlock: _disableBoundBlock,\n\t\t\t\t\t// Null values will make them fall back to the default behavior.\n\t\t\t\t\tbindingsPlaceholder: null,\n\t\t\t\t\tbindingsLabel: null,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { getBlockAttributes } = select( blockEditorStore );\n\t\t\tconst blockAttributes = getBlockAttributes( clientId );\n\t\t\tlet clientSideFieldLabel = null;\n\t\t\tif ( blockBindingsSource?.getFieldsList ) {\n\t\t\t\tconst fieldsItems = blockBindingsSource.getFieldsList( {\n\t\t\t\t\tselect,\n\t\t\t\t\tcontext: blockBindingsContext,\n\t\t\t\t} );\n\t\t\t\tclientSideFieldLabel = fieldsItems?.find( ( item ) =>\n\t\t\t\t\tfastDeepEqual( item.args, relatedBinding?.args )\n\t\t\t\t)?.label;\n\t\t\t}\n\n\t\t\tconst bindingKey =\n\t\t\t\tclientSideFieldLabel ?? blockBindingsSource?.label;\n\n\t\t\tconst _bindingsPlaceholder = _disableBoundBlock\n\t\t\t\t? bindingKey\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: connected field label or source label */\n\t\t\t\t\t\t__( 'Add %s' ),\n\t\t\t\t\t\tbindingKey\n\t\t\t\t );\n\t\t\tconst _bindingsLabel = _disableBoundBlock\n\t\t\t\t? relatedBinding?.args?.key || blockBindingsSource?.label\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: source label or key */\n\t\t\t\t\t\t__( 'Empty %s; start writing to edit its value' ),\n\t\t\t\t\t\trelatedBinding?.args?.key || blockBindingsSource?.label\n\t\t\t\t );\n\n\t\t\treturn {\n\t\t\t\tdisableBoundBlock: _disableBoundBlock,\n\t\t\t\tbindingsPlaceholder:\n\t\t\t\t\tblockAttributes?.placeholder || _bindingsPlaceholder,\n\t\t\t\tbindingsLabel: _bindingsLabel,\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tblockBindings,\n\t\t\tidentifier,\n\t\t\tbindableAttributes,\n\t\t\tadjustedValue,\n\t\t\tclientId,\n\t\t\tblockContext,\n\t\t]\n\t);\n\tconst isInsidePatternOverrides = !! blockContext?.[ 'pattern/overrides' ];\n\tconst hasOverrideEnabled =\n\t\tblockBindings?.__default?.source === 'core/pattern-overrides';\n\n\tconst shouldDisableForPattern =\n\t\tisInsidePatternOverrides && ! hasOverrideEnabled;\n\n\tconst shouldDisableEditing =\n\t\treadOnly || disableBoundBlock || shouldDisableForPattern;\n\n\tconst { getSelectionStart, getSelectionEnd, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tconst selection = {};\n\t\t\tconst unset = start === undefined && end === undefined;\n\n\t\t\tconst baseSelection = {\n\t\t\t\tclientId,\n\t\t\t\t[ identifier ? 'attributeKey' : instanceIdKey ]: identifier\n\t\t\t\t\t? identifier\n\t\t\t\t\t: instanceId,\n\t\t\t};\n\n\t\t\tif ( typeof start === 'number' || unset ) {\n\t\t\t\t// If we are only setting the start (or the end below), which\n\t\t\t\t// means a partial selection, and we're not updating a selection\n\t\t\t\t// with the same client ID, abort. This means the selected block\n\t\t\t\t// is a parent block.\n\t\t\t\tif (\n\t\t\t\t\tend === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionEnd().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.start = {\n\t\t\t\t\t...baseSelection,\n\t\t\t\t\toffset: start,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( typeof end === 'number' || unset ) {\n\t\t\t\tif (\n\t\t\t\t\tstart === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionStart().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.end = {\n\t\t\t\t\t...baseSelection,\n\t\t\t\t\toffset: end,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionChange( selection );\n\t\t},\n\t\t[\n\t\t\tclientId,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetSelectionEnd,\n\t\t\tgetSelectionStart,\n\t\t\tidentifier,\n\t\t\tinstanceId,\n\t\t\tselectionChange,\n\t\t]\n\t);\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t\twithoutInteractiveFormatting,\n\t\tdisableNoneEssentialFormatting: isContentOnly,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tgetValue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: adjustedValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tadjustedOnChange( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tonSelectionChange,\n\t\tplaceholder: bindingsPlaceholder || placeholder,\n\t\t__unstableIsSelected: isSelected,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tpreserveWhiteSpace,\n\t\t__unstableDependencies: [ ...dependencies, tagName ],\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\tconst autocompleteProps = useBlockEditorAutocompleteProps( {\n\t\tonReplace,\n\t\tcompleters: autocompleters,\n\t\trecord: value,\n\t\tonChange,\n\t} );\n\n\tuseMarkPersistent( { html: adjustedValue, value } );\n\n\tconst keyboardShortcuts = useRef( new Set() );\n\tconst inputEvents = useRef( new Set() );\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst TagName = tagName;\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<Popover.__unstableSlotNameProvider value=\"__unstable-block-tools-after\">\n\t\t\t\t\t\t\t{ children &&\n\t\t\t\t\t\t\t\tchildren( { value, onChange, onFocus } ) }\n\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover.__unstableSlotNameProvider>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t{ isSelected && hasFormats && (\n\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\teditableContentElement={ anchorRef.current }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<TagName\n\t\t\t\t// Overridable props.\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline={ ! disableLineBreaks }\n\t\t\t\taria-readonly={ shouldDisableEditing }\n\t\t\t\t{ ...props }\n\t\t\t\t// Unset draggable (coming from block props) for contentEditable\n\t\t\t\t// elements because it will interfere with multi block selection\n\t\t\t\t// when the contentEditable and draggable elements are the same\n\t\t\t\t// element.\n\t\t\t\tdraggable={ undefined }\n\t\t\t\taria-label={\n\t\t\t\t\tbindingsLabel || props[ 'aria-label' ] || placeholder\n\t\t\t\t}\n\t\t\t\t{ ...autocompleteProps }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t// Rich text ref must be first because its focus listener\n\t\t\t\t\t// must be set up before any other ref calls .focus() on\n\t\t\t\t\t// mount.\n\t\t\t\t\trichTextRef,\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tautocompleteProps.ref,\n\t\t\t\t\tprops.ref,\n\t\t\t\t\tuseEventListeners( {\n\t\t\t\t\t\tregistry,\n\t\t\t\t\t\tgetValue,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tselectionChange,\n\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\tdisableFormats,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\ttagName,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\t\t\tpastePlainText,\n\t\t\t\t\t\tonMerge,\n\t\t\t\t\t\tonRemove,\n\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\tdisableLineBreaks,\n\t\t\t\t\t\tonSplitAtEnd,\n\t\t\t\t\t\tonSplitAtDoubleLineEnd,\n\t\t\t\t\t\tkeyboardShortcuts,\n\t\t\t\t\t\tinputEvents,\n\t\t\t\t\t} ),\n\t\t\t\t\tanchorRef,\n\t\t\t\t] ) }\n\t\t\t\tcontentEditable={ ! shouldDisableEditing }\n\t\t\t\tsuppressContentEditableWarning\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-editor-rich-text__editable',\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'rich-text'\n\t\t\t\t) }\n\t\t\t\t// Setting tabIndex to 0 is unnecessary, the element is already\n\t\t\t\t// focusable because it's contentEditable. This also fixes a\n\t\t\t\t// Safari bug where it's not possible to Shift+Click multi\n\t\t\t\t// select blocks when Shift Clicking into an element with\n\t\t\t\t// tabIndex because Safari will focus the element. However,\n\t\t\t\t// Safari will correctly ignore nested contentEditable elements.\n\t\t\t\ttabIndex={\n\t\t\t\t\tprops.tabIndex === 0 && ! shouldDisableEditing\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: props.tabIndex\n\t\t\t\t}\n\t\t\t\tdata-wp-block-attribute-key={ identifier }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\n// This is the private API for the RichText component.\n// It allows access to all props, not just the public ones.\nexport const PrivateRichText = withDeprecations(\n\tforwardRef( RichTextWrapper )\n);\n\nPrivateRichText.Content = Content;\nPrivateRichText.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\n// This is the public API for the RichText component.\n// We wrap the PrivateRichText component to hide some props from the public API.\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md\n */\nconst PublicForwardedRichTextContainer = forwardRef( ( props, ref ) => {\n\tconst context = useBlockEditContext();\n\tconst isPreviewMode = context[ isPreviewModeKey ];\n\n\tif ( isPreviewMode ) {\n\t\t// Remove all non-content props.\n\t\tconst {\n\t\t\tchildren,\n\t\t\ttagName: Tag = 'div',\n\t\t\tvalue,\n\t\t\tonChange,\n\t\t\tisSelected,\n\t\t\tmultiline,\n\t\t\tinlineToolbar,\n\t\t\twrapperClassName,\n\t\t\tautocompleters,\n\t\t\tonReplace,\n\t\t\tplaceholder,\n\t\t\tallowedFormats,\n\t\t\twithoutInteractiveFormatting,\n\t\t\tonRemove,\n\t\t\tonMerge,\n\t\t\tonSplit,\n\t\t\t__unstableOnSplitAtEnd,\n\t\t\t__unstableOnSplitAtDoubleLineEnd,\n\t\t\tidentifier,\n\t\t\tpreserveWhiteSpace,\n\t\t\t__unstablePastePlainText,\n\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t__unstableDisableFormats,\n\t\t\tdisableLineBreaks,\n\t\t\t__unstableAllowPrefixTransformations,\n\t\t\treadOnly,\n\t\t\t...contentProps\n\t\t} = removeNativeProps( props );\n\t\treturn (\n\t\t\t<Tag\n\t\t\t\t{ ...contentProps }\n\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t__html: valueToHTMLString( value, multiline ),\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn <PrivateRichText ref={ ref } { ...props } readOnly={ false } />;\n} );\n\nPublicForwardedRichTextContainer.Content = Content;\nPublicForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\nexport default PublicForwardedRichTextContainer;\nexport { RichTextShortcut } from './shortcut';\nexport { RichTextToolbarButton } from './toolbar-button';\nexport { __unstableRichTextInputEvent } from './input-event';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoaE;AAjaF,kBAAiB;AACjB,iBAA0B;AAK1B,qBAMO;AACP,kBAAoD;AACpD,qBAA4C;AAC5C,uBAGO;AACP,wBAAwB;AACxB,oBAAuC;AACvC,wBAAuB;AACvB,kBAA4B;AAK5B,0BAAgD;AAChD,wBAAoC;AACpC,qBAAmD;AACnD,sCAAmC;AACnC,mBAA0C;AAC1C,iCAAkC;AAClC,8BAA+B;AAC/B,6BAAkC;AAClC,yBAAuB;AACvB,mBAAkC;AAClC,qBAA2C;AAC3C,+BAAiC;AACjC,2BAAyB;AACzB,mCAAoC;AAiiBpC,sBAAiC;AACjC,4BAAsC;AACtC,yBAA6C;AAjiBtC,MAAM,8BAA0B,8BAAc;AACrD,wBAAwB,cAAc;AAE/B,MAAM,wBAAoB,8BAAc;AAC/C,kBAAkB,cAAc;AAEhC,MAAM,gBAAgB,OAAQ,YAAa;AAU3C,SAAS,kBAAmB,OAAQ;AACnC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACJ,IAAI;AACJ,SAAO;AACR;AAEO,SAAS,gBACf;AAAA,EACC;AAAA,EACA,UAAU;AAAA,EACV,OAAO,gBAAgB;AAAA,EACvB,UAAU;AAAA,EACV,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,k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A,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACJ,IAAI,kBAAmB,KAAM;AAC7B,WACC;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACL,yBAA0B;AAAA,UACzB,YAAQ,kCAAmB,OAAO,SAAU;AAAA,QAC7C;AAAA;AAAA,IACD;AAAA,EAEF;AAEA,SAAO,4CAAC,mBAAgB,KAAc,GAAG,OAAQ,UAAW,OAAQ;AACrE,CAAE;AAEF,iCAAiC,UAAU;AAC3C,iCAAiC,UAAU,CAAE,UAAW;AACvD,SAAO,CAAE,SAAS,MAAM,WAAW;AACpC;AAEA,IAAO,oBAAQ;",
|
|
6
6
|
"names": ["deprecated", "BlockContext", "getSelectionStart", "getSelectionEnd", "blockEditorStore", "selectionStart", "selectionEnd", "isSelected", "fastDeepEqual", "value", "useRichText", "FormatEdit", "FormatToolbarContainer", "clsx"]
|
|
7
7
|
}
|
|
@@ -29,6 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var allowed_blocks_exports = {};
|
|
30
30
|
__export(allowed_blocks_exports, {
|
|
31
31
|
addAttribute: () => addAttribute,
|
|
32
|
+
addTransforms: () => addTransforms,
|
|
32
33
|
default: () => allowed_blocks_default
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(allowed_blocks_exports);
|
|
@@ -77,8 +78,56 @@ function addAttribute(settings) {
|
|
|
77
78
|
"core/allowedBlocks/attribute",
|
|
78
79
|
addAttribute
|
|
79
80
|
);
|
|
81
|
+
function addTransforms(result, source, index, results) {
|
|
82
|
+
if (!(0, import_blocks.hasBlockSupport)(result.name, "allowedBlocks")) {
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
if (source.length !== 1 && results.length === 1 && result.innerBlocks.length === source.length) {
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
if (results.length === 1 && source.length > 1 || results.length > 1 && source.length === 1) {
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
if (results.length > 1 && source.length > 1 && results.length !== source.length) {
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
if (result.attributes.allowedBlocks) {
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
const sourceAllowedBlocks = source[index]?.attributes?.allowedBlocks;
|
|
98
|
+
if (!sourceAllowedBlocks) {
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
const blockType = (0, import_blocks.getBlockType)(result.name);
|
|
102
|
+
const destinationAllowedBlocks = blockType?.allowedBlocks || [];
|
|
103
|
+
if (!destinationAllowedBlocks.length) {
|
|
104
|
+
return {
|
|
105
|
+
...result,
|
|
106
|
+
attributes: {
|
|
107
|
+
...result.attributes,
|
|
108
|
+
allowedBlocks: sourceAllowedBlocks
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const filteredSourceAllowedBlocks = sourceAllowedBlocks.filter(
|
|
113
|
+
(block) => destinationAllowedBlocks.includes(block)
|
|
114
|
+
);
|
|
115
|
+
return {
|
|
116
|
+
...result,
|
|
117
|
+
attributes: {
|
|
118
|
+
...result.attributes,
|
|
119
|
+
allowedBlocks: filteredSourceAllowedBlocks
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
(0, import_hooks.addFilter)(
|
|
124
|
+
"blocks.switchToBlockType.transformedBlock",
|
|
125
|
+
"core/allowedBlocks/addTransforms",
|
|
126
|
+
addTransforms
|
|
127
|
+
);
|
|
80
128
|
// Annotate the CommonJS export names for ESM import in node:
|
|
81
129
|
0 && (module.exports = {
|
|
82
|
-
addAttribute
|
|
130
|
+
addAttribute,
|
|
131
|
+
addTransforms
|
|
83
132
|
});
|
|
84
133
|
//# sourceMappingURL=allowed-blocks.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/allowed-blocks.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { PrivateInspectorControlsAllowedBlocks } from '../components/inspector-controls/groups';\nimport BlockAllowedBlocksControl from '../components/block-allowed-blocks/allowed-blocks-control';\n\nfunction BlockEditAllowedBlocksControlPure( { clientId } ) {\n\tconst isContentOnly = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\tselect( blockEditorStore ).getBlockEditingMode( clientId ) ===\n\t\t\t\t'contentOnly'\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( isContentOnly ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PrivateInspectorControlsAllowedBlocks.Fill>\n\t\t\t<BlockAllowedBlocksControl clientId={ clientId } />\n\t\t</PrivateInspectorControlsAllowedBlocks.Fill>\n\t);\n}\n\nexport default {\n\tedit: BlockEditAllowedBlocksControlPure,\n\tattributeKeys: [ 'allowedBlocks' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'allowedBlocks' );\n\t},\n};\n\n/**\n * Filters registered block settings, extending attributes with allowedBlocks.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( settings?.attributes?.allowedBlocks?.type ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'allowedBlocks' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tallowedBlocks: {\n\t\t\t\ttype: 'array',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/allowedBlocks/attribute',\n\taddAttribute\n);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BG;AA5BH,mBAA0B;AAC1B,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport, getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { PrivateInspectorControlsAllowedBlocks } from '../components/inspector-controls/groups';\nimport BlockAllowedBlocksControl from '../components/block-allowed-blocks/allowed-blocks-control';\n\nfunction BlockEditAllowedBlocksControlPure( { clientId } ) {\n\tconst isContentOnly = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\tselect( blockEditorStore ).getBlockEditingMode( clientId ) ===\n\t\t\t\t'contentOnly'\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( isContentOnly ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PrivateInspectorControlsAllowedBlocks.Fill>\n\t\t\t<BlockAllowedBlocksControl clientId={ clientId } />\n\t\t</PrivateInspectorControlsAllowedBlocks.Fill>\n\t);\n}\n\nexport default {\n\tedit: BlockEditAllowedBlocksControlPure,\n\tattributeKeys: [ 'allowedBlocks' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'allowedBlocks' );\n\t},\n};\n\n/**\n * Filters registered block settings, extending attributes with allowedBlocks.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( settings?.attributes?.allowedBlocks?.type ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'allowedBlocks' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tallowedBlocks: {\n\t\t\t\ttype: 'array',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/allowedBlocks/attribute',\n\taddAttribute\n);\n\n/**\n * Add transforms to preserve allowedBlocks on block transformations.\n *\n * @param {Object} result The transformed block.\n * @param {Array} source Original blocks transformed.\n * @param {number} index Index of the transformed block.\n * @param {Array} results All blocks that resulted from the transformation.\n * @return {Object} Modified transformed block.\n */\nexport function addTransforms( result, source, index, results ) {\n\tif ( ! hasBlockSupport( result.name, 'allowedBlocks' ) ) {\n\t\treturn result;\n\t}\n\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the attribute should not be kept.\n\tif (\n\t\tsource.length !== 1 &&\n\t\tresults.length === 1 &&\n\t\tresult.innerBlocks.length === source.length\n\t) {\n\t\treturn result;\n\t}\n\n\t// If we are transforming one block to multiple blocks or multiple blocks to one block,\n\t// we ignore the attribute during the transform.\n\tif (\n\t\t( results.length === 1 && source.length > 1 ) ||\n\t\t( results.length > 1 && source.length === 1 )\n\t) {\n\t\treturn result;\n\t}\n\n\t// If we are transforming multiple blocks to multiple blocks with different counts,\n\t// we ignore the attribute during the transform.\n\tif (\n\t\tresults.length > 1 &&\n\t\tsource.length > 1 &&\n\t\tresults.length !== source.length\n\t) {\n\t\treturn result;\n\t}\n\n\t// If the target block already has allowedBlocks, we don't need to preserve\n\t// the source allowedBlocks.\n\tif ( result.attributes.allowedBlocks ) {\n\t\treturn result;\n\t}\n\n\tconst sourceAllowedBlocks = source[ index ]?.attributes?.allowedBlocks;\n\n\tif ( ! sourceAllowedBlocks ) {\n\t\treturn result;\n\t}\n\n\tconst blockType = getBlockType( result.name );\n\tconst destinationAllowedBlocks = blockType?.allowedBlocks || [];\n\n\tif ( ! destinationAllowedBlocks.length ) {\n\t\treturn {\n\t\t\t...result,\n\t\t\tattributes: {\n\t\t\t\t...result.attributes,\n\t\t\t\tallowedBlocks: sourceAllowedBlocks,\n\t\t\t},\n\t\t};\n\t}\n\n\t// Filter out any source allowed blocks that are not defined in the destination allowed blocks.\n\tconst filteredSourceAllowedBlocks = sourceAllowedBlocks.filter( ( block ) =>\n\t\tdestinationAllowedBlocks.includes( block )\n\t);\n\n\treturn {\n\t\t...result,\n\t\tattributes: {\n\t\t\t...result.attributes,\n\t\t\tallowedBlocks: filteredSourceAllowedBlocks,\n\t\t},\n\t};\n}\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/allowedBlocks/addTransforms',\n\taddTransforms\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BG;AA5BH,mBAA0B;AAC1B,oBAA8C;AAC9C,kBAA0B;AAK1B,mBAA0C;AAC1C,oBAAsD;AACtD,oCAAsC;AAEtC,SAAS,kCAAmC,EAAE,SAAS,GAAI;AAC1D,QAAM,oBAAgB;AAAA,IACrB,CAAE,WAAY;AACb,aACC,OAAQ,aAAAA,KAAiB,EAAE,oBAAqB,QAAS,MACzD;AAAA,IAEF;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,MAAK,eAAgB;AACpB,WAAO;AAAA,EACR;AAEA,SACC,4CAAC,oDAAsC,MAAtC,EACA,sDAAC,8BAAAC,SAAA,EAA0B,UAAsB,GAClD;AAEF;AAEA,IAAO,yBAAQ;AAAA,EACd,MAAM;AAAA,EACN,eAAe,CAAE,eAAgB;AAAA,EACjC,WAAY,MAAO;AAClB,eAAO,+BAAiB,MAAM,eAAgB;AAAA,EAC/C;AACD;AASO,SAAS,aAAc,UAAW;AAExC,MAAK,UAAU,YAAY,eAAe,MAAO;AAChD,WAAO;AAAA,EACR;AACA,UAAK,+BAAiB,UAAU,eAAgB,GAAI;AAEnD,aAAS,aAAa;AAAA,MACrB,GAAG,SAAS;AAAA,MACZ,eAAe;AAAA,QACd,MAAM;AAAA,MACP;AAAA,IAC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