@wordpress/patterns 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/reset-overrides-control.js +1 -2
- package/build/components/reset-overrides-control.js.map +1 -1
- package/build-module/components/reset-overrides-control.js +2 -3
- package/build-module/components/reset-overrides-control.js.map +1 -1
- package/package.json +4 -4
- package/src/components/reset-overrides-control.js +3 -3
|
@@ -64,8 +64,7 @@ function ResetOverridesControl(props) {
|
|
|
64
64
|
[CONTENT]: newOverrides
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.
|
|
68
|
-
group: "other",
|
|
67
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.__unstableBlockToolbarLastItem, {
|
|
69
68
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarGroup, {
|
|
70
69
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarButton, {
|
|
71
70
|
onClick: onClick,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blockEditor","require","_components","_data","_i18n","_jsxRuntime","CONTENT","ResetOverridesControl","props","name","attributes","metadata","registry","useRegistry","isOverriden","useSelect","select","getBlockAttributes","getBlockParentsByBlockName","blockEditorStore","patternClientId","clientId","overrides","hasOwnProperty","onClick","updateBlockAttributes","__unstableMarkLastChangeAsPersistent","dispatch","newOverrides","Object","keys","length","undefined","jsx","
|
|
1
|
+
{"version":3,"names":["_blockEditor","require","_components","_data","_i18n","_jsxRuntime","CONTENT","ResetOverridesControl","props","name","attributes","metadata","registry","useRegistry","isOverriden","useSelect","select","getBlockAttributes","getBlockParentsByBlockName","blockEditorStore","patternClientId","clientId","overrides","hasOwnProperty","onClick","updateBlockAttributes","__unstableMarkLastChangeAsPersistent","dispatch","newOverrides","Object","keys","length","undefined","jsx","__unstableBlockToolbarLastItem","children","ToolbarGroup","ToolbarButton","disabled","__experimentalIsFocusable","__"],"sources":["@wordpress/patterns/src/components/reset-overrides-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blockEditorStore,\n\t__unstableBlockToolbarLastItem as BlockToolbarLastItem,\n} from '@wordpress/block-editor';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\nconst CONTENT = 'content';\n\nexport default function ResetOverridesControl( props ) {\n\tconst name = props.attributes.metadata?.name;\n\tconst registry = useRegistry();\n\tconst isOverriden = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! name ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { getBlockAttributes, getBlockParentsByBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\t\tprops.clientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tif ( ! patternClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst overrides = getBlockAttributes( patternClientId )[ CONTENT ];\n\n\t\t\tif ( ! overrides ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn overrides.hasOwnProperty( name );\n\t\t},\n\t\t[ props.clientId, name ]\n\t);\n\n\tfunction onClick() {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName } =\n\t\t\tregistry.select( blockEditorStore );\n\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\tprops.clientId,\n\t\t\t'core/block',\n\t\t\ttrue\n\t\t);\n\n\t\tif ( ! patternClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst overrides = getBlockAttributes( patternClientId )[ CONTENT ];\n\n\t\tif ( ! overrides.hasOwnProperty( name ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { updateBlockAttributes, __unstableMarkLastChangeAsPersistent } =\n\t\t\tregistry.dispatch( blockEditorStore );\n\t\t__unstableMarkLastChangeAsPersistent();\n\n\t\tlet newOverrides = { ...overrides };\n\t\tdelete newOverrides[ name ];\n\n\t\tif ( ! Object.keys( newOverrides ).length ) {\n\t\t\tnewOverrides = undefined;\n\t\t}\n\n\t\tupdateBlockAttributes( patternClientId, {\n\t\t\t[ CONTENT ]: newOverrides,\n\t\t} );\n\t}\n\n\treturn (\n\t\t<BlockToolbarLastItem>\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tdisabled={ ! isOverriden }\n\t\t\t\t\t__experimentalIsFocusable\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</ToolbarGroup>\n\t\t</BlockToolbarLastItem>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAAqC,IAAAI,WAAA,GAAAJ,OAAA;AATrC;AACA;AACA;;AASA,MAAMK,OAAO,GAAG,SAAS;AAEV,SAASC,qBAAqBA,CAAEC,KAAK,EAAG;EACtD,MAAMC,IAAI,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,EAAEF,IAAI;EAC5C,MAAMG,QAAQ,GAAG,IAAAC,iBAAW,EAAC,CAAC;EAC9B,MAAMC,WAAW,GAAG,IAAAC,eAAS,EAC1BC,MAAM,IAAM;IACb,IAAK,CAAEP,IAAI,EAAG;MACb;IACD;IAEA,MAAM;MAAEQ,kBAAkB;MAAEC;IAA2B,CAAC,GACvDF,MAAM,CAAEG,kBAAiB,CAAC;IAC3B,MAAM,CAAEC,eAAe,CAAE,GAAGF,0BAA0B,CACrDV,KAAK,CAACa,QAAQ,EACd,YAAY,EACZ,IACD,CAAC;IAED,IAAK,CAAED,eAAe,E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D,QAAA,eACZ,IAAA9B,WAAA,CAAA4B,GAAA,EAAC/B,WAAA,CAAAmC,aAAa;QACbb,OAAO,EAAGA,OAAS;QACnBc,QAAQ,EAAG,CAAExB,WAAa;QAC1ByB,yBAAyB;QAAAJ,QAAA,EAEvB,IAAAK,QAAE,EAAE,OAAQ;MAAC,CACD;IAAC,CACH;EAAC,CACM,CAAC;AAEzB","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { store as blockEditorStore,
|
|
4
|
+
import { store as blockEditorStore, __unstableBlockToolbarLastItem as BlockToolbarLastItem } from '@wordpress/block-editor';
|
|
5
5
|
import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
|
|
6
6
|
import { useRegistry, useSelect } from '@wordpress/data';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
@@ -57,8 +57,7 @@ export default function ResetOverridesControl(props) {
|
|
|
57
57
|
[CONTENT]: newOverrides
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
return /*#__PURE__*/_jsx(
|
|
61
|
-
group: "other",
|
|
60
|
+
return /*#__PURE__*/_jsx(BlockToolbarLastItem, {
|
|
62
61
|
children: /*#__PURE__*/_jsx(ToolbarGroup, {
|
|
63
62
|
children: /*#__PURE__*/_jsx(ToolbarButton, {
|
|
64
63
|
onClick: onClick,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","blockEditorStore","
|
|
1
|
+
{"version":3,"names":["store","blockEditorStore","__unstableBlockToolbarLastItem","BlockToolbarLastItem","ToolbarButton","ToolbarGroup","useRegistry","useSelect","__","jsx","_jsx","CONTENT","ResetOverridesControl","props","name","attributes","metadata","registry","isOverriden","select","getBlockAttributes","getBlockParentsByBlockName","patternClientId","clientId","overrides","hasOwnProperty","onClick","updateBlockAttributes","__unstableMarkLastChangeAsPersistent","dispatch","newOverrides","Object","keys","length","undefined","children","disabled","__experimentalIsFocusable"],"sources":["@wordpress/patterns/src/components/reset-overrides-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blockEditorStore,\n\t__unstableBlockToolbarLastItem as BlockToolbarLastItem,\n} from '@wordpress/block-editor';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\nconst CONTENT = 'content';\n\nexport default function ResetOverridesControl( props ) {\n\tconst name = props.attributes.metadata?.name;\n\tconst registry = useRegistry();\n\tconst isOverriden = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! name ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { getBlockAttributes, getBlockParentsByBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\t\tprops.clientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tif ( ! patternClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst overrides = getBlockAttributes( patternClientId )[ CONTENT ];\n\n\t\t\tif ( ! overrides ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn overrides.hasOwnProperty( name );\n\t\t},\n\t\t[ props.clientId, name ]\n\t);\n\n\tfunction onClick() {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName } =\n\t\t\tregistry.select( blockEditorStore );\n\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\tprops.clientId,\n\t\t\t'core/block',\n\t\t\ttrue\n\t\t);\n\n\t\tif ( ! patternClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst overrides = getBlockAttributes( patternClientId )[ CONTENT ];\n\n\t\tif ( ! overrides.hasOwnProperty( name ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { updateBlockAttributes, __unstableMarkLastChangeAsPersistent } =\n\t\t\tregistry.dispatch( blockEditorStore );\n\t\t__unstableMarkLastChangeAsPersistent();\n\n\t\tlet newOverrides = { ...overrides };\n\t\tdelete newOverrides[ name ];\n\n\t\tif ( ! Object.keys( newOverrides ).length ) {\n\t\t\tnewOverrides = undefined;\n\t\t}\n\n\t\tupdateBlockAttributes( patternClientId, {\n\t\t\t[ CONTENT ]: newOverrides,\n\t\t} );\n\t}\n\n\treturn (\n\t\t<BlockToolbarLastItem>\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tdisabled={ ! isOverriden }\n\t\t\t\t\t__experimentalIsFocusable\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</ToolbarGroup>\n\t\t</BlockToolbarLastItem>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,KAAK,IAAIC,gBAAgB,EACzBC,8BAA8B,IAAIC,oBAAoB,QAChD,yBAAyB;AAChC,SAASC,aAAa,EAAEC,YAAY,QAAQ,uBAAuB;AACnE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAErC,MAAMC,OAAO,GAAG,SAAS;AAEzB,eAAe,SAASC,qBAAqBA,CAAEC,KAAK,EAAG;EACtD,MAAMC,IAAI,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,EAAEF,IAAI;EAC5C,MAAMG,QAAQ,GAAGX,WAAW,CAAC,CAAC;EAC9B,MAAMY,WAAW,GAAGX,SAAS,CAC1BY,MAAM,IAAM;IACb,IAAK,CAAEL,IAAI,EAAG;MACb;IACD;IAEA,MAAM;MAAEM,kBAAkB;MAAEC;IAA2B,CAAC,GACvDF,MAAM,CAAElB,gBAAiB,CAAC;IAC3B,MAAM,CAAEqB,eAAe,CAAE,GAAGD,0BAA0B,CACrDR,KAAK,CAACU,QAAQ,EACd,YAAY,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AAa;QACbsB,OAAO,EAAGA,OAAS;QACnBU,QAAQ,EAAG,CAAElB,WAAa;QAC1BmB,yBAAyB;QAAAF,QAAA,EAEvB3B,EAAE,CAAE,OAAQ;MAAC,CACD;IAAC,CACH;EAAC,CACM,CAAC;AAEzB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/patterns",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "Management of user pattern editing.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.16.0",
|
|
35
35
|
"@wordpress/a11y": "^4.0.1",
|
|
36
|
-
"@wordpress/block-editor": "^13.0.
|
|
36
|
+
"@wordpress/block-editor": "^13.0.6",
|
|
37
37
|
"@wordpress/blocks": "^13.0.3",
|
|
38
38
|
"@wordpress/components": "^28.0.3",
|
|
39
39
|
"@wordpress/compose": "^7.0.1",
|
|
40
|
-
"@wordpress/core-data": "^7.0.
|
|
40
|
+
"@wordpress/core-data": "^7.0.6",
|
|
41
41
|
"@wordpress/data": "^10.0.2",
|
|
42
42
|
"@wordpress/element": "^6.0.1",
|
|
43
43
|
"@wordpress/html-entities": "^4.0.1",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "5c1d6bb774e6f78f0bbd4cdc85c4a7087da2f8a0"
|
|
58
58
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
store as blockEditorStore,
|
|
6
|
-
|
|
6
|
+
__unstableBlockToolbarLastItem as BlockToolbarLastItem,
|
|
7
7
|
} from '@wordpress/block-editor';
|
|
8
8
|
import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
|
|
9
9
|
import { useRegistry, useSelect } from '@wordpress/data';
|
|
@@ -79,7 +79,7 @@ export default function ResetOverridesControl( props ) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
return (
|
|
82
|
-
<
|
|
82
|
+
<BlockToolbarLastItem>
|
|
83
83
|
<ToolbarGroup>
|
|
84
84
|
<ToolbarButton
|
|
85
85
|
onClick={ onClick }
|
|
@@ -89,6 +89,6 @@ export default function ResetOverridesControl( props ) {
|
|
|
89
89
|
{ __( 'Reset' ) }
|
|
90
90
|
</ToolbarButton>
|
|
91
91
|
</ToolbarGroup>
|
|
92
|
-
</
|
|
92
|
+
</BlockToolbarLastItem>
|
|
93
93
|
);
|
|
94
94
|
}
|