@elementor/editor-site-navigation 4.5.0-1208 → 4.5.0-1210
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 +384 -269
- package/dist/index.mjs +353 -238
- package/package.json +10 -10
- package/src/api/post.ts +16 -0
- package/src/components/panel/actions-menu/actions/duplicate.tsx +3 -5
- package/src/components/panel/content-panel-header-add.tsx +35 -27
- package/src/components/panel/posts-list/list-items/list-item-view.tsx +13 -4
- package/src/components/panel/section-add-button.tsx +4 -5
- package/src/components/panel/shell-panel-body-content.tsx +44 -0
- package/src/components/panel/shell.tsx +10 -15
- package/src/components/panel/user-load-error.tsx +16 -0
- package/src/components/shared/page-title-and-status.tsx +67 -14
- package/src/env.ts +2 -0
- package/src/hooks/use-accessible-panel-post-types.ts +29 -0
- package/src/hooks/use-can-create.ts +9 -0
- package/src/init.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -61,11 +61,57 @@ var import_editor_sidebar = require("@elementor/editor-sidebar");
|
|
|
61
61
|
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
62
62
|
|
|
63
63
|
// src/components/panel/shell.tsx
|
|
64
|
-
var
|
|
65
|
-
var
|
|
64
|
+
var React26 = __toESM(require("react"));
|
|
65
|
+
var import_react9 = require("react");
|
|
66
66
|
var import_editor_panels = require("@elementor/editor-panels");
|
|
67
|
-
var
|
|
68
|
-
var
|
|
67
|
+
var import_ui16 = require("@elementor/ui");
|
|
68
|
+
var import_i18n18 = require("@wordpress/i18n");
|
|
69
|
+
|
|
70
|
+
// src/contexts/content-panel-coordinator.tsx
|
|
71
|
+
var React = __toESM(require("react"));
|
|
72
|
+
var import_react = require("react");
|
|
73
|
+
var ContentPanelCoordinatorContext = (0, import_react.createContext)(null);
|
|
74
|
+
function ContentPanelCoordinatorProvider({ children }) {
|
|
75
|
+
const sectionsRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
|
|
76
|
+
const [searchQuery, setSearchQuery] = (0, import_react.useState)("");
|
|
77
|
+
const registerSection = (0, import_react.useCallback)((type, handlers) => {
|
|
78
|
+
sectionsRef.current.set(type, handlers);
|
|
79
|
+
}, []);
|
|
80
|
+
const unregisterSection = (0, import_react.useCallback)((type) => {
|
|
81
|
+
sectionsRef.current.delete(type);
|
|
82
|
+
}, []);
|
|
83
|
+
const requestCreate = (0, import_react.useCallback)((type) => {
|
|
84
|
+
const handlers = sectionsRef.current.get(type);
|
|
85
|
+
if (!handlers) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
handlers.setExpanded(true);
|
|
89
|
+
handlers.startCreate();
|
|
90
|
+
}, []);
|
|
91
|
+
const value = (0, import_react.useMemo)(
|
|
92
|
+
() => ({
|
|
93
|
+
registerSection,
|
|
94
|
+
unregisterSection,
|
|
95
|
+
requestCreate,
|
|
96
|
+
searchQuery,
|
|
97
|
+
setSearchQuery
|
|
98
|
+
}),
|
|
99
|
+
[registerSection, unregisterSection, requestCreate, searchQuery]
|
|
100
|
+
);
|
|
101
|
+
return /* @__PURE__ */ React.createElement(ContentPanelCoordinatorContext.Provider, { value }, children);
|
|
102
|
+
}
|
|
103
|
+
function useContentPanelCoordinator() {
|
|
104
|
+
const context = (0, import_react.useContext)(ContentPanelCoordinatorContext);
|
|
105
|
+
if (!context) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
"The `useContentPanelCoordinator()` hook must be used within a `<ContentPanelCoordinatorProvider />`"
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return context;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// src/hooks/use-accessible-panel-post-types.ts
|
|
114
|
+
var import_react2 = require("react");
|
|
69
115
|
|
|
70
116
|
// src/api/post.ts
|
|
71
117
|
var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
|
|
@@ -92,6 +138,15 @@ var panelPostTypeSlugs = Object.keys(postTypesMap);
|
|
|
92
138
|
function getPostTypeCreateCapability(postTypeSlug) {
|
|
93
139
|
return postTypesMap[postTypeSlug].createCapability;
|
|
94
140
|
}
|
|
141
|
+
function getAccessiblePanelPostTypes(capabilities) {
|
|
142
|
+
return panelPostTypeSlugs.filter((slug) => capabilities[getPostTypeCreateCapability(slug)]);
|
|
143
|
+
}
|
|
144
|
+
function getCannotEditPanelItemMessage(postTypeSlug) {
|
|
145
|
+
if ("page" === postTypeSlug) {
|
|
146
|
+
return (0, import_i18n.__)("You cannot edit this page.", "elementor");
|
|
147
|
+
}
|
|
148
|
+
return (0, import_i18n.__)("You cannot edit this post.", "elementor");
|
|
149
|
+
}
|
|
95
150
|
var POST_PER_PAGE = 10;
|
|
96
151
|
var getRequest = async (postTypeSlug, page, search = "") => {
|
|
97
152
|
const baseUri = `/wp/v2/${postTypesMap[postTypeSlug].rest_base}`;
|
|
@@ -155,89 +210,56 @@ var duplicateRequest = (originalPost) => {
|
|
|
155
210
|
});
|
|
156
211
|
};
|
|
157
212
|
|
|
158
|
-
// src/
|
|
159
|
-
var
|
|
160
|
-
var
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const sectionsRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
|
|
164
|
-
const [searchQuery, setSearchQuery] = (0, import_react.useState)("");
|
|
165
|
-
const registerSection = (0, import_react.useCallback)((type, handlers) => {
|
|
166
|
-
sectionsRef.current.set(type, handlers);
|
|
167
|
-
}, []);
|
|
168
|
-
const unregisterSection = (0, import_react.useCallback)((type) => {
|
|
169
|
-
sectionsRef.current.delete(type);
|
|
170
|
-
}, []);
|
|
171
|
-
const requestCreate = (0, import_react.useCallback)((type) => {
|
|
172
|
-
const handlers = sectionsRef.current.get(type);
|
|
173
|
-
if (!handlers) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
handlers.setExpanded(true);
|
|
177
|
-
handlers.startCreate();
|
|
178
|
-
}, []);
|
|
179
|
-
const value = (0, import_react.useMemo)(
|
|
180
|
-
() => ({
|
|
181
|
-
registerSection,
|
|
182
|
-
unregisterSection,
|
|
183
|
-
requestCreate,
|
|
184
|
-
searchQuery,
|
|
185
|
-
setSearchQuery
|
|
186
|
-
}),
|
|
187
|
-
[registerSection, unregisterSection, requestCreate, searchQuery]
|
|
188
|
-
);
|
|
189
|
-
return /* @__PURE__ */ React.createElement(ContentPanelCoordinatorContext.Provider, { value }, children);
|
|
190
|
-
}
|
|
191
|
-
function useContentPanelCoordinator() {
|
|
192
|
-
const context = (0, import_react.useContext)(ContentPanelCoordinatorContext);
|
|
193
|
-
if (!context) {
|
|
194
|
-
throw new Error(
|
|
195
|
-
"The `useContentPanelCoordinator()` hook must be used within a `<ContentPanelCoordinatorProvider />`"
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
return context;
|
|
199
|
-
}
|
|
213
|
+
// src/env.ts
|
|
214
|
+
var import_env = require("@elementor/env");
|
|
215
|
+
var { env } = (0, import_env.parseEnv)("@elementor/editor-site-navigation", (envData) => {
|
|
216
|
+
return envData;
|
|
217
|
+
});
|
|
200
218
|
|
|
201
|
-
// src/
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
219
|
+
// src/hooks/use-user.ts
|
|
220
|
+
var import_query = require("@elementor/query");
|
|
221
|
+
|
|
222
|
+
// src/api/user.ts
|
|
223
|
+
var import_api_fetch2 = __toESM(require("@wordpress/api-fetch"));
|
|
224
|
+
var getUser = () => {
|
|
225
|
+
const baseUri = "/wp/v2/users/me";
|
|
226
|
+
const keys = ["capabilities"];
|
|
227
|
+
const queryParams = new URLSearchParams({
|
|
228
|
+
_fields: keys.join(","),
|
|
229
|
+
context: "edit"
|
|
230
|
+
});
|
|
231
|
+
const uri = baseUri + "?" + queryParams.toString();
|
|
232
|
+
return (0, import_api_fetch2.default)({ path: uri });
|
|
210
233
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
234
|
+
|
|
235
|
+
// src/hooks/use-user.ts
|
|
236
|
+
var userQueryKey = () => ["site-navigation", "user"];
|
|
237
|
+
function useUser() {
|
|
238
|
+
return (0, import_query.useQuery)({
|
|
239
|
+
queryKey: userQueryKey(),
|
|
240
|
+
queryFn: getUser,
|
|
241
|
+
staleTime: 30 * 60 * 1e3
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// src/hooks/use-accessible-panel-post-types.ts
|
|
246
|
+
function useAccessiblePanelPostTypes() {
|
|
247
|
+
const { data: user, isPending: isUserPending, isError: isUserError } = useUser();
|
|
248
|
+
const accessiblePostTypes = (0, import_react2.useMemo)(() => {
|
|
249
|
+
if (user?.capabilities) {
|
|
250
|
+
return getAccessiblePanelPostTypes(user.capabilities);
|
|
251
|
+
}
|
|
252
|
+
if (isUserError && env.can_access_site_content_panel) {
|
|
253
|
+
return panelPostTypeSlugs;
|
|
254
|
+
}
|
|
255
|
+
return [];
|
|
256
|
+
}, [user, isUserError]);
|
|
257
|
+
const showUserLoadError = isUserError && accessiblePostTypes.length === 0;
|
|
258
|
+
return {
|
|
259
|
+
accessiblePostTypes,
|
|
260
|
+
isUserPending,
|
|
261
|
+
showUserLoadError
|
|
220
262
|
};
|
|
221
|
-
return /* @__PURE__ */ React2.createElement(
|
|
222
|
-
PostListContext.Provider,
|
|
223
|
-
{
|
|
224
|
-
value: {
|
|
225
|
-
type,
|
|
226
|
-
editMode,
|
|
227
|
-
setEditMode,
|
|
228
|
-
resetEditMode,
|
|
229
|
-
setError
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
children
|
|
233
|
-
);
|
|
234
|
-
};
|
|
235
|
-
function usePostListContext() {
|
|
236
|
-
const context = (0, import_react2.useContext)(PostListContext);
|
|
237
|
-
if (!context) {
|
|
238
|
-
throw new Error("The `usePostListContext()` hook must be used within an `<PostListContextProvider />`");
|
|
239
|
-
}
|
|
240
|
-
return context;
|
|
241
263
|
}
|
|
242
264
|
|
|
243
265
|
// src/components/panel/content-panel-chrome.ts
|
|
@@ -293,44 +315,25 @@ var contentPanelListItemButtonSx = {
|
|
|
293
315
|
};
|
|
294
316
|
|
|
295
317
|
// src/components/panel/content-panel-header-add.tsx
|
|
296
|
-
var
|
|
318
|
+
var React3 = __toESM(require("react"));
|
|
297
319
|
var import_icons3 = require("@elementor/icons");
|
|
298
320
|
var import_ui2 = require("@elementor/ui");
|
|
299
321
|
var import_i18n2 = require("@wordpress/i18n");
|
|
300
322
|
|
|
301
|
-
// src/hooks/use-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
var getUser = () => {
|
|
307
|
-
const baseUri = "/wp/v2/users/me";
|
|
308
|
-
const keys = ["capabilities"];
|
|
309
|
-
const queryParams = new URLSearchParams({
|
|
310
|
-
_fields: keys.join(","),
|
|
311
|
-
context: "edit"
|
|
312
|
-
});
|
|
313
|
-
const uri = baseUri + "?" + queryParams.toString();
|
|
314
|
-
return (0, import_api_fetch2.default)({ path: uri });
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
// src/hooks/use-user.ts
|
|
318
|
-
var userQueryKey = () => ["site-navigation", "user"];
|
|
319
|
-
function useUser() {
|
|
320
|
-
return (0, import_query.useQuery)({
|
|
321
|
-
queryKey: userQueryKey(),
|
|
322
|
-
queryFn: getUser,
|
|
323
|
-
staleTime: 30 * 60 * 1e3
|
|
324
|
-
});
|
|
323
|
+
// src/hooks/use-can-create.ts
|
|
324
|
+
function useCanCreate(postTypeSlug) {
|
|
325
|
+
const { data: user } = useUser();
|
|
326
|
+
const capability = getPostTypeCreateCapability(postTypeSlug);
|
|
327
|
+
return !!user?.capabilities?.[capability];
|
|
325
328
|
}
|
|
326
329
|
|
|
327
330
|
// src/components/panel/content-panel-add-icon-button.tsx
|
|
328
|
-
var
|
|
331
|
+
var React2 = __toESM(require("react"));
|
|
329
332
|
var import_icons2 = require("@elementor/icons");
|
|
330
333
|
var import_ui = require("@elementor/ui");
|
|
331
334
|
var CONTENT_PANEL_ADD_ICON_SIZE = "tiny";
|
|
332
335
|
function ContentPanelAddIconButton(props) {
|
|
333
|
-
return /* @__PURE__ */
|
|
336
|
+
return /* @__PURE__ */ React2.createElement(import_ui.IconButton, { size: CONTENT_PANEL_ADD_ICON_SIZE, variant: "outlined", ...props }, /* @__PURE__ */ React2.createElement(import_icons2.PlusIcon, { fontSize: CONTENT_PANEL_ADD_ICON_SIZE }));
|
|
334
337
|
}
|
|
335
338
|
|
|
336
339
|
// src/components/panel/content-panel-header-add.tsx
|
|
@@ -338,45 +341,46 @@ var typeIcons = {
|
|
|
338
341
|
page: import_icons3.PageTypeIcon,
|
|
339
342
|
post: import_icons3.PostTypeIcon
|
|
340
343
|
};
|
|
344
|
+
function HeaderAddMenuItem({ slug, onSelect }) {
|
|
345
|
+
const canCreate = useCanCreate(slug);
|
|
346
|
+
const Icon = typeIcons[slug];
|
|
347
|
+
const singularName = postTypesMap[slug].labels.singular_name;
|
|
348
|
+
return /* @__PURE__ */ React3.createElement(import_ui2.MenuItem, { disabled: !canCreate, onClick: () => onSelect(slug) }, /* @__PURE__ */ React3.createElement(import_ui2.ListItemIcon, null, /* @__PURE__ */ React3.createElement(Icon, { fontSize: "small" })), /* @__PURE__ */ React3.createElement(import_ui2.ListItemText, { primary: singularName, primaryTypographyProps: { variant: "body2" } }));
|
|
349
|
+
}
|
|
341
350
|
function ContentPanelHeaderAdd() {
|
|
342
351
|
const { requestCreate } = useContentPanelCoordinator();
|
|
343
|
-
const {
|
|
352
|
+
const { accessiblePostTypes: accessibleSlugs } = useAccessiblePanelPostTypes();
|
|
344
353
|
const popupState = (0, import_ui2.usePopupState)({
|
|
345
354
|
variant: "popover",
|
|
346
355
|
popupId: "elementor-content-panel-header-add"
|
|
347
356
|
});
|
|
357
|
+
const canAddAny = accessibleSlugs.length > 0;
|
|
348
358
|
const buttonProps = (0, import_ui2.bindTrigger)(popupState);
|
|
349
359
|
const menuProps = (0, import_ui2.bindMenu)(popupState);
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
/* @__PURE__ */ React4.createElement(import_ui2.ListItemIcon, null, /* @__PURE__ */ React4.createElement(Icon, { fontSize: "small" })),
|
|
367
|
-
/* @__PURE__ */ React4.createElement(import_ui2.ListItemText, { primary: singularName, primaryTypographyProps: { variant: "body2" } })
|
|
368
|
-
);
|
|
369
|
-
})));
|
|
360
|
+
const handleSelectType = (slug) => {
|
|
361
|
+
popupState.close();
|
|
362
|
+
requestAnimationFrame(() => {
|
|
363
|
+
requestCreate(slug);
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
|
|
367
|
+
ContentPanelAddIconButton,
|
|
368
|
+
{
|
|
369
|
+
"aria-label": (0, import_i18n2.__)("Add new", "elementor"),
|
|
370
|
+
...buttonProps,
|
|
371
|
+
disabled: !canAddAny
|
|
372
|
+
}
|
|
373
|
+
), /* @__PURE__ */ React3.createElement(import_ui2.Menu, { ...menuProps }, accessibleSlugs.map((slug) => /* @__PURE__ */ React3.createElement(HeaderAddMenuItem, { key: slug, onSelect: handleSelectType, slug }))));
|
|
370
374
|
}
|
|
371
375
|
|
|
372
376
|
// src/components/panel/content-panel-search.tsx
|
|
373
|
-
var
|
|
377
|
+
var React4 = __toESM(require("react"));
|
|
374
378
|
var import_icons4 = require("@elementor/icons");
|
|
375
379
|
var import_ui3 = require("@elementor/ui");
|
|
376
380
|
var import_i18n3 = require("@wordpress/i18n");
|
|
377
381
|
function ContentPanelSearch() {
|
|
378
382
|
const { searchQuery, setSearchQuery } = useContentPanelCoordinator();
|
|
379
|
-
return /* @__PURE__ */
|
|
383
|
+
return /* @__PURE__ */ React4.createElement(import_ui3.Box, { component: "search", sx: contentPanelSearchBoxSx, "aria-label": (0, import_i18n3.__)("Search site content", "elementor") }, /* @__PURE__ */ React4.createElement(
|
|
380
384
|
import_ui3.TextField,
|
|
381
385
|
{
|
|
382
386
|
fullWidth: true,
|
|
@@ -388,17 +392,17 @@ function ContentPanelSearch() {
|
|
|
388
392
|
"aria-label": (0, import_i18n3.__)("Search", "elementor")
|
|
389
393
|
},
|
|
390
394
|
InputProps: {
|
|
391
|
-
startAdornment: /* @__PURE__ */
|
|
395
|
+
startAdornment: /* @__PURE__ */ React4.createElement(import_ui3.InputAdornment, { position: "start" }, /* @__PURE__ */ React4.createElement(import_icons4.SearchIcon, { fontSize: "tiny" }))
|
|
392
396
|
}
|
|
393
397
|
}
|
|
394
398
|
));
|
|
395
399
|
}
|
|
396
400
|
|
|
397
401
|
// src/components/panel/error-snackbar.tsx
|
|
398
|
-
var
|
|
402
|
+
var React5 = __toESM(require("react"));
|
|
399
403
|
var import_ui4 = require("@elementor/ui");
|
|
400
404
|
var ErrorSnackbar = ({ open, onClose }) => {
|
|
401
|
-
return /* @__PURE__ */
|
|
405
|
+
return /* @__PURE__ */ React5.createElement(
|
|
402
406
|
import_ui4.Snackbar,
|
|
403
407
|
{
|
|
404
408
|
open,
|
|
@@ -408,7 +412,7 @@ var ErrorSnackbar = ({ open, onClose }) => {
|
|
|
408
412
|
horizontal: "left"
|
|
409
413
|
}
|
|
410
414
|
},
|
|
411
|
-
/* @__PURE__ */
|
|
415
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Alert, { onClose, severity: "error", sx: { width: "100%" } }, /* @__PURE__ */ React5.createElement(
|
|
412
416
|
import_ui4.Typography,
|
|
413
417
|
{
|
|
414
418
|
component: "span",
|
|
@@ -422,11 +426,57 @@ var ErrorSnackbar = ({ open, onClose }) => {
|
|
|
422
426
|
};
|
|
423
427
|
var error_snackbar_default = ErrorSnackbar;
|
|
424
428
|
|
|
429
|
+
// src/components/panel/shell-panel-body-content.tsx
|
|
430
|
+
var React25 = __toESM(require("react"));
|
|
431
|
+
var import_ui15 = require("@elementor/ui");
|
|
432
|
+
|
|
433
|
+
// src/contexts/post-list-context.tsx
|
|
434
|
+
var React6 = __toESM(require("react"));
|
|
435
|
+
var import_react3 = require("react");
|
|
436
|
+
var defaultValues = {
|
|
437
|
+
type: "page",
|
|
438
|
+
editMode: { mode: "none", details: {} },
|
|
439
|
+
setEditMode: () => null,
|
|
440
|
+
resetEditMode: () => null,
|
|
441
|
+
setError: () => null
|
|
442
|
+
};
|
|
443
|
+
var PostListContext = (0, import_react3.createContext)(defaultValues);
|
|
444
|
+
var PostListContextProvider = ({
|
|
445
|
+
type,
|
|
446
|
+
setError,
|
|
447
|
+
children
|
|
448
|
+
}) => {
|
|
449
|
+
const [editMode, setEditMode] = (0, import_react3.useState)(defaultValues.editMode);
|
|
450
|
+
const resetEditMode = () => {
|
|
451
|
+
setEditMode(defaultValues.editMode);
|
|
452
|
+
};
|
|
453
|
+
return /* @__PURE__ */ React6.createElement(
|
|
454
|
+
PostListContext.Provider,
|
|
455
|
+
{
|
|
456
|
+
value: {
|
|
457
|
+
type,
|
|
458
|
+
editMode,
|
|
459
|
+
setEditMode,
|
|
460
|
+
resetEditMode,
|
|
461
|
+
setError
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
children
|
|
465
|
+
);
|
|
466
|
+
};
|
|
467
|
+
function usePostListContext() {
|
|
468
|
+
const context = (0, import_react3.useContext)(PostListContext);
|
|
469
|
+
if (!context) {
|
|
470
|
+
throw new Error("The `usePostListContext()` hook must be used within an `<PostListContextProvider />`");
|
|
471
|
+
}
|
|
472
|
+
return context;
|
|
473
|
+
}
|
|
474
|
+
|
|
425
475
|
// src/components/panel/posts-list/posts-collapsible-list.tsx
|
|
426
476
|
var React23 = __toESM(require("react"));
|
|
427
|
-
var
|
|
477
|
+
var import_react8 = require("react");
|
|
428
478
|
var import_ui13 = require("@elementor/ui");
|
|
429
|
-
var
|
|
479
|
+
var import_i18n16 = require("@wordpress/i18n");
|
|
430
480
|
|
|
431
481
|
// src/hooks/use-homepage.ts
|
|
432
482
|
var import_query2 = require("@elementor/query");
|
|
@@ -494,8 +544,7 @@ var React7 = __toESM(require("react"));
|
|
|
494
544
|
var import_i18n4 = require("@wordpress/i18n");
|
|
495
545
|
function SectionAddButton({ onBeforeCreate }) {
|
|
496
546
|
const { type, setEditMode } = usePostListContext();
|
|
497
|
-
const
|
|
498
|
-
const createCapability = getPostTypeCreateCapability(type);
|
|
547
|
+
const canCreate = useCanCreate(type);
|
|
499
548
|
const singularName = postTypesMap[type].labels.singular_name;
|
|
500
549
|
const ariaLabel = (0, import_i18n4.sprintf)(
|
|
501
550
|
/* translators: %s: Post type singular name (e.g. Page, Post). */
|
|
@@ -506,7 +555,7 @@ function SectionAddButton({ onBeforeCreate }) {
|
|
|
506
555
|
ContentPanelAddIconButton,
|
|
507
556
|
{
|
|
508
557
|
"aria-label": ariaLabel,
|
|
509
|
-
disabled: !
|
|
558
|
+
disabled: !canCreate,
|
|
510
559
|
onClick: (event) => {
|
|
511
560
|
event.stopPropagation();
|
|
512
561
|
onBeforeCreate?.();
|
|
@@ -518,7 +567,7 @@ function SectionAddButton({ onBeforeCreate }) {
|
|
|
518
567
|
|
|
519
568
|
// src/components/panel/posts-list/collapsible-list.tsx
|
|
520
569
|
var React8 = __toESM(require("react"));
|
|
521
|
-
var
|
|
570
|
+
var import_react4 = require("react");
|
|
522
571
|
var import_editor_ui = require("@elementor/editor-ui");
|
|
523
572
|
var import_ui5 = require("@elementor/ui");
|
|
524
573
|
var sectionHeaderListItemButtonSx = {
|
|
@@ -541,7 +590,7 @@ function CollapsibleList({
|
|
|
541
590
|
trailingActions,
|
|
542
591
|
children
|
|
543
592
|
}) {
|
|
544
|
-
const id = (0,
|
|
593
|
+
const id = (0, import_react4.useId)();
|
|
545
594
|
const labelId = `label-${id}`;
|
|
546
595
|
const contentId = `content-${id}`;
|
|
547
596
|
const sectionHeaderAriaLabel = getSectionHeaderAriaLabel(title, count);
|
|
@@ -706,7 +755,7 @@ function useInvalidatePosts(postTypeSlug) {
|
|
|
706
755
|
|
|
707
756
|
// src/components/panel/posts-list/list-items/edit-mode-template.tsx
|
|
708
757
|
var React10 = __toESM(require("react"));
|
|
709
|
-
var
|
|
758
|
+
var import_react5 = require("react");
|
|
710
759
|
var import_icons6 = require("@elementor/icons");
|
|
711
760
|
var import_ui7 = require("@elementor/ui");
|
|
712
761
|
var import_i18n6 = require("@wordpress/i18n");
|
|
@@ -748,10 +797,10 @@ var editRowInputSx = {
|
|
|
748
797
|
};
|
|
749
798
|
function EditModeTemplate({ postTitle, isLoading, callback }) {
|
|
750
799
|
const { resetEditMode } = usePostListContext();
|
|
751
|
-
const [title, setTitle] = (0,
|
|
752
|
-
const [touched, setTouched] = (0,
|
|
753
|
-
const [inputError, setInputError] = (0,
|
|
754
|
-
const closeButton = (0,
|
|
800
|
+
const [title, setTitle] = (0, import_react5.useState)(postTitle);
|
|
801
|
+
const [touched, setTouched] = (0, import_react5.useState)(false);
|
|
802
|
+
const [inputError, setInputError] = (0, import_react5.useState)(null);
|
|
803
|
+
const closeButton = (0, import_react5.useRef)();
|
|
755
804
|
const onBlur = (e) => {
|
|
756
805
|
if (closeButton.current === e.relatedTarget) {
|
|
757
806
|
return;
|
|
@@ -953,14 +1002,15 @@ var React21 = __toESM(require("react"));
|
|
|
953
1002
|
var import_editor_documents5 = require("@elementor/editor-documents");
|
|
954
1003
|
var import_icons12 = require("@elementor/icons");
|
|
955
1004
|
var import_ui12 = require("@elementor/ui");
|
|
956
|
-
var
|
|
1005
|
+
var import_i18n15 = require("@wordpress/i18n");
|
|
957
1006
|
|
|
958
1007
|
// src/components/shared/page-title-and-status.tsx
|
|
959
1008
|
var React14 = __toESM(require("react"));
|
|
960
1009
|
var import_ui8 = require("@elementor/ui");
|
|
1010
|
+
var import_i18n9 = require("@wordpress/i18n");
|
|
961
1011
|
|
|
962
1012
|
// src/hooks/use-reverse-html-entities.ts
|
|
963
|
-
var
|
|
1013
|
+
var import_react6 = require("react");
|
|
964
1014
|
|
|
965
1015
|
// src/utils/post-title-plain.ts
|
|
966
1016
|
function getPostTitlePlain(renderedTitle) {
|
|
@@ -974,31 +1024,71 @@ function getPostTitlePlain(renderedTitle) {
|
|
|
974
1024
|
|
|
975
1025
|
// src/hooks/use-reverse-html-entities.ts
|
|
976
1026
|
function useReverseHtmlEntities(escapedHTML = "") {
|
|
977
|
-
return (0,
|
|
1027
|
+
return (0, import_react6.useMemo)(() => getPostTitlePlain(escapedHTML), [escapedHTML]);
|
|
978
1028
|
}
|
|
979
1029
|
|
|
980
1030
|
// src/components/shared/page-title-and-status.tsx
|
|
1031
|
+
function humanizeStatusSlug(status) {
|
|
1032
|
+
return status.replace(/[-_]+/g, " ").trim();
|
|
1033
|
+
}
|
|
1034
|
+
var statusChipConfig = {
|
|
1035
|
+
draft: {
|
|
1036
|
+
color: "default",
|
|
1037
|
+
label: (0, import_i18n9.__)("Draft", "elementor")
|
|
1038
|
+
},
|
|
1039
|
+
future: {
|
|
1040
|
+
color: "default",
|
|
1041
|
+
label: (0, import_i18n9.__)("Scheduled", "elementor")
|
|
1042
|
+
},
|
|
1043
|
+
pending: {
|
|
1044
|
+
color: "warning",
|
|
1045
|
+
label: (0, import_i18n9.__)("Pending Review", "elementor")
|
|
1046
|
+
},
|
|
1047
|
+
private: {
|
|
1048
|
+
color: "default",
|
|
1049
|
+
label: (0, import_i18n9.__)("Private", "elementor")
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
function getStatusChipConfig(status) {
|
|
1053
|
+
const known = statusChipConfig[status];
|
|
1054
|
+
if (known) {
|
|
1055
|
+
return known;
|
|
1056
|
+
}
|
|
1057
|
+
return {
|
|
1058
|
+
color: "default",
|
|
1059
|
+
label: humanizeStatusSlug(status)
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
function isKnownPanelStatus(status) {
|
|
1063
|
+
return status in statusChipConfig;
|
|
1064
|
+
}
|
|
981
1065
|
var PageStatus = ({ status }) => {
|
|
982
1066
|
if ("publish" === status) {
|
|
983
1067
|
return null;
|
|
984
1068
|
}
|
|
1069
|
+
const { color, label } = getStatusChipConfig(status);
|
|
1070
|
+
const isKnownStatus = isKnownPanelStatus(status);
|
|
985
1071
|
return /* @__PURE__ */ React14.createElement(
|
|
986
|
-
import_ui8.
|
|
1072
|
+
import_ui8.Chip,
|
|
987
1073
|
{
|
|
1074
|
+
color,
|
|
988
1075
|
component: "span",
|
|
989
|
-
|
|
990
|
-
|
|
1076
|
+
label,
|
|
1077
|
+
size: "tiny",
|
|
991
1078
|
sx: {
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1079
|
+
flexShrink: isKnownStatus ? 0 : 1,
|
|
1080
|
+
maxWidth: isKnownStatus ? void 0 : "45%",
|
|
1081
|
+
minWidth: 0,
|
|
1082
|
+
ml: 0.5,
|
|
1083
|
+
"& .MuiChip-label": {
|
|
1084
|
+
overflow: "hidden",
|
|
1085
|
+
textOverflow: "ellipsis",
|
|
1086
|
+
whiteSpace: "nowrap"
|
|
1087
|
+
}
|
|
1088
|
+
},
|
|
1089
|
+
title: label,
|
|
1090
|
+
variant: "standard"
|
|
1091
|
+
}
|
|
1002
1092
|
);
|
|
1003
1093
|
};
|
|
1004
1094
|
var PageTitle = ({ title }) => {
|
|
@@ -1019,16 +1109,16 @@ var PageTitle = ({ title }) => {
|
|
|
1019
1109
|
);
|
|
1020
1110
|
};
|
|
1021
1111
|
function PageTitleAndStatus({ title, status }) {
|
|
1022
|
-
return /* @__PURE__ */ React14.createElement(import_ui8.Box, { display: "flex" }, /* @__PURE__ */ React14.createElement(PageTitle, { title }),
|
|
1112
|
+
return /* @__PURE__ */ React14.createElement(import_ui8.Box, { alignItems: "center", display: "flex", minWidth: 0 }, /* @__PURE__ */ React14.createElement(PageTitle, { title }), /* @__PURE__ */ React14.createElement(PageStatus, { status }));
|
|
1023
1113
|
}
|
|
1024
1114
|
|
|
1025
1115
|
// src/components/panel/actions-menu/actions/delete.tsx
|
|
1026
1116
|
var React16 = __toESM(require("react"));
|
|
1027
|
-
var
|
|
1117
|
+
var import_react7 = require("react");
|
|
1028
1118
|
var import_editor_documents4 = require("@elementor/editor-documents");
|
|
1029
1119
|
var import_icons7 = require("@elementor/icons");
|
|
1030
1120
|
var import_ui10 = require("@elementor/ui");
|
|
1031
|
-
var
|
|
1121
|
+
var import_i18n10 = require("@wordpress/i18n");
|
|
1032
1122
|
|
|
1033
1123
|
// src/components/panel/actions-menu/action-menu-item.tsx
|
|
1034
1124
|
var React15 = __toESM(require("react"));
|
|
@@ -1047,7 +1137,7 @@ function ActionMenuItem({ title, icon: Icon, MenuItemProps }) {
|
|
|
1047
1137
|
|
|
1048
1138
|
// src/components/panel/actions-menu/actions/delete.tsx
|
|
1049
1139
|
function Delete({ post }) {
|
|
1050
|
-
const [isDialogOpen, setIsDialogOpen] = (0,
|
|
1140
|
+
const [isDialogOpen, setIsDialogOpen] = (0, import_react7.useState)(false);
|
|
1051
1141
|
const activeDocument = (0, import_editor_documents4.__useActiveDocument)();
|
|
1052
1142
|
const isPostActive = activeDocument?.id === post.id;
|
|
1053
1143
|
const userCanDelete = post.user_can.delete;
|
|
@@ -1055,7 +1145,7 @@ function Delete({ post }) {
|
|
|
1055
1145
|
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(
|
|
1056
1146
|
ActionMenuItem,
|
|
1057
1147
|
{
|
|
1058
|
-
title: (0,
|
|
1148
|
+
title: (0, import_i18n10.__)("Delete", "elementor"),
|
|
1059
1149
|
icon: import_icons7.TrashIcon,
|
|
1060
1150
|
MenuItemProps: {
|
|
1061
1151
|
disabled: isDisabled,
|
|
@@ -1072,11 +1162,11 @@ function DeleteDialog({
|
|
|
1072
1162
|
const { type } = usePostListContext();
|
|
1073
1163
|
const { deletePost } = usePostActions(type);
|
|
1074
1164
|
const { setError } = usePostListContext();
|
|
1075
|
-
const dialogTitle = (0,
|
|
1076
|
-
const dialogBody = type === "post" ? (0,
|
|
1165
|
+
const dialogTitle = (0, import_i18n10.sprintf)((0, import_i18n10.__)('Delete "%s"?', "elementor"), post.title.rendered);
|
|
1166
|
+
const dialogBody = type === "post" ? (0, import_i18n10.__)(
|
|
1077
1167
|
"The post and its content will be deleted forever and we won\u2019t be able to recover them.",
|
|
1078
1168
|
"elementor"
|
|
1079
|
-
) : (0,
|
|
1169
|
+
) : (0, import_i18n10.__)(
|
|
1080
1170
|
"The page and its content will be deleted forever and we won\u2019t be able to recover them.",
|
|
1081
1171
|
"elementor"
|
|
1082
1172
|
);
|
|
@@ -1102,18 +1192,17 @@ function DeleteDialog({
|
|
|
1102
1192
|
onClick: handleCancel,
|
|
1103
1193
|
disabled: deletePost.isPending
|
|
1104
1194
|
},
|
|
1105
|
-
(0,
|
|
1106
|
-
), /* @__PURE__ */ React16.createElement(import_ui10.Button, { variant: "contained", color: "error", onClick: deletePage, disabled: deletePost.isPending }, !deletePost.isPending ? (0,
|
|
1195
|
+
(0, import_i18n10.__)("Cancel", "elementor")
|
|
1196
|
+
), /* @__PURE__ */ React16.createElement(import_ui10.Button, { variant: "contained", color: "error", onClick: deletePage, disabled: deletePost.isPending }, !deletePost.isPending ? (0, import_i18n10.__)("Delete", "elementor") : /* @__PURE__ */ React16.createElement(import_ui10.CircularProgress, null))));
|
|
1107
1197
|
}
|
|
1108
1198
|
|
|
1109
1199
|
// src/components/panel/actions-menu/actions/duplicate.tsx
|
|
1110
1200
|
var React17 = __toESM(require("react"));
|
|
1111
1201
|
var import_icons8 = require("@elementor/icons");
|
|
1112
|
-
var
|
|
1202
|
+
var import_i18n11 = require("@wordpress/i18n");
|
|
1113
1203
|
function Duplicate({ post, popupState }) {
|
|
1114
1204
|
const { setEditMode, type } = usePostListContext();
|
|
1115
|
-
const
|
|
1116
|
-
const createCapability = getPostTypeCreateCapability(type);
|
|
1205
|
+
const canCreate = useCanCreate(type);
|
|
1117
1206
|
const onClick = () => {
|
|
1118
1207
|
popupState.close();
|
|
1119
1208
|
setEditMode({
|
|
@@ -1124,11 +1213,11 @@ function Duplicate({ post, popupState }) {
|
|
|
1124
1213
|
}
|
|
1125
1214
|
});
|
|
1126
1215
|
};
|
|
1127
|
-
const isDisabled = !
|
|
1216
|
+
const isDisabled = !canCreate;
|
|
1128
1217
|
return /* @__PURE__ */ React17.createElement(
|
|
1129
1218
|
ActionMenuItem,
|
|
1130
1219
|
{
|
|
1131
|
-
title: (0,
|
|
1220
|
+
title: (0, import_i18n11.__)("Duplicate", "elementor"),
|
|
1132
1221
|
icon: import_icons8.CopyIcon,
|
|
1133
1222
|
MenuItemProps: {
|
|
1134
1223
|
disabled: isDisabled,
|
|
@@ -1141,13 +1230,13 @@ function Duplicate({ post, popupState }) {
|
|
|
1141
1230
|
// src/components/panel/actions-menu/actions/rename.tsx
|
|
1142
1231
|
var React18 = __toESM(require("react"));
|
|
1143
1232
|
var import_icons9 = require("@elementor/icons");
|
|
1144
|
-
var
|
|
1233
|
+
var import_i18n12 = require("@wordpress/i18n");
|
|
1145
1234
|
function Rename({ post }) {
|
|
1146
1235
|
const { setEditMode } = usePostListContext();
|
|
1147
1236
|
return /* @__PURE__ */ React18.createElement(
|
|
1148
1237
|
ActionMenuItem,
|
|
1149
1238
|
{
|
|
1150
|
-
title: (0,
|
|
1239
|
+
title: (0, import_i18n12.__)("Rename", "elementor"),
|
|
1151
1240
|
icon: import_icons9.EraseIcon,
|
|
1152
1241
|
MenuItemProps: {
|
|
1153
1242
|
disabled: !post.user_can.edit,
|
|
@@ -1168,7 +1257,7 @@ function Rename({ post }) {
|
|
|
1168
1257
|
var React19 = __toESM(require("react"));
|
|
1169
1258
|
var import_icons10 = require("@elementor/icons");
|
|
1170
1259
|
var import_ui11 = require("@elementor/ui");
|
|
1171
|
-
var
|
|
1260
|
+
var import_i18n13 = require("@wordpress/i18n");
|
|
1172
1261
|
|
|
1173
1262
|
// src/hooks/use-homepage-actions.ts
|
|
1174
1263
|
var import_query6 = require("@elementor/query");
|
|
@@ -1210,7 +1299,7 @@ function SetHome({ post, closeMenu }) {
|
|
|
1210
1299
|
return /* @__PURE__ */ React19.createElement(
|
|
1211
1300
|
ActionMenuItem,
|
|
1212
1301
|
{
|
|
1213
|
-
title: (0,
|
|
1302
|
+
title: (0, import_i18n13.__)("Set as homepage", "elementor"),
|
|
1214
1303
|
icon: !updateSettingsMutation.isPending ? import_icons10.HomeIcon : import_ui11.CircularProgress,
|
|
1215
1304
|
MenuItemProps: {
|
|
1216
1305
|
disabled: isDisabled,
|
|
@@ -1223,10 +1312,10 @@ function SetHome({ post, closeMenu }) {
|
|
|
1223
1312
|
// src/components/panel/actions-menu/actions/view.tsx
|
|
1224
1313
|
var React20 = __toESM(require("react"));
|
|
1225
1314
|
var import_icons11 = require("@elementor/icons");
|
|
1226
|
-
var
|
|
1315
|
+
var import_i18n14 = require("@wordpress/i18n");
|
|
1227
1316
|
function View({ post }) {
|
|
1228
1317
|
const { type } = usePostListContext();
|
|
1229
|
-
const title = (0,
|
|
1318
|
+
const title = (0, import_i18n14.__)("View %s", "elementor").replace("%s", postTypesMap[type].labels.singular_name);
|
|
1230
1319
|
return /* @__PURE__ */ React20.createElement(
|
|
1231
1320
|
ActionMenuItem,
|
|
1232
1321
|
{
|
|
@@ -1240,9 +1329,13 @@ function View({ post }) {
|
|
|
1240
1329
|
}
|
|
1241
1330
|
|
|
1242
1331
|
// src/components/panel/posts-list/list-items/list-item-view.tsx
|
|
1243
|
-
var DisabledPostTooltip = ({
|
|
1332
|
+
var DisabledPostTooltip = ({
|
|
1333
|
+
children,
|
|
1334
|
+
isDisabled,
|
|
1335
|
+
postTypeSlug
|
|
1336
|
+
}) => {
|
|
1244
1337
|
if (isDisabled) {
|
|
1245
|
-
const title = /* @__PURE__ */ React21.createElement(import_ui12.Typography, { variant: "caption" },
|
|
1338
|
+
const title = /* @__PURE__ */ React21.createElement(import_ui12.Typography, { variant: "caption" }, getCannotEditPanelItemMessage(postTypeSlug), /* @__PURE__ */ React21.createElement("br", null), (0, import_i18n15.__)("To edit it directly, contact the site owner", "elementor"));
|
|
1246
1339
|
return /* @__PURE__ */ React21.createElement(import_ui12.Tooltip, { title, placement: "bottom", arrow: false }, /* @__PURE__ */ React21.createElement("span", null, children));
|
|
1247
1340
|
}
|
|
1248
1341
|
return /* @__PURE__ */ React21.createElement(React21.Fragment, null, children);
|
|
@@ -1261,7 +1354,7 @@ function ListItemView({ post }) {
|
|
|
1261
1354
|
const title = isActive ? activeDocument?.title : post.title.rendered;
|
|
1262
1355
|
const isDisabled = !post.user_can.edit;
|
|
1263
1356
|
const menuTriggerProps = (0, import_ui12.bindTrigger)(popupState);
|
|
1264
|
-
return /* @__PURE__ */ React21.createElement(React21.Fragment, null, /* @__PURE__ */ React21.createElement(DisabledPostTooltip, { isDisabled }, /* @__PURE__ */ React21.createElement(
|
|
1357
|
+
return /* @__PURE__ */ React21.createElement(React21.Fragment, null, /* @__PURE__ */ React21.createElement(DisabledPostTooltip, { isDisabled, postTypeSlug: type }, /* @__PURE__ */ React21.createElement(
|
|
1265
1358
|
import_ui12.ListItem,
|
|
1266
1359
|
{
|
|
1267
1360
|
disablePadding: true,
|
|
@@ -1269,7 +1362,7 @@ function ListItemView({ post }) {
|
|
|
1269
1362
|
secondaryAction: /* @__PURE__ */ React21.createElement(
|
|
1270
1363
|
import_ui12.IconButton,
|
|
1271
1364
|
{
|
|
1272
|
-
"aria-label": (0,
|
|
1365
|
+
"aria-label": (0, import_i18n15.__)("More actions", "elementor"),
|
|
1273
1366
|
size: "tiny",
|
|
1274
1367
|
...menuTriggerProps,
|
|
1275
1368
|
onClick: (event) => {
|
|
@@ -1296,7 +1389,7 @@ function ListItemView({ post }) {
|
|
|
1296
1389
|
sx: contentPanelListItemButtonSx
|
|
1297
1390
|
},
|
|
1298
1391
|
/* @__PURE__ */ React21.createElement(import_ui12.ListItemText, { disableTypography: true, sx: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ React21.createElement(PageTitleAndStatus, { title, status })),
|
|
1299
|
-
post.isHome && /* @__PURE__ */ React21.createElement(import_icons12.HomeIcon, { titleAccess: (0,
|
|
1392
|
+
post.isHome && /* @__PURE__ */ React21.createElement(import_icons12.HomeIcon, { titleAccess: (0, import_i18n15.__)("Homepage", "elementor"), color: "disabled" })
|
|
1300
1393
|
)
|
|
1301
1394
|
)), /* @__PURE__ */ React21.createElement(
|
|
1302
1395
|
import_ui12.Menu,
|
|
@@ -1336,10 +1429,10 @@ var SEARCH_DEBOUNCE_MS = 300;
|
|
|
1336
1429
|
function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
1337
1430
|
const { type, editMode, setEditMode } = usePostListContext();
|
|
1338
1431
|
const { registerSection, unregisterSection, searchQuery } = useContentPanelCoordinator();
|
|
1339
|
-
const [isOpen, setIsOpen] = (0,
|
|
1432
|
+
const [isOpen, setIsOpen] = (0, import_react8.useState)(isOpenByDefault);
|
|
1340
1433
|
const trimmedSearch = searchQuery.trim();
|
|
1341
|
-
const [debouncedSearch, setDebouncedSearch] = (0,
|
|
1342
|
-
(0,
|
|
1434
|
+
const [debouncedSearch, setDebouncedSearch] = (0, import_react8.useState)(trimmedSearch);
|
|
1435
|
+
(0, import_react8.useEffect)(() => {
|
|
1343
1436
|
const handle = window.setTimeout(() => setDebouncedSearch(trimmedSearch), SEARCH_DEBOUNCE_MS);
|
|
1344
1437
|
return () => window.clearTimeout(handle);
|
|
1345
1438
|
}, [trimmedSearch]);
|
|
@@ -1353,14 +1446,14 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
|
1353
1446
|
} = usePosts(type, debouncedSearch);
|
|
1354
1447
|
const { data: homepageId } = useHomepage();
|
|
1355
1448
|
const isPageType = type === "page";
|
|
1356
|
-
(0,
|
|
1449
|
+
(0, import_react8.useEffect)(() => {
|
|
1357
1450
|
registerSection(type, {
|
|
1358
1451
|
setExpanded: setIsOpen,
|
|
1359
1452
|
startCreate: () => setEditMode({ mode: "create", details: {} })
|
|
1360
1453
|
});
|
|
1361
1454
|
return () => unregisterSection(type);
|
|
1362
1455
|
}, [registerSection, unregisterSection, type, setEditMode]);
|
|
1363
|
-
const filteredPosts = (0,
|
|
1456
|
+
const filteredPosts = (0, import_react8.useMemo)(() => {
|
|
1364
1457
|
if (!posts) {
|
|
1365
1458
|
return [];
|
|
1366
1459
|
}
|
|
@@ -1376,7 +1469,7 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
|
1376
1469
|
}) : mappedPosts;
|
|
1377
1470
|
return sorted;
|
|
1378
1471
|
}, [posts, isPageType, homepageId]);
|
|
1379
|
-
(0,
|
|
1472
|
+
(0, import_react8.useEffect)(() => {
|
|
1380
1473
|
if (debouncedSearch && filteredPosts.length > 0) {
|
|
1381
1474
|
setIsOpen(true);
|
|
1382
1475
|
}
|
|
@@ -1399,7 +1492,7 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
|
1399
1492
|
title: sectionTitle,
|
|
1400
1493
|
trailingActions: /* @__PURE__ */ React23.createElement(SectionAddButton, { onBeforeCreate: () => setIsOpen(true) })
|
|
1401
1494
|
},
|
|
1402
|
-
showNoResults && /* @__PURE__ */ React23.createElement(import_ui13.Box, { sx: { py: 2, px: 2 } }, /* @__PURE__ */ React23.createElement(import_ui13.Typography, { variant: "body2", color: "text.secondary" }, (0,
|
|
1495
|
+
showNoResults && /* @__PURE__ */ React23.createElement(import_ui13.Box, { sx: { py: 2, px: 2 } }, /* @__PURE__ */ React23.createElement(import_ui13.Typography, { variant: "body2", color: "text.secondary" }, (0, import_i18n16.__)("No results found", "elementor"))),
|
|
1403
1496
|
filteredPosts.map((post) => {
|
|
1404
1497
|
return /* @__PURE__ */ React23.createElement(PostListItem, { key: post.id, post });
|
|
1405
1498
|
}),
|
|
@@ -1412,16 +1505,44 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
|
1412
1505
|
justifyContent: "center"
|
|
1413
1506
|
}
|
|
1414
1507
|
},
|
|
1415
|
-
/* @__PURE__ */ React23.createElement(import_ui13.Button, { onClick: fetchNextPage, color: "secondary" }, isFetchingNextPage ? /* @__PURE__ */ React23.createElement(import_ui13.CircularProgress, null) : (0,
|
|
1508
|
+
/* @__PURE__ */ React23.createElement(import_ui13.Button, { onClick: fetchNextPage, color: "secondary" }, isFetchingNextPage ? /* @__PURE__ */ React23.createElement(import_ui13.CircularProgress, null) : (0, import_i18n16.__)("Load more", "elementor"))
|
|
1416
1509
|
)
|
|
1417
1510
|
);
|
|
1418
1511
|
}
|
|
1419
1512
|
|
|
1513
|
+
// src/components/panel/user-load-error.tsx
|
|
1514
|
+
var React24 = __toESM(require("react"));
|
|
1515
|
+
var import_ui14 = require("@elementor/ui");
|
|
1516
|
+
var import_i18n17 = require("@wordpress/i18n");
|
|
1517
|
+
function UserLoadError() {
|
|
1518
|
+
return /* @__PURE__ */ React24.createElement(import_ui14.Box, { sx: { px: 2, py: 2 } }, /* @__PURE__ */ React24.createElement(import_ui14.Typography, { variant: "body2", color: "text.secondary" }, (0, import_i18n17.__)(
|
|
1519
|
+
"We couldn\u2019t load your content permissions. Try closing and reopening this panel.",
|
|
1520
|
+
"elementor"
|
|
1521
|
+
)));
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
// src/components/panel/shell-panel-body-content.tsx
|
|
1525
|
+
function ShellPanelBodyContent({
|
|
1526
|
+
accessiblePostTypes,
|
|
1527
|
+
isUserPending,
|
|
1528
|
+
onListError,
|
|
1529
|
+
showUserLoadError
|
|
1530
|
+
}) {
|
|
1531
|
+
if (isUserPending) {
|
|
1532
|
+
return /* @__PURE__ */ React25.createElement(import_ui15.Stack, { spacing: 1, sx: { px: 2, py: 1 } }, /* @__PURE__ */ React25.createElement(import_ui15.Skeleton, { animation: "wave", height: 28, variant: "rounded", width: "100%" }), /* @__PURE__ */ React25.createElement(import_ui15.Skeleton, { animation: "wave", height: 28, variant: "rounded", width: "80%" }));
|
|
1533
|
+
}
|
|
1534
|
+
if (showUserLoadError) {
|
|
1535
|
+
return /* @__PURE__ */ React25.createElement(UserLoadError, null);
|
|
1536
|
+
}
|
|
1537
|
+
return /* @__PURE__ */ React25.createElement(import_ui15.List, { dense: true, disablePadding: true, sx: { py: 0, width: "100%" } }, accessiblePostTypes.map((postTypeSlug, index) => /* @__PURE__ */ React25.createElement(PostListContextProvider, { key: postTypeSlug, type: postTypeSlug, setError: onListError }, /* @__PURE__ */ React25.createElement(PostsCollapsibleList, { isOpenByDefault: index === 0 }))));
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1420
1540
|
// src/components/panel/shell.tsx
|
|
1421
1541
|
var Shell = () => {
|
|
1422
|
-
const [isErrorSnackbarOpen, setIsErrorSnackbarOpen] = (0,
|
|
1423
|
-
|
|
1424
|
-
|
|
1542
|
+
const [isErrorSnackbarOpen, setIsErrorSnackbarOpen] = (0, import_react9.useState)(false);
|
|
1543
|
+
const { accessiblePostTypes, isUserPending, showUserLoadError } = useAccessiblePanelPostTypes();
|
|
1544
|
+
return /* @__PURE__ */ React26.createElement(ContentPanelCoordinatorProvider, null, /* @__PURE__ */ React26.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React26.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React26.createElement(
|
|
1545
|
+
import_ui16.Stack,
|
|
1425
1546
|
{
|
|
1426
1547
|
alignItems: "center",
|
|
1427
1548
|
direction: "row",
|
|
@@ -1430,17 +1551,17 @@ var Shell = () => {
|
|
|
1430
1551
|
...contentPanelHeaderStackSx
|
|
1431
1552
|
}
|
|
1432
1553
|
},
|
|
1433
|
-
/* @__PURE__ */
|
|
1434
|
-
/* @__PURE__ */
|
|
1435
|
-
)), /* @__PURE__ */
|
|
1436
|
-
|
|
1554
|
+
/* @__PURE__ */ React26.createElement(import_editor_panels.PanelHeaderTitle, { sx: { flex: 1, minWidth: 0, textAlign: "start" } }, (0, import_i18n18.__)("Site content", "elementor")),
|
|
1555
|
+
/* @__PURE__ */ React26.createElement(ContentPanelHeaderAdd, null)
|
|
1556
|
+
)), /* @__PURE__ */ React26.createElement(import_ui16.Divider, null), /* @__PURE__ */ React26.createElement(import_editor_panels.PanelBody, null, /* @__PURE__ */ React26.createElement(ContentPanelSearch, null), /* @__PURE__ */ React26.createElement(
|
|
1557
|
+
ShellPanelBodyContent,
|
|
1437
1558
|
{
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
)
|
|
1559
|
+
accessiblePostTypes,
|
|
1560
|
+
isUserPending,
|
|
1561
|
+
onListError: () => setIsErrorSnackbarOpen(true),
|
|
1562
|
+
showUserLoadError
|
|
1563
|
+
}
|
|
1564
|
+
), /* @__PURE__ */ React26.createElement(error_snackbar_default, { open: isErrorSnackbarOpen, onClose: () => setIsErrorSnackbarOpen(false) }))));
|
|
1444
1565
|
};
|
|
1445
1566
|
var shell_default = Shell;
|
|
1446
1567
|
|
|
@@ -1451,26 +1572,26 @@ var { panel, usePanelStatus, usePanelActions } = (0, import_editor_panels2.creat
|
|
|
1451
1572
|
});
|
|
1452
1573
|
|
|
1453
1574
|
// src/components/top-bar/recently-edited.tsx
|
|
1454
|
-
var
|
|
1575
|
+
var React31 = __toESM(require("react"));
|
|
1455
1576
|
var import_editor_documents8 = require("@elementor/editor-documents");
|
|
1456
1577
|
var import_icons15 = require("@elementor/icons");
|
|
1457
|
-
var
|
|
1458
|
-
var
|
|
1578
|
+
var import_ui21 = require("@elementor/ui");
|
|
1579
|
+
var import_i18n20 = require("@wordpress/i18n");
|
|
1459
1580
|
|
|
1460
1581
|
// src/components/top-bar/create-post-list-item.tsx
|
|
1461
|
-
var
|
|
1582
|
+
var React27 = __toESM(require("react"));
|
|
1462
1583
|
var import_editor_documents6 = require("@elementor/editor-documents");
|
|
1463
1584
|
var import_events = require("@elementor/events");
|
|
1464
1585
|
var import_icons13 = require("@elementor/icons");
|
|
1465
|
-
var
|
|
1466
|
-
var
|
|
1586
|
+
var import_ui17 = require("@elementor/ui");
|
|
1587
|
+
var import_i18n19 = require("@wordpress/i18n");
|
|
1467
1588
|
|
|
1468
1589
|
// src/hooks/use-create-page.ts
|
|
1469
|
-
var
|
|
1590
|
+
var import_react10 = require("react");
|
|
1470
1591
|
var import_api_fetch5 = __toESM(require("@wordpress/api-fetch"));
|
|
1471
1592
|
var endpointPath = "/elementor/v1/site-navigation/add-new-post";
|
|
1472
1593
|
function useCreatePage() {
|
|
1473
|
-
const [isLoading, setIsLoading] = (0,
|
|
1594
|
+
const [isLoading, setIsLoading] = (0, import_react10.useState)(false);
|
|
1474
1595
|
return {
|
|
1475
1596
|
create: () => {
|
|
1476
1597
|
setIsLoading(true);
|
|
@@ -1493,8 +1614,8 @@ function CreatePostListItem({ closePopup, ...props }) {
|
|
|
1493
1614
|
const navigateToDocument = (0, import_editor_documents6.__useNavigateToDocument)();
|
|
1494
1615
|
const { data: user } = useUser();
|
|
1495
1616
|
const { dispatchEvent, config } = (0, import_events.useMixpanel)();
|
|
1496
|
-
return /* @__PURE__ */
|
|
1497
|
-
|
|
1617
|
+
return /* @__PURE__ */ React27.createElement(
|
|
1618
|
+
import_ui17.MenuItem,
|
|
1498
1619
|
{
|
|
1499
1620
|
disabled: isLoading || !user?.capabilities?.edit_pages,
|
|
1500
1621
|
onClick: async () => {
|
|
@@ -1517,26 +1638,26 @@ function CreatePostListItem({ closePopup, ...props }) {
|
|
|
1517
1638
|
},
|
|
1518
1639
|
...props
|
|
1519
1640
|
},
|
|
1520
|
-
/* @__PURE__ */
|
|
1521
|
-
/* @__PURE__ */
|
|
1522
|
-
|
|
1641
|
+
/* @__PURE__ */ React27.createElement(import_ui17.ListItemIcon, null, isLoading ? /* @__PURE__ */ React27.createElement(import_ui17.CircularProgress, { size: "1.25rem" }) : /* @__PURE__ */ React27.createElement(import_icons13.PlusIcon, { fontSize: "small" })),
|
|
1642
|
+
/* @__PURE__ */ React27.createElement(
|
|
1643
|
+
import_ui17.ListItemText,
|
|
1523
1644
|
{
|
|
1524
1645
|
primaryTypographyProps: { variant: "body2" },
|
|
1525
|
-
primary: (0,
|
|
1646
|
+
primary: (0, import_i18n19.__)("Add new page", "elementor")
|
|
1526
1647
|
}
|
|
1527
1648
|
)
|
|
1528
1649
|
);
|
|
1529
1650
|
}
|
|
1530
1651
|
|
|
1531
1652
|
// src/components/top-bar/indicator.tsx
|
|
1532
|
-
var
|
|
1533
|
-
var
|
|
1653
|
+
var React28 = __toESM(require("react"));
|
|
1654
|
+
var import_ui18 = require("@elementor/ui");
|
|
1534
1655
|
function Indicator({ title, status }) {
|
|
1535
|
-
return /* @__PURE__ */
|
|
1656
|
+
return /* @__PURE__ */ React28.createElement(Tooltip2, { title }, /* @__PURE__ */ React28.createElement(import_ui18.Stack, { component: "span", direction: "row", alignItems: "center", spacing: 0.5 }, /* @__PURE__ */ React28.createElement(import_ui18.Typography, { component: "span", variant: "body2", sx: { maxWidth: "120px" }, noWrap: true }, title), status.value !== "publish" && /* @__PURE__ */ React28.createElement(import_ui18.Typography, { component: "span", variant: "body2", sx: { fontStyle: "italic" } }, "(", status.label, ")")));
|
|
1536
1657
|
}
|
|
1537
1658
|
function Tooltip2(props) {
|
|
1538
|
-
return /* @__PURE__ */
|
|
1539
|
-
|
|
1659
|
+
return /* @__PURE__ */ React28.createElement(
|
|
1660
|
+
import_ui18.Tooltip,
|
|
1540
1661
|
{
|
|
1541
1662
|
PopperProps: {
|
|
1542
1663
|
sx: {
|
|
@@ -1551,21 +1672,21 @@ function Tooltip2(props) {
|
|
|
1551
1672
|
}
|
|
1552
1673
|
|
|
1553
1674
|
// src/components/top-bar/post-list-item.tsx
|
|
1554
|
-
var
|
|
1675
|
+
var React30 = __toESM(require("react"));
|
|
1555
1676
|
var import_editor_documents7 = require("@elementor/editor-documents");
|
|
1556
1677
|
var import_events2 = require("@elementor/events");
|
|
1557
|
-
var
|
|
1678
|
+
var import_ui20 = require("@elementor/ui");
|
|
1558
1679
|
|
|
1559
1680
|
// src/components/top-bar/chip-doc-type.tsx
|
|
1560
|
-
var
|
|
1681
|
+
var React29 = __toESM(require("react"));
|
|
1561
1682
|
var import_icons14 = require("@elementor/icons");
|
|
1562
|
-
var
|
|
1683
|
+
var import_ui19 = require("@elementor/ui");
|
|
1563
1684
|
var iconsMap2 = getIconsMap();
|
|
1564
1685
|
function DocTypeChip({ postType, docType, label }) {
|
|
1565
1686
|
const color = "elementor_library" === postType ? "global" : "accent";
|
|
1566
1687
|
const Icon = iconsMap2[docType] || import_icons14.PostTypeIcon;
|
|
1567
|
-
return /* @__PURE__ */
|
|
1568
|
-
|
|
1688
|
+
return /* @__PURE__ */ React29.createElement(
|
|
1689
|
+
import_ui19.Chip,
|
|
1569
1690
|
{
|
|
1570
1691
|
component: "span",
|
|
1571
1692
|
size: "small",
|
|
@@ -1573,7 +1694,7 @@ function DocTypeChip({ postType, docType, label }) {
|
|
|
1573
1694
|
label,
|
|
1574
1695
|
"data-value": docType,
|
|
1575
1696
|
color,
|
|
1576
|
-
icon: /* @__PURE__ */
|
|
1697
|
+
icon: /* @__PURE__ */ React29.createElement(Icon, null),
|
|
1577
1698
|
sx: { ml: 1, cursor: "inherit" }
|
|
1578
1699
|
}
|
|
1579
1700
|
);
|
|
@@ -1584,8 +1705,8 @@ function PostListItem2({ post, closePopup, ...props }) {
|
|
|
1584
1705
|
const navigateToDocument = (0, import_editor_documents7.__useNavigateToDocument)();
|
|
1585
1706
|
const postTitle = useReverseHtmlEntities(post.title);
|
|
1586
1707
|
const { dispatchEvent, config } = (0, import_events2.useMixpanel)();
|
|
1587
|
-
return /* @__PURE__ */
|
|
1588
|
-
|
|
1708
|
+
return /* @__PURE__ */ React30.createElement(
|
|
1709
|
+
import_ui20.MenuItem,
|
|
1589
1710
|
{
|
|
1590
1711
|
disabled: !post.user_can.edit,
|
|
1591
1712
|
onClick: async () => {
|
|
@@ -1607,15 +1728,15 @@ function PostListItem2({ post, closePopup, ...props }) {
|
|
|
1607
1728
|
},
|
|
1608
1729
|
...props
|
|
1609
1730
|
},
|
|
1610
|
-
/* @__PURE__ */
|
|
1611
|
-
|
|
1731
|
+
/* @__PURE__ */ React30.createElement(
|
|
1732
|
+
import_ui20.ListItemText,
|
|
1612
1733
|
{
|
|
1613
1734
|
sx: { flexGrow: 0 },
|
|
1614
1735
|
primaryTypographyProps: { variant: "body2", noWrap: true },
|
|
1615
1736
|
primary: postTitle
|
|
1616
1737
|
}
|
|
1617
1738
|
),
|
|
1618
|
-
/* @__PURE__ */
|
|
1739
|
+
/* @__PURE__ */ React30.createElement(DocTypeChip, { postType: post.type.post_type, docType: post.type.doc_type, label: post.type.label })
|
|
1619
1740
|
);
|
|
1620
1741
|
}
|
|
1621
1742
|
|
|
@@ -1632,7 +1753,7 @@ function RecentlyEdited() {
|
|
|
1632
1753
|
return data.filter((post) => post.id !== document2?.id).splice(0, NUMBER_OF_RECENT_POSTS - 1);
|
|
1633
1754
|
};
|
|
1634
1755
|
const recentPosts = getRecentPosts();
|
|
1635
|
-
const popupState = (0,
|
|
1756
|
+
const popupState = (0, import_ui21.usePopupState)({
|
|
1636
1757
|
variant: "popover",
|
|
1637
1758
|
popupId: "elementor-v2-top-bar-recently-edited"
|
|
1638
1759
|
});
|
|
@@ -1640,13 +1761,13 @@ function RecentlyEdited() {
|
|
|
1640
1761
|
if (!document2) {
|
|
1641
1762
|
return null;
|
|
1642
1763
|
}
|
|
1643
|
-
const buttonProps = (0,
|
|
1644
|
-
return /* @__PURE__ */
|
|
1645
|
-
|
|
1764
|
+
const buttonProps = (0, import_ui21.bindTrigger)(popupState);
|
|
1765
|
+
return /* @__PURE__ */ React31.createElement(React31.Fragment, null, /* @__PURE__ */ React31.createElement(
|
|
1766
|
+
import_ui21.Button,
|
|
1646
1767
|
{
|
|
1647
1768
|
color: "inherit",
|
|
1648
1769
|
size: "small",
|
|
1649
|
-
endIcon: /* @__PURE__ */
|
|
1770
|
+
endIcon: /* @__PURE__ */ React31.createElement(import_icons15.ChevronDownIcon, { fontSize: "small" }),
|
|
1650
1771
|
...buttonProps,
|
|
1651
1772
|
onClick: (e) => {
|
|
1652
1773
|
const extendedWindow = window;
|
|
@@ -1665,46 +1786,40 @@ function RecentlyEdited() {
|
|
|
1665
1786
|
buttonProps.onClick(e);
|
|
1666
1787
|
}
|
|
1667
1788
|
},
|
|
1668
|
-
/* @__PURE__ */
|
|
1669
|
-
), /* @__PURE__ */
|
|
1670
|
-
|
|
1789
|
+
/* @__PURE__ */ React31.createElement(Indicator, { title: documentTitle, status: document2.status })
|
|
1790
|
+
), /* @__PURE__ */ React31.createElement(
|
|
1791
|
+
import_ui21.Menu,
|
|
1671
1792
|
{
|
|
1672
1793
|
MenuListProps: {
|
|
1673
|
-
subheader: /* @__PURE__ */
|
|
1794
|
+
subheader: /* @__PURE__ */ React31.createElement(import_ui21.ListSubheader, { sx: { color: "accent.main", fontStyle: "italic", fontWeight: "300" } }, (0, import_i18n20.__)("Recent", "elementor"))
|
|
1674
1795
|
},
|
|
1675
1796
|
PaperProps: { sx: { mt: 2.5, width: 320 } },
|
|
1676
|
-
...(0,
|
|
1797
|
+
...(0, import_ui21.bindMenu)(popupState)
|
|
1677
1798
|
},
|
|
1678
|
-
recentPosts.map((post) => /* @__PURE__ */
|
|
1679
|
-
recentPosts.length === 0 && /* @__PURE__ */
|
|
1680
|
-
|
|
1799
|
+
recentPosts.map((post) => /* @__PURE__ */ React31.createElement(PostListItem2, { key: post.id, post, closePopup: popupState.close })),
|
|
1800
|
+
recentPosts.length === 0 && /* @__PURE__ */ React31.createElement(import_ui21.MenuItem, { disabled: true }, /* @__PURE__ */ React31.createElement(
|
|
1801
|
+
import_ui21.ListItemText,
|
|
1681
1802
|
{
|
|
1682
1803
|
primaryTypographyProps: {
|
|
1683
1804
|
variant: "caption",
|
|
1684
1805
|
fontStyle: "italic"
|
|
1685
1806
|
},
|
|
1686
|
-
primary: (0,
|
|
1807
|
+
primary: (0, import_i18n20.__)("There are no other pages or templates on this site yet.", "elementor")
|
|
1687
1808
|
}
|
|
1688
1809
|
)),
|
|
1689
|
-
/* @__PURE__ */
|
|
1690
|
-
/* @__PURE__ */
|
|
1810
|
+
/* @__PURE__ */ React31.createElement(import_ui21.Divider, { disabled: recentPosts.length === 0 }),
|
|
1811
|
+
/* @__PURE__ */ React31.createElement(CreatePostListItem, { closePopup: popupState.close })
|
|
1691
1812
|
));
|
|
1692
1813
|
}
|
|
1693
1814
|
|
|
1694
|
-
// src/env.ts
|
|
1695
|
-
var import_env = require("@elementor/env");
|
|
1696
|
-
var { env } = (0, import_env.parseEnv)("@elementor/editor-site-navigation", (envData) => {
|
|
1697
|
-
return envData;
|
|
1698
|
-
});
|
|
1699
|
-
|
|
1700
1815
|
// src/hooks/use-toggle-button-props.ts
|
|
1701
1816
|
var import_icons16 = require("@elementor/icons");
|
|
1702
|
-
var
|
|
1817
|
+
var import_i18n21 = require("@wordpress/i18n");
|
|
1703
1818
|
function useToggleButtonProps() {
|
|
1704
1819
|
const { isOpen: selectedState, isBlocked } = usePanelStatus();
|
|
1705
1820
|
const { open, close } = usePanelActions();
|
|
1706
1821
|
return {
|
|
1707
|
-
title: (0,
|
|
1822
|
+
title: (0, import_i18n21.__)("Site content", "elementor"),
|
|
1708
1823
|
icon: import_icons16.PagesIcon,
|
|
1709
1824
|
onClick: () => {
|
|
1710
1825
|
const extendedWindow = window;
|
|
@@ -1727,7 +1842,7 @@ function useToggleButtonProps() {
|
|
|
1727
1842
|
// src/init.ts
|
|
1728
1843
|
function init() {
|
|
1729
1844
|
registerTopBarMenuItems();
|
|
1730
|
-
if (env.is_pages_panel_active) {
|
|
1845
|
+
if (env.is_pages_panel_active && env.can_access_site_content_panel) {
|
|
1731
1846
|
(0, import_editor_panels3.registerPanel)(panel);
|
|
1732
1847
|
registerButton();
|
|
1733
1848
|
}
|