@wordpress/block-library 9.33.7 → 9.33.9
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/accordion/view.js +46 -4
- package/build/accordion/view.js.map +2 -2
- package/build/accordion-heading/block.json +1 -1
- package/build/accordion-heading/deprecated.js +1 -1
- package/build/accordion-heading/deprecated.js.map +2 -2
- package/build/accordion-panel/block.json +1 -1
- package/build/freeform/block.json +1 -1
- package/build/math/edit.js +4 -1
- package/build/math/edit.js.map +2 -2
- package/build/missing/block.json +1 -1
- package/build/navigation-link/edit.js +7 -1
- package/build/navigation-link/edit.js.map +2 -2
- package/build/navigation-link/shared/controls.js +15 -19
- package/build/navigation-link/shared/controls.js.map +2 -2
- package/build/navigation-link/shared/index.js +4 -0
- package/build/navigation-link/shared/index.js.map +2 -2
- package/build/navigation-link/shared/use-entity-binding.js +3 -2
- package/build/navigation-link/shared/use-entity-binding.js.map +2 -2
- package/build/pattern/block.json +1 -1
- package/build/social-links/edit.js +1 -1
- package/build/social-links/edit.js.map +1 -1
- package/build-module/accordion/view.js +46 -4
- package/build-module/accordion/view.js.map +2 -2
- package/build-module/accordion-heading/block.json +1 -1
- package/build-module/accordion-heading/deprecated.js +1 -1
- package/build-module/accordion-heading/deprecated.js.map +2 -2
- package/build-module/accordion-panel/block.json +1 -1
- package/build-module/freeform/block.json +1 -1
- package/build-module/math/edit.js +4 -1
- package/build-module/math/edit.js.map +2 -2
- package/build-module/missing/block.json +1 -1
- package/build-module/navigation-link/edit.js +21 -5
- package/build-module/navigation-link/edit.js.map +2 -2
- package/build-module/navigation-link/shared/controls.js +12 -18
- package/build-module/navigation-link/shared/controls.js.map +2 -2
- package/build-module/navigation-link/shared/index.js +3 -1
- package/build-module/navigation-link/shared/index.js.map +2 -2
- package/build-module/navigation-link/shared/use-entity-binding.js +3 -2
- package/build-module/navigation-link/shared/use-entity-binding.js.map +2 -2
- package/build-module/pattern/block.json +1 -1
- package/build-module/social-links/edit.js +1 -1
- package/build-module/social-links/edit.js.map +1 -1
- package/build-style/accordion/style-rtl.css +3 -0
- package/build-style/accordion/style.css +3 -0
- package/build-style/accordion-heading/style-rtl.css +1 -2
- package/build-style/accordion-heading/style.css +1 -2
- package/build-style/accordion-item/style-rtl.css +0 -7
- package/build-style/accordion-item/style.css +0 -7
- package/build-style/accordion-panel/style-rtl.css +1 -4
- package/build-style/accordion-panel/style.css +1 -4
- package/build-style/style-rtl.css +5 -12
- package/build-style/style.css +5 -12
- package/package.json +8 -8
- package/src/accordion/style.scss +4 -0
- package/src/accordion/view.js +60 -3
- package/src/accordion-heading/block.json +1 -1
- package/src/accordion-heading/deprecated.js +1 -1
- package/src/accordion-heading/style.scss +1 -9
- package/src/accordion-item/index.php +1 -0
- package/src/accordion-item/style.scss +2 -9
- package/src/accordion-panel/block.json +1 -1
- package/src/accordion-panel/style.scss +1 -5
- package/src/freeform/block.json +1 -1
- package/src/math/edit.js +4 -1
- package/src/missing/block.json +1 -1
- package/src/navigation-link/edit.js +28 -5
- package/src/navigation-link/shared/controls.js +13 -17
- package/src/navigation-link/shared/index.js +1 -1
- package/src/navigation-link/shared/use-entity-binding.js +5 -2
- package/src/pattern/block.json +1 -1
- package/src/social-links/edit.js +1 -1
- package/src/style.scss +1 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation-link/shared/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Shared components for Navigation Link and Navigation Submenu blocks.\n *\n * This module provides common functionality that can be used by both blocks\n * to reduce code duplication and ensure consistent behavior.\n */\n\nexport { Controls } from './controls';\nexport { updateAttributes } from './update-attributes';\nexport {\n\tuseEntityBinding,\n\tbuildNavigationLinkEntityBinding,\n} from './use-entity-binding';\nexport { LinkUI } from '../link-ui';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,
|
|
4
|
+
"sourcesContent": ["/**\n * Shared components for Navigation Link and Navigation Submenu blocks.\n *\n * This module provides common functionality that can be used by both blocks\n * to reduce code duplication and ensure consistent behavior.\n */\n\nexport { Controls, BindingHelpText, MissingEntityHelpText } from './controls';\nexport { updateAttributes } from './update-attributes';\nexport {\n\tuseEntityBinding,\n\tbuildNavigationLinkEntityBinding,\n} from './use-entity-binding';\nexport { LinkUI } from '../link-ui';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,sBAAiE;AACjE,+BAAiC;AACjC,gCAGO;AACP,qBAAuB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -69,10 +69,11 @@ function useEntityBinding({ clientId, attributes }) {
|
|
|
69
69
|
}
|
|
70
70
|
const { getEntityRecord, hasFinishedResolution } = select(import_core_data.store);
|
|
71
71
|
const entityType = isTaxonomy ? "taxonomy" : "postType";
|
|
72
|
-
const
|
|
72
|
+
const typeForAPI = type === "tag" ? "post_tag" : type;
|
|
73
|
+
const entityRecord = getEntityRecord(entityType, typeForAPI, id);
|
|
73
74
|
const hasResolved = hasFinishedResolution("getEntityRecord", [
|
|
74
75
|
entityType,
|
|
75
|
-
|
|
76
|
+
typeForAPI,
|
|
76
77
|
id
|
|
77
78
|
]);
|
|
78
79
|
return hasResolved ? entityRecord !== void 0 : true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation-link/shared/use-entity-binding.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tuseBlockBindingsUtils,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Builds entity binding configuration for navigation link URLs.\n * This function generates the structure used to bind navigation link URLs to their entity sources.\n *\n * Using a function instead of a constant allows for future enhancements where the binding\n * might need dynamic data (e.g., entity ID, context-specific arguments).\n *\n * @param {('post-type'|'taxonomy')} kind - The kind of entity. Only 'post-type' and 'taxonomy' are supported.\n * @return {Object} Entity binding configuration object\n * @throws {Error} If kind is not 'post-type' or 'taxonomy'\n */\nexport function buildNavigationLinkEntityBinding( kind ) {\n\t// Validate kind parameter exists.\n\tif ( kind === undefined ) {\n\t\tthrow new Error(\n\t\t\t'buildNavigationLinkEntityBinding requires a kind parameter. ' +\n\t\t\t\t'Only \"post-type\" and \"taxonomy\" are supported.'\n\t\t);\n\t}\n\n\t// Validate kind parameter value.\n\tif ( kind !== 'post-type' && kind !== 'taxonomy' ) {\n\t\tthrow new Error(\n\t\t\t`Invalid kind \"${ kind }\" provided to buildNavigationLinkEntityBinding. ` +\n\t\t\t\t`Only 'post-type' and 'taxonomy' are supported.`\n\t\t);\n\t}\n\n\tconst source = kind === 'taxonomy' ? 'core/term-data' : 'core/post-data';\n\n\treturn {\n\t\turl: {\n\t\t\tsource,\n\t\t\targs: {\n\t\t\t\tfield: 'link',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Shared hook for entity binding functionality in Navigation blocks.\n *\n * This hook provides common entity binding logic that can be used by both\n * Navigation Link and Navigation Submenu blocks to maintain feature parity.\n *\n * @param {Object} props - Hook parameters\n * @param {string} props.clientId - Block client ID\n * @param {Object} props.attributes - Block attributes\n * @return {Object} Hook return value\n */\nexport function useEntityBinding( { clientId, attributes } ) {\n\tconst { updateBlockBindings } = useBlockBindingsUtils( clientId );\n\tconst { metadata, id, kind, type } = attributes;\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst hasUrlBinding = !! metadata?.bindings?.url && !! id;\n\tconst expectedSource =\n\t\tkind === 'post-type' ? 'core/post-data' : 'core/term-data';\n\tconst hasCorrectBinding =\n\t\thasUrlBinding && metadata?.bindings?.url?.source === expectedSource;\n\n\t// Check if the bound entity is available (not deleted).\n\tconst isBoundEntityAvailable = useSelect(\n\t\t( select ) => {\n\t\t\t// First check: metadata/binding must exist\n\t\t\tif ( ! hasCorrectBinding || ! id ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst isPostType = kind === 'post-type';\n\t\t\tconst isTaxonomy = kind === 'taxonomy';\n\n\t\t\t// Only check entity availability for post types and taxonomies.\n\t\t\tif ( ! isPostType && ! isTaxonomy ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Skip check in disabled contexts to avoid unnecessary requests.\n\t\t\tif ( blockEditingMode === 'disabled' ) {\n\t\t\t\treturn true; // Assume available in disabled contexts.\n\t\t\t}\n\n\t\t\t// Second check: entity must exist\n\t\t\tconst { getEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\n\t\t\t// Use the correct entity type based on kind.\n\t\t\tconst entityType = isTaxonomy ? 'taxonomy' : 'postType';\n\t\t\tconst entityRecord = getEntityRecord( entityType,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAC5B,0BAGO;AACP,kBAA0B;AAC1B,uBAAmC;AAa5B,SAAS,iCAAkC,MAAO;AAExD,MAAK,SAAS,QAAY;AACzB,UAAM,IAAI;AAAA,MACT;AAAA,IAED;AAAA,EACD;AAGA,MAAK,SAAS,eAAe,SAAS,YAAa;AAClD,UAAM,IAAI;AAAA,MACT,iBAAkB,IAAK;AAAA,IAExB;AAAA,EACD;AAEA,QAAM,SAAS,SAAS,aAAa,mBAAmB;AAExD,SAAO;AAAA,IACN,KAAK;AAAA,MACJ;AAAA,MACA,MAAM;AAAA,QACL,OAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AACD;AAaO,SAAS,iBAAkB,EAAE,UAAU,WAAW,GAAI;AAC5D,QAAM,EAAE,oBAAoB,QAAI,2CAAuB,QAAS;AAChE,QAAM,EAAE,UAAU,IAAI,MAAM,KAAK,IAAI;AACrC,QAAM,uBAAmB,yCAAoB;AAE7C,QAAM,gBAAgB,CAAC,CAAE,UAAU,UAAU,OAAO,CAAC,CAAE;AACvD,QAAM,iBACL,SAAS,cAAc,mBAAmB;AAC3C,QAAM,oBACL,iBAAiB,UAAU,UAAU,KAAK,WAAW;AAGtD,QAAM,6BAAyB;AAAA,IAC9B,CAAE,WAAY;AAEb,UAAK,CAAE,qBAAqB,CAAE,IAAK;AAClC,eAAO;AAAA,MACR;AAEA,YAAM,aAAa,SAAS;AAC5B,YAAM,aAAa,SAAS;AAG5B,UAAK,CAAE,cAAc,CAAE,YAAa;AACnC,eAAO;AAAA,MACR;AAGA,UAAK,qBAAqB,YAAa;AACtC,eAAO;AAAA,MACR;AAGA,YAAM,EAAE,iBAAiB,sBAAsB,IAC9C,OAAQ,iBAAAA,KAAU;AAGnB,YAAM,aAAa,aAAa,aAAa;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tuseBlockBindingsUtils,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Builds entity binding configuration for navigation link URLs.\n * This function generates the structure used to bind navigation link URLs to their entity sources.\n *\n * Using a function instead of a constant allows for future enhancements where the binding\n * might need dynamic data (e.g., entity ID, context-specific arguments).\n *\n * @param {('post-type'|'taxonomy')} kind - The kind of entity. Only 'post-type' and 'taxonomy' are supported.\n * @return {Object} Entity binding configuration object\n * @throws {Error} If kind is not 'post-type' or 'taxonomy'\n */\nexport function buildNavigationLinkEntityBinding( kind ) {\n\t// Validate kind parameter exists.\n\tif ( kind === undefined ) {\n\t\tthrow new Error(\n\t\t\t'buildNavigationLinkEntityBinding requires a kind parameter. ' +\n\t\t\t\t'Only \"post-type\" and \"taxonomy\" are supported.'\n\t\t);\n\t}\n\n\t// Validate kind parameter value.\n\tif ( kind !== 'post-type' && kind !== 'taxonomy' ) {\n\t\tthrow new Error(\n\t\t\t`Invalid kind \"${ kind }\" provided to buildNavigationLinkEntityBinding. ` +\n\t\t\t\t`Only 'post-type' and 'taxonomy' are supported.`\n\t\t);\n\t}\n\n\tconst source = kind === 'taxonomy' ? 'core/term-data' : 'core/post-data';\n\n\treturn {\n\t\turl: {\n\t\t\tsource,\n\t\t\targs: {\n\t\t\t\tfield: 'link',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Shared hook for entity binding functionality in Navigation blocks.\n *\n * This hook provides common entity binding logic that can be used by both\n * Navigation Link and Navigation Submenu blocks to maintain feature parity.\n *\n * @param {Object} props - Hook parameters\n * @param {string} props.clientId - Block client ID\n * @param {Object} props.attributes - Block attributes\n * @return {Object} Hook return value\n */\nexport function useEntityBinding( { clientId, attributes } ) {\n\tconst { updateBlockBindings } = useBlockBindingsUtils( clientId );\n\tconst { metadata, id, kind, type } = attributes;\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst hasUrlBinding = !! metadata?.bindings?.url && !! id;\n\tconst expectedSource =\n\t\tkind === 'post-type' ? 'core/post-data' : 'core/term-data';\n\tconst hasCorrectBinding =\n\t\thasUrlBinding && metadata?.bindings?.url?.source === expectedSource;\n\n\t// Check if the bound entity is available (not deleted).\n\tconst isBoundEntityAvailable = useSelect(\n\t\t( select ) => {\n\t\t\t// First check: metadata/binding must exist\n\t\t\tif ( ! hasCorrectBinding || ! id ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst isPostType = kind === 'post-type';\n\t\t\tconst isTaxonomy = kind === 'taxonomy';\n\n\t\t\t// Only check entity availability for post types and taxonomies.\n\t\t\tif ( ! isPostType && ! isTaxonomy ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Skip check in disabled contexts to avoid unnecessary requests.\n\t\t\tif ( blockEditingMode === 'disabled' ) {\n\t\t\t\treturn true; // Assume available in disabled contexts.\n\t\t\t}\n\n\t\t\t// Second check: entity must exist\n\t\t\tconst { getEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\n\t\t\t// Use the correct entity type based on kind.\n\t\t\tconst entityType = isTaxonomy ? 'taxonomy' : 'postType';\n\t\t\t// Convert 'tag' back to 'post_tag' for the API call\n\t\t\t// (it was converted from 'post_tag' to 'tag' for storage in updateAttributes)\n\t\t\tconst typeForAPI = type === 'tag' ? 'post_tag' : type;\n\t\t\tconst entityRecord = getEntityRecord( entityType, typeForAPI, id );\n\t\t\tconst hasResolved = hasFinishedResolution( 'getEntityRecord', [\n\t\t\t\tentityType,\n\t\t\t\ttypeForAPI,\n\t\t\t\tid,\n\t\t\t] );\n\n\t\t\t// If resolution has finished and entityRecord is undefined, the entity was deleted.\n\t\t\t// Return true if entity exists, false if deleted.\n\t\t\treturn hasResolved ? entityRecord !== undefined : true;\n\t\t},\n\t\t[ kind, type, id, hasCorrectBinding, blockEditingMode ]\n\t);\n\n\tconst clearBinding = useCallback( () => {\n\t\tif ( hasUrlBinding ) {\n\t\t\tupdateBlockBindings( { url: undefined } );\n\t\t}\n\t}, [ updateBlockBindings, hasUrlBinding, metadata, id ] );\n\n\tconst createBinding = useCallback(\n\t\t( updatedAttributes ) => {\n\t\t\t// Use updated attributes if provided, otherwise fall back to closure attributes.\n\t\t\t// updatedAttributes needed to access the most up-to-date data when called synchronously.\n\t\t\tconst kindToUse = updatedAttributes?.kind ?? kind;\n\n\t\t\t// Avoid creating binding if no kind is provided.\n\t\t\tif ( ! kindToUse ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst binding = buildNavigationLinkEntityBinding( kindToUse );\n\t\t\t\tupdateBlockBindings( binding );\n\t\t\t} catch ( error ) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'Failed to create entity binding:',\n\t\t\t\t\terror.message\n\t\t\t\t);\n\t\t\t\t// Don't create binding if validation fails.\n\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R;AAGA,YAAM,EAAE,iBAAiB,sBAAsB,IAC9C,OAAQ,iBAAAA,KAAU;AAGnB,YAAM,aAAa,aAAa,aAAa;AAG7C,YAAM,aAAa,SAAS,QAAQ,aAAa;AACjD,YAAM,eAAe,gBAAiB,YAAY,YAAY,EAAG;AACjE,YAAM,cAAc,sBAAuB,mBAAmB;AAAA,QAC7D;AAAA,QACA;AAAA,QACA;AAAA,MACD,CAAE;AAIF,aAAO,cAAc,iBAAiB,SAAY;AAAA,IACnD;AAAA,IACA,CAAE,MAAM,MAAM,IAAI,mBAAmB,gBAAiB;AAAA,EACvD;AAEA,QAAM,mBAAe,4BAAa,MAAM;AACvC,QAAK,eAAgB;AACpB,0BAAqB,EAAE,KAAK,OAAU,CAAE;AAAA,IACzC;AAAA,EACD,GAAG,CAAE,qBAAqB,eAAe,UAAU,EAAG,CAAE;AAExD,QAAM,oBAAgB;AAAA,IACrB,CAAE,sBAAuB;AAGxB,YAAM,YAAY,mBAAmB,QAAQ;AAG7C,UAAK,CAAE,WAAY;AAClB;AAAA,MACD;AAEA,UAAI;AACH,cAAM,UAAU,iCAAkC,SAAU;AAC5D,4BAAqB,OAAQ;AAAA,MAC9B,SAAU,OAAQ;AAEjB,gBAAQ;AAAA,UACP;AAAA,UACA,MAAM;AAAA,QACP;AAAA,MAED;AAAA,IACD;AAAA,IACA,CAAE,qBAAqB,IAAK;AAAA,EAC7B;AAEA,SAAO;AAAA,IACN,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["coreStore"]
|
|
7
7
|
}
|
package/build/pattern/block.json
CHANGED
|
@@ -169,7 +169,7 @@ function SocialLinksEdit(props) {
|
|
|
169
169
|
{
|
|
170
170
|
__next40pxDefaultSize: true,
|
|
171
171
|
__nextHasNoMarginBottom: true,
|
|
172
|
-
label: (0, import_i18n.__)("Icon
|
|
172
|
+
label: (0, import_i18n.__)("Icon size"),
|
|
173
173
|
onChange: (newSize) => {
|
|
174
174
|
setAttributes({
|
|
175
175
|
size: newSize === "" ? void 0 : newSize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/social-links/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport {\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n\tInspectorControls,\n\tContrastChecker,\n\twithColors,\n\tInnerBlocks,\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tSelectControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst sizeOptions = [\n\t{ label: __( 'Default' ), value: '' },\n\t{ label: __( 'Small' ), value: 'has-small-icon-size' },\n\t{ label: __( 'Normal' ), value: 'has-normal-icon-size' },\n\t{ label: __( 'Large' ), value: 'has-large-icon-size' },\n\t{ label: __( 'Huge' ), value: 'has-huge-icon-size' },\n];\n\nexport function SocialLinksEdit( props ) {\n\tconst {\n\t\tclientId,\n\t\tattributes,\n\t\ticonBackgroundColor,\n\t\ticonColor,\n\t\tisSelected,\n\t\tsetAttributes,\n\t\tsetIconBackgroundColor,\n\t\tsetIconColor,\n\t} = props;\n\n\tconst {\n\t\ticonBackgroundColorValue,\n\t\ticonColorValue,\n\t\topenInNewTab,\n\t\tshowLabels,\n\t\tsize,\n\t} = attributes;\n\n\tconst { hasSocialIcons, hasSelectedChild } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockCount, hasSelectedInnerBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\thasSocialIcons: getBlockCount( clientId ) > 0,\n\t\t\t\thasSelectedChild: hasSelectedInnerBlock( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst hasAnySelected = isSelected || hasSelectedChild;\n\n\tconst logosOnly = attributes.className?.includes( 'is-style-logos-only' );\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t// Remove icon background color when logos only style is selected or\n\t// restore it when any other style is selected.\n\tuseEffect( () => {\n\t\tif ( logosOnly ) {\n\t\t\tlet restore;\n\t\t\tsetAttributes( ( prev ) => {\n\t\t\t\trestore = {\n\t\t\t\t\ticonBackgroundColor: prev.iconBackgroundColor,\n\t\t\t\t\ticonBackgroundColorValue: prev.iconBackgroundColorValue,\n\t\t\t\t\tcustomIconBackgroundColor: prev.customIconBackgroundColor,\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\ticonBackgroundColor: undefined,\n\t\t\t\t\ticonBackgroundColorValue: undefined,\n\t\t\t\t\tcustomIconBackgroundColor: undefined,\n\t\t\t\t};\n\t\t\t} );\n\n\t\t\treturn () => setAttributes( { ...restore } );\n\t\t}\n\t}, [ logosOnly, setAttributes ] );\n\n\t// Fallback color values are used maintain selections in case switching\n\t// themes and named colors in palette do not match.\n\tconst className = clsx( size, {\n\t\t'has-visible-labels': showLabels,\n\t\t'has-icon-color': iconColor.color || iconColorValue,\n\t\t'has-icon-background-color':\n\t\t\ticonBackgroundColor.color || iconBackgroundColorValue,\n\t} );\n\n\tconst blockProps = useBlockProps( { className } );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplateLock: false,\n\t\torientation: attributes.layout?.orientation ?? 'horizontal',\n\t\t__experimentalAppenderTagName: 'li',\n\t\trenderAppender:\n\t\t\t! hasSocialIcons || hasAnySelected\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: undefined,\n\t} );\n\n\tconst colorSettings = [\n\t\t{\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconColor.color || iconColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconColor( colorValue );\n\t\t\t\tsetAttributes( { iconColorValue: colorValue } );\n\t\t\t},\n\t\t\tlabel: __( 'Icon color' ),\n\t\t\tresetAllFilter: () => {\n\t\t\t\tsetIconColor( undefined );\n\t\t\t\tsetAttributes( { iconColorValue: undefined } );\n\t\t\t},\n\t\t},\n\t];\n\n\tif ( ! logosOnly ) {\n\t\tcolorSettings.push( {\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconBackgroundColor.color || iconBackgroundColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconBackgroundColor( colorValue );\n\t\t\t\tsetAttributes( {\n\t\t\t\t\ticonBackgroundColorValue: colorValue,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tlabel: __( 'Icon background' ),\n\t\t\tresetAllFilter: () => {\n\t\t\t\tsetIconBackgroundColor( undefined );\n\t\t\t\tsetAttributes( { iconBackgroundColorValue: undefined } );\n\t\t\t},\n\t\t} );\n\t}\n\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\topenInNewTab: false,\n\t\t\t\t\t\t\tshowLabels: false,\n\t\t\t\t\t\t\tsize: undefined,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! size }\n\t\t\t\t\t\tlabel={ __( 'Icon size' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { size: undefined } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Icon
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport {\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n\tInspectorControls,\n\tContrastChecker,\n\twithColors,\n\tInnerBlocks,\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tSelectControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst sizeOptions = [\n\t{ label: __( 'Default' ), value: '' },\n\t{ label: __( 'Small' ), value: 'has-small-icon-size' },\n\t{ label: __( 'Normal' ), value: 'has-normal-icon-size' },\n\t{ label: __( 'Large' ), value: 'has-large-icon-size' },\n\t{ label: __( 'Huge' ), value: 'has-huge-icon-size' },\n];\n\nexport function SocialLinksEdit( props ) {\n\tconst {\n\t\tclientId,\n\t\tattributes,\n\t\ticonBackgroundColor,\n\t\ticonColor,\n\t\tisSelected,\n\t\tsetAttributes,\n\t\tsetIconBackgroundColor,\n\t\tsetIconColor,\n\t} = props;\n\n\tconst {\n\t\ticonBackgroundColorValue,\n\t\ticonColorValue,\n\t\topenInNewTab,\n\t\tshowLabels,\n\t\tsize,\n\t} = attributes;\n\n\tconst { hasSocialIcons, hasSelectedChild } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockCount, hasSelectedInnerBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\thasSocialIcons: getBlockCount( clientId ) > 0,\n\t\t\t\thasSelectedChild: hasSelectedInnerBlock( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst hasAnySelected = isSelected || hasSelectedChild;\n\n\tconst logosOnly = attributes.className?.includes( 'is-style-logos-only' );\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t// Remove icon background color when logos only style is selected or\n\t// restore it when any other style is selected.\n\tuseEffect( () => {\n\t\tif ( logosOnly ) {\n\t\t\tlet restore;\n\t\t\tsetAttributes( ( prev ) => {\n\t\t\t\trestore = {\n\t\t\t\t\ticonBackgroundColor: prev.iconBackgroundColor,\n\t\t\t\t\ticonBackgroundColorValue: prev.iconBackgroundColorValue,\n\t\t\t\t\tcustomIconBackgroundColor: prev.customIconBackgroundColor,\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\ticonBackgroundColor: undefined,\n\t\t\t\t\ticonBackgroundColorValue: undefined,\n\t\t\t\t\tcustomIconBackgroundColor: undefined,\n\t\t\t\t};\n\t\t\t} );\n\n\t\t\treturn () => setAttributes( { ...restore } );\n\t\t}\n\t}, [ logosOnly, setAttributes ] );\n\n\t// Fallback color values are used maintain selections in case switching\n\t// themes and named colors in palette do not match.\n\tconst className = clsx( size, {\n\t\t'has-visible-labels': showLabels,\n\t\t'has-icon-color': iconColor.color || iconColorValue,\n\t\t'has-icon-background-color':\n\t\t\ticonBackgroundColor.color || iconBackgroundColorValue,\n\t} );\n\n\tconst blockProps = useBlockProps( { className } );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplateLock: false,\n\t\torientation: attributes.layout?.orientation ?? 'horizontal',\n\t\t__experimentalAppenderTagName: 'li',\n\t\trenderAppender:\n\t\t\t! hasSocialIcons || hasAnySelected\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: undefined,\n\t} );\n\n\tconst colorSettings = [\n\t\t{\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconColor.color || iconColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconColor( colorValue );\n\t\t\t\tsetAttributes( { iconColorValue: colorValue } );\n\t\t\t},\n\t\t\tlabel: __( 'Icon color' ),\n\t\t\tresetAllFilter: () => {\n\t\t\t\tsetIconColor( undefined );\n\t\t\t\tsetAttributes( { iconColorValue: undefined } );\n\t\t\t},\n\t\t},\n\t];\n\n\tif ( ! logosOnly ) {\n\t\tcolorSettings.push( {\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconBackgroundColor.color || iconBackgroundColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconBackgroundColor( colorValue );\n\t\t\t\tsetAttributes( {\n\t\t\t\t\ticonBackgroundColorValue: colorValue,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tlabel: __( 'Icon background' ),\n\t\t\tresetAllFilter: () => {\n\t\t\t\tsetIconBackgroundColor( undefined );\n\t\t\t\tsetAttributes( { iconBackgroundColorValue: undefined } );\n\t\t\t},\n\t\t} );\n\t}\n\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\topenInNewTab: false,\n\t\t\t\t\t\t\tshowLabels: false,\n\t\t\t\t\t\t\tsize: undefined,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! size }\n\t\t\t\t\t\tlabel={ __( 'Icon size' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { size: undefined } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Icon size' ) }\n\t\t\t\t\t\t\tonChange={ ( newSize ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tsize: newSize === '' ? undefined : newSize,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tvalue={ size ?? '' }\n\t\t\t\t\t\t\toptions={ sizeOptions }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\tlabel={ __( 'Show text' ) }\n\t\t\t\t\t\thasValue={ () => !! showLabels }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showLabels: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Show text' ) }\n\t\t\t\t\t\t\tchecked={ showLabels }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showLabels: ! showLabels } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\tlabel={ __( 'Open links in new tab' ) }\n\t\t\t\t\t\thasValue={ () => !! openInNewTab }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { openInNewTab: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Open links in new tab' ) }\n\t\t\t\t\t\t\tchecked={ openInNewTab }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\topenInNewTab: ! openInNewTab,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t{ colorGradientSettings.hasColorsOrGradients && (\n\t\t\t\t<InspectorControls group=\"color\">\n\t\t\t\t\t{ colorSettings.map(\n\t\t\t\t\t\t( { onChange, label, value, resetAllFilter } ) => (\n\t\t\t\t\t\t\t<ColorGradientSettingsDropdown\n\t\t\t\t\t\t\t\tkey={ `social-links-color-${ label }` }\n\t\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t\t\tsettings={ [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcolorValue: value,\n\t\t\t\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\t\t\t\tonColorChange: onChange,\n\t\t\t\t\t\t\t\t\t\tisShownByDefault: true,\n\t\t\t\t\t\t\t\t\t\tresetAllFilter,\n\t\t\t\t\t\t\t\t\t\tenableAlpha: true,\n\t\t\t\t\t\t\t\t\t\tclearable: true,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t\t\t\t{ ...colorGradientSettings }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! logosOnly && (\n\t\t\t\t\t\t<ContrastChecker\n\t\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\t\ttextColor: iconColorValue,\n\t\t\t\t\t\t\t\tbackgroundColor: iconBackgroundColorValue,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisLargeText={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<ul { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n\nconst iconColorAttributes = {\n\ticonColor: 'icon-color',\n\ticonBackgroundColor: 'icon-background-color',\n};\n\nexport default withColors( iconColorAttributes )( SocialLinksEdit );\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiKE;AA9JF,kBAAiB;AAKjB,qBAA0B;AAC1B,0BAUO;AACP,wBAKO;AACP,kBAAmB;AACnB,kBAA0B;AAK1B,mBAA+C;AAE/C,MAAM,cAAc;AAAA,EACnB,EAAE,WAAO,gBAAI,SAAU,GAAG,OAAO,GAAG;AAAA,EACpC,EAAE,WAAO,gBAAI,OAAQ,GAAG,OAAO,sBAAsB;AAAA,EACrD,EAAE,WAAO,gBAAI,QAAS,GAAG,OAAO,uBAAuB;AAAA,EACvD,EAAE,WAAO,gBAAI,OAAQ,GAAG,OAAO,sBAAsB;AAAA,EACrD,EAAE,WAAO,gBAAI,MAAO,GAAG,OAAO,qBAAqB;AACpD;AAEO,SAAS,gBAAiB,OAAQ;AACxC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAA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AAA,cACV;AAAA,gBACC,YAAY;AAAA,gBACZ;AAAA,gBACA,eAAe;AAAA,gBACf,kBAAkB;AAAA,gBAClB;AAAA,gBACA,aAAa;AAAA,gBACb,WAAW;AAAA,cACZ;AAAA,YACD;AAAA,YACA,SAAU;AAAA,YACR,GAAG;AAAA;AAAA,UAdC,sBAAuB,KAAM;AAAA,QAepC;AAAA,MAEF;AAAA,MACE,CAAE,aACH;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,YACJ,WAAW;AAAA,YACX,iBAAiB;AAAA,UAClB;AAAA,UACA,aAAc;AAAA;AAAA,MACf;AAAA,OAEF;AAAA,IAED,4CAAC,QAAK,GAAG,kBAAmB;AAAA,KAC7B;AAEF;AAEA,MAAM,sBAAsB;AAAA,EAC3B,WAAW;AAAA,EACX,qBAAqB;AACtB;AAEA,IAAO,mBAAQ,gCAAY,mBAAoB,EAAG,eAAgB;",
|
|
6
6
|
"names": ["blockEditorStore", "clsx", "useMultipleOriginColorsAndGradients", "ToolsPanel", "ToolsPanelItem", "ColorGradientSettingsDropdown"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { store, getContext, withSyncEvent } from "@wordpress/interactivity";
|
|
2
|
-
|
|
2
|
+
let hashHandled = false;
|
|
3
|
+
const { actions } = store(
|
|
3
4
|
"core/accordion",
|
|
4
5
|
{
|
|
5
6
|
state: {
|
|
@@ -59,16 +60,57 @@ store(
|
|
|
59
60
|
if (nextButton) {
|
|
60
61
|
nextButton.focus();
|
|
61
62
|
}
|
|
62
|
-
})
|
|
63
|
+
}),
|
|
64
|
+
openPanelByHash: () => {
|
|
65
|
+
if (hashHandled || !window.location?.hash?.length) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const context = getContext();
|
|
69
|
+
const { id, accordionItems, autoclose } = context;
|
|
70
|
+
const hash = decodeURIComponent(
|
|
71
|
+
window.location.hash.slice(1)
|
|
72
|
+
);
|
|
73
|
+
const targetElement = window.document.getElementById(hash);
|
|
74
|
+
if (!targetElement) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const panelElement = window.document.querySelector(
|
|
78
|
+
'.wp-block-accordion-panel[aria-labelledby="' + id + '"]'
|
|
79
|
+
);
|
|
80
|
+
if (!panelElement || !panelElement.contains(targetElement)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
hashHandled = true;
|
|
84
|
+
if (autoclose) {
|
|
85
|
+
accordionItems.forEach((item) => {
|
|
86
|
+
item.isOpen = item.id === id;
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
const targetItem = accordionItems.find(
|
|
90
|
+
(item) => item.id === id
|
|
91
|
+
);
|
|
92
|
+
if (targetItem) {
|
|
93
|
+
targetItem.isOpen = true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
window.setTimeout(() => {
|
|
97
|
+
targetElement.scrollIntoView();
|
|
98
|
+
}, 0);
|
|
99
|
+
}
|
|
63
100
|
},
|
|
64
101
|
callbacks: {
|
|
65
102
|
initAccordionItems: () => {
|
|
66
103
|
const context = getContext();
|
|
67
|
-
const { id, openByDefault } = context;
|
|
68
|
-
|
|
104
|
+
const { id, openByDefault, accordionItems } = context;
|
|
105
|
+
accordionItems.push({
|
|
69
106
|
id,
|
|
70
107
|
isOpen: openByDefault
|
|
71
108
|
});
|
|
109
|
+
actions.openPanelByHash();
|
|
110
|
+
},
|
|
111
|
+
hashChange: () => {
|
|
112
|
+
hashHandled = false;
|
|
113
|
+
actions.openPanelByHash();
|
|
72
114
|
}
|
|
73
115
|
}
|
|
74
116
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/accordion/view.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store, getContext, withSyncEvent } from '@wordpress/interactivity';\n\
|
|
5
|
-
"mappings": "AAGA,SAAS,OAAO,YAAY,qBAAqB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store, getContext, withSyncEvent } from '@wordpress/interactivity';\n\n// Whether the hash has been handled for the current page load.\n// This is used to prevent the hash from being handled multiple times.\nlet hashHandled = false;\n\nconst { actions } = store(\n\t'core/accordion',\n\t{\n\t\tstate: {\n\t\t\tget isOpen() {\n\t\t\t\tconst { id, accordionItems } = getContext();\n\t\t\t\tconst accordionItem = accordionItems.find(\n\t\t\t\t\t( item ) => item.id === id\n\t\t\t\t);\n\t\t\t\treturn accordionItem ? accordionItem.isOpen : false;\n\t\t\t},\n\t\t},\n\t\tactions: {\n\t\t\ttoggle: () => {\n\t\t\t\tconst context = getContext();\n\t\t\t\tconst { id, autoclose, accordionItems } = context;\n\t\t\t\tconst accordionItem = accordionItems.find(\n\t\t\t\t\t( item ) => item.id === id\n\t\t\t\t);\n\n\t\t\t\tif ( autoclose ) {\n\t\t\t\t\taccordionItems.forEach( ( item ) => {\n\t\t\t\t\t\titem.isOpen =\n\t\t\t\t\t\t\titem.id === id ? ! accordionItem.isOpen : false;\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\taccordionItem.isOpen = ! accordionItem.isOpen;\n\t\t\t\t}\n\t\t\t},\n\t\t\thandleKeyDown: withSyncEvent( ( event ) => {\n\t\t\t\tif (\n\t\t\t\t\tevent.key !== 'ArrowUp' &&\n\t\t\t\t\tevent.key !== 'ArrowDown' &&\n\t\t\t\t\tevent.key !== 'Home' &&\n\t\t\t\t\tevent.key !== 'End'\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst context = getContext();\n\t\t\t\tconst { id, accordionItems } = context;\n\t\t\t\tconst currentIndex = accordionItems.findIndex(\n\t\t\t\t\t( item ) => item.id === id\n\t\t\t\t);\n\n\t\t\t\tlet nextIndex;\n\n\t\t\t\tswitch ( event.key ) {\n\t\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\t\tnextIndex = Math.max( 0, currentIndex - 1 );\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\t\tnextIndex = Math.min(\n\t\t\t\t\t\t\tcurrentIndex + 1,\n\t\t\t\t\t\t\taccordionItems.length - 1\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Home':\n\t\t\t\t\t\tnextIndex = 0;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'End':\n\t\t\t\t\t\tnextIndex = accordionItems.length - 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst nextId = accordionItems[ nextIndex ].id;\n\t\t\t\tconst nextButton = document.getElementById( nextId );\n\t\t\t\tif ( nextButton ) {\n\t\t\t\t\tnextButton.focus();\n\t\t\t\t}\n\t\t\t} ),\n\t\t\topenPanelByHash: () => {\n\t\t\t\tif ( hashHandled || ! window.location?.hash?.length ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst context = getContext();\n\t\t\t\tconst { id, accordionItems, autoclose } = context;\n\t\t\t\tconst hash = decodeURIComponent(\n\t\t\t\t\twindow.location.hash.slice( 1 )\n\t\t\t\t);\n\t\t\t\tconst targetElement = window.document.getElementById( hash );\n\n\t\t\t\tif ( ! targetElement ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst panelElement = window.document.querySelector(\n\t\t\t\t\t'.wp-block-accordion-panel[aria-labelledby=\"' + id + '\"]'\n\t\t\t\t);\n\n\t\t\t\tif (\n\t\t\t\t\t! panelElement ||\n\t\t\t\t\t! panelElement.contains( targetElement )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\thashHandled = true;\n\n\t\t\t\tif ( autoclose ) {\n\t\t\t\t\taccordionItems.forEach( ( item ) => {\n\t\t\t\t\t\titem.isOpen = item.id === id;\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tconst targetItem = accordionItems.find(\n\t\t\t\t\t\t( item ) => item.id === id\n\t\t\t\t\t);\n\n\t\t\t\t\tif ( targetItem ) {\n\t\t\t\t\t\ttargetItem.isOpen = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Wait for the panel to be opened before scrolling to it.\n\t\t\t\twindow.setTimeout( () => {\n\t\t\t\t\ttargetElement.scrollIntoView();\n\t\t\t\t}, 0 );\n\t\t\t},\n\t\t},\n\t\tcallbacks: {\n\t\t\tinitAccordionItems: () => {\n\t\t\t\tconst context = getContext();\n\t\t\t\tconst { id, openByDefault, accordionItems } = context;\n\t\t\t\taccordionItems.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tisOpen: openByDefault,\n\t\t\t\t} );\n\t\t\t\tactions.openPanelByHash();\n\t\t\t},\n\t\t\thashChange: () => {\n\t\t\t\thashHandled = false;\n\t\t\t\tactions.openPanelByHash();\n\t\t\t},\n\t\t},\n\t},\n\t{ lock: true }\n);\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,OAAO,YAAY,qBAAqB;AAIjD,IAAI,cAAc;AAElB,MAAM,EAAE,QAAQ,IAAI;AAAA,EACnB;AAAA,EACA;AAAA,IACC,OAAO;AAAA,MACN,IAAI,SAAS;AACZ,cAAM,EAAE,IAAI,eAAe,IAAI,WAAW;AAC1C,cAAM,gBAAgB,eAAe;AAAA,UACpC,CAAE,SAAU,KAAK,OAAO;AAAA,QACzB;AACA,eAAO,gBAAgB,cAAc,SAAS;AAAA,MAC/C;AAAA,IACD;AAAA,IACA,SAAS;AAAA,MACR,QAAQ,MAAM;AACb,cAAM,UAAU,WAAW;AAC3B,cAAM,EAAE,IAAI,WAAW,eAAe,IAAI;AAC1C,cAAM,gBAAgB,eAAe;AAAA,UACpC,CAAE,SAAU,KAAK,OAAO;AAAA,QACzB;AAEA,YAAK,WAAY;AAChB,yBAAe,QAAS,CAAE,SAAU;AACnC,iBAAK,SACJ,KAAK,OAAO,KAA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YACC,CAAE,gBACF,CAAE,aAAa,SAAU,aAAc,GACtC;AACD;AAAA,QACD;AAEA,sBAAc;AAEd,YAAK,WAAY;AAChB,yBAAe,QAAS,CAAE,SAAU;AACnC,iBAAK,SAAS,KAAK,OAAO;AAAA,UAC3B,CAAE;AAAA,QACH,OAAO;AACN,gBAAM,aAAa,eAAe;AAAA,YACjC,CAAE,SAAU,KAAK,OAAO;AAAA,UACzB;AAEA,cAAK,YAAa;AACjB,uBAAW,SAAS;AAAA,UACrB;AAAA,QACD;AAGA,eAAO,WAAY,MAAM;AACxB,wBAAc,eAAe;AAAA,QAC9B,GAAG,CAAE;AAAA,MACN;AAAA,IACD;AAAA,IACA,WAAW;AAAA,MACV,oBAAoB,MAAM;AACzB,cAAM,UAAU,WAAW;AAC3B,cAAM,EAAE,IAAI,eAAe,eAAe,IAAI;AAC9C,uBAAe,KAAM;AAAA,UACpB;AAAA,UACA,QAAQ;AAAA,QACT,CAAE;AACF,gBAAQ,gBAAgB;AAAA,MACzB;AAAA,MACA,YAAY,MAAM;AACjB,sBAAc;AACd,gBAAQ,gBAAgB;AAAA,MACzB;AAAA,IACD;AAAA,EACD;AAAA,EACA,EAAE,MAAM,KAAK;AACd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/accordion-heading/deprecated.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\t__experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles,\n\tRichText,\n} from '@wordpress/block-editor';\n\nconst v1 = {\n\tattributes: {\n\t\topenByDefault: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: 'rich-text',\n\t\t\tsource: 'rich-text',\n\t\t\tselector: '.wp-block-accordion-heading__toggle-title',\n\t\t\trole: 'content',\n\t\t},\n\t\tlevel: {\n\t\t\ttype: 'number',\n\t\t},\n\t\ticonPosition: {\n\t\t\ttype: 'string',\n\t\t\tenum: [ 'left', 'right' ],\n\t\t\tdefault: 'right',\n\t\t},\n\t\tshowIcon: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: true,\n\t\t},\n\t},\n\tsupports: {\n\t\tanchor: true,\n\t\tcolor: {\n\t\t\tbackground: true,\n\t\t\tgradients: true,\n\t\t},\n\t\talign: false,\n\t\tinteractivity: true,\n\t\tspacing: {\n\t\t\tpadding: true,\n\t\t\t__experimentalDefaultControls: {\n\t\t\t\tpadding: true,\n\t\t\t},\n\t\t\t__experimentalSkipSerialization: true,\n\t\t\t__experimentalSelector: '.wp-block-accordion-heading__toggle',\n\t\t},\n\t\t__experimentalBorder: {\n\t\t\tcolor: true,\n\t\t\tradius: true,\n\t\t\tstyle: true,\n\t\t\twidth: true,\n\t\t\t__experimentalDefaultControls: {\n\t\t\t\tcolor: true,\n\t\t\t\tradius: true,\n\t\t\t\tstyle: true,\n\t\t\t\twidth: true,\n\t\t\t},\n\t\t},\n\t\ttypography: {\n\t\t\tfontSize: true,\n\t\t\t__experimentalFontFamily: true,\n\t\t\t__experimentalFontWeight: true,\n\t\t\t__experimentalFontStyle: true,\n\t\t\t__experimentalTextTransform: true,\n\t\t\t__experimentalTextDecoration: true,\n\t\t\t__experimentalLetterSpacing: true,\n\t\t\t__experimentalDefaultControls: {\n\t\t\t\tfontSize: true,\n\t\t\t\tfontFamily: true,\n\t\t\t},\n\t\t},\n\t\tshadow: true,\n\t\
|
|
5
|
-
"mappings": "AAuFI,SAKE,KALF;AApFJ;AAAA,EACC;AAAA,EACA,4CAA4C;AAAA,EAC5C;AAAA,OACM;AAEP,MAAM,KAAK;AAAA,EACV,YAAY;AAAA,IACX,eAAe;AAAA,MACd,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,IACP;AAAA,IACA,cAAc;AAAA,MACb,MAAM;AAAA,MACN,MAAM,CAAE,QAAQ,OAAQ;AAAA,MACxB,SAAS;AAAA,IACV;AAAA,IACA,UAAU;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,EACD;AAAA,EACA,UAAU;AAAA,IACT,QAAQ;AAAA,IACR,OAAO;AAAA,MACN,YAAY;AAAA,MACZ,WAAW;AAAA,IACZ;AAAA,IACA,OAAO;AAAA,IACP,eAAe;AAAA,IACf,SAAS;AAAA,MACR,SAAS;AAAA,MACT,+BAA+B;AAAA,QAC9B,SAAS;AAAA,MACV;AAAA,MACA,iCAAiC;AAAA,MACjC,wBAAwB;AAAA,IACzB;AAAA,IACA,sBAAsB;AAAA,MACrB,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,OAAO;AAAA,MACP,+BAA+B;AAAA,QAC9B,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,OAAO;AAAA,MACR;AAAA,IACD;AAAA,IACA,YAAY;AAAA,MACX,UAAU;AAAA,MACV,0BAA0B;AAAA,MAC1B,0BAA0B;AAAA,MAC1B,yBAAyB;AAAA,MACzB,6BAA6B;AAAA,MAC7B,8BAA8B;AAAA,MAC9B,6BAA6B;AAAA,MAC7B,+BAA+B;AAAA,QAC9B,UAAU;AAAA,QACV,YAAY;AAAA,MACb;AAAA,IACD;AAAA,IACA,QAAQ;AAAA,IACR,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\t__experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles,\n\tRichText,\n} from '@wordpress/block-editor';\n\nconst v1 = {\n\tattributes: {\n\t\topenByDefault: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: 'rich-text',\n\t\t\tsource: 'rich-text',\n\t\t\tselector: '.wp-block-accordion-heading__toggle-title',\n\t\t\trole: 'content',\n\t\t},\n\t\tlevel: {\n\t\t\ttype: 'number',\n\t\t},\n\t\ticonPosition: {\n\t\t\ttype: 'string',\n\t\t\tenum: [ 'left', 'right' ],\n\t\t\tdefault: 'right',\n\t\t},\n\t\tshowIcon: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: true,\n\t\t},\n\t},\n\tsupports: {\n\t\tanchor: true,\n\t\tcolor: {\n\t\t\tbackground: true,\n\t\t\tgradients: true,\n\t\t},\n\t\talign: false,\n\t\tinteractivity: true,\n\t\tspacing: {\n\t\t\tpadding: true,\n\t\t\t__experimentalDefaultControls: {\n\t\t\t\tpadding: true,\n\t\t\t},\n\t\t\t__experimentalSkipSerialization: true,\n\t\t\t__experimentalSelector: '.wp-block-accordion-heading__toggle',\n\t\t},\n\t\t__experimentalBorder: {\n\t\t\tcolor: true,\n\t\t\tradius: true,\n\t\t\tstyle: true,\n\t\t\twidth: true,\n\t\t\t__experimentalDefaultControls: {\n\t\t\t\tcolor: true,\n\t\t\t\tradius: true,\n\t\t\t\tstyle: true,\n\t\t\t\twidth: true,\n\t\t\t},\n\t\t},\n\t\ttypography: {\n\t\t\tfontSize: true,\n\t\t\t__experimentalFontFamily: true,\n\t\t\t__experimentalFontWeight: true,\n\t\t\t__experimentalFontStyle: true,\n\t\t\t__experimentalTextTransform: true,\n\t\t\t__experimentalTextDecoration: true,\n\t\t\t__experimentalLetterSpacing: true,\n\t\t\t__experimentalDefaultControls: {\n\t\t\t\tfontSize: true,\n\t\t\t\tfontFamily: true,\n\t\t\t},\n\t\t},\n\t\tshadow: true,\n\t\tvisibility: false,\n\t},\n\tsave( { attributes } ) {\n\t\tconst { level, title, iconPosition, showIcon } = attributes;\n\t\tconst TagName = 'h' + ( level || 3 );\n\n\t\tconst blockProps = useBlockProps.save();\n\t\tconst spacingProps = getSpacingClassesAndStyles( attributes );\n\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<button\n\t\t\t\t\tclassName=\"wp-block-accordion-heading__toggle\"\n\t\t\t\t\tstyle={ spacingProps.style }\n\t\t\t\t>\n\t\t\t\t\t{ showIcon && iconPosition === 'left' && (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"wp-block-accordion-heading__toggle-icon\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t+\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t<RichText.Content\n\t\t\t\t\t\tclassName=\"wp-block-accordion-heading__toggle-title\"\n\t\t\t\t\t\ttagName=\"span\"\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t/>\n\t\t\t\t\t{ showIcon && iconPosition === 'right' && (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"wp-block-accordion-heading__toggle-icon\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t+\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</button>\n\t\t\t</TagName>\n\t\t);\n\t},\n};\n\nexport default [ v1 ];\n"],
|
|
5
|
+
"mappings": "AAuFI,SAKE,KALF;AApFJ;AAAA,EACC;AAAA,EACA,4CAA4C;AAAA,EAC5C;AAAA,OACM;AAEP,MAAM,KAAK;AAAA,EACV,YAAY;AAAA,IACX,eAAe;AAAA,MACd,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,IACP;AAAA,IACA,cAAc;AAAA,MACb,MAAM;AAAA,MACN,MAAM,CAAE,QAAQ,OAAQ;AAAA,MACxB,SAAS;AAAA,IACV;AAAA,IACA,UAAU;AAAA,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,YAAT;AAAA,cACA,WAAU;AAAA,cACV,SAAQ;AAAA,cACR,OAAQ;AAAA;AAAA,UACT;AAAA,UACE,YAAY,iBAAiB,WAC9B;AAAA,YAAC;AAAA;AAAA,cACA,WAAU;AAAA,cACV,eAAY;AAAA,cACZ;AAAA;AAAA,UAED;AAAA;AAAA;AAAA,IAEF,GACD;AAAA,EAEF;AACD;AAEA,IAAO,qBAAQ,CAAE,EAAG;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from "@wordpress/components";
|
|
13
13
|
import { useState, useEffect, useRef } from "@wordpress/element";
|
|
14
14
|
import { useDispatch } from "@wordpress/data";
|
|
15
|
+
import { speak } from "@wordpress/a11y";
|
|
15
16
|
import { unlock } from "../lock-unlock";
|
|
16
17
|
const { Badge } = unlock(componentsPrivateApis);
|
|
17
18
|
function MathEdit({ attributes, setAttributes, isSelected }) {
|
|
@@ -56,7 +57,8 @@ function MathEdit({ attributes, setAttributes, isSelected }) {
|
|
|
56
57
|
placement: "bottom-start",
|
|
57
58
|
offset: 8,
|
|
58
59
|
anchor: blockRef,
|
|
59
|
-
focusOnMount:
|
|
60
|
+
focusOnMount: false,
|
|
61
|
+
__unstableSlotName: "__unstable-block-tools-after",
|
|
60
62
|
children: /* @__PURE__ */ jsx("div", { style: { padding: "4px", minWidth: "300px" }, children: /* @__PURE__ */ jsxs(VStack, { spacing: 1, children: [
|
|
61
63
|
/* @__PURE__ */ jsx(
|
|
62
64
|
TextareaControl,
|
|
@@ -80,6 +82,7 @@ function MathEdit({ attributes, setAttributes, isSelected }) {
|
|
|
80
82
|
setError(null);
|
|
81
83
|
} catch (err) {
|
|
82
84
|
setError(err.message);
|
|
85
|
+
speak(err.message);
|
|
83
86
|
}
|
|
84
87
|
setAttributes({
|
|
85
88
|
mathML: newMathML,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/math/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tTextareaControl,\n\tPopover,\n\t__experimentalVStack as VStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { Badge } = unlock( componentsPrivateApis );\n\nexport default function MathEdit( { attributes, setAttributes, isSelected } ) {\n\tconst { latex, mathML } = attributes;\n\tconst [ blockRef, setBlockRef ] = useState();\n\tconst [ error, setError ] = useState( null );\n\tconst [ latexToMathML, setLatexToMathML ] = useState();\n\tconst initialLatex = useRef( latex );\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\timport( '@wordpress/latex-to-mathml' ).then( ( module ) => {\n\t\t\tsetLatexToMathML( () => module.default );\n\t\t\tif ( initialLatex.current ) {\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tmathML: module.default( initialLatex.current, {\n\t\t\t\t\t\tdisplayMode: true,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [\n\t\tinitialLatex,\n\t\tsetAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\tconst blockProps = useBlockProps( {\n\t\tref: setBlockRef,\n\t\tposition: 'relative',\n\t} );\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ mathML ? (\n\t\t\t\t<math\n\t\t\t\t\t// We can't spread block props on the math element because\n\t\t\t\t\t// it only supports a limited amount of global attributes.\n\t\t\t\t\t// For example, draggable will have no effect.\n\t\t\t\t\tdisplay=\"block\"\n\t\t\t\t\tdangerouslySetInnerHTML={ { __html: mathML } }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t'\\u200B'\n\t\t\t) }\n\t\t\t{ isSelected && (\n\t\t\t\t<Popover\n\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\toffset={ 8 }\n\t\t\t\t\tanchor={ blockRef }\n\t\t\t\t\tfocusOnMount=\"
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tTextareaControl,\n\tPopover,\n\t__experimentalVStack as VStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { Badge } = unlock( componentsPrivateApis );\n\nexport default function MathEdit( { attributes, setAttributes, isSelected } ) {\n\tconst { latex, mathML } = attributes;\n\tconst [ blockRef, setBlockRef ] = useState();\n\tconst [ error, setError ] = useState( null );\n\tconst [ latexToMathML, setLatexToMathML ] = useState();\n\tconst initialLatex = useRef( latex );\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\timport( '@wordpress/latex-to-mathml' ).then( ( module ) => {\n\t\t\tsetLatexToMathML( () => module.default );\n\t\t\tif ( initialLatex.current ) {\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tmathML: module.default( initialLatex.current, {\n\t\t\t\t\t\tdisplayMode: true,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [\n\t\tinitialLatex,\n\t\tsetAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\tconst blockProps = useBlockProps( {\n\t\tref: setBlockRef,\n\t\tposition: 'relative',\n\t} );\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ mathML ? (\n\t\t\t\t<math\n\t\t\t\t\t// We can't spread block props on the math element because\n\t\t\t\t\t// it only supports a limited amount of global attributes.\n\t\t\t\t\t// For example, draggable will have no effect.\n\t\t\t\t\tdisplay=\"block\"\n\t\t\t\t\tdangerouslySetInnerHTML={ { __html: mathML } }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t'\\u200B'\n\t\t\t) }\n\t\t\t{ isSelected && (\n\t\t\t\t<Popover\n\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\toffset={ 8 }\n\t\t\t\t\tanchor={ blockRef }\n\t\t\t\t\tfocusOnMount={ false }\n\t\t\t\t\t__unstableSlotName=\"__unstable-block-tools-after\"\n\t\t\t\t>\n\t\t\t\t\t<div style={ { padding: '4px', minWidth: '300px' } }>\n\t\t\t\t\t\t<VStack spacing={ 1 }>\n\t\t\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tlabel={ __( 'LaTeX math syntax' ) }\n\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\tvalue={ latex }\n\t\t\t\t\t\t\t\tclassName=\"wp-block-math__textarea-control\"\n\t\t\t\t\t\t\t\tonChange={ ( newLatex ) => {\n\t\t\t\t\t\t\t\t\tif ( ! latexToMathML ) {\n\t\t\t\t\t\t\t\t\t\tsetAttributes( { latex: newLatex } );\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tlet newMathML = '';\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tnewMathML = latexToMathML( newLatex, {\n\t\t\t\t\t\t\t\t\t\t\tdisplayMode: true,\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\tsetError( null );\n\t\t\t\t\t\t\t\t\t} catch ( err ) {\n\t\t\t\t\t\t\t\t\t\tsetError( err.message );\n\t\t\t\t\t\t\t\t\t\tspeak( err.message );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tmathML: newMathML,\n\t\t\t\t\t\t\t\t\t\tlatex: newLatex,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tplaceholder={ __( 'e.g., x^2, \\\\frac{a}{b}' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ error && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<Badge\n\t\t\t\t\t\t\t\t\t\tintent=\"error\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"wp-block-math__error\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ error }\n\t\t\t\t\t\t\t\t\t</Badge>\n\t\t\t\t\t\t\t\t\t<style children=\".wp-block-math__error .components-badge__content{white-space:normal}\" />\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</div>\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AA4DI,SAkDI,UAlDJ,KAkDI,YAlDJ;AAzDJ,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,eAAe;AAAA,OACT;AACP,SAAS,UAAU,WAAW,cAAc;AAC5C,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AAKtB,SAAS,cAAc;AAEvB,MAAM,EAAE,MAAM,IAAI,OAAQ,qBAAsB;AAEjC,SAA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AAA,cACV,UAAW,CAAE,aAAc;AAC1B,oBAAK,CAAE,eAAgB;AACtB,gCAAe,EAAE,OAAO,SAAS,CAAE;AACnC;AAAA,gBACD;AACA,oBAAI,YAAY;AAChB,oBAAI;AACH,8BAAY,cAAe,UAAU;AAAA,oBACpC,aAAa;AAAA,kBACd,CAAE;AACF,2BAAU,IAAK;AAAA,gBAChB,SAAU,KAAM;AACf,2BAAU,IAAI,OAAQ;AACtB,wBAAO,IAAI,OAAQ;AAAA,gBACpB;AACA,8BAAe;AAAA,kBACd,QAAQ;AAAA,kBACR,OAAO;AAAA,gBACR,CAAE;AAAA,cACH;AAAA,cACA,aAAc,GAAI,yBAA0B;AAAA;AAAA,UAC7C;AAAA,UACE,SACD,iCACC;AAAA;AAAA,cAAC;AAAA;AAAA,gBACA,QAAO;AAAA,gBACP,WAAU;AAAA,gBAER;AAAA;AAAA,YACH;AAAA,YACA,oBAAC,WAAM,UAAS,wEAAuE;AAAA,aACxF;AAAA,WAEF,GACD;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,9 +2,13 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import { createBlock } from "@wordpress/blocks";
|
|
4
4
|
import { useSelect, useDispatch } from "@wordpress/data";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ToolbarButton,
|
|
7
|
+
ToolbarGroup,
|
|
8
|
+
VisuallyHidden
|
|
9
|
+
} from "@wordpress/components";
|
|
6
10
|
import { displayShortcut, isKeyboardEvent } from "@wordpress/keycodes";
|
|
7
|
-
import { __ } from "@wordpress/i18n";
|
|
11
|
+
import { __, sprintf } from "@wordpress/i18n";
|
|
8
12
|
import {
|
|
9
13
|
BlockControls,
|
|
10
14
|
InspectorControls,
|
|
@@ -20,9 +24,15 @@ import { useState, useEffect, useRef, useCallback } from "@wordpress/element";
|
|
|
20
24
|
import { decodeEntities } from "@wordpress/html-entities";
|
|
21
25
|
import { link as linkIcon, addSubmenu } from "@wordpress/icons";
|
|
22
26
|
import { store as coreStore } from "@wordpress/core-data";
|
|
23
|
-
import { useMergeRefs, usePrevious } from "@wordpress/compose";
|
|
27
|
+
import { useMergeRefs, usePrevious, useInstanceId } from "@wordpress/compose";
|
|
24
28
|
import { getColors } from "../navigation/edit/utils";
|
|
25
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
Controls,
|
|
31
|
+
LinkUI,
|
|
32
|
+
updateAttributes,
|
|
33
|
+
useEntityBinding,
|
|
34
|
+
MissingEntityHelpText
|
|
35
|
+
} from "./shared";
|
|
26
36
|
const DEFAULT_BLOCK = { name: "core/navigation-link" };
|
|
27
37
|
const NESTING_BLOCK_NAMES = [
|
|
28
38
|
"core/navigation-link",
|
|
@@ -132,7 +142,7 @@ function NavigationLinkEdit({
|
|
|
132
142
|
const ref = useRef();
|
|
133
143
|
const linkUIref = useRef();
|
|
134
144
|
const prevUrl = usePrevious(url);
|
|
135
|
-
const isNewLink = useRef(!url);
|
|
145
|
+
const isNewLink = useRef(!url && !metadata?.bindings?.url);
|
|
136
146
|
const {
|
|
137
147
|
isAtMaxNesting,
|
|
138
148
|
isTopLevelLink,
|
|
@@ -257,6 +267,9 @@ function NavigationLinkEdit({
|
|
|
257
267
|
setIsLinkOpen(true);
|
|
258
268
|
}
|
|
259
269
|
}
|
|
270
|
+
const instanceId = useInstanceId(NavigationLinkEdit);
|
|
271
|
+
const hasMissingEntity = hasUrlBinding && !isBoundEntityAvailable;
|
|
272
|
+
const missingEntityDescriptionId = hasMissingEntity ? sprintf("navigation-link-edit-%d-desc", instanceId) : void 0;
|
|
260
273
|
const blockProps = useBlockProps({
|
|
261
274
|
ref: useMergeRefs([setPopoverAnchor, listItemRef]),
|
|
262
275
|
className: clsx("wp-block-navigation-item", {
|
|
@@ -269,6 +282,8 @@ function NavigationLinkEdit({
|
|
|
269
282
|
"has-background": !!backgroundColor || customBackgroundColor,
|
|
270
283
|
[getColorClassName("background-color", backgroundColor)]: !!backgroundColor
|
|
271
284
|
}),
|
|
285
|
+
"aria-describedby": missingEntityDescriptionId,
|
|
286
|
+
"aria-invalid": hasMissingEntity,
|
|
272
287
|
style: {
|
|
273
288
|
color: !textColor && customTextColor,
|
|
274
289
|
backgroundColor: !backgroundColor && customBackgroundColor
|
|
@@ -330,6 +345,7 @@ function NavigationLinkEdit({
|
|
|
330
345
|
}
|
|
331
346
|
) }),
|
|
332
347
|
/* @__PURE__ */ jsxs("div", { ...blockProps, children: [
|
|
348
|
+
hasMissingEntity && /* @__PURE__ */ jsx(VisuallyHidden, { id: missingEntityDescriptionId, children: /* @__PURE__ */ jsx(MissingEntityHelpText, { type, kind }) }),
|
|
333
349
|
/* @__PURE__ */ jsxs("a", { className: classes, children: [
|
|
334
350
|
!url && !metadata?.bindings?.url ? /* @__PURE__ */ jsx("div", { className: "wp-block-navigation-link__placeholder-text", children: /* @__PURE__ */ jsx("span", { children: missingText }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
335
351
|
!isInvalid && !isDraft && /* @__PURE__ */ jsxs(Fragment, { children: [
|