@wordpress/patterns 2.32.0 → 2.32.1-next.ff1cebbba.0
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/api/index.js +35 -29
- package/build/api/index.js.map +7 -1
- package/build/components/allow-overrides-modal.js +149 -112
- package/build/components/allow-overrides-modal.js.map +7 -1
- package/build/components/category-selector.js +59 -38
- package/build/components/category-selector.js.map +7 -1
- package/build/components/create-pattern-modal.js +162 -111
- package/build/components/create-pattern-modal.js.map +7 -1
- package/build/components/duplicate-pattern-modal.js +85 -66
- package/build/components/duplicate-pattern-modal.js.map +7 -1
- package/build/components/index.js +50 -33
- package/build/components/index.js.map +7 -1
- package/build/components/overrides-panel.js +44 -39
- package/build/components/overrides-panel.js.map +7 -1
- package/build/components/pattern-convert-button.js +144 -133
- package/build/components/pattern-convert-button.js.map +7 -1
- package/build/components/pattern-overrides-block-controls.js +109 -109
- package/build/components/pattern-overrides-block-controls.js.map +7 -1
- package/build/components/pattern-overrides-controls.js +86 -69
- package/build/components/pattern-overrides-controls.js.map +7 -1
- package/build/components/patterns-manage-button.js +96 -97
- package/build/components/patterns-manage-button.js.map +7 -1
- package/build/components/rename-pattern-category-modal.js +122 -111
- package/build/components/rename-pattern-category-modal.js.map +7 -1
- package/build/components/rename-pattern-modal.js +95 -73
- package/build/components/rename-pattern-modal.js.map +7 -1
- package/build/components/reset-overrides-control.js +61 -57
- package/build/components/reset-overrides-control.js.map +7 -1
- package/build/constants.js +57 -23
- package/build/constants.js.map +7 -1
- package/build/index.js +27 -24
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/private-apis.js +71 -48
- package/build/private-apis.js.map +7 -1
- package/build/private-hooks.js +57 -69
- package/build/private-hooks.js.map +7 -1
- package/build/store/actions.js +72 -85
- package/build/store/actions.js.map +7 -1
- package/build/store/constants.js +27 -10
- package/build/store/constants.js.map +7 -1
- package/build/store/index.js +50 -44
- package/build/store/index.js.map +7 -1
- package/build/store/reducer.js +30 -14
- package/build/store/reducer.js.map +7 -1
- package/build/store/selectors.js +26 -13
- package/build/store/selectors.js.map +7 -1
- package/build-module/api/index.js +14 -25
- package/build-module/api/index.js.map +7 -1
- package/build-module/components/allow-overrides-modal.js +131 -103
- package/build-module/components/allow-overrides-modal.js.map +7 -1
- package/build-module/components/category-selector.js +35 -29
- package/build-module/components/category-selector.js.map +7 -1
- package/build-module/components/create-pattern-modal.js +137 -99
- package/build-module/components/create-pattern-modal.js.map +7 -1
- package/build-module/components/duplicate-pattern-modal.js +53 -58
- package/build-module/components/duplicate-pattern-modal.js.map +7 -1
- package/build-module/components/index.js +22 -26
- package/build-module/components/index.js.map +7 -1
- package/build-module/components/overrides-panel.js +30 -34
- package/build-module/components/overrides-panel.js.map +7 -1
- package/build-module/components/pattern-convert-button.js +120 -125
- package/build-module/components/pattern-convert-button.js.map +7 -1
- package/build-module/components/pattern-overrides-block-controls.js +100 -103
- package/build-module/components/pattern-overrides-block-controls.js.map +7 -1
- package/build-module/components/pattern-overrides-controls.js +69 -58
- package/build-module/components/pattern-overrides-controls.js.map +7 -1
- package/build-module/components/patterns-manage-button.js +78 -91
- package/build-module/components/patterns-manage-button.js.map +7 -1
- package/build-module/components/rename-pattern-category-modal.js +106 -101
- package/build-module/components/rename-pattern-category-modal.js.map +7 -1
- package/build-module/components/rename-pattern-modal.js +80 -64
- package/build-module/components/rename-pattern-modal.js.map +7 -1
- package/build-module/components/reset-overrides-control.js +46 -51
- package/build-module/components/reset-overrides-control.js.map +7 -1
- package/build-module/constants.js +29 -18
- package/build-module/constants.js.map +7 -1
- package/build-module/index.js +6 -6
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/private-apis.js +31 -18
- package/build-module/private-apis.js.map +7 -1
- package/build-module/private-hooks.js +35 -64
- package/build-module/private-hooks.js.map +7 -1
- package/build-module/store/actions.js +44 -74
- package/build-module/store/actions.js.map +7 -1
- package/build-module/store/constants.js +5 -5
- package/build-module/store/constants.js.map +7 -1
- package/build-module/store/index.js +13 -32
- package/build-module/store/index.js.map +7 -1
- package/build-module/store/reducer.js +9 -8
- package/build-module/store/reducer.js.map +7 -1
- package/build-module/store/selectors.js +5 -9
- package/build-module/store/selectors.js.map +7 -1
- package/build-style/style-rtl.css +3 -138
- package/build-style/style.css +3 -138
- package/package.json +24 -17
- package/src/components/style.scss +5 -0
- package/src/style.scss +2 -1
- package/build/index.native.js +0 -18
- package/build/index.native.js.map +0 -1
- package/build-module/index.native.js +0 -11
- package/build-module/index.native.js.map +0 -1
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
Modal,
|
|
5
|
+
TextControl,
|
|
6
|
+
__experimentalHStack as HStack,
|
|
7
|
+
__experimentalVStack as VStack
|
|
8
|
+
} from "@wordpress/components";
|
|
9
|
+
import { store as coreStore } from "@wordpress/core-data";
|
|
10
|
+
import { useDispatch } from "@wordpress/data";
|
|
11
|
+
import { useState } from "@wordpress/element";
|
|
12
|
+
import { decodeEntities } from "@wordpress/html-entities";
|
|
13
|
+
import { __ } from "@wordpress/i18n";
|
|
14
|
+
import { store as noticesStore } from "@wordpress/notices";
|
|
15
|
+
function RenamePatternModal({
|
|
13
16
|
onClose,
|
|
14
17
|
onError,
|
|
15
18
|
onSuccess,
|
|
@@ -23,79 +26,92 @@ export default function RenamePatternModal({
|
|
|
23
26
|
editEntityRecord,
|
|
24
27
|
__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits
|
|
25
28
|
} = useDispatch(coreStore);
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
createErrorNotice
|
|
29
|
-
} = useDispatch(noticesStore);
|
|
30
|
-
const onRename = async event => {
|
|
29
|
+
const { createSuccessNotice, createErrorNotice } = useDispatch(noticesStore);
|
|
30
|
+
const onRename = async (event) => {
|
|
31
31
|
event.preventDefault();
|
|
32
32
|
if (!name || name === pattern.title || isSaving) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
try {
|
|
36
|
-
await editEntityRecord(
|
|
36
|
+
await editEntityRecord("postType", pattern.type, pattern.id, {
|
|
37
37
|
title: name
|
|
38
38
|
});
|
|
39
39
|
setIsSaving(true);
|
|
40
|
-
setName(
|
|
40
|
+
setName("");
|
|
41
41
|
onClose?.();
|
|
42
|
-
const savedRecord = await saveSpecifiedEntityEdits(
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
const savedRecord = await saveSpecifiedEntityEdits(
|
|
43
|
+
"postType",
|
|
44
|
+
pattern.type,
|
|
45
|
+
pattern.id,
|
|
46
|
+
["title"],
|
|
47
|
+
{ throwOnError: true }
|
|
48
|
+
);
|
|
45
49
|
onSuccess?.(savedRecord);
|
|
46
|
-
createSuccessNotice(__(
|
|
47
|
-
type:
|
|
48
|
-
id:
|
|
50
|
+
createSuccessNotice(__("Pattern renamed"), {
|
|
51
|
+
type: "snackbar",
|
|
52
|
+
id: "pattern-update"
|
|
49
53
|
});
|
|
50
54
|
} catch (error) {
|
|
51
55
|
onError?.();
|
|
52
|
-
const errorMessage = error.message && error.code !==
|
|
56
|
+
const errorMessage = error.message && error.code !== "unknown_error" ? error.message : __("An error occurred while renaming the pattern.");
|
|
53
57
|
createErrorNotice(errorMessage, {
|
|
54
|
-
type:
|
|
55
|
-
id:
|
|
58
|
+
type: "snackbar",
|
|
59
|
+
id: "pattern-update"
|
|
56
60
|
});
|
|
57
61
|
} finally {
|
|
58
62
|
setIsSaving(false);
|
|
59
|
-
setName(
|
|
63
|
+
setName("");
|
|
60
64
|
}
|
|
61
65
|
};
|
|
62
66
|
const onRequestClose = () => {
|
|
63
67
|
onClose?.();
|
|
64
|
-
setName(
|
|
68
|
+
setName("");
|
|
65
69
|
};
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
children:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
label: __('Name'),
|
|
80
|
-
value: name,
|
|
81
|
-
onChange: setName,
|
|
82
|
-
required: true
|
|
83
|
-
}), /*#__PURE__*/_jsxs(HStack, {
|
|
84
|
-
justify: "right",
|
|
85
|
-
children: [/*#__PURE__*/_jsx(Button, {
|
|
70
|
+
return /* @__PURE__ */ jsx(
|
|
71
|
+
Modal,
|
|
72
|
+
{
|
|
73
|
+
title: __("Rename"),
|
|
74
|
+
...props,
|
|
75
|
+
onRequestClose: onClose,
|
|
76
|
+
focusOnMount: "firstContentElement",
|
|
77
|
+
size: "small",
|
|
78
|
+
children: /* @__PURE__ */ jsx("form", { onSubmit: onRename, children: /* @__PURE__ */ jsxs(VStack, { spacing: "5", children: [
|
|
79
|
+
/* @__PURE__ */ jsx(
|
|
80
|
+
TextControl,
|
|
81
|
+
{
|
|
82
|
+
__nextHasNoMarginBottom: true,
|
|
86
83
|
__next40pxDefaultSize: true,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
84
|
+
label: __("Name"),
|
|
85
|
+
value: name,
|
|
86
|
+
onChange: setName,
|
|
87
|
+
required: true
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ jsxs(HStack, { justify: "right", children: [
|
|
91
|
+
/* @__PURE__ */ jsx(
|
|
92
|
+
Button,
|
|
93
|
+
{
|
|
94
|
+
__next40pxDefaultSize: true,
|
|
95
|
+
variant: "tertiary",
|
|
96
|
+
onClick: onRequestClose,
|
|
97
|
+
children: __("Cancel")
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
/* @__PURE__ */ jsx(
|
|
101
|
+
Button,
|
|
102
|
+
{
|
|
103
|
+
__next40pxDefaultSize: true,
|
|
104
|
+
variant: "primary",
|
|
105
|
+
type: "submit",
|
|
106
|
+
children: __("Save")
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
] })
|
|
110
|
+
] }) })
|
|
111
|
+
}
|
|
112
|
+
);
|
|
100
113
|
}
|
|
101
|
-
|
|
114
|
+
export {
|
|
115
|
+
RenamePatternModal as default
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=rename-pattern-modal.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/components/rename-pattern-modal.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function RenamePatternModal( {\n\tonClose,\n\tonError,\n\tonSuccess,\n\tpattern,\n\t...props\n} ) {\n\tconst originalName = decodeEntities( pattern.title );\n\tconst [ name, setName ] = useState( originalName );\n\tconst [ isSaving, setIsSaving ] = useState( false );\n\n\tconst {\n\t\teditEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst onRename = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( ! name || name === pattern.title || isSaving ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', pattern.type, pattern.id, {\n\t\t\t\ttitle: name,\n\t\t\t} );\n\n\t\t\tsetIsSaving( true );\n\t\t\tsetName( '' );\n\t\t\tonClose?.();\n\n\t\t\tconst savedRecord = await saveSpecifiedEntityEdits(\n\t\t\t\t'postType',\n\t\t\t\tpattern.type,\n\t\t\t\tpattern.id,\n\t\t\t\t[ 'title' ],\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tonSuccess?.( savedRecord );\n\n\t\t\tcreateSuccessNotice( __( 'Pattern renamed' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-update',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError?.();\n\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the pattern.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-update',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsSaving( false );\n\t\t\tsetName( '' );\n\t\t}\n\t};\n\n\tconst onRequestClose = () => {\n\t\tonClose?.();\n\t\tsetName( '' );\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\t{ ...props }\n\t\t\tonRequestClose={ onClose }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t<form onSubmit={ onRename }>\n\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\tonChange={ setName }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAmGK,cASA,YATA;AAhGL;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,SAAS,iBAAiB;AACnC,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,UAAU;AACnB,SAAS,SAAS,oBAAoB;AAEvB,SAAR,mBAAqC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,GAAI;AACH,QAAM,eAAe,eAAgB,QAAQ,KAAM;AACnD,QAAM,CAAE,MAAM,OAAQ,IAAI,SAAU,YAAa;AACjD,QAAM,CAAE,UAAU,WAAY,IAAI,SAAU,KAAM;AAElD,QAAM;AAAA,IACL;AAAA,IACA,wCAAwC;AAAA,EACzC,IAAI,YAAa,SAAU;AAE3B,QAAM,EAAE,qBAAqB,kBAAkB,IAC9C,YAAa,YAAa;AAE3B,QAAM,WAAW,OAAQ,UAAW;AACnC,UAAM,e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B;AAAA,cACrB,SAAQ;AAAA,cACR,SAAU;AAAA,cAER,aAAI,QAAS;AAAA;AAAA,UAChB;AAAA,UAEA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,MAAK;AAAA,cAEH,aAAI,MAAO;AAAA;AAAA,UACd;AAAA,WACD;AAAA,SACD,GACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,39 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
const CONTENT =
|
|
10
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
store as blockEditorStore,
|
|
4
|
+
__unstableBlockToolbarLastItem as BlockToolbarLastItem
|
|
5
|
+
} from "@wordpress/block-editor";
|
|
6
|
+
import { ToolbarButton, ToolbarGroup } from "@wordpress/components";
|
|
7
|
+
import { useRegistry, useSelect } from "@wordpress/data";
|
|
8
|
+
import { __ } from "@wordpress/i18n";
|
|
9
|
+
const CONTENT = "content";
|
|
10
|
+
function ResetOverridesControl(props) {
|
|
11
11
|
const name = props.attributes.metadata?.name;
|
|
12
12
|
const registry = useRegistry();
|
|
13
|
-
const isOverridden = useSelect(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
getBlockAttributes,
|
|
19
|
-
getBlockParentsByBlockName
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
const isOverridden = useSelect(
|
|
14
|
+
(select) => {
|
|
15
|
+
if (!name) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const { getBlockAttributes, getBlockParentsByBlockName } = select(blockEditorStore);
|
|
19
|
+
const [patternClientId] = getBlockParentsByBlockName(
|
|
20
|
+
props.clientId,
|
|
21
|
+
"core/block",
|
|
22
|
+
true
|
|
23
|
+
);
|
|
24
|
+
if (!patternClientId) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const overrides = getBlockAttributes(patternClientId)[CONTENT];
|
|
28
|
+
if (!overrides) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
return overrides.hasOwnProperty(name);
|
|
32
|
+
},
|
|
33
|
+
[props.clientId, name]
|
|
34
|
+
);
|
|
31
35
|
function onClick() {
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
const { getBlockAttributes, getBlockParentsByBlockName } = registry.select(blockEditorStore);
|
|
37
|
+
const [patternClientId] = getBlockParentsByBlockName(
|
|
38
|
+
props.clientId,
|
|
39
|
+
"core/block",
|
|
40
|
+
true
|
|
41
|
+
);
|
|
37
42
|
if (!patternClientId) {
|
|
38
43
|
return;
|
|
39
44
|
}
|
|
@@ -41,30 +46,20 @@ export default function ResetOverridesControl(props) {
|
|
|
41
46
|
if (!overrides.hasOwnProperty(name)) {
|
|
42
47
|
return;
|
|
43
48
|
}
|
|
44
|
-
const {
|
|
45
|
-
updateBlockAttributes,
|
|
46
|
-
__unstableMarkLastChangeAsPersistent
|
|
47
|
-
} = registry.dispatch(blockEditorStore);
|
|
49
|
+
const { updateBlockAttributes, __unstableMarkLastChangeAsPersistent } = registry.dispatch(blockEditorStore);
|
|
48
50
|
__unstableMarkLastChangeAsPersistent();
|
|
49
|
-
let newOverrides = {
|
|
50
|
-
...overrides
|
|
51
|
-
};
|
|
51
|
+
let newOverrides = { ...overrides };
|
|
52
52
|
delete newOverrides[name];
|
|
53
53
|
if (!Object.keys(newOverrides).length) {
|
|
54
|
-
newOverrides =
|
|
54
|
+
newOverrides = void 0;
|
|
55
55
|
}
|
|
56
56
|
updateBlockAttributes(patternClientId, {
|
|
57
57
|
[CONTENT]: newOverrides
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
return
|
|
61
|
-
children: /*#__PURE__*/_jsx(ToolbarGroup, {
|
|
62
|
-
children: /*#__PURE__*/_jsx(ToolbarButton, {
|
|
63
|
-
onClick: onClick,
|
|
64
|
-
disabled: !isOverridden,
|
|
65
|
-
children: __('Reset')
|
|
66
|
-
})
|
|
67
|
-
})
|
|
68
|
-
});
|
|
60
|
+
return /* @__PURE__ */ jsx(BlockToolbarLastItem, { children: /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(ToolbarButton, { onClick, disabled: !isOverridden, children: __("Reset") }) }) });
|
|
69
61
|
}
|
|
70
|
-
|
|
62
|
+
export {
|
|
63
|
+
ResetOverridesControl as default
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=reset-overrides-control.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/components/reset-overrides-control.js"],
|
|
4
|
+
"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 isOverridden = 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 onClick={ onClick } disabled={ ! isOverridden }>\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"],
|
|
5
|
+
"mappings": "AAmFI;AAhFJ;AAAA,EACC,SAAS;AAAA,EACT,kCAAkC;AAAA,OAC5B;AACP,SAAS,eAAe,oBAAoB;AAC5C,SAAS,aAAa,iBAAiB;AACvC,SAAS,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AAE,cAC7C,aAAI,OAAQ,GACf,GACD,GACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
theme:
|
|
3
|
-
user:
|
|
1
|
+
const PATTERN_TYPES = {
|
|
2
|
+
theme: "pattern",
|
|
3
|
+
user: "wp_block"
|
|
4
4
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
const PATTERN_DEFAULT_CATEGORY = "all-patterns";
|
|
6
|
+
const PATTERN_USER_CATEGORY = "my-patterns";
|
|
7
|
+
const EXCLUDED_PATTERN_SOURCES = [
|
|
8
|
+
"core",
|
|
9
|
+
"pattern-directory/core",
|
|
10
|
+
"pattern-directory/featured"
|
|
11
|
+
];
|
|
12
|
+
const PATTERN_SYNC_TYPES = {
|
|
13
|
+
full: "fully",
|
|
14
|
+
unsynced: "unsynced"
|
|
11
15
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'core/button': ['text', 'url', 'linkTarget', 'rel'],
|
|
18
|
-
'core/image': ['id', 'url', 'title', 'alt']
|
|
16
|
+
const PARTIAL_SYNCING_SUPPORTED_BLOCKS = {
|
|
17
|
+
"core/paragraph": ["content"],
|
|
18
|
+
"core/heading": ["content"],
|
|
19
|
+
"core/button": ["text", "url", "linkTarget", "rel"],
|
|
20
|
+
"core/image": ["id", "url", "title", "alt"]
|
|
19
21
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
const PATTERN_OVERRIDES_BINDING_SOURCE = "core/pattern-overrides";
|
|
23
|
+
export {
|
|
24
|
+
EXCLUDED_PATTERN_SOURCES,
|
|
25
|
+
PARTIAL_SYNCING_SUPPORTED_BLOCKS,
|
|
26
|
+
PATTERN_DEFAULT_CATEGORY,
|
|
27
|
+
PATTERN_OVERRIDES_BINDING_SOURCE,
|
|
28
|
+
PATTERN_SYNC_TYPES,
|
|
29
|
+
PATTERN_TYPES,
|
|
30
|
+
PATTERN_USER_CATEGORY
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/constants.js"],
|
|
4
|
+
"sourcesContent": ["export const PATTERN_TYPES = {\n\ttheme: 'pattern',\n\tuser: 'wp_block',\n};\n\nexport const PATTERN_DEFAULT_CATEGORY = 'all-patterns';\nexport const PATTERN_USER_CATEGORY = 'my-patterns';\nexport const EXCLUDED_PATTERN_SOURCES = [\n\t'core',\n\t'pattern-directory/core',\n\t'pattern-directory/featured',\n];\nexport const PATTERN_SYNC_TYPES = {\n\tfull: 'fully',\n\tunsynced: 'unsynced',\n};\n\n// TODO: This should not be hardcoded. Maybe there should be a config and/or an UI.\nexport const PARTIAL_SYNCING_SUPPORTED_BLOCKS = {\n\t'core/paragraph': [ 'content' ],\n\t'core/heading': [ 'content' ],\n\t'core/button': [ 'text', 'url', 'linkTarget', 'rel' ],\n\t'core/image': [ 'id', 'url', 'title', 'alt' ],\n};\n\nexport const PATTERN_OVERRIDES_BINDING_SOURCE = 'core/pattern-overrides';\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,gBAAgB;AAAA,EAC5B,OAAO;AAAA,EACP,MAAM;AACP;AAEO,MAAM,2BAA2B;AACjC,MAAM,wBAAwB;AAC9B,MAAM,2BAA2B;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AACD;AACO,MAAM,qBAAqB;AAAA,EACjC,MAAM;AAAA,EACN,UAAU;AACX;AAGO,MAAM,mCAAmC;AAAA,EAC/C,kBAAkB,CAAE,SAAU;AAAA,EAC9B,gBAAgB,CAAE,SAAU;AAAA,EAC5B,eAAe,CAAE,QAAQ,OAAO,cAAc,KAAM;AAAA,EACpD,cAAc,CAAE,MAAM,OAAO,SAAS,KAAM;AAC7C;AAEO,MAAM,mCAAmC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build-module/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { store } from "./store";
|
|
2
|
+
export * from "./private-apis";
|
|
3
|
+
export {
|
|
4
|
+
store
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nexport { store } from './store';\nexport * from './private-apis';\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,aAAa;AACtB,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from "@wordpress/private-apis";
|
|
2
|
+
const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules(
|
|
3
|
+
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
|
|
4
|
+
"@wordpress/patterns"
|
|
5
|
+
);
|
|
6
|
+
export {
|
|
6
7
|
lock,
|
|
7
8
|
unlock
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=lock-unlock.js.map
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=lock-unlock.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lock-unlock.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/patterns'\n\t);\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,wDAAwD;AAC1D,MAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
|
|
1
|
+
import { lock } from "./lock-unlock";
|
|
2
|
+
import OverridesPanel from "./components/overrides-panel";
|
|
3
|
+
import {
|
|
4
|
+
default as CreatePatternModal,
|
|
5
|
+
CreatePatternModalContents
|
|
6
|
+
} from "./components/create-pattern-modal";
|
|
7
|
+
import {
|
|
8
|
+
default as DuplicatePatternModal,
|
|
9
|
+
useDuplicatePatternProps
|
|
10
|
+
} from "./components/duplicate-pattern-modal";
|
|
11
|
+
import { isOverridableBlock, hasOverridableBlocks } from "./api";
|
|
12
|
+
import RenamePatternModal from "./components/rename-pattern-modal";
|
|
13
|
+
import PatternsMenuItems from "./components";
|
|
14
|
+
import RenamePatternCategoryModal from "./components/rename-pattern-category-modal";
|
|
15
|
+
import PatternOverridesControls from "./components/pattern-overrides-controls";
|
|
16
|
+
import ResetOverridesControl from "./components/reset-overrides-control";
|
|
17
|
+
import PatternOverridesBlockControls from "./components/pattern-overrides-block-controls";
|
|
18
|
+
import { useAddPatternCategory } from "./private-hooks";
|
|
19
|
+
import {
|
|
20
|
+
PATTERN_TYPES,
|
|
21
|
+
PATTERN_DEFAULT_CATEGORY,
|
|
22
|
+
PATTERN_USER_CATEGORY,
|
|
23
|
+
EXCLUDED_PATTERN_SOURCES,
|
|
24
|
+
PATTERN_SYNC_TYPES,
|
|
25
|
+
PARTIAL_SYNCING_SUPPORTED_BLOCKS
|
|
26
|
+
} from "./constants";
|
|
27
|
+
const privateApis = {};
|
|
18
28
|
lock(privateApis, {
|
|
19
29
|
OverridesPanel,
|
|
20
30
|
CreatePatternModal,
|
|
@@ -37,4 +47,7 @@ lock(privateApis, {
|
|
|
37
47
|
PATTERN_SYNC_TYPES,
|
|
38
48
|
PARTIAL_SYNCING_SUPPORTED_BLOCKS
|
|
39
49
|
});
|
|
40
|
-
|
|
50
|
+
export {
|
|
51
|
+
privateApis
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=private-apis.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/private-apis.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\nimport OverridesPanel from './components/overrides-panel';\nimport {\n\tdefault as CreatePatternModal,\n\tCreatePatternModalContents,\n} from './components/create-pattern-modal';\nimport {\n\tdefault as DuplicatePatternModal,\n\tuseDuplicatePatternProps,\n} from './components/duplicate-pattern-modal';\nimport { isOverridableBlock, hasOverridableBlocks } from './api';\nimport RenamePatternModal from './components/rename-pattern-modal';\nimport PatternsMenuItems from './components';\nimport RenamePatternCategoryModal from './components/rename-pattern-category-modal';\nimport PatternOverridesControls from './components/pattern-overrides-controls';\nimport ResetOverridesControl from './components/reset-overrides-control';\nimport PatternOverridesBlockControls from './components/pattern-overrides-block-controls';\nimport { useAddPatternCategory } from './private-hooks';\nimport {\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tPATTERN_USER_CATEGORY,\n\tEXCLUDED_PATTERN_SOURCES,\n\tPATTERN_SYNC_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\n} from './constants';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tOverridesPanel,\n\tCreatePatternModal,\n\tCreatePatternModalContents,\n\tDuplicatePatternModal,\n\tisOverridableBlock,\n\thasOverridableBlocks,\n\tuseDuplicatePatternProps,\n\tRenamePatternModal,\n\tPatternsMenuItems,\n\tRenamePatternCategoryModal,\n\tPatternOverridesControls,\n\tResetOverridesControl,\n\tPatternOverridesBlockControls,\n\tuseAddPatternCategory,\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tPATTERN_USER_CATEGORY,\n\tEXCLUDED_PATTERN_SOURCES,\n\tPATTERN_SYNC_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\n} );\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,YAAY;AACrB,OAAO,oBAAoB;AAC3B;AAAA,EACC,WAAW;AAAA,EACX;AAAA,OACM;AACP;AAAA,EACC,WAAW;AAAA,EACX;AAAA,OACM;AACP,SAAS,oBAAoB,4BAA4B;AACzD,OAAO,wBAAwB;AAC/B,OAAO,uBAAuB;AAC9B,OAAO,gCAAgC;AACvC,OAAO,8BAA8B;AACrC,OAAO,2BAA2B;AAClC,OAAO,mCAAmC;AAC1C,SAAS,6BAA6B;AACtC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEA,MAAM,cAAc,CAAC;AAC5B,KAAM,aAAa;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|