← All changes
|
assets/js/packages/editor-widget-creation/editor-widget-creation.js
+2
-429
4.2.2
→
4.1.0-beta3
View file →
| @@ -1,430 +1,3 @@ | ||
| 1 | -/******/ (function() { // webpackBootstrap | |
| 2 | -/******/ "use strict"; | |
| 3 | -/******/ var __webpack_modules__ = ({ | |
| 4 | - | |
| 5 | -/***/ "./packages/packages/core/editor-widget-creation/src/components/create-widget.tsx": | |
| 6 | -/*!****************************************************************************************!*\ | |
| 7 | - !*** ./packages/packages/core/editor-widget-creation/src/components/create-widget.tsx ***! | |
| 8 | - \****************************************************************************************/ | |
| 9 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 10 | - | |
| 11 | -__webpack_require__.r(__webpack_exports__); | |
| 12 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 13 | -/* harmony export */ CreateWidget: function() { return /* binding */ CreateWidget; } | |
| 14 | -/* harmony export */ }); | |
| 15 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 16 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 17 | -/* harmony import */ var _elementor_editor_mcp__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @elementor/editor-mcp */ "@elementor/editor-mcp"); | |
| 18 | -/* harmony import */ var _elementor_editor_mcp__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_elementor_editor_mcp__WEBPACK_IMPORTED_MODULE_1__); | |
| 19 | -/* harmony import */ var _elementor_editor_ui__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @elementor/editor-ui */ "@elementor/editor-ui"); | |
| 20 | -/* harmony import */ var _elementor_editor_ui__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_elementor_editor_ui__WEBPACK_IMPORTED_MODULE_2__); | |
| 21 | -/* harmony import */ var _elementor_events__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @elementor/events */ "@elementor/events"); | |
| 22 | -/* harmony import */ var _elementor_events__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_elementor_events__WEBPACK_IMPORTED_MODULE_3__); | |
| 23 | -/* harmony import */ var _elementor_icons__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @elementor/icons */ "@elementor/icons"); | |
| 24 | -/* harmony import */ var _elementor_icons__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_elementor_icons__WEBPACK_IMPORTED_MODULE_4__); | |
| 25 | -/* harmony import */ var _elementor_ui__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @elementor/ui */ "@elementor/ui"); | |
| 26 | -/* harmony import */ var _elementor_ui__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__); | |
| 27 | -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); | |
| 28 | -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_6__); | |
| 29 | -/* harmony import */ var _interpolate_links__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../interpolate-links */ "./packages/packages/core/editor-widget-creation/src/interpolate-links.tsx"); | |
| 30 | - | |
| 31 | - | |
| 32 | - | |
| 33 | - | |
| 34 | - | |
| 35 | - | |
| 36 | - | |
| 37 | - | |
| 38 | - | |
| 39 | -const CREATE_WIDGET_EVENT = 'elementor/editor/create-widget'; | |
| 40 | -const ANGIE_MODAL_PROMOTION_IMAGE_URL = 'https://assets.elementor.com/packages/v1/images/angie-modal-promotion.png'; | |
| 41 | -const ANGIE_CTA_CLICKED_EVENT = 'ai_widget_cta_clicked'; | |
| 42 | -const ANGIE_INSTALL_STARTED_EVENT = 'angie_install_started'; | |
| 43 | -const ANGIE_INSTALL_COMPLETED_EVENT = 'angie_install_completed'; | |
| 44 | -const ANGIE_INSTALL_ABANDONED_EVENT = 'angie_install_abandoned'; | |
| 45 | -function CreateWidgetModal({ | |
| 46 | - prompt, | |
| 47 | - entryPoint, | |
| 48 | - onClose | |
| 49 | -}) { | |
| 50 | - const [installState, setInstallState] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)('idle'); | |
| 51 | - const [agreedToTerms, setAgreedToTerms] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false); | |
| 52 | - const handleClose = () => { | |
| 53 | - if (installState === 'installing') { | |
| 54 | - return; | |
| 55 | - } | |
| 56 | - (0,_elementor_events__WEBPACK_IMPORTED_MODULE_3__.trackEvent)({ | |
| 57 | - eventName: ANGIE_INSTALL_ABANDONED_EVENT, | |
| 58 | - abandon_step: installState === 'error' ? 'install_error' : 'install_modal', | |
| 59 | - trigger_source: entryPoint | |
| 60 | - }); | |
| 61 | - onClose(); | |
| 62 | - }; | |
| 63 | - const handleInstall = async () => { | |
| 64 | - setInstallState('installing'); | |
| 65 | - (0,_elementor_events__WEBPACK_IMPORTED_MODULE_3__.trackEvent)({ | |
| 66 | - eventName: ANGIE_INSTALL_STARTED_EVENT, | |
| 67 | - trigger_source: entryPoint | |
| 68 | - }); | |
| 69 | - const [result] = await Promise.all([(0,_elementor_editor_mcp__WEBPACK_IMPORTED_MODULE_1__.installAngiePlugin)(), (0,_elementor_editor_mcp__WEBPACK_IMPORTED_MODULE_1__.saveAngieConsent)()]); | |
| 70 | - if (!result.success) { | |
| 71 | - setInstallState('error'); | |
| 72 | - return; | |
| 73 | - } | |
| 74 | - (0,_elementor_events__WEBPACK_IMPORTED_MODULE_3__.trackEvent)({ | |
| 75 | - eventName: ANGIE_INSTALL_COMPLETED_EVENT, | |
| 76 | - trigger_source: entryPoint | |
| 77 | - }); | |
| 78 | - (0,_elementor_editor_mcp__WEBPACK_IMPORTED_MODULE_1__.redirectToAppAdmin)(prompt); | |
| 79 | - }; | |
| 80 | - const handleFallbackInstall = () => { | |
| 81 | - (0,_elementor_editor_mcp__WEBPACK_IMPORTED_MODULE_1__.redirectToInstallation)(prompt); | |
| 82 | - }; | |
| 83 | - return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_editor_ui__WEBPACK_IMPORTED_MODULE_2__.ThemeProvider, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Dialog, { | |
| 84 | - fullWidth: true, | |
| 85 | - maxWidth: "md", | |
| 86 | - open: true, | |
| 87 | - onClose: handleClose | |
| 88 | - }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.IconButton, { | |
| 89 | - "aria-label": (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_6__.__)('Close', 'elementor'), | |
| 90 | - onClick: handleClose, | |
| 91 | - sx: { | |
| 92 | - position: 'absolute', | |
| 93 | - right: 8, | |
| 94 | - top: 8, | |
| 95 | - zIndex: 1 | |
| 96 | - } | |
| 97 | - }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_icons__WEBPACK_IMPORTED_MODULE_4__.XIcon, null)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.DialogContent, { | |
| 98 | - sx: { | |
| 99 | - p: 0, | |
| 100 | - overflow: 'hidden' | |
| 101 | - } | |
| 102 | - }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Stack, { | |
| 103 | - direction: "row", | |
| 104 | - sx: { | |
| 105 | - height: 400 | |
| 106 | - } | |
| 107 | - }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Image, { | |
| 108 | - sx: { | |
| 109 | - height: '100%', | |
| 110 | - aspectRatio: '1 / 1', | |
| 111 | - objectFit: 'cover', | |
| 112 | - objectPosition: 'right center' | |
| 113 | - }, | |
| 114 | - src: ANGIE_MODAL_PROMOTION_IMAGE_URL | |
| 115 | - }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Stack, { | |
| 116 | - justifyContent: "space-between", | |
| 117 | - p: 4 | |
| 118 | - }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Stack, { | |
| 119 | - gap: 2.5, | |
| 120 | - justifyContent: "center", | |
| 121 | - sx: { | |
| 122 | - flex: 1, | |
| 123 | - paddingInlineEnd: 2.5 | |
| 124 | - } | |
| 125 | - }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Typography, { | |
| 126 | - variant: "h4", | |
| 127 | - fontWeight: 600, | |
| 128 | - color: "text.secondary" | |
| 129 | - }, installState === 'error' ? (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_6__.__)('Installation failed', 'elementor') : (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_6__.__)('Create custom widgets with Angie', 'elementor')), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Typography, { | |
| 130 | - variant: "body2" | |
| 131 | - }, installState === 'error' ? (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_6__.__)("We couldn't install Angie automatically. Click below to install it manually.", 'elementor') : (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_6__.__)('Build custom widgets, sections, and code using simple instructions. Install once to start building directly from the editor.', 'elementor')), installState !== 'error' && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.FormControlLabel, { | |
| 132 | - control: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Checkbox, { | |
| 133 | - size: "small", | |
| 134 | - checked: agreedToTerms, | |
| 135 | - onChange: (_e, checked) => setAgreedToTerms(checked) | |
| 136 | - }), | |
| 137 | - label: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Typography, { | |
| 138 | - variant: "body2", | |
| 139 | - color: "text.secondary" | |
| 140 | - }, (0,_interpolate_links__WEBPACK_IMPORTED_MODULE_7__.interpolateLinks)((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_6__.sprintf)( | |
| 141 | - // translators: %1$s is the Terms link, %2$s is the Privacy Policy link. | |
| 142 | - (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_6__.__)('I agree to the %1$s & %2$s.', 'elementor'), '{{terms}}', '{{privacy}}'), { | |
| 143 | - terms: { | |
| 144 | - label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_6__.__)('Terms', 'elementor'), | |
| 145 | - href: 'https://elementor.com/terms/angie-terms-conditions/' | |
| 146 | - }, | |
| 147 | - privacy: { | |
| 148 | - label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_6__.__)('Privacy Policy', 'elementor'), | |
| 149 | - href: 'https://elementor.com/about/privacy/' | |
| 150 | - } | |
| 151 | - })) | |
| 152 | - })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Stack, { | |
| 153 | - direction: "row", | |
| 154 | - justifyContent: "flex-end" | |
| 155 | - }, installState === 'error' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Button, { | |
| 156 | - variant: "contained", | |
| 157 | - color: "accent", | |
| 158 | - onClick: handleFallbackInstall | |
| 159 | - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_6__.__)('Install Manually', 'elementor')) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Button, { | |
| 160 | - variant: "contained", | |
| 161 | - color: "accent", | |
| 162 | - onClick: handleInstall, | |
| 163 | - disabled: installState === 'installing' || !agreedToTerms, | |
| 164 | - startIcon: installState === 'installing' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.CircularProgress, { | |
| 165 | - size: 18, | |
| 166 | - color: "inherit" | |
| 167 | - }) : undefined | |
| 168 | - }, installState === 'installing' ? (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_6__.__)('Installing…', 'elementor') : (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_6__.__)('Install & Activate', 'elementor')))))))); | |
| 169 | -} | |
| 170 | -function CreateWidget() { | |
| 171 | - const [modalData, setModalData] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null); | |
| 172 | - (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { | |
| 173 | - const handleShow = event => { | |
| 174 | - const customEvent = event; | |
| 175 | - const hasAngieInstalled = (0,_elementor_editor_mcp__WEBPACK_IMPORTED_MODULE_1__.isAngieAvailable)(); | |
| 176 | - (0,_elementor_events__WEBPACK_IMPORTED_MODULE_3__.trackEvent)({ | |
| 177 | - eventName: ANGIE_CTA_CLICKED_EVENT, | |
| 178 | - entry_point: customEvent.detail.entry_point, | |
| 179 | - has_angie_installed: hasAngieInstalled | |
| 180 | - }); | |
| 181 | - if (hasAngieInstalled) { | |
| 182 | - (0,_elementor_editor_mcp__WEBPACK_IMPORTED_MODULE_1__.sendPromptToAngie)(customEvent.detail?.prompt); | |
| 183 | - return; | |
| 184 | - } | |
| 185 | - setModalData(customEvent.detail); | |
| 186 | - }; | |
| 187 | - window.addEventListener(CREATE_WIDGET_EVENT, handleShow); | |
| 188 | - return () => { | |
| 189 | - window.removeEventListener(CREATE_WIDGET_EVENT, handleShow); | |
| 190 | - }; | |
| 191 | - }, []); | |
| 192 | - if (!modalData) { | |
| 193 | - return null; | |
| 194 | - } | |
| 195 | - return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(CreateWidgetModal, { | |
| 196 | - prompt: modalData.prompt, | |
| 197 | - entryPoint: modalData.entry_point, | |
| 198 | - onClose: () => setModalData(null) | |
| 199 | - }); | |
| 200 | -} | |
| 201 | - | |
| 202 | -/***/ }), | |
| 203 | - | |
| 204 | -/***/ "./packages/packages/core/editor-widget-creation/src/init.ts": | |
| 205 | -/*!*******************************************************************!*\ | |
| 206 | - !*** ./packages/packages/core/editor-widget-creation/src/init.ts ***! | |
| 207 | - \*******************************************************************/ | |
| 208 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 209 | - | |
| 210 | -__webpack_require__.r(__webpack_exports__); | |
| 211 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 212 | -/* harmony export */ init: function() { return /* binding */ init; } | |
| 213 | -/* harmony export */ }); | |
| 214 | -/* harmony import */ var _elementor_editor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @elementor/editor */ "@elementor/editor"); | |
| 215 | -/* harmony import */ var _elementor_editor__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_elementor_editor__WEBPACK_IMPORTED_MODULE_0__); | |
| 216 | -/* harmony import */ var _components_create_widget__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/create-widget */ "./packages/packages/core/editor-widget-creation/src/components/create-widget.tsx"); | |
| 217 | - | |
| 218 | - | |
| 219 | -function init() { | |
| 220 | - (0,_elementor_editor__WEBPACK_IMPORTED_MODULE_0__.injectIntoTop)({ | |
| 221 | - id: 'create-widget', | |
| 222 | - component: _components_create_widget__WEBPACK_IMPORTED_MODULE_1__.CreateWidget | |
| 223 | - }); | |
| 224 | -} | |
| 225 | - | |
| 226 | -/***/ }), | |
| 227 | - | |
| 228 | -/***/ "./packages/packages/core/editor-widget-creation/src/interpolate-links.tsx": | |
| 229 | -/*!*********************************************************************************!*\ | |
| 230 | - !*** ./packages/packages/core/editor-widget-creation/src/interpolate-links.tsx ***! | |
| 231 | - \*********************************************************************************/ | |
| 232 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 233 | - | |
| 234 | -__webpack_require__.r(__webpack_exports__); | |
| 235 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 236 | -/* harmony export */ interpolateLinks: function() { return /* binding */ interpolateLinks; } | |
| 237 | -/* harmony export */ }); | |
| 238 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 239 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 240 | -/* harmony import */ var _elementor_ui__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @elementor/ui */ "@elementor/ui"); | |
| 241 | -/* harmony import */ var _elementor_ui__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_elementor_ui__WEBPACK_IMPORTED_MODULE_1__); | |
| 242 | - | |
| 243 | - | |
| 244 | -const LINK_PLACEHOLDER_PATTERN = /\{\{(\w+)}}/g; | |
| 245 | -const interpolateLinks = (text, links) => { | |
| 246 | - return text.split(LINK_PLACEHOLDER_PATTERN).map((part, i) => { | |
| 247 | - const link = links[part]; | |
| 248 | - if (!link) { | |
| 249 | - return part; | |
| 250 | - } | |
| 251 | - return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_1__.Link, { | |
| 252 | - key: i, | |
| 253 | - sx: { | |
| 254 | - px: 0.5 | |
| 255 | - }, | |
| 256 | - href: link.href, | |
| 257 | - target: "_blank", | |
| 258 | - rel: "noopener noreferrer" | |
| 259 | - }, link.label); | |
| 260 | - }); | |
| 261 | -}; | |
| 262 | - | |
| 263 | -/***/ }), | |
| 264 | - | |
| 265 | -/***/ "@elementor/editor": | |
| 266 | -/*!*****************************************!*\ | |
| 267 | - !*** external ["elementorV2","editor"] ***! | |
| 268 | - \*****************************************/ | |
| 269 | -/***/ (function(module) { | |
| 270 | - | |
| 271 | -module.exports = window["elementorV2"]["editor"]; | |
| 272 | - | |
| 273 | -/***/ }), | |
| 274 | - | |
| 275 | -/***/ "@elementor/editor-mcp": | |
| 276 | -/*!********************************************!*\ | |
| 277 | - !*** external ["elementorV2","editorMcp"] ***! | |
| 278 | - \********************************************/ | |
| 279 | -/***/ (function(module) { | |
| 280 | - | |
| 281 | -module.exports = window["elementorV2"]["editorMcp"]; | |
| 282 | - | |
| 283 | -/***/ }), | |
| 284 | - | |
| 285 | -/***/ "@elementor/editor-ui": | |
| 286 | -/*!*******************************************!*\ | |
| 287 | - !*** external ["elementorV2","editorUi"] ***! | |
| 288 | - \*******************************************/ | |
| 289 | -/***/ (function(module) { | |
| 290 | - | |
| 291 | -module.exports = window["elementorV2"]["editorUi"]; | |
| 292 | - | |
| 293 | -/***/ }), | |
| 294 | - | |
| 295 | -/***/ "@elementor/events": | |
| 296 | -/*!*****************************************!*\ | |
| 297 | - !*** external ["elementorV2","events"] ***! | |
| 298 | - \*****************************************/ | |
| 299 | -/***/ (function(module) { | |
| 300 | - | |
| 301 | -module.exports = window["elementorV2"]["events"]; | |
| 302 | - | |
| 303 | -/***/ }), | |
| 304 | - | |
| 305 | -/***/ "@elementor/icons": | |
| 306 | -/*!****************************************!*\ | |
| 307 | - !*** external ["elementorV2","icons"] ***! | |
| 308 | - \****************************************/ | |
| 309 | -/***/ (function(module) { | |
| 310 | - | |
| 311 | -module.exports = window["elementorV2"]["icons"]; | |
| 312 | - | |
| 313 | -/***/ }), | |
| 314 | - | |
| 315 | -/***/ "@elementor/ui": | |
| 316 | -/*!*************************************!*\ | |
| 317 | - !*** external ["elementorV2","ui"] ***! | |
| 318 | - \*************************************/ | |
| 319 | -/***/ (function(module) { | |
| 320 | - | |
| 321 | -module.exports = window["elementorV2"]["ui"]; | |
| 322 | - | |
| 323 | -/***/ }), | |
| 324 | - | |
| 325 | -/***/ "@wordpress/i18n": | |
| 326 | -/*!******************************!*\ | |
| 327 | - !*** external ["wp","i18n"] ***! | |
| 328 | - \******************************/ | |
| 329 | -/***/ (function(module) { | |
| 330 | - | |
| 331 | -module.exports = window["wp"]["i18n"]; | |
| 332 | - | |
| 333 | -/***/ }), | |
| 334 | - | |
| 335 | -/***/ "react": | |
| 336 | -/*!**************************!*\ | |
| 337 | - !*** external ["React"] ***! | |
| 338 | - \**************************/ | |
| 339 | -/***/ (function(module) { | |
| 340 | - | |
| 341 | -module.exports = window["React"]; | |
| 342 | - | |
| 343 | -/***/ }) | |
| 344 | - | |
| 345 | -/******/ }); | |
| 346 | -/************************************************************************/ | |
| 347 | -/******/ // The module cache | |
| 348 | -/******/ var __webpack_module_cache__ = {}; | |
| 349 | -/******/ | |
| 350 | -/******/ // The require function | |
| 351 | -/******/ function __webpack_require__(moduleId) { | |
| 352 | -/******/ // Check if module is in cache | |
| 353 | -/******/ var cachedModule = __webpack_module_cache__[moduleId]; | |
| 354 | -/******/ if (cachedModule !== undefined) { | |
| 355 | -/******/ return cachedModule.exports; | |
| 356 | -/******/ } | |
| 357 | -/******/ // Create a new module (and put it into the cache) | |
| 358 | -/******/ var module = __webpack_module_cache__[moduleId] = { | |
| 359 | -/******/ // no module.id needed | |
| 360 | -/******/ // no module.loaded needed | |
| 361 | -/******/ exports: {} | |
| 362 | -/******/ }; | |
| 363 | -/******/ | |
| 364 | -/******/ // Execute the module function | |
| 365 | -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); | |
| 366 | -/******/ | |
| 367 | -/******/ // Return the exports of the module | |
| 368 | -/******/ return module.exports; | |
| 369 | -/******/ } | |
| 370 | -/******/ | |
| 371 | -/************************************************************************/ | |
| 372 | -/******/ /* webpack/runtime/compat get default export */ | |
| 373 | -/******/ !function() { | |
| 374 | -/******/ // getDefaultExport function for compatibility with non-harmony modules | |
| 375 | -/******/ __webpack_require__.n = function(module) { | |
| 376 | -/******/ var getter = module && module.__esModule ? | |
| 377 | -/******/ function() { return module['default']; } : | |
| 378 | -/******/ function() { return module; }; | |
| 379 | -/******/ __webpack_require__.d(getter, { a: getter }); | |
| 380 | -/******/ return getter; | |
| 381 | -/******/ }; | |
| 382 | -/******/ }(); | |
| 383 | -/******/ | |
| 384 | -/******/ /* webpack/runtime/define property getters */ | |
| 385 | -/******/ !function() { | |
| 386 | -/******/ // define getter functions for harmony exports | |
| 387 | -/******/ __webpack_require__.d = function(exports, definition) { | |
| 388 | -/******/ for(var key in definition) { | |
| 389 | -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 390 | -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 391 | -/******/ } | |
| 392 | -/******/ } | |
| 393 | -/******/ }; | |
| 394 | -/******/ }(); | |
| 395 | -/******/ | |
| 396 | -/******/ /* webpack/runtime/hasOwnProperty shorthand */ | |
| 397 | -/******/ !function() { | |
| 398 | -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } | |
| 399 | -/******/ }(); | |
| 400 | -/******/ | |
| 401 | -/******/ /* webpack/runtime/make namespace object */ | |
| 402 | -/******/ !function() { | |
| 403 | -/******/ // define __esModule on exports | |
| 404 | -/******/ __webpack_require__.r = function(exports) { | |
| 405 | -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | |
| 406 | -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | |
| 407 | -/******/ } | |
| 408 | -/******/ Object.defineProperty(exports, '__esModule', { value: true }); | |
| 409 | -/******/ }; | |
| 410 | -/******/ }(); | |
| 411 | -/******/ | |
| 412 | -/************************************************************************/ | |
| 413 | -var __webpack_exports__ = {}; | |
| 414 | -// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk. | |
| 415 | -!function() { | |
| 416 | -/*!********************************************************************!*\ | |
| 417 | - !*** ./packages/packages/core/editor-widget-creation/src/index.ts ***! | |
| 418 | - \********************************************************************/ | |
| 419 | -__webpack_require__.r(__webpack_exports__); | |
| 420 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 421 | -/* harmony export */ init: function() { return /* reexport safe */ _init__WEBPACK_IMPORTED_MODULE_0__.init; } | |
| 422 | -/* harmony export */ }); | |
| 423 | -/* harmony import */ var _init__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./init */ "./packages/packages/core/editor-widget-creation/src/init.ts"); | |
| 424 | - | |
| 425 | -}(); | |
| 426 | -(window.elementorV2 = window.elementorV2 || {}).editorWidgetCreation = __webpack_exports__; | |
| 427 | -/******/ })() | |
| 428 | -; | |
| 429 | -window.elementorV2.editorWidgetCreation?.init?.(); | |
| 1 | +/*! For license information please see editor-widget-creation.js.LICENSE.txt */ | |
| 2 | +!function(){"use strict";var e={"./packages/packages/core/editor-widget-creation/src/components/create-widget.tsx":function(e,t,n){n.r(t),n.d(t,{CreateWidget:function(){return CreateWidget}});var r=n("react"),o=n("@elementor/editor-mcp"),i=n("@elementor/editor-ui"),a=n("@elementor/events"),l=n("@elementor/icons"),c=n("@elementor/ui"),s=n("@wordpress/i18n");const d="elementor/editor/create-widget",_="https://assets.elementor.com/packages/v1/images/angie-modal-promotion.png",m="ai_widget_cta_clicked",u="angie_install_started",p="angie_install_completed",g="angie_install_abandoned";function CreateWidgetModal({prompt:e,entryPoint:t,onClose:n}){const[d,m]=(0,r.useState)("idle"),[w,f]=(0,r.useState)(!1),handleClose=()=>{"installing"!==d&&((0,a.trackEvent)({eventName:g,abandon_step:"error"===d?"install_error":"install_modal",trigger_source:t}),n())};return r.createElement(i.ThemeProvider,null,r.createElement(c.Dialog,{fullWidth:!0,maxWidth:"md",open:!0,onClose:handleClose},r.createElement(c.IconButton,{"aria-label":(0,s.__)("Close","elementor"),onClick:handleClose,sx:{position:"absolute",right:8,top:8,zIndex:1}},r.createElement(l.XIcon,null)),r.createElement(c.DialogContent,{sx:{p:0,overflow:"hidden"}},r.createElement(c.Stack,{direction:"row",sx:{height:400}},r.createElement(c.Image,{sx:{height:"100%",aspectRatio:"1 / 1",objectFit:"cover",objectPosition:"right center"},src:_}),r.createElement(c.Stack,{justifyContent:"space-between",p:4},r.createElement(c.Stack,{gap:2.5,justifyContent:"center",sx:{flex:1,paddingInlineEnd:2.5}},r.createElement(c.Typography,{variant:"h4",fontWeight:600,color:"text.secondary"},"error"===d?(0,s.__)("Installation failed","elementor"):(0,s.__)("Create custom widgets with Angie","elementor")),r.createElement(c.Typography,{variant:"body2"},"error"===d?(0,s.__)("We couldn't install Angie automatically. Click below to install it manually.","elementor"):(0,s.__)("Build custom widgets, sections, and code using simple instructions. Install once to start building directly from the editor.","elementor")),"error"!==d&&r.createElement(c.FormControlLabel,{control:r.createElement(c.Checkbox,{size:"small",checked:w,onChange:(e,t)=>f(t)}),label:r.createElement(c.Typography,{variant:"body2",color:"text.secondary"},(0,s.__)("I agree to the","elementor"),r.createElement(c.Link,{sx:{px:.5},href:"https://elementor.com/terms/angie-terms-conditions/",target:"_blank",rel:"noopener noreferrer"},(0,s.__)("Terms","elementor")),(0,s.__)("&","elementor"),r.createElement(c.Link,{sx:{px:.5},href:"https://elementor.com/about/privacy/",target:"_blank",rel:"noopener noreferrer"},(0,s.__)("Privacy Policy.","elementor")))})),r.createElement(c.Stack,{direction:"row",justifyContent:"flex-end"},"error"===d?r.createElement(c.Button,{variant:"contained",color:"accent",onClick:()=>{(0,o.redirectToInstallation)(e)}},(0,s.__)("Install Manually","elementor")):r.createElement(c.Button,{variant:"contained",color:"accent",onClick:async()=>{m("installing"),(0,a.trackEvent)({eventName:u,trigger_source:t});const[n]=await Promise.all([(0,o.installAngiePlugin)(),(0,o.saveAngieConsent)()]);n.success?((0,a.trackEvent)({eventName:p,trigger_source:t}),(0,o.redirectToAppAdmin)(e)):m("error")},disabled:"installing"===d||!w,startIcon:"installing"===d?r.createElement(c.CircularProgress,{size:18,color:"inherit"}):void 0},"installing"===d?(0,s.__)("Installing…","elementor"):(0,s.__)("Install & Activate","elementor"))))))))}function CreateWidget(){const[e,t]=(0,r.useState)(null);return(0,r.useEffect)(()=>{const handleShow=e=>{const n=e,r=(0,o.isAngieAvailable)();(0,a.trackEvent)({eventName:m,entry_point:n.detail.entry_point,has_angie_installed:r}),r?(0,o.sendPromptToAngie)(n.detail?.prompt):t(n.detail)};return window.addEventListener(d,handleShow),()=>{window.removeEventListener(d,handleShow)}},[]),e?r.createElement(CreateWidgetModal,{prompt:e.prompt,entryPoint:e.entry_point,onClose:()=>t(null)}):null}},"./packages/packages/core/editor-widget-creation/src/init.ts":function(e,t,n){n.r(t),n.d(t,{init:function(){return init}});var r=n("@elementor/editor"),o=n("./packages/packages/core/editor-widget-creation/src/components/create-widget.tsx");function init(){(0,r.injectIntoTop)({id:"create-widget",component:o.CreateWidget})}},"@elementor/editor":function(e){e.exports=window.elementorV2.editor},"@elementor/editor-mcp":function(e){e.exports=window.elementorV2.editorMcp},"@elementor/editor-ui":function(e){e.exports=window.elementorV2.editorUi},"@elementor/events":function(e){e.exports=window.elementorV2.events},"@elementor/icons":function(e){e.exports=window.elementorV2.icons},"@elementor/ui":function(e){e.exports=window.elementorV2.ui},"@wordpress/i18n":function(e){e.exports=window.wp.i18n},react:function(e){e.exports=window.React}},t={};function __webpack_require__(n){var r=t[n];if(void 0!==r)return r.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,__webpack_require__),o.exports}__webpack_require__.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=function(e,t){for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};!function(){__webpack_require__.r(n),__webpack_require__.d(n,{init:function(){return e.init}});var e=__webpack_require__("./packages/packages/core/editor-widget-creation/src/init.ts")}(),(window.elementorV2=window.elementorV2||{}).editorWidgetCreation=n}(),window.elementorV2.editorWidgetCreation?.init?.(); | |
| 430 | 3 | //# sourceMappingURL=editor-widget-creation.js.map |