@wordpress/block-library 9.33.3 → 9.33.5
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/edit.js +1 -1
- package/build/accordion/edit.js.map +2 -2
- package/build/accordion/view.js +71 -67
- package/build/accordion/view.js.map +2 -2
- package/build/math/block.json +3 -0
- package/build/math/edit.js +7 -7
- package/build/math/edit.js.map +2 -2
- package/build-module/accordion/edit.js +1 -1
- package/build-module/accordion/edit.js.map +2 -2
- package/build-module/accordion/view.js +71 -67
- package/build-module/accordion/view.js.map +2 -2
- package/build-module/math/block.json +3 -0
- package/build-module/math/edit.js +7 -7
- package/build-module/math/edit.js.map +2 -2
- package/build-style/accordion-heading/style-rtl.css +1 -4
- package/build-style/accordion-heading/style.css +1 -4
- package/build-style/heading/style-rtl.css +6 -6
- package/build-style/heading/style.css +6 -6
- package/build-style/style-rtl.css +7 -10
- package/build-style/style.css +7 -10
- package/package.json +8 -8
- package/src/accordion/edit.js +1 -1
- package/src/accordion/view.js +78 -74
- package/src/accordion-heading/style.scss +1 -6
- package/src/heading/style.scss +1 -1
- package/src/math/block.json +3 -0
- package/src/math/edit.js +7 -7
package/build/accordion/edit.js
CHANGED
|
@@ -93,7 +93,7 @@ function Edit({
|
|
|
93
93
|
onChange: updateHeadingLevel
|
|
94
94
|
}
|
|
95
95
|
) }) }),
|
|
96
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockControls, { group: "other", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ToolbarButton, { onClick: addAccordionItemBlock, children: (0, import_i18n.__)("Add") }) })
|
|
96
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockControls, { group: "other", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ToolbarButton, { onClick: addAccordionItemBlock, children: (0, import_i18n.__)("Add item") }) })
|
|
97
97
|
] }),
|
|
98
98
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.InspectorControls, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
99
99
|
import_components.__experimentalToolsPanel,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/accordion/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tBlockControls,\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n\tHeadingLevelDropdown,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tToggleControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst ACCORDION_BLOCK_NAME = 'core/accordion-item';\nconst ACCORDION_HEADING_BLOCK_NAME = 'core/accordion-heading';\nconst ACCORDION_BLOCK = {\n\tname: ACCORDION_BLOCK_NAME,\n};\n\nexport default function Edit( {\n\tattributes: {\n\t\tautoclose,\n\t\ticonPosition,\n\t\tshowIcon,\n\t\theadingLevel,\n\t\tlevelOptions,\n\t},\n\tclientId,\n\tsetAttributes,\n\tisSelected: isSingleSelected,\n} ) {\n\tconst registry = useRegistry();\n\tconst { getBlockOrder } = useSelect( blockEditorStore );\n\tconst blockProps = useBlockProps( {\n\t\trole: 'group',\n\t} );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst { updateBlockAttributes, insertBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isContentOnlyMode = blockEditingMode === 'contentOnly';\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: [ [ ACCORDION_BLOCK_NAME ] ],\n\t\tdefaultBlock: ACCORDION_BLOCK,\n\t\tdirectInsert: true,\n\t\ttemplateInsertUpdatesSelection: true,\n\t} );\n\n\tconst addAccordionItemBlock = () => {\n\t\t// When adding, set the header's level to current headingLevel\n\t\tconst newAccordionItem = createBlock( ACCORDION_BLOCK_NAME, {}, [\n\t\t\tcreateBlock( ACCORDION_HEADING_BLOCK_NAME, {\n\t\t\t\tlevel: headingLevel,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/accordion-panel', {} ),\n\t\t] );\n\t\tinsertBlock( newAccordionItem, undefined, clientId );\n\t};\n\n\t/**\n\t * Update all child Accordion Header blocks with a new heading level\n\t * based on the accordion group setting.\n\t * @param {number} newHeadingLevel The new heading level to set\n\t */\n\tconst updateHeadingLevel = ( newHeadingLevel ) => {\n\t\tconst innerBlockClientIds = getBlockOrder( clientId );\n\n\t\t// Get all accordion-header blocks from all accordion-content blocks.\n\t\tconst accordionHeaderClientIds = [];\n\t\tinnerBlockClientIds.forEach( ( contentClientId ) => {\n\t\t\tconst headerClientIds = getBlockOrder( contentClientId );\n\t\t\taccordionHeaderClientIds.push( ...headerClientIds );\n\t\t} );\n\n\t\t// Update own and child block heading levels.\n\t\tregistry.batch( () => {\n\t\t\tsetAttributes( { headingLevel: newHeadingLevel } );\n\t\t\tupdateBlockAttributes( accordionHeaderClientIds, {\n\t\t\t\tlevel: newHeadingLevel,\n\t\t\t} );\n\t\t} );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{ isSingleSelected && ! isContentOnlyMode && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<HeadingLevelDropdown\n\t\t\t\t\t\t\t\tvalue={ headingLevel }\n\t\t\t\t\t\t\t\toptions={ levelOptions }\n\t\t\t\t\t\t\t\tonChange={ updateHeadingLevel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<ToolbarButton onClick={ addAccordionItemBlock }>\n\t\t\t\t\t\t\t{ __( 'Add' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<InspectorControls key=\"setting\">\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\tautoclose: false,\n\t\t\t\t\t\t\tshowIcon: true,\n\t\t\t\t\t\t\ticonPosition: 'right',\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\tlabel={ __( 'Auto-close' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! autoclose }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { autoclose: 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\tisBlock\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Auto-close' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tautoclose: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tchecked={ autoclose }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Automatically close accordions when a new one is opened.'\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\tlabel={ __( 'Show icon' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showIcon }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { showIcon: true } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Show icon' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowIcon: value,\n\t\t\t\t\t\t\t\t\ticonPosition: value\n\t\t\t\t\t\t\t\t\t\t? iconPosition\n\t\t\t\t\t\t\t\t\t\t: 'right',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tchecked={ showIcon }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Display a plus icon next to the accordion header.'\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{ showIcon && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Icon Position' ) }\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\thasValue={ () => iconPosition !== 'right' }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { iconPosition: 'right' } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleGroupControl\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\tisBlock\n\t\t\t\t\t\t\t\tlabel={ __( 'Icon Position' ) }\n\t\t\t\t\t\t\t\tvalue={ iconPosition }\n\t\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( { iconPosition: value } );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Left' ) }\n\t\t\t\t\t\t\t\t\tvalue=\"left\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Right' ) }\n\t\t\t\t\t\t\t\t\tvalue=\"right\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwGI;AArGJ,0BAQO;AACP,kBAAmB;AACnB,wBAQO;AACP,kBAAoD;AACpD,oBAA4B;AAK5B,mBAA+C;AAE/C,MAAM,uBAAuB;AAC7B,MAAM,+BAA+B;AACrC,MAAM,kBAAkB;AAAA,EACvB,MAAM;AACP;AAEe,SAAR,KAAuB;AAAA,EAC7B,YAAY;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AACb,GAAI;AACH,QAAM,eAAW,yBAAY;AAC7B,QAAM,EAAE,cAAc,QAAI,uBAAW,oBAAAA,KAAiB;AACtD,QAAM,iBAAa,mCAAe;AAAA,IACjC,MAAM;AAAA,EACP,CAAE;AACF,QAAM,wBAAoB,6CAA+B;AACzD,QAAM,EAAE,uBAAuB,YAAY,QAC1C,yBAAa,oBAAAA,KAAiB;AAC/B,QAAM,uBAAmB,yCAAoB;AAC7C,QAAM,oBAAoB,qBAAqB;AAE/C,QAAM,uBAAmB,yCAAqB,YAAY;AAAA,IACzD,UAAU,CAAE,CAAE,oBAAqB,CAAE;AAAA,IACrC,cAAc;AAAA,IACd,cAAc;AAAA,IACd,gCAAgC;AAAA,EACjC,CAAE;AAEF,QAAM,wBAAwB,MAAM;AAEnC,UAAM,uBAAmB,2BAAa,sBAAsB,CAAC,GAAG;AAAA,UAC/D,2BAAa,8BAA8B;AAAA,QAC1C,OAAO;AAAA,MACR,CAAE;AAAA,UACF,2BAAa,wBAAwB,CAAC,CAAE;AAAA,IACzC,CAAE;AACF,gBAAa,kBAAkB,QAAW,QAAS;AAAA,EACpD;AAOA,QAAM,qBAAqB,CAAE,oBAAqB;AACjD,UAAM,sBAAsB,cAAe,QAAS;AAGpD,UAAM,2BAA2B,CAAC;AAClC,wBAAoB,QAAS,CAAE,oBAAqB;AACnD,YAAM,kBAAkB,cAAe,eAAgB;AACvD,+BAAyB,KAAM,GAAG,eAAgB;AAAA,IACnD,CAAE;AAGF,aAAS,MAAO,MAAM;AACrB,oBAAe,EAAE,cAAc,gBAAgB,CAAE;AACjD,4BAAuB,0BAA0B;AAAA,QAChD,OAAO;AAAA,MACR,CAAE;AAAA,IACH,CAAE;AAAA,EACH;AAEA,SACC,4EACG;AAAA,wBAAoB,CAAE,qBACvB,4EACC;AAAA,kDAAC,qCACA,sDAAC,kCACA;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ;AAAA,UACR,SAAU;AAAA,UACV,UAAW;AAAA;AAAA,MACZ,GACD,GACD;AAAA,MACA,4CAAC,qCAAc,OAAM,SACpB,sDAAC,mCAAc,SAAU,uBACtB,8BAAI,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tBlockControls,\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n\tHeadingLevelDropdown,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tToggleControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst ACCORDION_BLOCK_NAME = 'core/accordion-item';\nconst ACCORDION_HEADING_BLOCK_NAME = 'core/accordion-heading';\nconst ACCORDION_BLOCK = {\n\tname: ACCORDION_BLOCK_NAME,\n};\n\nexport default function Edit( {\n\tattributes: {\n\t\tautoclose,\n\t\ticonPosition,\n\t\tshowIcon,\n\t\theadingLevel,\n\t\tlevelOptions,\n\t},\n\tclientId,\n\tsetAttributes,\n\tisSelected: isSingleSelected,\n} ) {\n\tconst registry = useRegistry();\n\tconst { getBlockOrder } = useSelect( blockEditorStore );\n\tconst blockProps = useBlockProps( {\n\t\trole: 'group',\n\t} );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst { updateBlockAttributes, insertBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isContentOnlyMode = blockEditingMode === 'contentOnly';\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: [ [ ACCORDION_BLOCK_NAME ] ],\n\t\tdefaultBlock: ACCORDION_BLOCK,\n\t\tdirectInsert: true,\n\t\ttemplateInsertUpdatesSelection: true,\n\t} );\n\n\tconst addAccordionItemBlock = () => {\n\t\t// When adding, set the header's level to current headingLevel\n\t\tconst newAccordionItem = createBlock( ACCORDION_BLOCK_NAME, {}, [\n\t\t\tcreateBlock( ACCORDION_HEADING_BLOCK_NAME, {\n\t\t\t\tlevel: headingLevel,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/accordion-panel', {} ),\n\t\t] );\n\t\tinsertBlock( newAccordionItem, undefined, clientId );\n\t};\n\n\t/**\n\t * Update all child Accordion Header blocks with a new heading level\n\t * based on the accordion group setting.\n\t * @param {number} newHeadingLevel The new heading level to set\n\t */\n\tconst updateHeadingLevel = ( newHeadingLevel ) => {\n\t\tconst innerBlockClientIds = getBlockOrder( clientId );\n\n\t\t// Get all accordion-header blocks from all accordion-content blocks.\n\t\tconst accordionHeaderClientIds = [];\n\t\tinnerBlockClientIds.forEach( ( contentClientId ) => {\n\t\t\tconst headerClientIds = getBlockOrder( contentClientId );\n\t\t\taccordionHeaderClientIds.push( ...headerClientIds );\n\t\t} );\n\n\t\t// Update own and child block heading levels.\n\t\tregistry.batch( () => {\n\t\t\tsetAttributes( { headingLevel: newHeadingLevel } );\n\t\t\tupdateBlockAttributes( accordionHeaderClientIds, {\n\t\t\t\tlevel: newHeadingLevel,\n\t\t\t} );\n\t\t} );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{ isSingleSelected && ! isContentOnlyMode && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<HeadingLevelDropdown\n\t\t\t\t\t\t\t\tvalue={ headingLevel }\n\t\t\t\t\t\t\t\toptions={ levelOptions }\n\t\t\t\t\t\t\t\tonChange={ updateHeadingLevel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<ToolbarButton onClick={ addAccordionItemBlock }>\n\t\t\t\t\t\t\t{ __( 'Add item' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<InspectorControls key=\"setting\">\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\tautoclose: false,\n\t\t\t\t\t\t\tshowIcon: true,\n\t\t\t\t\t\t\ticonPosition: 'right',\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\tlabel={ __( 'Auto-close' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! autoclose }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { autoclose: 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\tisBlock\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Auto-close' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tautoclose: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tchecked={ autoclose }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Automatically close accordions when a new one is opened.'\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\tlabel={ __( 'Show icon' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showIcon }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { showIcon: true } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Show icon' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowIcon: value,\n\t\t\t\t\t\t\t\t\ticonPosition: value\n\t\t\t\t\t\t\t\t\t\t? iconPosition\n\t\t\t\t\t\t\t\t\t\t: 'right',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tchecked={ showIcon }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Display a plus icon next to the accordion header.'\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{ showIcon && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Icon Position' ) }\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\thasValue={ () => iconPosition !== 'right' }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { iconPosition: 'right' } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleGroupControl\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\tisBlock\n\t\t\t\t\t\t\t\tlabel={ __( 'Icon Position' ) }\n\t\t\t\t\t\t\t\tvalue={ iconPosition }\n\t\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( { iconPosition: value } );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Left' ) }\n\t\t\t\t\t\t\t\t\tvalue=\"left\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t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BACA,WAAQ,gBAAI,MAAO;AAAA,wBACnB,OAAM;AAAA;AAAA,oBACP;AAAA,oBACA;AAAA,sBAAC,kBAAAA;AAAA,sBAAA;AAAA,wBACA,WAAQ,gBAAI,OAAQ;AAAA,wBACpB,OAAM;AAAA;AAAA,oBACP;AAAA;AAAA;AAAA,cACD;AAAA;AAAA,UACD;AAAA;AAAA;AAAA,IAEF,KAzFsB,SA0FvB;AAAA,IACA,4CAAC,SAAM,GAAG,kBAAmB;AAAA,KAC9B;AAEF;",
|
|
6
6
|
"names": ["blockEditorStore", "ToolsPanel", "ToolsPanelItem", "ToggleGroupControl", "ToggleGroupControlOption"]
|
|
7
7
|
}
|
package/build/accordion/view.js
CHANGED
|
@@ -1,74 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var import_interactivity = require("@wordpress/interactivity");
|
|
3
|
-
(0, import_interactivity.store)(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
actions: {
|
|
14
|
-
toggle: () => {
|
|
15
|
-
const context = (0, import_interactivity.getContext)();
|
|
16
|
-
const { id, autoclose, accordionItems } = context;
|
|
17
|
-
const accordionItem = accordionItems.find(
|
|
18
|
-
(item) => item.id === id
|
|
19
|
-
);
|
|
20
|
-
if (autoclose) {
|
|
21
|
-
accordionItems.forEach((item) => {
|
|
22
|
-
item.isOpen = item.id === id ? !accordionItem.isOpen : false;
|
|
23
|
-
});
|
|
24
|
-
} else {
|
|
25
|
-
accordionItem.isOpen = !accordionItem.isOpen;
|
|
3
|
+
(0, import_interactivity.store)(
|
|
4
|
+
"core/accordion",
|
|
5
|
+
{
|
|
6
|
+
state: {
|
|
7
|
+
get isOpen() {
|
|
8
|
+
const { id, accordionItems } = (0, import_interactivity.getContext)();
|
|
9
|
+
const accordionItem = accordionItems.find(
|
|
10
|
+
(item) => item.id === id
|
|
11
|
+
);
|
|
12
|
+
return accordionItem ? accordionItem.isOpen : false;
|
|
26
13
|
}
|
|
27
14
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
15
|
+
actions: {
|
|
16
|
+
toggle: () => {
|
|
17
|
+
const context = (0, import_interactivity.getContext)();
|
|
18
|
+
const { id, autoclose, accordionItems } = context;
|
|
19
|
+
const accordionItem = accordionItems.find(
|
|
20
|
+
(item) => item.id === id
|
|
21
|
+
);
|
|
22
|
+
if (autoclose) {
|
|
23
|
+
accordionItems.forEach((item) => {
|
|
24
|
+
item.isOpen = item.id === id ? !accordionItem.isOpen : false;
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
accordionItem.isOpen = !accordionItem.isOpen;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
handleKeyDown: (0, import_interactivity.withSyncEvent)((event) => {
|
|
31
|
+
if (event.key !== "ArrowUp" && event.key !== "ArrowDown" && event.key !== "Home" && event.key !== "End") {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
const context = (0, import_interactivity.getContext)();
|
|
36
|
+
const { id, accordionItems } = context;
|
|
37
|
+
const currentIndex = accordionItems.findIndex(
|
|
38
|
+
(item) => item.id === id
|
|
39
|
+
);
|
|
40
|
+
let nextIndex;
|
|
41
|
+
switch (event.key) {
|
|
42
|
+
case "ArrowUp":
|
|
43
|
+
nextIndex = Math.max(0, currentIndex - 1);
|
|
44
|
+
break;
|
|
45
|
+
case "ArrowDown":
|
|
46
|
+
nextIndex = Math.min(
|
|
47
|
+
currentIndex + 1,
|
|
48
|
+
accordionItems.length - 1
|
|
49
|
+
);
|
|
50
|
+
break;
|
|
51
|
+
case "Home":
|
|
52
|
+
nextIndex = 0;
|
|
53
|
+
break;
|
|
54
|
+
case "End":
|
|
55
|
+
nextIndex = accordionItems.length - 1;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
const nextId = accordionItems[nextIndex].id;
|
|
59
|
+
const nextButton = document.getElementById(nextId);
|
|
60
|
+
if (nextButton) {
|
|
61
|
+
nextButton.focus();
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
},
|
|
65
|
+
callbacks: {
|
|
66
|
+
initAccordionItems: () => {
|
|
67
|
+
const context = (0, import_interactivity.getContext)();
|
|
68
|
+
const { id, openByDefault } = context;
|
|
69
|
+
context.accordionItems.push({
|
|
70
|
+
id,
|
|
71
|
+
isOpen: openByDefault
|
|
72
|
+
});
|
|
60
73
|
}
|
|
61
|
-
})
|
|
62
|
-
},
|
|
63
|
-
callbacks: {
|
|
64
|
-
initAccordionItems: () => {
|
|
65
|
-
const context = (0, import_interactivity.getContext)();
|
|
66
|
-
const { id, openByDefault } = context;
|
|
67
|
-
context.accordionItems.push({
|
|
68
|
-
id,
|
|
69
|
-
isOpen: openByDefault
|
|
70
|
-
});
|
|
71
74
|
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
75
|
+
},
|
|
76
|
+
{ lock: true }
|
|
77
|
+
);
|
|
74
78
|
//# sourceMappingURL=view.js.map
|
|
@@ -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\nstore(
|
|
5
|
-
"mappings": ";AAGA,2BAAiD;AAAA,IAEjD,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store, getContext, withSyncEvent } from '@wordpress/interactivity';\n\nstore(\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},\n\t\tcallbacks: {\n\t\t\tinitAccordionItems: () => {\n\t\t\t\tconst context = getContext();\n\t\t\t\tconst { id, openByDefault } = context;\n\t\t\t\tcontext.accordionItems.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tisOpen: openByDefault,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t},\n\t{ lock: true }\n);\n"],
|
|
5
|
+
"mappings": ";AAGA,2BAAiD;AAAA,IAEjD;AAAA,EACC;AAAA,EACA;AAAA,IACC,OAAO;AAAA,MACN,IAAI,SAAS;AACZ,cAAM,EAAE,IAAI,eAAe,QAAI,iCAAW;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,cAAU,iCAAW;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;A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data = require("@wordpress/data");
|
|
|
40
40
|
var import_lock_unlock = require("../lock-unlock");
|
|
41
41
|
const { Badge } = (0, import_lock_unlock.unlock)(import_components.privateApis);
|
|
42
42
|
function MathEdit({ attributes, setAttributes, isSelected }) {
|
|
43
|
-
const { latex } = attributes;
|
|
43
|
+
const { latex, mathML } = attributes;
|
|
44
44
|
const [blockRef, setBlockRef] = (0, import_element.useState)();
|
|
45
45
|
const [error, setError] = (0, import_element.useState)(null);
|
|
46
46
|
const [latexToMathML, setLatexToMathML] = (0, import_element.useState)();
|
|
47
|
-
const initialLatex = (0, import_element.useRef)(
|
|
47
|
+
const initialLatex = (0, import_element.useRef)(latex);
|
|
48
48
|
const { __unstableMarkNextChangeAsNotPersistent } = (0, import_data.useDispatch)(import_block_editor.store);
|
|
49
49
|
(0, import_element.useEffect)(() => {
|
|
50
50
|
import("@wordpress/latex-to-mathml").then((module2) => {
|
|
@@ -68,11 +68,11 @@ function MathEdit({ attributes, setAttributes, isSelected }) {
|
|
|
68
68
|
position: "relative"
|
|
69
69
|
});
|
|
70
70
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...blockProps, children: [
|
|
71
|
-
|
|
71
|
+
mathML ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
72
72
|
"math",
|
|
73
73
|
{
|
|
74
74
|
display: "block",
|
|
75
|
-
dangerouslySetInnerHTML: { __html:
|
|
75
|
+
dangerouslySetInnerHTML: { __html: mathML }
|
|
76
76
|
}
|
|
77
77
|
) : "\u200B",
|
|
78
78
|
isSelected && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -97,9 +97,9 @@ function MathEdit({ attributes, setAttributes, isSelected }) {
|
|
|
97
97
|
setAttributes({ latex: newLatex });
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
-
let
|
|
100
|
+
let newMathML = "";
|
|
101
101
|
try {
|
|
102
|
-
|
|
102
|
+
newMathML = latexToMathML(newLatex, {
|
|
103
103
|
displayMode: true
|
|
104
104
|
});
|
|
105
105
|
setError(null);
|
|
@@ -107,7 +107,7 @@ function MathEdit({ attributes, setAttributes, isSelected }) {
|
|
|
107
107
|
setError(err.message);
|
|
108
108
|
}
|
|
109
109
|
setAttributes({
|
|
110
|
-
mathML,
|
|
110
|
+
mathML: newMathML,
|
|
111
111
|
latex: newLatex
|
|
112
112
|
});
|
|
113
113
|
},
|
package/build/math/edit.js.map
CHANGED
|
@@ -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 } = attributes;\n\tconst [ blockRef, setBlockRef ] = useState();\n\tconst [ error, setError ] = useState( null );\n\tconst [ latexToMathML, setLatexToMathML ] = useState();\n\tconst initialLatex = useRef(
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2DI;AAxDJ,kBAAmB;AACnB,0BAGO;AACP,wBAKO;AACP,qBAA4C;AAC5C,kBAA4B;AAK5B,yBAAuB;AAEvB,MAAM,EAAE,MAAM,QAAI,2BAAQ,kBAAAA,WAAsB;AAEjC,SAAR,SAA2B,EAAE,YAAY,eAAe,WAAW,GAAI;AAC7E,QAAM,EAAE,
|
|
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=\"firstContentElement\"\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}\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2DI;AAxDJ,kBAAmB;AACnB,0BAGO;AACP,wBAKO;AACP,qBAA4C;AAC5C,kBAA4B;AAK5B,yBAAuB;AAEvB,MAAM,EAAE,MAAM,QAAI,2BAAQ,kBAAAA,WAAsB;AAEjC,SAAR,SAA2B,EAAE,YAAY,eAAe,WAAW,GAAI;AAC7E,QAAM,EAAE,OAAO,OAAO,IAAI;AAC1B,QAAM,CAAE,UAAU,WAAY,QAAI,yBAAS;AAC3C,QAAM,CAAE,OAAO,QAAS,QAAI,yBAAU,IAAK;AAC3C,QAAM,CAAE,eAAe,gBAAiB,QAAI,yBAAS;AACrD,QAAM,mBAAe,uBAAQ,KAAM;AACnC,QAAM,EAAE,wCAAwC,QAC/C,yBAAa,oBAAAC,KAAiB;AAE/B,gCAAW,MAAM;AAChB,WAAQ,4BAA6B,EAAE,KAAM,CAAEC,YAAY;AAC1D,uBAAkB,MAAMA,QAAO,OAAQ;AACvC,UAAK,aAAa,SAAU;AAC3B,gDAAwC;AACxC,sBAAe;AAAA,UACd,QAAQA,QAAO,QAAS,aAA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AA,gBACP,WAAU;AAAA,gBAER;AAAA;AAAA,YACH;AAAA,YACA,4CAAC,WAAM,UAAS,wEAAuE;AAAA,aACxF;AAAA,WAEF,GACD;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": ["componentsPrivateApis", "blockEditorStore", "module", "VStack"]
|
|
7
7
|
}
|
|
@@ -86,7 +86,7 @@ function Edit({
|
|
|
86
86
|
onChange: updateHeadingLevel
|
|
87
87
|
}
|
|
88
88
|
) }) }),
|
|
89
|
-
/* @__PURE__ */ jsx(BlockControls, { group: "other", children: /* @__PURE__ */ jsx(ToolbarButton, { onClick: addAccordionItemBlock, children: __("Add") }) })
|
|
89
|
+
/* @__PURE__ */ jsx(BlockControls, { group: "other", children: /* @__PURE__ */ jsx(ToolbarButton, { onClick: addAccordionItemBlock, children: __("Add item") }) })
|
|
90
90
|
] }),
|
|
91
91
|
/* @__PURE__ */ jsx(InspectorControls, { children: /* @__PURE__ */ jsxs(
|
|
92
92
|
ToolsPanel,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/accordion/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tBlockControls,\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n\tHeadingLevelDropdown,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tToggleControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst ACCORDION_BLOCK_NAME = 'core/accordion-item';\nconst ACCORDION_HEADING_BLOCK_NAME = 'core/accordion-heading';\nconst ACCORDION_BLOCK = {\n\tname: ACCORDION_BLOCK_NAME,\n};\n\nexport default function Edit( {\n\tattributes: {\n\t\tautoclose,\n\t\ticonPosition,\n\t\tshowIcon,\n\t\theadingLevel,\n\t\tlevelOptions,\n\t},\n\tclientId,\n\tsetAttributes,\n\tisSelected: isSingleSelected,\n} ) {\n\tconst registry = useRegistry();\n\tconst { getBlockOrder } = useSelect( blockEditorStore );\n\tconst blockProps = useBlockProps( {\n\t\trole: 'group',\n\t} );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst { updateBlockAttributes, insertBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isContentOnlyMode = blockEditingMode === 'contentOnly';\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: [ [ ACCORDION_BLOCK_NAME ] ],\n\t\tdefaultBlock: ACCORDION_BLOCK,\n\t\tdirectInsert: true,\n\t\ttemplateInsertUpdatesSelection: true,\n\t} );\n\n\tconst addAccordionItemBlock = () => {\n\t\t// When adding, set the header's level to current headingLevel\n\t\tconst newAccordionItem = createBlock( ACCORDION_BLOCK_NAME, {}, [\n\t\t\tcreateBlock( ACCORDION_HEADING_BLOCK_NAME, {\n\t\t\t\tlevel: headingLevel,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/accordion-panel', {} ),\n\t\t] );\n\t\tinsertBlock( newAccordionItem, undefined, clientId );\n\t};\n\n\t/**\n\t * Update all child Accordion Header blocks with a new heading level\n\t * based on the accordion group setting.\n\t * @param {number} newHeadingLevel The new heading level to set\n\t */\n\tconst updateHeadingLevel = ( newHeadingLevel ) => {\n\t\tconst innerBlockClientIds = getBlockOrder( clientId );\n\n\t\t// Get all accordion-header blocks from all accordion-content blocks.\n\t\tconst accordionHeaderClientIds = [];\n\t\tinnerBlockClientIds.forEach( ( contentClientId ) => {\n\t\t\tconst headerClientIds = getBlockOrder( contentClientId );\n\t\t\taccordionHeaderClientIds.push( ...headerClientIds );\n\t\t} );\n\n\t\t// Update own and child block heading levels.\n\t\tregistry.batch( () => {\n\t\t\tsetAttributes( { headingLevel: newHeadingLevel } );\n\t\t\tupdateBlockAttributes( accordionHeaderClientIds, {\n\t\t\t\tlevel: newHeadingLevel,\n\t\t\t} );\n\t\t} );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{ isSingleSelected && ! isContentOnlyMode && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<HeadingLevelDropdown\n\t\t\t\t\t\t\t\tvalue={ headingLevel }\n\t\t\t\t\t\t\t\toptions={ levelOptions }\n\t\t\t\t\t\t\t\tonChange={ updateHeadingLevel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<ToolbarButton onClick={ addAccordionItemBlock }>\n\t\t\t\t\t\t\t{ __( 'Add' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<InspectorControls key=\"setting\">\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\tautoclose: false,\n\t\t\t\t\t\t\tshowIcon: true,\n\t\t\t\t\t\t\ticonPosition: 'right',\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\tlabel={ __( 'Auto-close' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! autoclose }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { autoclose: 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\tisBlock\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Auto-close' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tautoclose: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tchecked={ autoclose }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Automatically close accordions when a new one is opened.'\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\tlabel={ __( 'Show icon' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showIcon }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { showIcon: true } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Show icon' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowIcon: value,\n\t\t\t\t\t\t\t\t\ticonPosition: value\n\t\t\t\t\t\t\t\t\t\t? iconPosition\n\t\t\t\t\t\t\t\t\t\t: 'right',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tchecked={ showIcon }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Display a plus icon next to the accordion header.'\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{ showIcon && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Icon Position' ) }\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\thasValue={ () => iconPosition !== 'right' }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { iconPosition: 'right' } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleGroupControl\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\tisBlock\n\t\t\t\t\t\t\t\tlabel={ __( 'Icon Position' ) }\n\t\t\t\t\t\t\t\tvalue={ iconPosition }\n\t\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( { iconPosition: value } );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Left' ) }\n\t\t\t\t\t\t\t\t\tvalue=\"left\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Right' ) }\n\t\t\t\t\t\t\t\t\tvalue=\"right\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],
|
|
5
|
-
"mappings": "AAwGI,mBAGG,KAHH;AArGJ;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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AS;AAGpD,UAAM,2BAA2B,CAAC;AAClC,wBAAoB,QAAS,CAAE,oBAAqB;AACnD,YAAM,kBAAkB,cAAe,eAAgB;AACvD,+BAAyB,KAAM,GAAG,eAAgB;AAAA,IACnD,CAAE;AAGF,aAAS,MAAO,MAAM;AACrB,oBAAe,EAAE,cAAc,gBAAgB,CAAE;AACjD,4BAAuB,0BAA0B;AAAA,QAChD,OAAO;AAAA,MACR,CAAE;AAAA,IACH,CAAE;AAAA,EACH;AAEA,SACC,iCACG;AAAA,wBAAoB,CAAE,qBACvB,iCACC;AAAA,0BAAC,iBACA,8BAAC,gBACA;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ;AAAA,UACR,SAAU;AAAA,UACV,UAAW;AAAA;AAAA,MACZ,GACD,GACD;AAAA,MACA,oBAAC,iBAAc,OAAM,SACpB,8BAAC,iBAAc,SAAU,uBACtB,aAAI,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tBlockControls,\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n\tHeadingLevelDropdown,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tToggleControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst ACCORDION_BLOCK_NAME = 'core/accordion-item';\nconst ACCORDION_HEADING_BLOCK_NAME = 'core/accordion-heading';\nconst ACCORDION_BLOCK = {\n\tname: ACCORDION_BLOCK_NAME,\n};\n\nexport default function Edit( {\n\tattributes: {\n\t\tautoclose,\n\t\ticonPosition,\n\t\tshowIcon,\n\t\theadingLevel,\n\t\tlevelOptions,\n\t},\n\tclientId,\n\tsetAttributes,\n\tisSelected: isSingleSelected,\n} ) {\n\tconst registry = useRegistry();\n\tconst { getBlockOrder } = useSelect( blockEditorStore );\n\tconst blockProps = useBlockProps( {\n\t\trole: 'group',\n\t} );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst { updateBlockAttributes, insertBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isContentOnlyMode = blockEditingMode === 'contentOnly';\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: [ [ ACCORDION_BLOCK_NAME ] ],\n\t\tdefaultBlock: ACCORDION_BLOCK,\n\t\tdirectInsert: true,\n\t\ttemplateInsertUpdatesSelection: true,\n\t} );\n\n\tconst addAccordionItemBlock = () => {\n\t\t// When adding, set the header's level to current headingLevel\n\t\tconst newAccordionItem = createBlock( ACCORDION_BLOCK_NAME, {}, [\n\t\t\tcreateBlock( ACCORDION_HEADING_BLOCK_NAME, {\n\t\t\t\tlevel: headingLevel,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/accordion-panel', {} ),\n\t\t] );\n\t\tinsertBlock( newAccordionItem, undefined, clientId );\n\t};\n\n\t/**\n\t * Update all child Accordion Header blocks with a new heading level\n\t * based on the accordion group setting.\n\t * @param {number} newHeadingLevel The new heading level to set\n\t */\n\tconst updateHeadingLevel = ( newHeadingLevel ) => {\n\t\tconst innerBlockClientIds = getBlockOrder( clientId );\n\n\t\t// Get all accordion-header blocks from all accordion-content blocks.\n\t\tconst accordionHeaderClientIds = [];\n\t\tinnerBlockClientIds.forEach( ( contentClientId ) => {\n\t\t\tconst headerClientIds = getBlockOrder( contentClientId );\n\t\t\taccordionHeaderClientIds.push( ...headerClientIds );\n\t\t} );\n\n\t\t// Update own and child block heading levels.\n\t\tregistry.batch( () => {\n\t\t\tsetAttributes( { headingLevel: newHeadingLevel } );\n\t\t\tupdateBlockAttributes( accordionHeaderClientIds, {\n\t\t\t\tlevel: newHeadingLevel,\n\t\t\t} );\n\t\t} );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{ isSingleSelected && ! isContentOnlyMode && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<HeadingLevelDropdown\n\t\t\t\t\t\t\t\tvalue={ headingLevel }\n\t\t\t\t\t\t\t\toptions={ levelOptions }\n\t\t\t\t\t\t\t\tonChange={ updateHeadingLevel }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<ToolbarButton onClick={ addAccordionItemBlock }>\n\t\t\t\t\t\t\t{ __( 'Add item' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<InspectorControls key=\"setting\">\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\tautoclose: false,\n\t\t\t\t\t\t\tshowIcon: true,\n\t\t\t\t\t\t\ticonPosition: 'right',\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\tlabel={ __( 'Auto-close' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! autoclose }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { autoclose: 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\tisBlock\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Auto-close' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tautoclose: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tchecked={ autoclose }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Automatically close accordions when a new one is opened.'\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\tlabel={ __( 'Show icon' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showIcon }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { showIcon: true } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Show icon' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowIcon: value,\n\t\t\t\t\t\t\t\t\ticonPosition: value\n\t\t\t\t\t\t\t\t\t\t? iconPosition\n\t\t\t\t\t\t\t\t\t\t: 'right',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tchecked={ showIcon }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Display a plus icon next to the accordion header.'\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{ showIcon && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Icon Position' ) }\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\thasValue={ () => iconPosition !== 'right' }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { iconPosition: 'right' } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleGroupControl\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\tisBlock\n\t\t\t\t\t\t\t\tlabel={ __( 'Icon Position' ) }\n\t\t\t\t\t\t\t\tvalue={ iconPosition }\n\t\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( { iconPosition: value } );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Left' ) }\n\t\t\t\t\t\t\t\t\tvalue=\"left\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Right' ) }\n\t\t\t\t\t\t\t\t\tvalue=\"right\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAwGI,mBAGG,KAHH;AArGJ;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,OACM;AACP,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA,oCAAoC;AAAA,EACpC,0CAA0C;AAAA,EAC1C,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,EAChC;A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|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
actions: {
|
|
13
|
-
toggle: () => {
|
|
14
|
-
const context = getContext();
|
|
15
|
-
const { id, autoclose, accordionItems } = context;
|
|
16
|
-
const accordionItem = accordionItems.find(
|
|
17
|
-
(item) => item.id === id
|
|
18
|
-
);
|
|
19
|
-
if (autoclose) {
|
|
20
|
-
accordionItems.forEach((item) => {
|
|
21
|
-
item.isOpen = item.id === id ? !accordionItem.isOpen : false;
|
|
22
|
-
});
|
|
23
|
-
} else {
|
|
24
|
-
accordionItem.isOpen = !accordionItem.isOpen;
|
|
2
|
+
store(
|
|
3
|
+
"core/accordion",
|
|
4
|
+
{
|
|
5
|
+
state: {
|
|
6
|
+
get isOpen() {
|
|
7
|
+
const { id, accordionItems } = getContext();
|
|
8
|
+
const accordionItem = accordionItems.find(
|
|
9
|
+
(item) => item.id === id
|
|
10
|
+
);
|
|
11
|
+
return accordionItem ? accordionItem.isOpen : false;
|
|
25
12
|
}
|
|
26
13
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
14
|
+
actions: {
|
|
15
|
+
toggle: () => {
|
|
16
|
+
const context = getContext();
|
|
17
|
+
const { id, autoclose, accordionItems } = context;
|
|
18
|
+
const accordionItem = accordionItems.find(
|
|
19
|
+
(item) => item.id === id
|
|
20
|
+
);
|
|
21
|
+
if (autoclose) {
|
|
22
|
+
accordionItems.forEach((item) => {
|
|
23
|
+
item.isOpen = item.id === id ? !accordionItem.isOpen : false;
|
|
24
|
+
});
|
|
25
|
+
} else {
|
|
26
|
+
accordionItem.isOpen = !accordionItem.isOpen;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
handleKeyDown: withSyncEvent((event) => {
|
|
30
|
+
if (event.key !== "ArrowUp" && event.key !== "ArrowDown" && event.key !== "Home" && event.key !== "End") {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
const context = getContext();
|
|
35
|
+
const { id, accordionItems } = context;
|
|
36
|
+
const currentIndex = accordionItems.findIndex(
|
|
37
|
+
(item) => item.id === id
|
|
38
|
+
);
|
|
39
|
+
let nextIndex;
|
|
40
|
+
switch (event.key) {
|
|
41
|
+
case "ArrowUp":
|
|
42
|
+
nextIndex = Math.max(0, currentIndex - 1);
|
|
43
|
+
break;
|
|
44
|
+
case "ArrowDown":
|
|
45
|
+
nextIndex = Math.min(
|
|
46
|
+
currentIndex + 1,
|
|
47
|
+
accordionItems.length - 1
|
|
48
|
+
);
|
|
49
|
+
break;
|
|
50
|
+
case "Home":
|
|
51
|
+
nextIndex = 0;
|
|
52
|
+
break;
|
|
53
|
+
case "End":
|
|
54
|
+
nextIndex = accordionItems.length - 1;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
const nextId = accordionItems[nextIndex].id;
|
|
58
|
+
const nextButton = document.getElementById(nextId);
|
|
59
|
+
if (nextButton) {
|
|
60
|
+
nextButton.focus();
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
},
|
|
64
|
+
callbacks: {
|
|
65
|
+
initAccordionItems: () => {
|
|
66
|
+
const context = getContext();
|
|
67
|
+
const { id, openByDefault } = context;
|
|
68
|
+
context.accordionItems.push({
|
|
69
|
+
id,
|
|
70
|
+
isOpen: openByDefault
|
|
71
|
+
});
|
|
59
72
|
}
|
|
60
|
-
})
|
|
61
|
-
},
|
|
62
|
-
callbacks: {
|
|
63
|
-
initAccordionItems: () => {
|
|
64
|
-
const context = getContext();
|
|
65
|
-
const { id, openByDefault } = context;
|
|
66
|
-
context.accordionItems.push({
|
|
67
|
-
id,
|
|
68
|
-
isOpen: openByDefault
|
|
69
|
-
});
|
|
70
73
|
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
74
|
+
},
|
|
75
|
+
{ lock: true }
|
|
76
|
+
);
|
|
73
77
|
//# sourceMappingURL=view.js.map
|
|
@@ -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\nstore(
|
|
5
|
-
"mappings": "AAGA,SAAS,OAAO,YAAY,qBAAqB;AAEjD,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store, getContext, withSyncEvent } from '@wordpress/interactivity';\n\nstore(\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},\n\t\tcallbacks: {\n\t\t\tinitAccordionItems: () => {\n\t\t\t\tconst context = getContext();\n\t\t\t\tconst { id, openByDefault } = context;\n\t\t\t\tcontext.accordionItems.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tisOpen: openByDefault,\n\t\t\t\t} );\n\t\t\t},\n\t\t},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D,KAAK;AACJ,wBAAY,eAAe,SAAS;AACpC;AAAA,QACF;AAEA,cAAM,SAAS,eAAgB,SAAU,EAAE;AAC3C,cAAM,aAAa,SAAS,eAAgB,MAAO;AACnD,YAAK,YAAa;AACjB,qBAAW,MAAM;AAAA,QAClB;AAAA,MACD,CAAE;AAAA,IACH;AAAA,IACA,WAAW;AAAA,MACV,oBAAoB,MAAM;AACzB,cAAM,UAAU,WAAW;AAC3B,cAAM,EAAE,IAAI,cAAc,IAAI;AAC9B,gBAAQ,eAAe,KAAM;AAAA,UAC5B;AAAA,UACA,QAAQ;AAAA,QACT,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AAAA,EACA,EAAE,MAAM,KAAK;AACd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -15,11 +15,11 @@ import { useDispatch } from "@wordpress/data";
|
|
|
15
15
|
import { unlock } from "../lock-unlock";
|
|
16
16
|
const { Badge } = unlock(componentsPrivateApis);
|
|
17
17
|
function MathEdit({ attributes, setAttributes, isSelected }) {
|
|
18
|
-
const { latex } = attributes;
|
|
18
|
+
const { latex, mathML } = attributes;
|
|
19
19
|
const [blockRef, setBlockRef] = useState();
|
|
20
20
|
const [error, setError] = useState(null);
|
|
21
21
|
const [latexToMathML, setLatexToMathML] = useState();
|
|
22
|
-
const initialLatex = useRef(
|
|
22
|
+
const initialLatex = useRef(latex);
|
|
23
23
|
const { __unstableMarkNextChangeAsNotPersistent } = useDispatch(blockEditorStore);
|
|
24
24
|
useEffect(() => {
|
|
25
25
|
import("@wordpress/latex-to-mathml").then((module) => {
|
|
@@ -43,11 +43,11 @@ function MathEdit({ attributes, setAttributes, isSelected }) {
|
|
|
43
43
|
position: "relative"
|
|
44
44
|
});
|
|
45
45
|
return /* @__PURE__ */ jsxs("div", { ...blockProps, children: [
|
|
46
|
-
|
|
46
|
+
mathML ? /* @__PURE__ */ jsx(
|
|
47
47
|
"math",
|
|
48
48
|
{
|
|
49
49
|
display: "block",
|
|
50
|
-
dangerouslySetInnerHTML: { __html:
|
|
50
|
+
dangerouslySetInnerHTML: { __html: mathML }
|
|
51
51
|
}
|
|
52
52
|
) : "\u200B",
|
|
53
53
|
isSelected && /* @__PURE__ */ jsx(
|
|
@@ -72,9 +72,9 @@ function MathEdit({ attributes, setAttributes, isSelected }) {
|
|
|
72
72
|
setAttributes({ latex: newLatex });
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
-
let
|
|
75
|
+
let newMathML = "";
|
|
76
76
|
try {
|
|
77
|
-
|
|
77
|
+
newMathML = latexToMathML(newLatex, {
|
|
78
78
|
displayMode: true
|
|
79
79
|
});
|
|
80
80
|
setError(null);
|
|
@@ -82,7 +82,7 @@ function MathEdit({ attributes, setAttributes, isSelected }) {
|
|
|
82
82
|
setError(err.message);
|
|
83
83
|
}
|
|
84
84
|
setAttributes({
|
|
85
|
-
mathML,
|
|
85
|
+
mathML: newMathML,
|
|
86
86
|
latex: newLatex
|
|
87
87
|
});
|
|
88
88
|
},
|
|
@@ -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 } = attributes;\n\tconst [ blockRef, setBlockRef ] = useState();\n\tconst [ error, setError ] = useState( null );\n\tconst [ latexToMathML, setLatexToMathML ] = useState();\n\tconst initialLatex = useRef(
|
|
5
|
-
"mappings": "AA2DI,SAgDI,UAhDJ,KAgDI,YAhDJ;AAxDJ,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;AAK5B,SAAS,cAAc;AAEvB,MAAM,EAAE,MAAM,IAAI,OAAQ,qBAAsB;AAEjC,SAAR,SAA2B,EAAE,YAAY,eAAe,WAAW,GAAI;AAC7E,QAAM,EAAE,
|
|
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=\"firstContentElement\"\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}\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": "AA2DI,SAgDI,UAhDJ,KAgDI,YAhDJ;AAxDJ,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;AAK5B,SAAS,cAAc;AAEvB,MAAM,EAAE,MAAM,IAAI,OAAQ,qB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,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;AAAA,gBACvB;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
|
}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
.wp-block-accordion .wp-block-accordion-heading {
|
|
2
|
-
padding: 0;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
1
|
.wp-block-accordion-heading__toggle {
|
|
6
2
|
font-family: inherit;
|
|
7
3
|
font-size: inherit;
|
|
@@ -11,6 +7,7 @@
|
|
|
11
7
|
text-transform: inherit;
|
|
12
8
|
text-decoration: inherit;
|
|
13
9
|
word-spacing: inherit;
|
|
10
|
+
font-style: inherit;
|
|
14
11
|
background: none;
|
|
15
12
|
border: none;
|
|
16
13
|
color: inherit;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
.wp-block-accordion .wp-block-accordion-heading {
|
|
2
|
-
padding: 0;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
1
|
.wp-block-accordion-heading__toggle {
|
|
6
2
|
font-family: inherit;
|
|
7
3
|
font-size: inherit;
|
|
@@ -11,6 +7,7 @@
|
|
|
11
7
|
text-transform: inherit;
|
|
12
8
|
text-decoration: inherit;
|
|
13
9
|
word-spacing: inherit;
|
|
10
|
+
font-style: inherit;
|
|
14
11
|
background: none;
|
|
15
12
|
border: none;
|
|
16
13
|
color: inherit;
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
* React Native specific.
|
|
44
44
|
* These variables do not appear to be used anywhere else.
|
|
45
45
|
*/
|
|
46
|
-
h1.has-background,
|
|
47
|
-
h2.has-background,
|
|
48
|
-
h3.has-background,
|
|
49
|
-
h4.has-background,
|
|
50
|
-
h5.has-background,
|
|
51
|
-
h6.has-background {
|
|
46
|
+
h1:where(.wp-block-heading).has-background,
|
|
47
|
+
h2:where(.wp-block-heading).has-background,
|
|
48
|
+
h3:where(.wp-block-heading).has-background,
|
|
49
|
+
h4:where(.wp-block-heading).has-background,
|
|
50
|
+
h5:where(.wp-block-heading).has-background,
|
|
51
|
+
h6:where(.wp-block-heading).has-background {
|
|
52
52
|
padding: 1.25em 2.375em;
|
|
53
53
|
}
|
|
54
54
|
h1.has-text-align-right[style*=writing-mode]:where([style*=vertical-rl]), h1.has-text-align-left[style*=writing-mode]:where([style*=vertical-lr]),
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
* React Native specific.
|
|
44
44
|
* These variables do not appear to be used anywhere else.
|
|
45
45
|
*/
|
|
46
|
-
h1.has-background,
|
|
47
|
-
h2.has-background,
|
|
48
|
-
h3.has-background,
|
|
49
|
-
h4.has-background,
|
|
50
|
-
h5.has-background,
|
|
51
|
-
h6.has-background {
|
|
46
|
+
h1:where(.wp-block-heading).has-background,
|
|
47
|
+
h2:where(.wp-block-heading).has-background,
|
|
48
|
+
h3:where(.wp-block-heading).has-background,
|
|
49
|
+
h4:where(.wp-block-heading).has-background,
|
|
50
|
+
h5:where(.wp-block-heading).has-background,
|
|
51
|
+
h6:where(.wp-block-heading).has-background {
|
|
52
52
|
padding: 1.25em 2.375em;
|
|
53
53
|
}
|
|
54
54
|
h1.has-text-align-right[style*=writing-mode]:where([style*=vertical-rl]), h1.has-text-align-left[style*=writing-mode]:where([style*=vertical-lr]),
|
|
@@ -21,10 +21,6 @@
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
.wp-block-accordion .wp-block-accordion-heading {
|
|
25
|
-
padding: 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
24
|
.wp-block-accordion-heading__toggle {
|
|
29
25
|
font-family: inherit;
|
|
30
26
|
font-size: inherit;
|
|
@@ -34,6 +30,7 @@
|
|
|
34
30
|
text-transform: inherit;
|
|
35
31
|
text-decoration: inherit;
|
|
36
32
|
word-spacing: inherit;
|
|
33
|
+
font-style: inherit;
|
|
37
34
|
background: none;
|
|
38
35
|
border: none;
|
|
39
36
|
color: inherit;
|
|
@@ -1667,12 +1664,12 @@ figure.wp-block-gallery.has-nested-images {
|
|
|
1667
1664
|
position: relative;
|
|
1668
1665
|
}
|
|
1669
1666
|
|
|
1670
|
-
h1.has-background,
|
|
1671
|
-
h2.has-background,
|
|
1672
|
-
h3.has-background,
|
|
1673
|
-
h4.has-background,
|
|
1674
|
-
h5.has-background,
|
|
1675
|
-
h6.has-background {
|
|
1667
|
+
h1:where(.wp-block-heading).has-background,
|
|
1668
|
+
h2:where(.wp-block-heading).has-background,
|
|
1669
|
+
h3:where(.wp-block-heading).has-background,
|
|
1670
|
+
h4:where(.wp-block-heading).has-background,
|
|
1671
|
+
h5:where(.wp-block-heading).has-background,
|
|
1672
|
+
h6:where(.wp-block-heading).has-background {
|
|
1676
1673
|
padding: 1.25em 2.375em;
|
|
1677
1674
|
}
|
|
1678
1675
|
h1.has-text-align-right[style*=writing-mode]:where([style*=vertical-rl]), h1.has-text-align-left[style*=writing-mode]:where([style*=vertical-lr]),
|
package/build-style/style.css
CHANGED
|
@@ -21,10 +21,6 @@
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
.wp-block-accordion .wp-block-accordion-heading {
|
|
25
|
-
padding: 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
24
|
.wp-block-accordion-heading__toggle {
|
|
29
25
|
font-family: inherit;
|
|
30
26
|
font-size: inherit;
|
|
@@ -34,6 +30,7 @@
|
|
|
34
30
|
text-transform: inherit;
|
|
35
31
|
text-decoration: inherit;
|
|
36
32
|
word-spacing: inherit;
|
|
33
|
+
font-style: inherit;
|
|
37
34
|
background: none;
|
|
38
35
|
border: none;
|
|
39
36
|
color: inherit;
|
|
@@ -1675,12 +1672,12 @@ figure.wp-block-gallery.has-nested-images {
|
|
|
1675
1672
|
position: relative;
|
|
1676
1673
|
}
|
|
1677
1674
|
|
|
1678
|
-
h1.has-background,
|
|
1679
|
-
h2.has-background,
|
|
1680
|
-
h3.has-background,
|
|
1681
|
-
h4.has-background,
|
|
1682
|
-
h5.has-background,
|
|
1683
|
-
h6.has-background {
|
|
1675
|
+
h1:where(.wp-block-heading).has-background,
|
|
1676
|
+
h2:where(.wp-block-heading).has-background,
|
|
1677
|
+
h3:where(.wp-block-heading).has-background,
|
|
1678
|
+
h4:where(.wp-block-heading).has-background,
|
|
1679
|
+
h5:where(.wp-block-heading).has-background,
|
|
1680
|
+
h6:where(.wp-block-heading).has-background {
|
|
1684
1681
|
padding: 1.25em 2.375em;
|
|
1685
1682
|
}
|
|
1686
1683
|
h1.has-text-align-right[style*=writing-mode]:where([style*=vertical-rl]), h1.has-text-align-left[style*=writing-mode]:where([style*=vertical-lr]),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-library",
|
|
3
|
-
"version": "9.33.
|
|
3
|
+
"version": "9.33.5",
|
|
4
4
|
"description": "Block library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -86,11 +86,11 @@
|
|
|
86
86
|
"@wordpress/autop": "^4.33.1",
|
|
87
87
|
"@wordpress/base-styles": "^6.9.1",
|
|
88
88
|
"@wordpress/blob": "^4.33.1",
|
|
89
|
-
"@wordpress/block-editor": "^15.6.
|
|
89
|
+
"@wordpress/block-editor": "^15.6.4",
|
|
90
90
|
"@wordpress/blocks": "^15.6.1",
|
|
91
|
-
"@wordpress/components": "^30.6.
|
|
91
|
+
"@wordpress/components": "^30.6.2",
|
|
92
92
|
"@wordpress/compose": "^7.33.1",
|
|
93
|
-
"@wordpress/core-data": "^7.33.
|
|
93
|
+
"@wordpress/core-data": "^7.33.4",
|
|
94
94
|
"@wordpress/data": "^10.33.1",
|
|
95
95
|
"@wordpress/date": "^5.33.1",
|
|
96
96
|
"@wordpress/deprecated": "^4.33.1",
|
|
@@ -107,12 +107,12 @@
|
|
|
107
107
|
"@wordpress/keycodes": "^4.33.1",
|
|
108
108
|
"@wordpress/latex-to-mathml": "^1.1.1",
|
|
109
109
|
"@wordpress/notices": "^5.33.1",
|
|
110
|
-
"@wordpress/patterns": "^2.33.
|
|
110
|
+
"@wordpress/patterns": "^2.33.4",
|
|
111
111
|
"@wordpress/primitives": "^4.33.1",
|
|
112
112
|
"@wordpress/private-apis": "^1.33.1",
|
|
113
|
-
"@wordpress/reusable-blocks": "^5.33.
|
|
113
|
+
"@wordpress/reusable-blocks": "^5.33.4",
|
|
114
114
|
"@wordpress/rich-text": "^7.33.1",
|
|
115
|
-
"@wordpress/server-side-render": "^6.9.
|
|
115
|
+
"@wordpress/server-side-render": "^6.9.2",
|
|
116
116
|
"@wordpress/url": "^4.33.1",
|
|
117
117
|
"@wordpress/viewport": "^6.33.1",
|
|
118
118
|
"@wordpress/wordcount": "^4.33.1",
|
|
@@ -133,5 +133,5 @@
|
|
|
133
133
|
"publishConfig": {
|
|
134
134
|
"access": "public"
|
|
135
135
|
},
|
|
136
|
-
"gitHead": "
|
|
136
|
+
"gitHead": "2e2a11a11f0c5c9cb2bba2dd40b8046d2a10dc9d"
|
|
137
137
|
}
|
package/src/accordion/edit.js
CHANGED
package/src/accordion/view.js
CHANGED
|
@@ -3,85 +3,89 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { store, getContext, withSyncEvent } from '@wordpress/interactivity';
|
|
5
5
|
|
|
6
|
-
store(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
store(
|
|
7
|
+
'core/accordion',
|
|
8
|
+
{
|
|
9
|
+
state: {
|
|
10
|
+
get isOpen() {
|
|
11
|
+
const { id, accordionItems } = getContext();
|
|
12
|
+
const accordionItem = accordionItems.find(
|
|
13
|
+
( item ) => item.id === id
|
|
14
|
+
);
|
|
15
|
+
return accordionItem ? accordionItem.isOpen : false;
|
|
16
|
+
},
|
|
14
17
|
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
);
|
|
18
|
+
actions: {
|
|
19
|
+
toggle: () => {
|
|
20
|
+
const context = getContext();
|
|
21
|
+
const { id, autoclose, accordionItems } = context;
|
|
22
|
+
const accordionItem = accordionItems.find(
|
|
23
|
+
( item ) => item.id === id
|
|
24
|
+
);
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
if ( autoclose ) {
|
|
27
|
+
accordionItems.forEach( ( item ) => {
|
|
28
|
+
item.isOpen =
|
|
29
|
+
item.id === id ? ! accordionItem.isOpen : false;
|
|
30
|
+
} );
|
|
31
|
+
} else {
|
|
32
|
+
accordionItem.isOpen = ! accordionItem.isOpen;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
handleKeyDown: withSyncEvent( ( event ) => {
|
|
36
|
+
if (
|
|
37
|
+
event.key !== 'ArrowUp' &&
|
|
38
|
+
event.key !== 'ArrowDown' &&
|
|
39
|
+
event.key !== 'Home' &&
|
|
40
|
+
event.key !== 'End'
|
|
41
|
+
) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
const context = getContext();
|
|
47
|
+
const { id, accordionItems } = context;
|
|
48
|
+
const currentIndex = accordionItems.findIndex(
|
|
49
|
+
( item ) => item.id === id
|
|
50
|
+
);
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
let nextIndex;
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
54
|
+
switch ( event.key ) {
|
|
55
|
+
case 'ArrowUp':
|
|
56
|
+
nextIndex = Math.max( 0, currentIndex - 1 );
|
|
57
|
+
break;
|
|
58
|
+
case 'ArrowDown':
|
|
59
|
+
nextIndex = Math.min(
|
|
60
|
+
currentIndex + 1,
|
|
61
|
+
accordionItems.length - 1
|
|
62
|
+
);
|
|
63
|
+
break;
|
|
64
|
+
case 'Home':
|
|
65
|
+
nextIndex = 0;
|
|
66
|
+
break;
|
|
67
|
+
case 'End':
|
|
68
|
+
nextIndex = accordionItems.length - 1;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
72
|
+
const nextId = accordionItems[ nextIndex ].id;
|
|
73
|
+
const nextButton = document.getElementById( nextId );
|
|
74
|
+
if ( nextButton ) {
|
|
75
|
+
nextButton.focus();
|
|
76
|
+
}
|
|
77
|
+
} ),
|
|
78
|
+
},
|
|
79
|
+
callbacks: {
|
|
80
|
+
initAccordionItems: () => {
|
|
81
|
+
const context = getContext();
|
|
82
|
+
const { id, openByDefault } = context;
|
|
83
|
+
context.accordionItems.push( {
|
|
84
|
+
id,
|
|
85
|
+
isOpen: openByDefault,
|
|
86
|
+
} );
|
|
87
|
+
},
|
|
85
88
|
},
|
|
86
89
|
},
|
|
87
|
-
}
|
|
90
|
+
{ lock: true }
|
|
91
|
+
);
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
// The .wp-block-accordion selector is needed to make this CSS stronger
|
|
2
|
-
// than the default heading padding when background color is applied.
|
|
3
|
-
.wp-block-accordion .wp-block-accordion-heading {
|
|
4
|
-
padding: 0;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
1
|
.wp-block-accordion-heading__toggle {
|
|
8
2
|
font-family: inherit;
|
|
9
3
|
font-size: inherit;
|
|
@@ -13,6 +7,7 @@
|
|
|
13
7
|
text-transform: inherit;
|
|
14
8
|
text-decoration: inherit;
|
|
15
9
|
word-spacing: inherit;
|
|
10
|
+
font-style: inherit;
|
|
16
11
|
background: none;
|
|
17
12
|
border: none;
|
|
18
13
|
color: inherit;
|
package/src/heading/style.scss
CHANGED
package/src/math/block.json
CHANGED
package/src/math/edit.js
CHANGED
|
@@ -23,11 +23,11 @@ import { unlock } from '../lock-unlock';
|
|
|
23
23
|
const { Badge } = unlock( componentsPrivateApis );
|
|
24
24
|
|
|
25
25
|
export default function MathEdit( { attributes, setAttributes, isSelected } ) {
|
|
26
|
-
const { latex } = attributes;
|
|
26
|
+
const { latex, mathML } = attributes;
|
|
27
27
|
const [ blockRef, setBlockRef ] = useState();
|
|
28
28
|
const [ error, setError ] = useState( null );
|
|
29
29
|
const [ latexToMathML, setLatexToMathML ] = useState();
|
|
30
|
-
const initialLatex = useRef(
|
|
30
|
+
const initialLatex = useRef( latex );
|
|
31
31
|
const { __unstableMarkNextChangeAsNotPersistent } =
|
|
32
32
|
useDispatch( blockEditorStore );
|
|
33
33
|
|
|
@@ -56,13 +56,13 @@ export default function MathEdit( { attributes, setAttributes, isSelected } ) {
|
|
|
56
56
|
|
|
57
57
|
return (
|
|
58
58
|
<div { ...blockProps }>
|
|
59
|
-
{
|
|
59
|
+
{ mathML ? (
|
|
60
60
|
<math
|
|
61
61
|
// We can't spread block props on the math element because
|
|
62
62
|
// it only supports a limited amount of global attributes.
|
|
63
63
|
// For example, draggable will have no effect.
|
|
64
64
|
display="block"
|
|
65
|
-
dangerouslySetInnerHTML={ { __html:
|
|
65
|
+
dangerouslySetInnerHTML={ { __html: mathML } }
|
|
66
66
|
/>
|
|
67
67
|
) : (
|
|
68
68
|
'\u200B'
|
|
@@ -88,9 +88,9 @@ export default function MathEdit( { attributes, setAttributes, isSelected } ) {
|
|
|
88
88
|
setAttributes( { latex: newLatex } );
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
|
-
let
|
|
91
|
+
let newMathML = '';
|
|
92
92
|
try {
|
|
93
|
-
|
|
93
|
+
newMathML = latexToMathML( newLatex, {
|
|
94
94
|
displayMode: true,
|
|
95
95
|
} );
|
|
96
96
|
setError( null );
|
|
@@ -98,7 +98,7 @@ export default function MathEdit( { attributes, setAttributes, isSelected } ) {
|
|
|
98
98
|
setError( err.message );
|
|
99
99
|
}
|
|
100
100
|
setAttributes( {
|
|
101
|
-
mathML,
|
|
101
|
+
mathML: newMathML,
|
|
102
102
|
latex: newLatex,
|
|
103
103
|
} );
|
|
104
104
|
} }
|