PluginProbe
Elementor Website Builder – more than just a page builder / 3.13.0-beta1
Elementor Website Builder – more than just a page builder v3.13.0-beta1
4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 All 455 releases
elementor / assets / js / packages / recently-edited.js

recently-edited.js in Elementor Website Builder – more than just a page builder 3.13.0-beta1, at assets/js/packages/recently-edited.js

296 lines 12.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (function() { // webpackBootstrap
2 /******/ "use strict";
3 /******/ // The require scope
4 /******/ var __webpack_require__ = {};
5 /******/
6 /************************************************************************/
7 /******/ /* webpack/runtime/compat get default export */
8 /******/ !function() {
9 /******/ // getDefaultExport function for compatibility with non-harmony modules
10 /******/ __webpack_require__.n = function(module) {
11 /******/ var getter = module && module.__esModule ?
12 /******/ function() { return module['default']; } :
13 /******/ function() { return module; };
14 /******/ __webpack_require__.d(getter, { a: getter });
15 /******/ return getter;
16 /******/ };
17 /******/ }();
18 /******/
19 /******/ /* webpack/runtime/define property getters */
20 /******/ !function() {
21 /******/ // define getter functions for harmony exports
22 /******/ __webpack_require__.d = function(exports, definition) {
23 /******/ for(var key in definition) {
24 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
25 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
26 /******/ }
27 /******/ }
28 /******/ };
29 /******/ }();
30 /******/
31 /******/ /* webpack/runtime/hasOwnProperty shorthand */
32 /******/ !function() {
33 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
34 /******/ }();
35 /******/
36 /******/ /* webpack/runtime/make namespace object */
37 /******/ !function() {
38 /******/ // define __esModule on exports
39 /******/ __webpack_require__.r = function(exports) {
40 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
41 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
42 /******/ }
43 /******/ Object.defineProperty(exports, '__esModule', { value: true });
44 /******/ };
45 /******/ }();
46 /******/
47 /************************************************************************/
48 var __webpack_exports__ = {};
49 // ESM COMPAT FLAG
50 __webpack_require__.r(__webpack_exports__);
51
52 ;// CONCATENATED MODULE: external "__UNSTABLE__elementorPackages.ui"
53 var external_UNSTABLE_elementorPackages_ui_namespaceObject = __UNSTABLE__elementorPackages.ui;
54 ;// CONCATENATED MODULE: external "__UNSTABLE__elementorPackages.icons"
55 var external_UNSTABLE_elementorPackages_icons_namespaceObject = __UNSTABLE__elementorPackages.icons;
56 ;// CONCATENATED MODULE: external "__UNSTABLE__elementorPackages.documents"
57 var external_UNSTABLE_elementorPackages_documents_namespaceObject = __UNSTABLE__elementorPackages.documents;
58 ;// CONCATENATED MODULE: external "wp.i18n"
59 var external_wp_i18n_namespaceObject = wp.i18n;
60 ;// CONCATENATED MODULE: external "__UNSTABLE__elementorPackages.v1Adapters"
61 var external_UNSTABLE_elementorPackages_v1Adapters_namespaceObject = __UNSTABLE__elementorPackages.v1Adapters;
62 ;// CONCATENATED MODULE: ./packages/recently-edited/src/components/top-bar/settings-button.tsx
63
64
65
66
67 function SettingsButton({
68 type
69 }) {
70 const {
71 isActive,
72 isBlocked
73 } = (0,external_UNSTABLE_elementorPackages_v1Adapters_namespaceObject.useRouteStatus)('panel/page-settings');
74
75 /* translators: %s: Post type label. */
76 const title = (0,external_wp_i18n_namespaceObject.__)('%s Settings', 'elementor').replace('%s', type.label);
77 return /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.Tooltip, {
78 title: title
79 }, /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.Box, {
80 component: "span",
81 "aria-label": undefined
82 }, /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.ToggleButton, {
83 value: "document-settings",
84 selected: isActive,
85 disabled: isBlocked,
86 onChange: () => (0,external_UNSTABLE_elementorPackages_v1Adapters_namespaceObject.openRoute)('panel/page-settings/settings'),
87 "aria-label": title,
88 size: "small"
89 }, /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_icons_namespaceObject.SettingsIcon, null))));
90 }
91 ;// CONCATENATED MODULE: ./packages/recently-edited/src/components/top-bar/indicator.tsx
92
93 function Indicator({
94 title,
95 status
96 }) {
97 return /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.Tooltip, {
98 title: title
99 }, /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.Stack, {
100 direction: "row",
101 alignItems: "center",
102 spacing: 2
103 }, /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.Typography, {
104 variant: "body2",
105 sx: {
106 maxWidth: '120px'
107 },
108 noWrap: true
109 }, title), status.value !== 'publish' && /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.Typography, {
110 variant: "body2",
111 sx: {
112 fontStyle: 'italic'
113 }
114 }, "(", status.label, ")")));
115 }
116 ;// CONCATENATED MODULE: external "React"
117 var external_React_namespaceObject = React;
118 ;// CONCATENATED MODULE: ./packages/recently-edited/src/components/top-bar/chip-doc-type.tsx
119
120
121
122 const iconsDocType = {
123 header: external_UNSTABLE_elementorPackages_icons_namespaceObject.HeaderTemplateIcon,
124 footer: external_UNSTABLE_elementorPackages_icons_namespaceObject.FooterTemplateIcon,
125 'single-post': external_UNSTABLE_elementorPackages_icons_namespaceObject.PostTypeIcon,
126 'single-page': external_UNSTABLE_elementorPackages_icons_namespaceObject.PageTypeIcon,
127 popup: external_UNSTABLE_elementorPackages_icons_namespaceObject.PopupTemplateIcon,
128 archive: external_UNSTABLE_elementorPackages_icons_namespaceObject.ArchiveTemplateIcon,
129 'search-results': external_UNSTABLE_elementorPackages_icons_namespaceObject.SearchResultsTemplateIcon,
130 'loop-item': external_UNSTABLE_elementorPackages_icons_namespaceObject.LoopItemTemplateIcon,
131 'error-404': external_UNSTABLE_elementorPackages_icons_namespaceObject.Error404TemplateIcon,
132 'landing-page': external_UNSTABLE_elementorPackages_icons_namespaceObject.LandingPageTemplateIcon,
133 page: external_UNSTABLE_elementorPackages_icons_namespaceObject.PageTemplateIcon,
134 section: external_UNSTABLE_elementorPackages_icons_namespaceObject.SectionTemplateIcon,
135 container: external_UNSTABLE_elementorPackages_icons_namespaceObject.ContainerTemplateIcon,
136 'wp-page': external_UNSTABLE_elementorPackages_icons_namespaceObject.PageTypeIcon,
137 'wp-post': external_UNSTABLE_elementorPackages_icons_namespaceObject.PostTypeIcon
138 };
139 function DocTypeChip({
140 postType,
141 docType,
142 label
143 }) {
144 const color = 'elementor_library' === postType ? 'global' : 'primary';
145 const Icon = iconsDocType?.[docType] || external_UNSTABLE_elementorPackages_icons_namespaceObject.PostTypeIcon;
146 return /*#__PURE__*/external_React_namespaceObject.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.Chip, {
147 size: "medium",
148 variant: "standard",
149 label: label,
150 color: color,
151 icon: /*#__PURE__*/external_React_namespaceObject.createElement(Icon, null)
152 });
153 }
154 ;// CONCATENATED MODULE: ./packages/recently-edited/src/components/top-bar/posts-list.tsx
155
156
157
158 function PostsList({
159 recentPosts
160 }) {
161 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.ListSubheader, {
162 sx: {
163 fontSize: 12,
164 fontStyle: 'italic',
165 pl: 4
166 },
167 component: "div",
168 id: "nested-list-subheader"
169 }, (0,external_wp_i18n_namespaceObject.__)('Recent', 'elementor')), recentPosts.length ? recentPosts.map(({
170 title,
171 edit_url: editUrl,
172 type,
173 id
174 }) => /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.MenuItem, {
175 key: id,
176 component: "a",
177 href: editUrl
178 }, title, /*#__PURE__*/React.createElement(DocTypeChip, {
179 postType: type.post_type,
180 docType: type.doc_type,
181 label: type.label
182 }))) : /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.Typography, {
183 variant: "caption",
184 sx: {
185 color: 'grey.500',
186 fontStyle: 'italic',
187 p: 4
188 },
189 component: "div",
190 "aria-label": undefined
191 }, (0,external_wp_i18n_namespaceObject.__)('There are no other pages or templates on this site yet.', 'elementor')));
192 }
193 ;// CONCATENATED MODULE: external "wp.apiFetch"
194 var external_wp_apiFetch_namespaceObject = wp.apiFetch;
195 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
196 ;// CONCATENATED MODULE: external "wp.url"
197 var external_wp_url_namespaceObject = wp.url;
198 ;// CONCATENATED MODULE: ./packages/recently-edited/src/hooks/use-recent-posts.ts
199
200
201
202 function useRecentPosts(documentId) {
203 const [recentPosts, setRecentPosts] = (0,external_React_namespaceObject.useState)([]);
204 const [isLoading, setIsLoading] = (0,external_React_namespaceObject.useState)(false);
205 (0,external_React_namespaceObject.useEffect)(() => {
206 if (documentId) {
207 setIsLoading(true);
208 fetchRecentlyEditedPosts(documentId).then(posts => {
209 setRecentPosts(posts);
210 setIsLoading(false);
211 });
212 }
213 }, [documentId]);
214 return {
215 isLoading,
216 recentPosts
217 };
218 }
219 async function fetchRecentlyEditedPosts(documentId) {
220 const queryParams = {
221 posts_per_page: 5,
222 post__not_in: documentId
223 };
224 return await external_wp_apiFetch_default()({
225 path: (0,external_wp_url_namespaceObject.addQueryArgs)('/elementor/v1/site-navigation/recent-posts', queryParams)
226 }).then(response => response).catch(() => []);
227 }
228 ;// CONCATENATED MODULE: ./packages/recently-edited/src/components/top-bar/recently-edited.tsx
229 function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
230
231
232
233
234
235
236
237 function RecentlyEdited() {
238 const activeDocument = (0,external_UNSTABLE_elementorPackages_documents_namespaceObject.useActiveDocument)();
239 const hostDocument = (0,external_UNSTABLE_elementorPackages_documents_namespaceObject.useHostDocument)();
240 const document = activeDocument && activeDocument.type.value !== 'kit' ? activeDocument : hostDocument;
241 const {
242 recentPosts
243 } = useRecentPosts(document?.id);
244 const popupState = (0,external_UNSTABLE_elementorPackages_ui_namespaceObject.usePopupState)({
245 variant: 'popover',
246 popupId: 'elementor-v2-top-bar-recently-edited'
247 });
248 if (!document) {
249 return null;
250 }
251 return /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.Stack, {
252 direction: "row",
253 spacing: 1,
254 alignItems: "center",
255 sx: {
256 paddingInlineStart: 1,
257 cursor: 'default'
258 }
259 }, /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.Button, _extends({
260 color: "inherit",
261 endIcon: /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_icons_namespaceObject.ChevronDownIcon, null)
262 }, (0,external_UNSTABLE_elementorPackages_ui_namespaceObject.bindTrigger)(popupState)), /*#__PURE__*/React.createElement(Indicator, {
263 title: document.title,
264 status: document.status
265 })), /*#__PURE__*/React.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.Menu, _extends({
266 PaperProps: {
267 sx: {
268 minWidth: 314
269 }
270 }
271 }, (0,external_UNSTABLE_elementorPackages_ui_namespaceObject.bindMenu)(popupState)), /*#__PURE__*/React.createElement(PostsList, {
272 recentPosts: recentPosts
273 })), /*#__PURE__*/React.createElement(SettingsButton, {
274 type: document.type
275 }));
276 }
277 ;// CONCATENATED MODULE: external "__UNSTABLE__elementorPackages.topBar"
278 var external_UNSTABLE_elementorPackages_topBar_namespaceObject = __UNSTABLE__elementorPackages.topBar;
279 ;// CONCATENATED MODULE: ./packages/recently-edited/src/init.ts
280
281
282 function init() {
283 registerTopBarMenuItems();
284 }
285 function registerTopBarMenuItems() {
286 (0,external_UNSTABLE_elementorPackages_topBar_namespaceObject.injectIntoCanvasDisplay)({
287 name: 'document-recently-edited',
288 filler: RecentlyEdited
289 });
290 }
291 ;// CONCATENATED MODULE: ./packages/recently-edited/src/index.ts
292
293 init();
294 (window.__UNSTABLE__elementorPackages = window.__UNSTABLE__elementorPackages || {}).recentlyEdited = __webpack_exports__;
295 /******/ })()
296 ;