@elementor/editor-components 3.33.0-180 → 3.33.0-182
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/dist/index.js +151 -71
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -12
- package/src/api.ts +10 -1
- package/src/components/components-tab/components-item.tsx +2 -49
- package/src/hooks/use-components.ts +1 -1
- package/src/hooks/use-create-component.ts +2 -2
- package/src/init.ts +18 -1
- package/src/populate-store.ts +1 -1
- package/src/store/components-styles-provider.ts +24 -0
- package/src/store/load-components-styles.ts +51 -0
- package/src/store/remove-component-styles.ts +9 -0
- package/src/{store.ts → store/store.ts} +23 -7
- package/src/{thunks.ts → store/thunks.ts} +1 -1
- package/src/types.ts +15 -0
- package/src/utils/get-component-ids.ts +24 -0
package/dist/index.js
CHANGED
|
@@ -36,13 +36,16 @@ module.exports = __toCommonJS(index_exports);
|
|
|
36
36
|
|
|
37
37
|
// src/init.ts
|
|
38
38
|
var import_editor = require("@elementor/editor");
|
|
39
|
+
var import_editor_documents = require("@elementor/editor-documents");
|
|
39
40
|
var import_editor_elements_panel = require("@elementor/editor-elements-panel");
|
|
40
|
-
var
|
|
41
|
-
var
|
|
41
|
+
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
42
|
+
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
43
|
+
var import_store14 = require("@elementor/store");
|
|
44
|
+
var import_i18n5 = require("@wordpress/i18n");
|
|
42
45
|
|
|
43
46
|
// src/components/components-tab/components.tsx
|
|
44
47
|
var React6 = __toESM(require("react"));
|
|
45
|
-
var
|
|
48
|
+
var import_editor_ui = require("@elementor/editor-ui");
|
|
46
49
|
|
|
47
50
|
// src/components/components-tab/component-search.tsx
|
|
48
51
|
var React2 = __toESM(require("react"));
|
|
@@ -96,26 +99,34 @@ var ComponentSearch = () => {
|
|
|
96
99
|
var React5 = __toESM(require("react"));
|
|
97
100
|
var import_icons3 = require("@elementor/icons");
|
|
98
101
|
var import_ui4 = require("@elementor/ui");
|
|
99
|
-
var
|
|
102
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
100
103
|
|
|
101
104
|
// src/hooks/use-components.ts
|
|
102
105
|
var import_store3 = require("@elementor/store");
|
|
103
106
|
|
|
104
|
-
// src/store.ts
|
|
107
|
+
// src/store/store.ts
|
|
105
108
|
var import_store2 = require("@elementor/store");
|
|
106
109
|
|
|
107
|
-
// src/thunks.ts
|
|
110
|
+
// src/store/thunks.ts
|
|
108
111
|
var import_store = require("@elementor/store");
|
|
109
112
|
|
|
110
113
|
// src/api.ts
|
|
114
|
+
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
111
115
|
var import_http_client = require("@elementor/http-client");
|
|
112
116
|
var BASE_URL = "elementor/v1/components";
|
|
117
|
+
var getParams = (id) => ({
|
|
118
|
+
action: "get_document_config",
|
|
119
|
+
unique_id: `document-config-${id}`,
|
|
120
|
+
data: { id }
|
|
121
|
+
});
|
|
113
122
|
var apiClient = {
|
|
114
123
|
get: () => (0, import_http_client.httpService)().get(`${BASE_URL}`).then((res) => res.data.data),
|
|
115
|
-
create: (payload) => (0, import_http_client.httpService)().post(`${BASE_URL}`, payload).then((res) => res.data.data)
|
|
124
|
+
create: (payload) => (0, import_http_client.httpService)().post(`${BASE_URL}`, payload).then((res) => res.data.data),
|
|
125
|
+
getComponentConfig: (id) => import_editor_v1_adapters.ajax.load(getParams(id)),
|
|
126
|
+
invalidateComponentConfigCache: (id) => import_editor_v1_adapters.ajax.invalidateCache(getParams(id))
|
|
116
127
|
};
|
|
117
128
|
|
|
118
|
-
// src/thunks.ts
|
|
129
|
+
// src/store/thunks.ts
|
|
119
130
|
var createComponent = (0, import_store.__createAsyncThunk)(
|
|
120
131
|
"components/create",
|
|
121
132
|
async (payload) => {
|
|
@@ -128,11 +139,12 @@ var loadComponents = (0, import_store.__createAsyncThunk)("components/load", asy
|
|
|
128
139
|
return response;
|
|
129
140
|
});
|
|
130
141
|
|
|
131
|
-
// src/store.ts
|
|
142
|
+
// src/store/store.ts
|
|
132
143
|
var initialState = {
|
|
133
144
|
data: [],
|
|
134
145
|
loadStatus: "idle",
|
|
135
|
-
createStatus: "idle"
|
|
146
|
+
createStatus: "idle",
|
|
147
|
+
styles: {}
|
|
136
148
|
};
|
|
137
149
|
var SLICE_NAME = "components";
|
|
138
150
|
var slice = (0, import_store2.__createSlice)({
|
|
@@ -140,10 +152,17 @@ var slice = (0, import_store2.__createSlice)({
|
|
|
140
152
|
initialState,
|
|
141
153
|
reducers: {
|
|
142
154
|
add: (state, { payload }) => {
|
|
143
|
-
state.data
|
|
155
|
+
state.data = { ...payload };
|
|
144
156
|
},
|
|
145
157
|
load: (state, { payload }) => {
|
|
146
158
|
state.data = payload;
|
|
159
|
+
},
|
|
160
|
+
removeStyles(state, { payload }) {
|
|
161
|
+
const { [payload.id]: _, ...rest } = state.styles;
|
|
162
|
+
state.styles = rest;
|
|
163
|
+
},
|
|
164
|
+
addStyles: (state, { payload }) => {
|
|
165
|
+
state.styles = { ...state.styles, ...payload };
|
|
147
166
|
}
|
|
148
167
|
},
|
|
149
168
|
extraReducers: (builder) => {
|
|
@@ -175,11 +194,14 @@ var slice = (0, import_store2.__createSlice)({
|
|
|
175
194
|
var selectData = (state) => state[SLICE_NAME].data;
|
|
176
195
|
var selectLoadStatus = (state) => state[SLICE_NAME].loadStatus;
|
|
177
196
|
var selectCreateStatus = (state) => state[SLICE_NAME].createStatus;
|
|
197
|
+
var selectStylesDefinitions = (state) => state[SLICE_NAME].styles ?? {};
|
|
178
198
|
var selectComponents = (0, import_store2.__createSelector)(selectData, (data) => data);
|
|
179
199
|
var selectLoadIsPending = (0, import_store2.__createSelector)(selectLoadStatus, (status) => status === "pending");
|
|
180
200
|
var selectLoadIsError = (0, import_store2.__createSelector)(selectLoadStatus, (status) => status === "error");
|
|
181
201
|
var selectCreateIsPending = (0, import_store2.__createSelector)(selectCreateStatus, (status) => status === "pending");
|
|
182
202
|
var selectCreateIsError = (0, import_store2.__createSelector)(selectCreateStatus, (status) => status === "error");
|
|
203
|
+
var selectStyles = (state) => state[SLICE_NAME].styles ?? {};
|
|
204
|
+
var selectFlatStyles = (0, import_store2.__createSelector)(selectStylesDefinitions, (data) => Object.values(data).flat());
|
|
183
205
|
|
|
184
206
|
// src/hooks/use-components.ts
|
|
185
207
|
var useComponents = () => {
|
|
@@ -192,10 +214,8 @@ var useComponents = () => {
|
|
|
192
214
|
var React3 = __toESM(require("react"));
|
|
193
215
|
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
194
216
|
var import_editor_elements3 = require("@elementor/editor-elements");
|
|
195
|
-
var import_editor_ui = require("@elementor/editor-ui");
|
|
196
217
|
var import_icons2 = require("@elementor/icons");
|
|
197
218
|
var import_ui2 = require("@elementor/ui");
|
|
198
|
-
var import_i18n2 = require("@wordpress/i18n");
|
|
199
219
|
|
|
200
220
|
// src/utils/get-container-for-new-element.ts
|
|
201
221
|
var import_editor_elements = require("@elementor/editor-elements");
|
|
@@ -259,10 +279,6 @@ var createComponentModel = (component) => {
|
|
|
259
279
|
// src/components/components-tab/components-item.tsx
|
|
260
280
|
var ComponentItem = ({ component }) => {
|
|
261
281
|
const componentModel = createComponentModel({ id: component.id, name: component.name });
|
|
262
|
-
const popupState = (0, import_ui2.usePopupState)({
|
|
263
|
-
variant: "popover",
|
|
264
|
-
disableAutoFocus: true
|
|
265
|
-
});
|
|
266
282
|
const handleClick = () => {
|
|
267
283
|
addComponentToPage(componentModel);
|
|
268
284
|
};
|
|
@@ -280,32 +296,7 @@ var ComponentItem = ({ component }) => {
|
|
|
280
296
|
{
|
|
281
297
|
primary: /* @__PURE__ */ React3.createElement(import_ui2.Typography, { variant: "caption", sx: { color: "text.primary" } }, component.name)
|
|
282
298
|
}
|
|
283
|
-
))
|
|
284
|
-
/* @__PURE__ */ React3.createElement(import_ui2.IconButton, { size: "tiny", "aria-label": "More actions", ...(0, import_ui2.bindTrigger)(popupState) }, /* @__PURE__ */ React3.createElement(import_icons2.DotsVerticalIcon, { fontSize: "tiny" })),
|
|
285
|
-
/* @__PURE__ */ React3.createElement(
|
|
286
|
-
import_ui2.Menu,
|
|
287
|
-
{
|
|
288
|
-
...(0, import_ui2.bindMenu)(popupState),
|
|
289
|
-
anchorOrigin: {
|
|
290
|
-
vertical: "bottom",
|
|
291
|
-
horizontal: "right"
|
|
292
|
-
},
|
|
293
|
-
transformOrigin: {
|
|
294
|
-
vertical: "top",
|
|
295
|
-
horizontal: "right"
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
/* @__PURE__ */ React3.createElement(import_editor_ui.MenuListItem, { sx: { minWidth: "160px" } }, /* @__PURE__ */ React3.createElement(import_ui2.Typography, { variant: "caption", sx: { color: "text.primary" } }, (0, import_i18n2.__)("Rename", "elementor"))),
|
|
299
|
-
/* @__PURE__ */ React3.createElement(
|
|
300
|
-
import_editor_ui.MenuListItem,
|
|
301
|
-
{
|
|
302
|
-
onClick: () => {
|
|
303
|
-
popupState.close();
|
|
304
|
-
}
|
|
305
|
-
},
|
|
306
|
-
/* @__PURE__ */ React3.createElement(import_ui2.Typography, { variant: "caption", sx: { color: "error.light" } }, (0, import_i18n2.__)("Delete", "elementor"))
|
|
307
|
-
)
|
|
308
|
-
)
|
|
299
|
+
))
|
|
309
300
|
);
|
|
310
301
|
};
|
|
311
302
|
var addComponentToPage = (model) => {
|
|
@@ -387,13 +378,13 @@ var EmptyState = () => {
|
|
|
387
378
|
overflow: "hidden"
|
|
388
379
|
},
|
|
389
380
|
/* @__PURE__ */ React5.createElement(import_ui4.Icon, { fontSize: "large" }, /* @__PURE__ */ React5.createElement(import_icons3.EyeIcon, { fontSize: "large" })),
|
|
390
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "subtitle2", color: "text.secondary", fontWeight: "bold" }, (0,
|
|
391
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", align: "center", color: "text.secondary" }, (0,
|
|
381
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "subtitle2", color: "text.secondary", fontWeight: "bold" }, (0, import_i18n2.__)("Text that explains that there are no Components yet.", "elementor")),
|
|
382
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", align: "center", color: "text.secondary" }, (0, import_i18n2.__)(
|
|
392
383
|
"Once you have Components, this is where you can manage them\u2014rearrange, duplicate, rename and delete irrelevant classes.",
|
|
393
384
|
"elementor"
|
|
394
385
|
)),
|
|
395
386
|
/* @__PURE__ */ React5.createElement(import_ui4.Divider, { sx: { width: "100%" }, color: "text.secondary" }),
|
|
396
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "left", variant: "caption", color: "text.secondary" }, (0,
|
|
387
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "left", variant: "caption", color: "text.secondary" }, (0, import_i18n2.__)("To create a component, first design it, then choose one of three options:", "elementor")),
|
|
397
388
|
/* @__PURE__ */ React5.createElement(
|
|
398
389
|
import_ui4.Typography,
|
|
399
390
|
{
|
|
@@ -402,9 +393,9 @@ var EmptyState = () => {
|
|
|
402
393
|
color: "text.secondary",
|
|
403
394
|
sx: { display: "flex", flexDirection: "column" }
|
|
404
395
|
},
|
|
405
|
-
/* @__PURE__ */ React5.createElement("span", null, (0,
|
|
406
|
-
/* @__PURE__ */ React5.createElement("span", null, (0,
|
|
407
|
-
/* @__PURE__ */ React5.createElement("span", null, (0,
|
|
396
|
+
/* @__PURE__ */ React5.createElement("span", null, (0, import_i18n2.__)("1. Right-click and select Create Component", "elementor")),
|
|
397
|
+
/* @__PURE__ */ React5.createElement("span", null, (0, import_i18n2.__)("2. Use the component icon in the Structure panel", "elementor")),
|
|
398
|
+
/* @__PURE__ */ React5.createElement("span", null, (0, import_i18n2.__)("3. Use the component icon in the Edit panel header", "elementor"))
|
|
408
399
|
)
|
|
409
400
|
);
|
|
410
401
|
};
|
|
@@ -428,7 +419,7 @@ var EmptySearchResult = () => {
|
|
|
428
419
|
width: "100%"
|
|
429
420
|
}
|
|
430
421
|
},
|
|
431
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "subtitle2", color: "inherit" }, (0,
|
|
422
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "subtitle2", color: "inherit" }, (0, import_i18n2.__)("Sorry, nothing matched", "elementor")),
|
|
432
423
|
searchValue && /* @__PURE__ */ React5.createElement(
|
|
433
424
|
import_ui4.Typography,
|
|
434
425
|
{
|
|
@@ -455,8 +446,8 @@ var EmptySearchResult = () => {
|
|
|
455
446
|
/* @__PURE__ */ React5.createElement("span", null, "\u201D.")
|
|
456
447
|
)
|
|
457
448
|
),
|
|
458
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "caption", color: "inherit" }, (0,
|
|
459
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "caption", color: "inherit" }, /* @__PURE__ */ React5.createElement(import_ui4.Link, { color: "secondary", variant: "caption", component: "button", onClick: clearSearch }, (0,
|
|
449
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "caption", color: "inherit" }, (0, import_i18n2.__)("Try something else.", "elementor")),
|
|
450
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "caption", color: "inherit" }, /* @__PURE__ */ React5.createElement(import_ui4.Link, { color: "secondary", variant: "caption", component: "button", onClick: clearSearch }, (0, import_i18n2.__)("Clear & try again", "elementor")))
|
|
460
451
|
);
|
|
461
452
|
};
|
|
462
453
|
var useFilteredComponents = () => {
|
|
@@ -473,26 +464,26 @@ var useFilteredComponents = () => {
|
|
|
473
464
|
|
|
474
465
|
// src/components/components-tab/components.tsx
|
|
475
466
|
var Components = () => {
|
|
476
|
-
return /* @__PURE__ */ React6.createElement(
|
|
467
|
+
return /* @__PURE__ */ React6.createElement(import_editor_ui.ThemeProvider, null, /* @__PURE__ */ React6.createElement(SearchProvider, { localStorageKey: "elementor-components-search" }, /* @__PURE__ */ React6.createElement(ComponentSearch, null), /* @__PURE__ */ React6.createElement(ComponentsList, null)));
|
|
477
468
|
};
|
|
478
469
|
|
|
479
470
|
// src/components/create-component-form/create-component-form.tsx
|
|
480
471
|
var React7 = __toESM(require("react"));
|
|
481
472
|
var import_react3 = require("react");
|
|
482
473
|
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
483
|
-
var
|
|
474
|
+
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
484
475
|
var import_icons4 = require("@elementor/icons");
|
|
485
476
|
var import_ui5 = require("@elementor/ui");
|
|
486
|
-
var
|
|
477
|
+
var import_i18n4 = require("@wordpress/i18n");
|
|
487
478
|
|
|
488
479
|
// src/hooks/use-create-component.ts
|
|
489
480
|
var import_store5 = require("@elementor/store");
|
|
490
481
|
var useCreateComponent = () => {
|
|
491
|
-
const
|
|
482
|
+
const dispatch4 = (0, import_store5.__useDispatch)();
|
|
492
483
|
const isPending = (0, import_store5.__useSelector)(selectCreateIsPending);
|
|
493
484
|
const isError = (0, import_store5.__useSelector)(selectCreateIsError);
|
|
494
485
|
const createComponentAction = async (payload) => {
|
|
495
|
-
const result = await
|
|
486
|
+
const result = await dispatch4(createComponent(payload));
|
|
496
487
|
return result.payload;
|
|
497
488
|
};
|
|
498
489
|
return {
|
|
@@ -553,16 +544,16 @@ var validateForm = (values, schema) => {
|
|
|
553
544
|
|
|
554
545
|
// src/components/create-component-form/utils/component-form-schema.ts
|
|
555
546
|
var import_schema = require("@elementor/schema");
|
|
556
|
-
var
|
|
547
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
557
548
|
var MIN_NAME_LENGTH = 2;
|
|
558
549
|
var MAX_NAME_LENGTH = 50;
|
|
559
550
|
var createBaseComponentSchema = (existingNames) => {
|
|
560
551
|
return import_schema.z.object({
|
|
561
552
|
componentName: import_schema.z.string().trim().max(
|
|
562
553
|
MAX_NAME_LENGTH,
|
|
563
|
-
(0,
|
|
554
|
+
(0, import_i18n3.__)("Component name is too long. Please keep it under 50 characters.", "elementor")
|
|
564
555
|
).refine((value) => !existingNames.includes(value), {
|
|
565
|
-
message: (0,
|
|
556
|
+
message: (0, import_i18n3.__)("Component name already exists", "elementor")
|
|
566
557
|
})
|
|
567
558
|
});
|
|
568
559
|
};
|
|
@@ -570,9 +561,9 @@ var createSubmitComponentSchema = (existingNames) => {
|
|
|
570
561
|
const baseSchema = createBaseComponentSchema(existingNames);
|
|
571
562
|
return baseSchema.extend({
|
|
572
563
|
componentName: baseSchema.shape.componentName.refine((value) => value.length > 0, {
|
|
573
|
-
message: (0,
|
|
564
|
+
message: (0, import_i18n3.__)("Component name is required.", "elementor")
|
|
574
565
|
}).refine((value) => value.length >= MIN_NAME_LENGTH, {
|
|
575
|
-
message: (0,
|
|
566
|
+
message: (0, import_i18n3.__)("Component name is too short. Please enter at least 2 characters.", "elementor")
|
|
576
567
|
})
|
|
577
568
|
});
|
|
578
569
|
};
|
|
@@ -613,12 +604,12 @@ function CreateComponentForm() {
|
|
|
613
604
|
setResultNotification({
|
|
614
605
|
show: true,
|
|
615
606
|
// Translators: %1$s: Component name, %2$s: Component ID
|
|
616
|
-
message: (0,
|
|
607
|
+
message: (0, import_i18n4.__)("Component saved successfully as: %1$s (ID: %2$s)", "elementor").replace("%1$s", values.componentName).replace("%2$s", result.component_id.toString()),
|
|
617
608
|
type: "success"
|
|
618
609
|
});
|
|
619
610
|
resetAndClosePopup();
|
|
620
611
|
} catch {
|
|
621
|
-
const errorMessage = (0,
|
|
612
|
+
const errorMessage = (0, import_i18n4.__)("Failed to save component. Please try again.", "elementor");
|
|
622
613
|
setResultNotification({
|
|
623
614
|
show: true,
|
|
624
615
|
message: errorMessage,
|
|
@@ -630,7 +621,7 @@ function CreateComponentForm() {
|
|
|
630
621
|
setElement(null);
|
|
631
622
|
setAnchorPosition(void 0);
|
|
632
623
|
};
|
|
633
|
-
return /* @__PURE__ */ React7.createElement(
|
|
624
|
+
return /* @__PURE__ */ React7.createElement(import_editor_ui2.ThemeProvider, null, /* @__PURE__ */ React7.createElement(
|
|
634
625
|
import_ui5.Popover,
|
|
635
626
|
{
|
|
636
627
|
open: element !== null,
|
|
@@ -693,8 +684,8 @@ var Form = ({
|
|
|
693
684
|
sx: { columnGap: 0.5, borderBottom: "1px solid", borderColor: "divider", width: "100%" }
|
|
694
685
|
},
|
|
695
686
|
/* @__PURE__ */ React7.createElement(import_icons4.StarIcon, { fontSize: FONT_SIZE }),
|
|
696
|
-
/* @__PURE__ */ React7.createElement(import_ui5.Typography, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, (0,
|
|
697
|
-
), /* @__PURE__ */ React7.createElement(import_ui5.Grid, { container: true, gap: 0.75, alignItems: "start", p: 1.5 }, /* @__PURE__ */ React7.createElement(import_ui5.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React7.createElement(import_ui5.FormLabel, { htmlFor: "component-name", size: "tiny" }, (0,
|
|
687
|
+
/* @__PURE__ */ React7.createElement(import_ui5.Typography, { variant: "caption", sx: { color: "text.primary", fontWeight: "500", lineHeight: 1 } }, (0, import_i18n4.__)("Save as a component", "elementor"))
|
|
688
|
+
), /* @__PURE__ */ React7.createElement(import_ui5.Grid, { container: true, gap: 0.75, alignItems: "start", p: 1.5 }, /* @__PURE__ */ React7.createElement(import_ui5.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React7.createElement(import_ui5.FormLabel, { htmlFor: "component-name", size: "tiny" }, (0, import_i18n4.__)("Name", "elementor"))), /* @__PURE__ */ React7.createElement(import_ui5.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React7.createElement(
|
|
698
689
|
import_ui5.TextField,
|
|
699
690
|
{
|
|
700
691
|
id: "component-name",
|
|
@@ -706,7 +697,7 @@ var Form = ({
|
|
|
706
697
|
error: Boolean(errors.componentName),
|
|
707
698
|
helperText: errors.componentName
|
|
708
699
|
}
|
|
709
|
-
))), /* @__PURE__ */ React7.createElement(import_ui5.Stack, { direction: "row", justifyContent: "flex-end", alignSelf: "end", py: 1, px: 1.5 }, /* @__PURE__ */ React7.createElement(import_ui5.Button, { onClick: closePopup, disabled: isSubmitting, color: "secondary", variant: "text", size: "small" }, (0,
|
|
700
|
+
))), /* @__PURE__ */ React7.createElement(import_ui5.Stack, { direction: "row", justifyContent: "flex-end", alignSelf: "end", py: 1, px: 1.5 }, /* @__PURE__ */ React7.createElement(import_ui5.Button, { onClick: closePopup, disabled: isSubmitting, color: "secondary", variant: "text", size: "small" }, (0, import_i18n4.__)("Cancel", "elementor")), /* @__PURE__ */ React7.createElement(
|
|
710
701
|
import_ui5.Button,
|
|
711
702
|
{
|
|
712
703
|
onClick: handleSubmit,
|
|
@@ -715,7 +706,7 @@ var Form = ({
|
|
|
715
706
|
color: "primary",
|
|
716
707
|
size: "small"
|
|
717
708
|
},
|
|
718
|
-
isSubmitting ? (0,
|
|
709
|
+
isSubmitting ? (0, import_i18n4.__)("Creating\u2026", "elementor") : (0, import_i18n4.__)("Create", "elementor")
|
|
719
710
|
)));
|
|
720
711
|
};
|
|
721
712
|
|
|
@@ -729,12 +720,94 @@ function PopulateStore() {
|
|
|
729
720
|
return null;
|
|
730
721
|
}
|
|
731
722
|
|
|
723
|
+
// src/store/components-styles-provider.ts
|
|
724
|
+
var import_editor_styles_repository = require("@elementor/editor-styles-repository");
|
|
725
|
+
var import_store8 = require("@elementor/store");
|
|
726
|
+
var componentsStylesProvider = (0, import_editor_styles_repository.createStylesProvider)({
|
|
727
|
+
key: "components-styles",
|
|
728
|
+
priority: 100,
|
|
729
|
+
subscribe: (cb) => (0, import_store8.__subscribeWithSelector)(
|
|
730
|
+
(state) => state[SLICE_NAME],
|
|
731
|
+
() => {
|
|
732
|
+
cb();
|
|
733
|
+
}
|
|
734
|
+
),
|
|
735
|
+
actions: {
|
|
736
|
+
all: () => {
|
|
737
|
+
return selectFlatStyles((0, import_store8.__getState)());
|
|
738
|
+
},
|
|
739
|
+
get: (id) => {
|
|
740
|
+
return selectFlatStyles((0, import_store8.__getState)()).find((style) => style.id === id) ?? null;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
// src/store/load-components-styles.ts
|
|
746
|
+
var import_store10 = require("@elementor/store");
|
|
747
|
+
|
|
748
|
+
// src/utils/get-component-ids.ts
|
|
749
|
+
var import_editor_props2 = require("@elementor/editor-props");
|
|
750
|
+
var getComponentIds = (elements) => {
|
|
751
|
+
return elements.flatMap((element) => {
|
|
752
|
+
const ids = [];
|
|
753
|
+
const type = element.widgetType || element.elType;
|
|
754
|
+
if (type === "e-component" && element.settings?.component_id && (0, import_editor_props2.isTransformable)(element.settings?.component_id)) {
|
|
755
|
+
ids.push(element.settings.component_id.value);
|
|
756
|
+
}
|
|
757
|
+
if (element.elements) {
|
|
758
|
+
ids.push(...getComponentIds(element.elements));
|
|
759
|
+
}
|
|
760
|
+
return ids;
|
|
761
|
+
});
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
// src/store/load-components-styles.ts
|
|
765
|
+
async function loadComponentsStyles(elements) {
|
|
766
|
+
const componentIds = Array.from(new Set(getComponentIds(elements)));
|
|
767
|
+
if (!componentIds.length) {
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
const knownComponents = selectStyles((0, import_store10.__getState)());
|
|
771
|
+
const unknownComponentIds = componentIds.filter((id) => !knownComponents[id]);
|
|
772
|
+
if (!unknownComponentIds.length) {
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
addComponentStyles(unknownComponentIds);
|
|
776
|
+
}
|
|
777
|
+
async function addComponentStyles(ids) {
|
|
778
|
+
const newComponents = await loadStyles(ids);
|
|
779
|
+
addStyles(newComponents);
|
|
780
|
+
Object.values(newComponents).forEach(([, data]) => {
|
|
781
|
+
loadComponentsStyles(data.elements);
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
async function loadStyles(ids) {
|
|
785
|
+
return Promise.all(ids.map(async (id) => [id, await apiClient.getComponentConfig(id)]));
|
|
786
|
+
}
|
|
787
|
+
function addStyles(data) {
|
|
788
|
+
const styles = Object.fromEntries(
|
|
789
|
+
data.map(([componentId, componentData]) => [componentId, extractStyles(componentData)])
|
|
790
|
+
);
|
|
791
|
+
(0, import_store10.__dispatch)(slice.actions.addStyles(styles));
|
|
792
|
+
}
|
|
793
|
+
function extractStyles(element) {
|
|
794
|
+
return [...Object.values(element.styles ?? {}), ...(element.elements ?? []).flatMap(extractStyles)];
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// src/store/remove-component-styles.ts
|
|
798
|
+
var import_store12 = require("@elementor/store");
|
|
799
|
+
function removeComponentStyles(id) {
|
|
800
|
+
apiClient.invalidateComponentConfigCache(id);
|
|
801
|
+
(0, import_store12.__dispatch)(slice.actions.removeStyles({ id }));
|
|
802
|
+
}
|
|
803
|
+
|
|
732
804
|
// src/init.ts
|
|
733
805
|
function init() {
|
|
734
|
-
|
|
806
|
+
import_editor_styles_repository2.stylesRepository.register(componentsStylesProvider);
|
|
807
|
+
(0, import_store14.__registerSlice)(slice);
|
|
735
808
|
(0, import_editor_elements_panel.injectTab)({
|
|
736
809
|
id: "components",
|
|
737
|
-
label: (0,
|
|
810
|
+
label: (0, import_i18n5.__)("Components", "elementor"),
|
|
738
811
|
component: Components
|
|
739
812
|
});
|
|
740
813
|
(0, import_editor.injectIntoTop)({
|
|
@@ -745,6 +818,13 @@ function init() {
|
|
|
745
818
|
id: "components-populate-store",
|
|
746
819
|
component: PopulateStore
|
|
747
820
|
});
|
|
821
|
+
(0, import_editor_v1_adapters2.__privateListenTo)((0, import_editor_v1_adapters2.commandStartEvent)("editor/documents/attach-preview"), () => {
|
|
822
|
+
const { id, config } = (0, import_editor_documents.getV1CurrentDocument)();
|
|
823
|
+
if (id) {
|
|
824
|
+
removeComponentStyles(id);
|
|
825
|
+
}
|
|
826
|
+
loadComponentsStyles(config?.elements ?? []);
|
|
827
|
+
});
|
|
748
828
|
}
|
|
749
829
|
// Annotate the CommonJS export names for ESM import in node:
|
|
750
830
|
0 && (module.exports = {
|