@elementor/editor-widget-creation 4.2.0-888 → 4.2.0-895
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 +48 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/components/create-widget.tsx +21 -20
- package/src/interpolate-links.tsx +27 -0
package/dist/index.js
CHANGED
|
@@ -38,14 +38,30 @@ module.exports = __toCommonJS(index_exports);
|
|
|
38
38
|
var import_editor = require("@elementor/editor");
|
|
39
39
|
|
|
40
40
|
// src/components/create-widget.tsx
|
|
41
|
-
var
|
|
41
|
+
var React2 = __toESM(require("react"));
|
|
42
42
|
var import_react = require("react");
|
|
43
43
|
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
44
44
|
var import_editor_ui = require("@elementor/editor-ui");
|
|
45
45
|
var import_events = require("@elementor/events");
|
|
46
46
|
var import_icons = require("@elementor/icons");
|
|
47
|
-
var
|
|
47
|
+
var import_ui2 = require("@elementor/ui");
|
|
48
48
|
var import_i18n = require("@wordpress/i18n");
|
|
49
|
+
|
|
50
|
+
// src/interpolate-links.tsx
|
|
51
|
+
var React = __toESM(require("react"));
|
|
52
|
+
var import_ui = require("@elementor/ui");
|
|
53
|
+
var LINK_PLACEHOLDER_PATTERN = /\{\{(\w+)}}/g;
|
|
54
|
+
var interpolateLinks = (text, links) => {
|
|
55
|
+
return text.split(LINK_PLACEHOLDER_PATTERN).map((part, i) => {
|
|
56
|
+
const link = links[part];
|
|
57
|
+
if (!link) {
|
|
58
|
+
return part;
|
|
59
|
+
}
|
|
60
|
+
return /* @__PURE__ */ React.createElement(import_ui.Link, { key: i, sx: { px: 0.5 }, href: link.href, target: "_blank", rel: "noopener noreferrer" }, link.label);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/components/create-widget.tsx
|
|
49
65
|
var CREATE_WIDGET_EVENT = "elementor/editor/create-widget";
|
|
50
66
|
var ANGIE_MODAL_PROMOTION_IMAGE_URL = "https://assets.elementor.com/packages/v1/images/angie-modal-promotion.png";
|
|
51
67
|
var ANGIE_CTA_CLICKED_EVENT = "ai_widget_cta_clicked";
|
|
@@ -86,8 +102,8 @@ function CreateWidgetModal({ prompt, entryPoint, onClose }) {
|
|
|
86
102
|
const handleFallbackInstall = () => {
|
|
87
103
|
(0, import_editor_mcp.redirectToInstallation)(prompt);
|
|
88
104
|
};
|
|
89
|
-
return /* @__PURE__ */
|
|
90
|
-
|
|
105
|
+
return /* @__PURE__ */ React2.createElement(import_editor_ui.ThemeProvider, null, /* @__PURE__ */ React2.createElement(import_ui2.Dialog, { fullWidth: true, maxWidth: "md", open: true, onClose: handleClose }, /* @__PURE__ */ React2.createElement(
|
|
106
|
+
import_ui2.IconButton,
|
|
91
107
|
{
|
|
92
108
|
"aria-label": (0, import_i18n.__)("Close", "elementor"),
|
|
93
109
|
onClick: handleClose,
|
|
@@ -98,9 +114,9 @@ function CreateWidgetModal({ prompt, entryPoint, onClose }) {
|
|
|
98
114
|
zIndex: 1
|
|
99
115
|
}
|
|
100
116
|
},
|
|
101
|
-
/* @__PURE__ */
|
|
102
|
-
), /* @__PURE__ */
|
|
103
|
-
|
|
117
|
+
/* @__PURE__ */ React2.createElement(import_icons.XIcon, null)
|
|
118
|
+
), /* @__PURE__ */ React2.createElement(import_ui2.DialogContent, { sx: { p: 0, overflow: "hidden" } }, /* @__PURE__ */ React2.createElement(import_ui2.Stack, { direction: "row", sx: { height: 400 } }, /* @__PURE__ */ React2.createElement(
|
|
119
|
+
import_ui2.Image,
|
|
104
120
|
{
|
|
105
121
|
sx: {
|
|
106
122
|
height: "100%",
|
|
@@ -110,51 +126,50 @@ function CreateWidgetModal({ prompt, entryPoint, onClose }) {
|
|
|
110
126
|
},
|
|
111
127
|
src: ANGIE_MODAL_PROMOTION_IMAGE_URL
|
|
112
128
|
}
|
|
113
|
-
), /* @__PURE__ */
|
|
129
|
+
), /* @__PURE__ */ React2.createElement(import_ui2.Stack, { justifyContent: "space-between", p: 4 }, /* @__PURE__ */ React2.createElement(import_ui2.Stack, { gap: 2.5, justifyContent: "center", sx: { flex: 1, paddingInlineEnd: 2.5 } }, /* @__PURE__ */ React2.createElement(import_ui2.Typography, { variant: "h4", fontWeight: 600, color: "text.secondary" }, installState === "error" ? (0, import_i18n.__)("Installation failed", "elementor") : (0, import_i18n.__)("Create custom widgets with Angie", "elementor")), /* @__PURE__ */ React2.createElement(import_ui2.Typography, { variant: "body2" }, installState === "error" ? (0, import_i18n.__)(
|
|
114
130
|
"We couldn't install Angie automatically. Click below to install it manually.",
|
|
115
131
|
"elementor"
|
|
116
132
|
) : (0, import_i18n.__)(
|
|
117
133
|
"Build custom widgets, sections, and code using simple instructions. Install once to start building directly from the editor.",
|
|
118
134
|
"elementor"
|
|
119
|
-
)), installState !== "error" && /* @__PURE__ */
|
|
120
|
-
|
|
135
|
+
)), installState !== "error" && /* @__PURE__ */ React2.createElement(
|
|
136
|
+
import_ui2.FormControlLabel,
|
|
121
137
|
{
|
|
122
|
-
control: /* @__PURE__ */
|
|
123
|
-
|
|
138
|
+
control: /* @__PURE__ */ React2.createElement(
|
|
139
|
+
import_ui2.Checkbox,
|
|
124
140
|
{
|
|
125
141
|
size: "small",
|
|
126
142
|
checked: agreedToTerms,
|
|
127
143
|
onChange: (_e, checked) => setAgreedToTerms(checked)
|
|
128
144
|
}
|
|
129
145
|
),
|
|
130
|
-
label: /* @__PURE__ */
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
},
|
|
138
|
-
(0, import_i18n.__)("Terms", "elementor")
|
|
139
|
-
), (0, import_i18n.__)("&", "elementor"), /* @__PURE__ */ React.createElement(
|
|
140
|
-
import_ui.Link,
|
|
146
|
+
label: /* @__PURE__ */ React2.createElement(import_ui2.Typography, { variant: "body2", color: "text.secondary" }, interpolateLinks(
|
|
147
|
+
(0, import_i18n.sprintf)(
|
|
148
|
+
// translators: %1$s is the Terms link, %2$s is the Privacy Policy link.
|
|
149
|
+
(0, import_i18n.__)("I agree to the %1$s & %2$s.", "elementor"),
|
|
150
|
+
"{{terms}}",
|
|
151
|
+
"{{privacy}}"
|
|
152
|
+
),
|
|
141
153
|
{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
terms: {
|
|
155
|
+
label: (0, import_i18n.__)("Terms", "elementor"),
|
|
156
|
+
href: "https://elementor.com/terms/angie-terms-conditions/"
|
|
157
|
+
},
|
|
158
|
+
privacy: {
|
|
159
|
+
label: (0, import_i18n.__)("Privacy Policy", "elementor"),
|
|
160
|
+
href: "https://elementor.com/about/privacy/"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
148
163
|
))
|
|
149
164
|
}
|
|
150
|
-
)), /* @__PURE__ */
|
|
151
|
-
|
|
165
|
+
)), /* @__PURE__ */ React2.createElement(import_ui2.Stack, { direction: "row", justifyContent: "flex-end" }, installState === "error" ? /* @__PURE__ */ React2.createElement(import_ui2.Button, { variant: "contained", color: "accent", onClick: handleFallbackInstall }, (0, import_i18n.__)("Install Manually", "elementor")) : /* @__PURE__ */ React2.createElement(
|
|
166
|
+
import_ui2.Button,
|
|
152
167
|
{
|
|
153
168
|
variant: "contained",
|
|
154
169
|
color: "accent",
|
|
155
170
|
onClick: handleInstall,
|
|
156
171
|
disabled: installState === "installing" || !agreedToTerms,
|
|
157
|
-
startIcon: installState === "installing" ? /* @__PURE__ */
|
|
172
|
+
startIcon: installState === "installing" ? /* @__PURE__ */ React2.createElement(import_ui2.CircularProgress, { size: 18, color: "inherit" }) : void 0
|
|
158
173
|
},
|
|
159
174
|
installState === "installing" ? (0, import_i18n.__)("Installing\u2026", "elementor") : (0, import_i18n.__)("Install & Activate", "elementor")
|
|
160
175
|
)))))));
|
|
@@ -184,7 +199,7 @@ function CreateWidget() {
|
|
|
184
199
|
if (!modalData) {
|
|
185
200
|
return null;
|
|
186
201
|
}
|
|
187
|
-
return /* @__PURE__ */
|
|
202
|
+
return /* @__PURE__ */ React2.createElement(
|
|
188
203
|
CreateWidgetModal,
|
|
189
204
|
{
|
|
190
205
|
prompt: modalData.prompt,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/init.ts","../src/components/create-widget.tsx"],"sourcesContent":["export { init } from './init';\n","import { injectIntoTop } from '@elementor/editor';\n\nimport { CreateWidget } from './components/create-widget';\n\nexport function init() {\n\tinjectIntoTop( {\n\t\tid: 'create-widget',\n\t\tcomponent: CreateWidget,\n\t} );\n}\n","import * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport {\n\tinstallAngiePlugin,\n\tisAngieAvailable,\n\tredirectToAppAdmin,\n\tredirectToInstallation,\n\tsaveAngieConsent,\n\tsendPromptToAngie,\n} from '@elementor/editor-mcp';\nimport { ThemeProvider } from '@elementor/editor-ui';\nimport { trackEvent } from '@elementor/events';\nimport { XIcon } from '@elementor/icons';\nimport {\n\tButton,\n\tCheckbox,\n\tCircularProgress,\n\tDialog,\n\tDialogContent,\n\tFormControlLabel,\n\tIconButton,\n\tImage,\n\tLink,\n\tStack,\n\tTypography,\n} from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\ntype ShowModalEventDetail = {\n\tprompt?: string;\n\tentry_point: string;\n};\n\ntype InstallState = 'idle' | 'installing' | 'error';\n\ntype CreateWidgetModalProps = {\n\tprompt?: string;\n\tentryPoint: string;\n\tonClose: () => void;\n};\n\nconst CREATE_WIDGET_EVENT = 'elementor/editor/create-widget';\nconst ANGIE_MODAL_PROMOTION_IMAGE_URL = 'https://assets.elementor.com/packages/v1/images/angie-modal-promotion.png';\nconst ANGIE_CTA_CLICKED_EVENT = 'ai_widget_cta_clicked' as const;\nconst ANGIE_INSTALL_STARTED_EVENT = 'angie_install_started' as const;\nconst ANGIE_INSTALL_COMPLETED_EVENT = 'angie_install_completed' as const;\nconst ANGIE_INSTALL_ABANDONED_EVENT = 'angie_install_abandoned' as const;\n\nfunction CreateWidgetModal( { prompt, entryPoint, onClose }: CreateWidgetModalProps ) {\n\tconst [ installState, setInstallState ] = useState< InstallState >( 'idle' );\n\tconst [ agreedToTerms, setAgreedToTerms ] = useState( false );\n\n\tconst handleClose = () => {\n\t\tif ( installState === 'installing' ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttrackEvent( {\n\t\t\teventName: ANGIE_INSTALL_ABANDONED_EVENT,\n\t\t\tabandon_step: installState === 'error' ? 'install_error' : 'install_modal',\n\t\t\ttrigger_source: entryPoint,\n\t\t} );\n\n\t\tonClose();\n\t};\n\n\tconst handleInstall = async () => {\n\t\tsetInstallState( 'installing' );\n\n\t\ttrackEvent( {\n\t\t\teventName: ANGIE_INSTALL_STARTED_EVENT,\n\t\t\ttrigger_source: entryPoint,\n\t\t} );\n\n\t\tconst [ result ] = await Promise.all( [ installAngiePlugin(), saveAngieConsent() ] );\n\n\t\tif ( ! result.success ) {\n\t\t\tsetInstallState( 'error' );\n\n\t\t\treturn;\n\t\t}\n\n\t\ttrackEvent( {\n\t\t\teventName: ANGIE_INSTALL_COMPLETED_EVENT,\n\t\t\ttrigger_source: entryPoint,\n\t\t} );\n\n\t\tredirectToAppAdmin( prompt );\n\t};\n\n\tconst handleFallbackInstall = () => {\n\t\tredirectToInstallation( prompt );\n\t};\n\n\treturn (\n\t\t<ThemeProvider>\n\t\t\t<Dialog fullWidth maxWidth=\"md\" open onClose={ handleClose }>\n\t\t\t\t<IconButton\n\t\t\t\t\taria-label={ __( 'Close', 'elementor' ) }\n\t\t\t\t\tonClick={ handleClose }\n\t\t\t\t\tsx={ {\n\t\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t\tright: 8,\n\t\t\t\t\t\ttop: 8,\n\t\t\t\t\t\tzIndex: 1,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<XIcon />\n\t\t\t\t</IconButton>\n\t\t\t\t<DialogContent sx={ { p: 0, overflow: 'hidden' } }>\n\t\t\t\t\t<Stack direction=\"row\" sx={ { height: 400 } }>\n\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\tsx={ {\n\t\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\t\taspectRatio: '1 / 1',\n\t\t\t\t\t\t\t\tobjectFit: 'cover',\n\t\t\t\t\t\t\t\tobjectPosition: 'right center',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsrc={ ANGIE_MODAL_PROMOTION_IMAGE_URL }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Stack justifyContent=\"space-between\" p={ 4 }>\n\t\t\t\t\t\t\t<Stack gap={ 2.5 } justifyContent=\"center\" sx={ { flex: 1, paddingInlineEnd: 2.5 } }>\n\t\t\t\t\t\t\t\t<Typography variant=\"h4\" fontWeight={ 600 } color=\"text.secondary\">\n\t\t\t\t\t\t\t\t\t{ installState === 'error'\n\t\t\t\t\t\t\t\t\t\t? __( 'Installation failed', 'elementor' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Create custom widgets with Angie', 'elementor' ) }\n\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t<Typography variant=\"body2\">\n\t\t\t\t\t\t\t\t\t{ installState === 'error'\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t\"We couldn't install Angie automatically. Click below to install it manually.\",\n\t\t\t\t\t\t\t\t\t\t\t\t'elementor'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Build custom widgets, sections, and code using simple instructions. Install once to start building directly from the editor.',\n\t\t\t\t\t\t\t\t\t\t\t\t'elementor'\n\t\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t{ installState !== 'error' && (\n\t\t\t\t\t\t\t\t\t<FormControlLabel\n\t\t\t\t\t\t\t\t\t\tcontrol={\n\t\t\t\t\t\t\t\t\t\t\t<Checkbox\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\tchecked={ agreedToTerms }\n\t\t\t\t\t\t\t\t\t\t\t\tonChange={ (\n\t\t\t\t\t\t\t\t\t\t\t\t\t_e: React.ChangeEvent< HTMLInputElement >,\n\t\t\t\t\t\t\t\t\t\t\t\t\tchecked: boolean\n\t\t\t\t\t\t\t\t\t\t\t\t) => setAgreedToTerms( checked ) }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\t<Typography variant=\"body2\" color=\"text.secondary\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'I agree to the', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\t\t\t\t\t\t\tsx={ { px: 0.5 } }\n\t\t\t\t\t\t\t\t\t\t\t\t\thref=\"https://elementor.com/terms/angie-terms-conditions/\"\n\t\t\t\t\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Terms', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( '&', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\t\t\t\t\t\t\tsx={ { px: 0.5 } }\n\t\t\t\t\t\t\t\t\t\t\t\t\thref=\"https://elementor.com/about/privacy/\"\n\t\t\t\t\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Privacy Policy.', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Stack>\n\t\t\t\t\t\t\t<Stack direction=\"row\" justifyContent=\"flex-end\">\n\t\t\t\t\t\t\t\t{ installState === 'error' ? (\n\t\t\t\t\t\t\t\t\t<Button variant=\"contained\" color=\"accent\" onClick={ handleFallbackInstall }>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Install Manually', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"contained\"\n\t\t\t\t\t\t\t\t\t\tcolor=\"accent\"\n\t\t\t\t\t\t\t\t\t\tonClick={ handleInstall }\n\t\t\t\t\t\t\t\t\t\tdisabled={ installState === 'installing' || ! agreedToTerms }\n\t\t\t\t\t\t\t\t\t\tstartIcon={\n\t\t\t\t\t\t\t\t\t\t\tinstallState === 'installing' ? (\n\t\t\t\t\t\t\t\t\t\t\t\t<CircularProgress size={ 18 } color=\"inherit\" />\n\t\t\t\t\t\t\t\t\t\t\t) : undefined\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ installState === 'installing'\n\t\t\t\t\t\t\t\t\t\t\t? __( 'Installing…', 'elementor' )\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Install & Activate', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Stack>\n\t\t\t\t\t\t</Stack>\n\t\t\t\t\t</Stack>\n\t\t\t\t</DialogContent>\n\t\t\t</Dialog>\n\t\t</ThemeProvider>\n\t);\n}\n\nexport function CreateWidget() {\n\tconst [ modalData, setModalData ] = useState< ShowModalEventDetail | null >( null );\n\n\tuseEffect( () => {\n\t\tconst handleShow = ( event: Event ) => {\n\t\t\tconst customEvent = event as CustomEvent< ShowModalEventDetail >;\n\t\t\tconst hasAngieInstalled = isAngieAvailable();\n\n\t\t\ttrackEvent( {\n\t\t\t\teventName: ANGIE_CTA_CLICKED_EVENT,\n\t\t\t\tentry_point: customEvent.detail.entry_point,\n\t\t\t\thas_angie_installed: hasAngieInstalled,\n\t\t\t} );\n\n\t\t\tif ( hasAngieInstalled ) {\n\t\t\t\tsendPromptToAngie( customEvent.detail?.prompt );\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetModalData( customEvent.detail );\n\t\t};\n\n\t\twindow.addEventListener( CREATE_WIDGET_EVENT, handleShow );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( CREATE_WIDGET_EVENT, handleShow );\n\t\t};\n\t}, [] );\n\n\tif ( ! modalData ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<CreateWidgetModal\n\t\t\tprompt={ modalData.prompt }\n\t\t\tentryPoint={ modalData.entry_point }\n\t\t\tonClose={ () => setModalData( null ) }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA8B;;;ACA9B,YAAuB;AACvB,mBAAoC;AACpC,wBAOO;AACP,uBAA8B;AAC9B,oBAA2B;AAC3B,mBAAsB;AACtB,gBAYO;AACP,kBAAmB;AAenB,IAAM,sBAAsB;AAC5B,IAAM,kCAAkC;AACxC,IAAM,0BAA0B;AAChC,IAAM,8BAA8B;AACpC,IAAM,gCAAgC;AACtC,IAAM,gCAAgC;AAEtC,SAAS,kBAAmB,EAAE,QAAQ,YAAY,QAAQ,GAA4B;AACrF,QAAM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AC;AAAA;AAAA,MACA,SAAQ;AAAA,MACR,OAAM;AAAA,MACN,SAAU;AAAA,MACV,UAAW,iBAAiB,gBAAgB,CAAE;AAAA,MAC9C,WACC,iBAAiB,eAChB,oCAAC,8BAAiB,MAAO,IAAK,OAAM,WAAU,IAC3C;AAAA;AAAA,IAGH,iBAAiB,mBAChB,gBAAI,oBAAe,WAAY,QAC/B,gBAAI,sBAAsB,WAAY;AAAA,EAC1C,CAEF,CACD,CACD,CACD,CACD,CACD;AAEF;AAEO,SAAS,eAAe;AAC9B,QAAM,CAAE,WAAW,YAAa,QAAI,uBAAyC,IAAK;AAElF,8BAAW,MAAM;AAChB,UAAM,aAAa,CAAE,UAAkB;AACtC,YAAM,cAAc;AACpB,YAAM,wBAAoB,oCAAiB;AAE3C,oCAAY;AAAA,QACX,WAAW;AAAA,QACX,aAAa,YAAY,OAAO;AAAA,QAChC,qBAAqB;AAAA,MACtB,CAAE;AAEF,UAAK,mBAAoB;AACxB,iDAAmB,YAAY,QAAQ,MAAO;AAE9C;AAAA,MACD;AAEA,mBAAc,YAAY,MAAO;AAAA,IAClC;AAEA,WAAO,iBAAkB,qBAAqB,UAAW;AAEzD,WAAO,MAAM;AACZ,aAAO,oBAAqB,qBAAqB,UAAW;AAAA,IAC7D;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,QAAS,UAAU;AAAA,MACnB,YAAa,UAAU;AAAA,MACvB,SAAU,MAAM,aAAc,IAAK;AAAA;AAAA,EACpC;AAEF;;;ADnPO,SAAS,OAAO;AACtB,mCAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/init.ts","../src/components/create-widget.tsx","../src/interpolate-links.tsx"],"sourcesContent":["export { init } from './init';\n","import { injectIntoTop } from '@elementor/editor';\n\nimport { CreateWidget } from './components/create-widget';\n\nexport function init() {\n\tinjectIntoTop( {\n\t\tid: 'create-widget',\n\t\tcomponent: CreateWidget,\n\t} );\n}\n","import * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport {\n\tinstallAngiePlugin,\n\tisAngieAvailable,\n\tredirectToAppAdmin,\n\tredirectToInstallation,\n\tsaveAngieConsent,\n\tsendPromptToAngie,\n} from '@elementor/editor-mcp';\nimport { ThemeProvider } from '@elementor/editor-ui';\nimport { trackEvent } from '@elementor/events';\nimport { XIcon } from '@elementor/icons';\nimport {\n\tButton,\n\tCheckbox,\n\tCircularProgress,\n\tDialog,\n\tDialogContent,\n\tFormControlLabel,\n\tIconButton,\n\tImage,\n\tStack,\n\tTypography,\n} from '@elementor/ui';\nimport { __, sprintf } from '@wordpress/i18n';\n\nimport { interpolateLinks } from '../interpolate-links';\n\ntype ShowModalEventDetail = {\n\tprompt?: string;\n\tentry_point: string;\n};\n\ntype InstallState = 'idle' | 'installing' | 'error';\n\ntype CreateWidgetModalProps = {\n\tprompt?: string;\n\tentryPoint: string;\n\tonClose: () => void;\n};\n\nconst CREATE_WIDGET_EVENT = 'elementor/editor/create-widget';\nconst ANGIE_MODAL_PROMOTION_IMAGE_URL = 'https://assets.elementor.com/packages/v1/images/angie-modal-promotion.png';\nconst ANGIE_CTA_CLICKED_EVENT = 'ai_widget_cta_clicked' as const;\nconst ANGIE_INSTALL_STARTED_EVENT = 'angie_install_started' as const;\nconst ANGIE_INSTALL_COMPLETED_EVENT = 'angie_install_completed' as const;\nconst ANGIE_INSTALL_ABANDONED_EVENT = 'angie_install_abandoned' as const;\n\nfunction CreateWidgetModal( { prompt, entryPoint, onClose }: CreateWidgetModalProps ) {\n\tconst [ installState, setInstallState ] = useState< InstallState >( 'idle' );\n\tconst [ agreedToTerms, setAgreedToTerms ] = useState( false );\n\n\tconst handleClose = () => {\n\t\tif ( installState === 'installing' ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttrackEvent( {\n\t\t\teventName: ANGIE_INSTALL_ABANDONED_EVENT,\n\t\t\tabandon_step: installState === 'error' ? 'install_error' : 'install_modal',\n\t\t\ttrigger_source: entryPoint,\n\t\t} );\n\n\t\tonClose();\n\t};\n\n\tconst handleInstall = async () => {\n\t\tsetInstallState( 'installing' );\n\n\t\ttrackEvent( {\n\t\t\teventName: ANGIE_INSTALL_STARTED_EVENT,\n\t\t\ttrigger_source: entryPoint,\n\t\t} );\n\n\t\tconst [ result ] = await Promise.all( [ installAngiePlugin(), saveAngieConsent() ] );\n\n\t\tif ( ! result.success ) {\n\t\t\tsetInstallState( 'error' );\n\n\t\t\treturn;\n\t\t}\n\n\t\ttrackEvent( {\n\t\t\teventName: ANGIE_INSTALL_COMPLETED_EVENT,\n\t\t\ttrigger_source: entryPoint,\n\t\t} );\n\n\t\tredirectToAppAdmin( prompt );\n\t};\n\n\tconst handleFallbackInstall = () => {\n\t\tredirectToInstallation( prompt );\n\t};\n\n\treturn (\n\t\t<ThemeProvider>\n\t\t\t<Dialog fullWidth maxWidth=\"md\" open onClose={ handleClose }>\n\t\t\t\t<IconButton\n\t\t\t\t\taria-label={ __( 'Close', 'elementor' ) }\n\t\t\t\t\tonClick={ handleClose }\n\t\t\t\t\tsx={ {\n\t\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t\tright: 8,\n\t\t\t\t\t\ttop: 8,\n\t\t\t\t\t\tzIndex: 1,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<XIcon />\n\t\t\t\t</IconButton>\n\t\t\t\t<DialogContent sx={ { p: 0, overflow: 'hidden' } }>\n\t\t\t\t\t<Stack direction=\"row\" sx={ { height: 400 } }>\n\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\tsx={ {\n\t\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\t\taspectRatio: '1 / 1',\n\t\t\t\t\t\t\t\tobjectFit: 'cover',\n\t\t\t\t\t\t\t\tobjectPosition: 'right center',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsrc={ ANGIE_MODAL_PROMOTION_IMAGE_URL }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Stack justifyContent=\"space-between\" p={ 4 }>\n\t\t\t\t\t\t\t<Stack gap={ 2.5 } justifyContent=\"center\" sx={ { flex: 1, paddingInlineEnd: 2.5 } }>\n\t\t\t\t\t\t\t\t<Typography variant=\"h4\" fontWeight={ 600 } color=\"text.secondary\">\n\t\t\t\t\t\t\t\t\t{ installState === 'error'\n\t\t\t\t\t\t\t\t\t\t? __( 'Installation failed', 'elementor' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Create custom widgets with Angie', 'elementor' ) }\n\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t<Typography variant=\"body2\">\n\t\t\t\t\t\t\t\t\t{ installState === 'error'\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t\"We couldn't install Angie automatically. Click below to install it manually.\",\n\t\t\t\t\t\t\t\t\t\t\t\t'elementor'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Build custom widgets, sections, and code using simple instructions. Install once to start building directly from the editor.',\n\t\t\t\t\t\t\t\t\t\t\t\t'elementor'\n\t\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t{ installState !== 'error' && (\n\t\t\t\t\t\t\t\t\t<FormControlLabel\n\t\t\t\t\t\t\t\t\t\tcontrol={\n\t\t\t\t\t\t\t\t\t\t\t<Checkbox\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\tchecked={ agreedToTerms }\n\t\t\t\t\t\t\t\t\t\t\t\tonChange={ (\n\t\t\t\t\t\t\t\t\t\t\t\t\t_e: React.ChangeEvent< HTMLInputElement >,\n\t\t\t\t\t\t\t\t\t\t\t\t\tchecked: boolean\n\t\t\t\t\t\t\t\t\t\t\t\t) => setAgreedToTerms( checked ) }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\t<Typography variant=\"body2\" color=\"text.secondary\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ interpolateLinks(\n\t\t\t\t\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t// translators: %1$s is the Terms link, %2$s is the Privacy Policy link.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__( 'I agree to the %1$s & %2$s.', 'elementor' ),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{{terms}}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{{privacy}}'\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tterms: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Terms', 'elementor' ),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\thref: 'https://elementor.com/terms/angie-terms-conditions/',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tprivacy: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Privacy Policy', 'elementor' ),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\thref: 'https://elementor.com/about/privacy/',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Stack>\n\t\t\t\t\t\t\t<Stack direction=\"row\" justifyContent=\"flex-end\">\n\t\t\t\t\t\t\t\t{ installState === 'error' ? (\n\t\t\t\t\t\t\t\t\t<Button variant=\"contained\" color=\"accent\" onClick={ handleFallbackInstall }>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Install Manually', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"contained\"\n\t\t\t\t\t\t\t\t\t\tcolor=\"accent\"\n\t\t\t\t\t\t\t\t\t\tonClick={ handleInstall }\n\t\t\t\t\t\t\t\t\t\tdisabled={ installState === 'installing' || ! agreedToTerms }\n\t\t\t\t\t\t\t\t\t\tstartIcon={\n\t\t\t\t\t\t\t\t\t\t\tinstallState === 'installing' ? (\n\t\t\t\t\t\t\t\t\t\t\t\t<CircularProgress size={ 18 } color=\"inherit\" />\n\t\t\t\t\t\t\t\t\t\t\t) : undefined\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ installState === 'installing'\n\t\t\t\t\t\t\t\t\t\t\t? __( 'Installing…', 'elementor' )\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Install & Activate', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Stack>\n\t\t\t\t\t\t</Stack>\n\t\t\t\t\t</Stack>\n\t\t\t\t</DialogContent>\n\t\t\t</Dialog>\n\t\t</ThemeProvider>\n\t);\n}\n\nexport function CreateWidget() {\n\tconst [ modalData, setModalData ] = useState< ShowModalEventDetail | null >( null );\n\n\tuseEffect( () => {\n\t\tconst handleShow = ( event: Event ) => {\n\t\t\tconst customEvent = event as CustomEvent< ShowModalEventDetail >;\n\t\t\tconst hasAngieInstalled = isAngieAvailable();\n\n\t\t\ttrackEvent( {\n\t\t\t\teventName: ANGIE_CTA_CLICKED_EVENT,\n\t\t\t\tentry_point: customEvent.detail.entry_point,\n\t\t\t\thas_angie_installed: hasAngieInstalled,\n\t\t\t} );\n\n\t\t\tif ( hasAngieInstalled ) {\n\t\t\t\tsendPromptToAngie( customEvent.detail?.prompt );\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetModalData( customEvent.detail );\n\t\t};\n\n\t\twindow.addEventListener( CREATE_WIDGET_EVENT, handleShow );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( CREATE_WIDGET_EVENT, handleShow );\n\t\t};\n\t}, [] );\n\n\tif ( ! modalData ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<CreateWidgetModal\n\t\t\tprompt={ modalData.prompt }\n\t\t\tentryPoint={ modalData.entry_point }\n\t\t\tonClose={ () => setModalData( null ) }\n\t\t/>\n\t);\n}\n","import * as React from 'react';\nimport { Link } from '@elementor/ui';\n\ntype LinkConfig = {\n\tlabel: string;\n\thref: string;\n};\n\ntype LinksMap = Record< string, LinkConfig >;\n\nconst LINK_PLACEHOLDER_PATTERN = /\\{\\{(\\w+)}}/g;\n\nexport const interpolateLinks = ( text: string, links: LinksMap ) => {\n\treturn text.split( LINK_PLACEHOLDER_PATTERN ).map( ( part, i ) => {\n\t\tconst link = links[ part ];\n\n\t\tif ( ! link ) {\n\t\t\treturn part;\n\t\t}\n\n\t\treturn (\n\t\t\t<Link key={ i } sx={ { px: 0.5 } } href={ link.href } target=\"_blank\" rel=\"noopener noreferrer\">\n\t\t\t\t{ link.label }\n\t\t\t</Link>\n\t\t);\n\t} );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA8B;;;ACA9B,IAAAA,SAAuB;AACvB,mBAAoC;AACpC,wBAOO;AACP,uBAA8B;AAC9B,oBAA2B;AAC3B,mBAAsB;AACtB,IAAAC,aAWO;AACP,kBAA4B;;;ACzB5B,YAA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AqB,qBAAqB,UAAW;AAAA,IAC7D;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,QAAS,UAAU;AAAA,MACnB,YAAa,UAAU;AAAA,MACvB,SAAU,MAAM,aAAc,IAAK;AAAA;AAAA,EACpC;AAEF;;;ADpPO,SAAS,OAAO;AACtB,mCAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":["React","import_ui"]}
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { injectIntoTop } from "@elementor/editor";
|
|
3
3
|
|
|
4
4
|
// src/components/create-widget.tsx
|
|
5
|
-
import * as
|
|
5
|
+
import * as React2 from "react";
|
|
6
6
|
import { useEffect, useState } from "react";
|
|
7
7
|
import {
|
|
8
8
|
installAngiePlugin,
|
|
@@ -24,11 +24,26 @@ import {
|
|
|
24
24
|
FormControlLabel,
|
|
25
25
|
IconButton,
|
|
26
26
|
Image,
|
|
27
|
-
Link,
|
|
28
27
|
Stack,
|
|
29
28
|
Typography
|
|
30
29
|
} from "@elementor/ui";
|
|
31
|
-
import { __ } from "@wordpress/i18n";
|
|
30
|
+
import { __, sprintf } from "@wordpress/i18n";
|
|
31
|
+
|
|
32
|
+
// src/interpolate-links.tsx
|
|
33
|
+
import * as React from "react";
|
|
34
|
+
import { Link } from "@elementor/ui";
|
|
35
|
+
var LINK_PLACEHOLDER_PATTERN = /\{\{(\w+)}}/g;
|
|
36
|
+
var interpolateLinks = (text, links) => {
|
|
37
|
+
return text.split(LINK_PLACEHOLDER_PATTERN).map((part, i) => {
|
|
38
|
+
const link = links[part];
|
|
39
|
+
if (!link) {
|
|
40
|
+
return part;
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */ React.createElement(Link, { key: i, sx: { px: 0.5 }, href: link.href, target: "_blank", rel: "noopener noreferrer" }, link.label);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// src/components/create-widget.tsx
|
|
32
47
|
var CREATE_WIDGET_EVENT = "elementor/editor/create-widget";
|
|
33
48
|
var ANGIE_MODAL_PROMOTION_IMAGE_URL = "https://assets.elementor.com/packages/v1/images/angie-modal-promotion.png";
|
|
34
49
|
var ANGIE_CTA_CLICKED_EVENT = "ai_widget_cta_clicked";
|
|
@@ -69,7 +84,7 @@ function CreateWidgetModal({ prompt, entryPoint, onClose }) {
|
|
|
69
84
|
const handleFallbackInstall = () => {
|
|
70
85
|
redirectToInstallation(prompt);
|
|
71
86
|
};
|
|
72
|
-
return /* @__PURE__ */
|
|
87
|
+
return /* @__PURE__ */ React2.createElement(ThemeProvider, null, /* @__PURE__ */ React2.createElement(Dialog, { fullWidth: true, maxWidth: "md", open: true, onClose: handleClose }, /* @__PURE__ */ React2.createElement(
|
|
73
88
|
IconButton,
|
|
74
89
|
{
|
|
75
90
|
"aria-label": __("Close", "elementor"),
|
|
@@ -81,8 +96,8 @@ function CreateWidgetModal({ prompt, entryPoint, onClose }) {
|
|
|
81
96
|
zIndex: 1
|
|
82
97
|
}
|
|
83
98
|
},
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
), /* @__PURE__ */
|
|
99
|
+
/* @__PURE__ */ React2.createElement(XIcon, null)
|
|
100
|
+
), /* @__PURE__ */ React2.createElement(DialogContent, { sx: { p: 0, overflow: "hidden" } }, /* @__PURE__ */ React2.createElement(Stack, { direction: "row", sx: { height: 400 } }, /* @__PURE__ */ React2.createElement(
|
|
86
101
|
Image,
|
|
87
102
|
{
|
|
88
103
|
sx: {
|
|
@@ -93,16 +108,16 @@ function CreateWidgetModal({ prompt, entryPoint, onClose }) {
|
|
|
93
108
|
},
|
|
94
109
|
src: ANGIE_MODAL_PROMOTION_IMAGE_URL
|
|
95
110
|
}
|
|
96
|
-
), /* @__PURE__ */
|
|
111
|
+
), /* @__PURE__ */ React2.createElement(Stack, { justifyContent: "space-between", p: 4 }, /* @__PURE__ */ React2.createElement(Stack, { gap: 2.5, justifyContent: "center", sx: { flex: 1, paddingInlineEnd: 2.5 } }, /* @__PURE__ */ React2.createElement(Typography, { variant: "h4", fontWeight: 600, color: "text.secondary" }, installState === "error" ? __("Installation failed", "elementor") : __("Create custom widgets with Angie", "elementor")), /* @__PURE__ */ React2.createElement(Typography, { variant: "body2" }, installState === "error" ? __(
|
|
97
112
|
"We couldn't install Angie automatically. Click below to install it manually.",
|
|
98
113
|
"elementor"
|
|
99
114
|
) : __(
|
|
100
115
|
"Build custom widgets, sections, and code using simple instructions. Install once to start building directly from the editor.",
|
|
101
116
|
"elementor"
|
|
102
|
-
)), installState !== "error" && /* @__PURE__ */
|
|
117
|
+
)), installState !== "error" && /* @__PURE__ */ React2.createElement(
|
|
103
118
|
FormControlLabel,
|
|
104
119
|
{
|
|
105
|
-
control: /* @__PURE__ */
|
|
120
|
+
control: /* @__PURE__ */ React2.createElement(
|
|
106
121
|
Checkbox,
|
|
107
122
|
{
|
|
108
123
|
size: "small",
|
|
@@ -110,34 +125,33 @@ function CreateWidgetModal({ prompt, entryPoint, onClose }) {
|
|
|
110
125
|
onChange: (_e, checked) => setAgreedToTerms(checked)
|
|
111
126
|
}
|
|
112
127
|
),
|
|
113
|
-
label: /* @__PURE__ */
|
|
114
|
-
|
|
128
|
+
label: /* @__PURE__ */ React2.createElement(Typography, { variant: "body2", color: "text.secondary" }, interpolateLinks(
|
|
129
|
+
sprintf(
|
|
130
|
+
// translators: %1$s is the Terms link, %2$s is the Privacy Policy link.
|
|
131
|
+
__("I agree to the %1$s & %2$s.", "elementor"),
|
|
132
|
+
"{{terms}}",
|
|
133
|
+
"{{privacy}}"
|
|
134
|
+
),
|
|
115
135
|
{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
sx: { px: 0.5 },
|
|
126
|
-
href: "https://elementor.com/about/privacy/",
|
|
127
|
-
target: "_blank",
|
|
128
|
-
rel: "noopener noreferrer"
|
|
129
|
-
},
|
|
130
|
-
__("Privacy Policy.", "elementor")
|
|
136
|
+
terms: {
|
|
137
|
+
label: __("Terms", "elementor"),
|
|
138
|
+
href: "https://elementor.com/terms/angie-terms-conditions/"
|
|
139
|
+
},
|
|
140
|
+
privacy: {
|
|
141
|
+
label: __("Privacy Policy", "elementor"),
|
|
142
|
+
href: "https://elementor.com/about/privacy/"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
131
145
|
))
|
|
132
146
|
}
|
|
133
|
-
)), /* @__PURE__ */
|
|
147
|
+
)), /* @__PURE__ */ React2.createElement(Stack, { direction: "row", justifyContent: "flex-end" }, installState === "error" ? /* @__PURE__ */ React2.createElement(Button, { variant: "contained", color: "accent", onClick: handleFallbackInstall }, __("Install Manually", "elementor")) : /* @__PURE__ */ React2.createElement(
|
|
134
148
|
Button,
|
|
135
149
|
{
|
|
136
150
|
variant: "contained",
|
|
137
151
|
color: "accent",
|
|
138
152
|
onClick: handleInstall,
|
|
139
153
|
disabled: installState === "installing" || !agreedToTerms,
|
|
140
|
-
startIcon: installState === "installing" ? /* @__PURE__ */
|
|
154
|
+
startIcon: installState === "installing" ? /* @__PURE__ */ React2.createElement(CircularProgress, { size: 18, color: "inherit" }) : void 0
|
|
141
155
|
},
|
|
142
156
|
installState === "installing" ? __("Installing\u2026", "elementor") : __("Install & Activate", "elementor")
|
|
143
157
|
)))))));
|
|
@@ -167,7 +181,7 @@ function CreateWidget() {
|
|
|
167
181
|
if (!modalData) {
|
|
168
182
|
return null;
|
|
169
183
|
}
|
|
170
|
-
return /* @__PURE__ */
|
|
184
|
+
return /* @__PURE__ */ React2.createElement(
|
|
171
185
|
CreateWidgetModal,
|
|
172
186
|
{
|
|
173
187
|
prompt: modalData.prompt,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/init.ts","../src/components/create-widget.tsx"],"sourcesContent":["import { injectIntoTop } from '@elementor/editor';\n\nimport { CreateWidget } from './components/create-widget';\n\nexport function init() {\n\tinjectIntoTop( {\n\t\tid: 'create-widget',\n\t\tcomponent: CreateWidget,\n\t} );\n}\n","import * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport {\n\tinstallAngiePlugin,\n\tisAngieAvailable,\n\tredirectToAppAdmin,\n\tredirectToInstallation,\n\tsaveAngieConsent,\n\tsendPromptToAngie,\n} from '@elementor/editor-mcp';\nimport { ThemeProvider } from '@elementor/editor-ui';\nimport { trackEvent } from '@elementor/events';\nimport { XIcon } from '@elementor/icons';\nimport {\n\tButton,\n\tCheckbox,\n\tCircularProgress,\n\tDialog,\n\tDialogContent,\n\tFormControlLabel,\n\tIconButton,\n\tImage,\n\tLink,\n\tStack,\n\tTypography,\n} from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\ntype ShowModalEventDetail = {\n\tprompt?: string;\n\tentry_point: string;\n};\n\ntype InstallState = 'idle' | 'installing' | 'error';\n\ntype CreateWidgetModalProps = {\n\tprompt?: string;\n\tentryPoint: string;\n\tonClose: () => void;\n};\n\nconst CREATE_WIDGET_EVENT = 'elementor/editor/create-widget';\nconst ANGIE_MODAL_PROMOTION_IMAGE_URL = 'https://assets.elementor.com/packages/v1/images/angie-modal-promotion.png';\nconst ANGIE_CTA_CLICKED_EVENT = 'ai_widget_cta_clicked' as const;\nconst ANGIE_INSTALL_STARTED_EVENT = 'angie_install_started' as const;\nconst ANGIE_INSTALL_COMPLETED_EVENT = 'angie_install_completed' as const;\nconst ANGIE_INSTALL_ABANDONED_EVENT = 'angie_install_abandoned' as const;\n\nfunction CreateWidgetModal( { prompt, entryPoint, onClose }: CreateWidgetModalProps ) {\n\tconst [ installState, setInstallState ] = useState< InstallState >( 'idle' );\n\tconst [ agreedToTerms, setAgreedToTerms ] = useState( false );\n\n\tconst handleClose = () => {\n\t\tif ( installState === 'installing' ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttrackEvent( {\n\t\t\teventName: ANGIE_INSTALL_ABANDONED_EVENT,\n\t\t\tabandon_step: installState === 'error' ? 'install_error' : 'install_modal',\n\t\t\ttrigger_source: entryPoint,\n\t\t} );\n\n\t\tonClose();\n\t};\n\n\tconst handleInstall = async () => {\n\t\tsetInstallState( 'installing' );\n\n\t\ttrackEvent( {\n\t\t\teventName: ANGIE_INSTALL_STARTED_EVENT,\n\t\t\ttrigger_source: entryPoint,\n\t\t} );\n\n\t\tconst [ result ] = await Promise.all( [ installAngiePlugin(), saveAngieConsent() ] );\n\n\t\tif ( ! result.success ) {\n\t\t\tsetInstallState( 'error' );\n\n\t\t\treturn;\n\t\t}\n\n\t\ttrackEvent( {\n\t\t\teventName: ANGIE_INSTALL_COMPLETED_EVENT,\n\t\t\ttrigger_source: entryPoint,\n\t\t} );\n\n\t\tredirectToAppAdmin( prompt );\n\t};\n\n\tconst handleFallbackInstall = () => {\n\t\tredirectToInstallation( prompt );\n\t};\n\n\treturn (\n\t\t<ThemeProvider>\n\t\t\t<Dialog fullWidth maxWidth=\"md\" open onClose={ handleClose }>\n\t\t\t\t<IconButton\n\t\t\t\t\taria-label={ __( 'Close', 'elementor' ) }\n\t\t\t\t\tonClick={ handleClose }\n\t\t\t\t\tsx={ {\n\t\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t\tright: 8,\n\t\t\t\t\t\ttop: 8,\n\t\t\t\t\t\tzIndex: 1,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<XIcon />\n\t\t\t\t</IconButton>\n\t\t\t\t<DialogContent sx={ { p: 0, overflow: 'hidden' } }>\n\t\t\t\t\t<Stack direction=\"row\" sx={ { height: 400 } }>\n\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\tsx={ {\n\t\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\t\taspectRatio: '1 / 1',\n\t\t\t\t\t\t\t\tobjectFit: 'cover',\n\t\t\t\t\t\t\t\tobjectPosition: 'right center',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsrc={ ANGIE_MODAL_PROMOTION_IMAGE_URL }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Stack justifyContent=\"space-between\" p={ 4 }>\n\t\t\t\t\t\t\t<Stack gap={ 2.5 } justifyContent=\"center\" sx={ { flex: 1, paddingInlineEnd: 2.5 } }>\n\t\t\t\t\t\t\t\t<Typography variant=\"h4\" fontWeight={ 600 } color=\"text.secondary\">\n\t\t\t\t\t\t\t\t\t{ installState === 'error'\n\t\t\t\t\t\t\t\t\t\t? __( 'Installation failed', 'elementor' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Create custom widgets with Angie', 'elementor' ) }\n\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t<Typography variant=\"body2\">\n\t\t\t\t\t\t\t\t\t{ installState === 'error'\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t\"We couldn't install Angie automatically. Click below to install it manually.\",\n\t\t\t\t\t\t\t\t\t\t\t\t'elementor'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Build custom widgets, sections, and code using simple instructions. Install once to start building directly from the editor.',\n\t\t\t\t\t\t\t\t\t\t\t\t'elementor'\n\t\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t{ installState !== 'error' && (\n\t\t\t\t\t\t\t\t\t<FormControlLabel\n\t\t\t\t\t\t\t\t\t\tcontrol={\n\t\t\t\t\t\t\t\t\t\t\t<Checkbox\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\tchecked={ agreedToTerms }\n\t\t\t\t\t\t\t\t\t\t\t\tonChange={ (\n\t\t\t\t\t\t\t\t\t\t\t\t\t_e: React.ChangeEvent< HTMLInputElement >,\n\t\t\t\t\t\t\t\t\t\t\t\t\tchecked: boolean\n\t\t\t\t\t\t\t\t\t\t\t\t) => setAgreedToTerms( checked ) }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\t<Typography variant=\"body2\" color=\"text.secondary\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'I agree to the', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\t\t\t\t\t\t\tsx={ { px: 0.5 } }\n\t\t\t\t\t\t\t\t\t\t\t\t\thref=\"https://elementor.com/terms/angie-terms-conditions/\"\n\t\t\t\t\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Terms', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( '&', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t<Link\n\t\t\t\t\t\t\t\t\t\t\t\t\tsx={ { px: 0.5 } }\n\t\t\t\t\t\t\t\t\t\t\t\t\thref=\"https://elementor.com/about/privacy/\"\n\t\t\t\t\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Privacy Policy.', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Link>\n\t\t\t\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Stack>\n\t\t\t\t\t\t\t<Stack direction=\"row\" justifyContent=\"flex-end\">\n\t\t\t\t\t\t\t\t{ installState === 'error' ? (\n\t\t\t\t\t\t\t\t\t<Button variant=\"contained\" color=\"accent\" onClick={ handleFallbackInstall }>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Install Manually', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"contained\"\n\t\t\t\t\t\t\t\t\t\tcolor=\"accent\"\n\t\t\t\t\t\t\t\t\t\tonClick={ handleInstall }\n\t\t\t\t\t\t\t\t\t\tdisabled={ installState === 'installing' || ! agreedToTerms }\n\t\t\t\t\t\t\t\t\t\tstartIcon={\n\t\t\t\t\t\t\t\t\t\t\tinstallState === 'installing' ? (\n\t\t\t\t\t\t\t\t\t\t\t\t<CircularProgress size={ 18 } color=\"inherit\" />\n\t\t\t\t\t\t\t\t\t\t\t) : undefined\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ installState === 'installing'\n\t\t\t\t\t\t\t\t\t\t\t? __( 'Installing…', 'elementor' )\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Install & Activate', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Stack>\n\t\t\t\t\t\t</Stack>\n\t\t\t\t\t</Stack>\n\t\t\t\t</DialogContent>\n\t\t\t</Dialog>\n\t\t</ThemeProvider>\n\t);\n}\n\nexport function CreateWidget() {\n\tconst [ modalData, setModalData ] = useState< ShowModalEventDetail | null >( null );\n\n\tuseEffect( () => {\n\t\tconst handleShow = ( event: Event ) => {\n\t\t\tconst customEvent = event as CustomEvent< ShowModalEventDetail >;\n\t\t\tconst hasAngieInstalled = isAngieAvailable();\n\n\t\t\ttrackEvent( {\n\t\t\t\teventName: ANGIE_CTA_CLICKED_EVENT,\n\t\t\t\tentry_point: customEvent.detail.entry_point,\n\t\t\t\thas_angie_installed: hasAngieInstalled,\n\t\t\t} );\n\n\t\t\tif ( hasAngieInstalled ) {\n\t\t\t\tsendPromptToAngie( customEvent.detail?.prompt );\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetModalData( customEvent.detail );\n\t\t};\n\n\t\twindow.addEventListener( CREATE_WIDGET_EVENT, handleShow );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( CREATE_WIDGET_EVENT, handleShow );\n\t\t};\n\t}, [] );\n\n\tif ( ! modalData ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<CreateWidgetModal\n\t\t\tprompt={ modalData.prompt }\n\t\t\tentryPoint={ modalData.entry_point }\n\t\t\tonClose={ () => setModalData( null ) }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA,SAAS,qBAAqB;;;ACA9B,YAAY,WAAW;AACvB,SAAS,WAAW,gBAAgB;AACpC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AAenB,IAAM,sBAAsB;AAC5B,IAAM,kCAAkC;AACxC,IAAM,0BAA0B;AAChC,IAAM,8BAA8B;AACpC,IAAM,gCAAgC;AACtC,IAAM,gCAAgC;AAEtC,SAAS,kBAAmB,EAAE,QAAQ,YAAY,QAAQ,GAA4B;AACrF,QAAM,CAAE,cAAc,eAAgB,IAAI,SAA0B,MAAO;AAC3E,QAAM,CAAE,eAAe,gBAAiB,IAAI,SAAU,KAAM;AAE5D,QAAM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,oCAAC,oBAAiB,MAAO,IAAK,OAAM,WAAU,IAC3C;AAAA;AAAA,IAGH,iBAAiB,eAChB,GAAI,oBAAe,WAAY,IAC/B,GAAI,sBAAsB,WAAY;AAAA,EAC1C,CAEF,CACD,CACD,CACD,CACD,CACD;AAEF;AAEO,SAAS,eAAe;AAC9B,QAAM,CAAE,WAAW,YAAa,IAAI,SAAyC,IAAK;AAElF,YAAW,MAAM;AAChB,UAAM,aAAa,CAAE,UAAkB;AACtC,YAAM,cAAc;AACpB,YAAM,oBAAoB,iBAAiB;AAE3C,iBAAY;AAAA,QACX,WAAW;AAAA,QACX,aAAa,YAAY,OAAO;AAAA,QAChC,qBAAqB;AAAA,MACtB,CAAE;AAEF,UAAK,mBAAoB;AACxB,0BAAmB,YAAY,QAAQ,MAAO;AAE9C;AAAA,MACD;AAEA,mBAAc,YAAY,MAAO;AAAA,IAClC;AAEA,WAAO,iBAAkB,qBAAqB,UAAW;AAEzD,WAAO,MAAM;AACZ,aAAO,oBAAqB,qBAAqB,UAAW;AAAA,IAC7D;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,QAAS,UAAU;AAAA,MACnB,YAAa,UAAU;AAAA,MACvB,SAAU,MAAM,aAAc,IAAK;AAAA;AAAA,EACpC;AAEF;;;ADnPO,SAAS,OAAO;AACtB,gBAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/init.ts","../src/components/create-widget.tsx","../src/interpolate-links.tsx"],"sourcesContent":["import { injectIntoTop } from '@elementor/editor';\n\nimport { CreateWidget } from './components/create-widget';\n\nexport function init() {\n\tinjectIntoTop( {\n\t\tid: 'create-widget',\n\t\tcomponent: CreateWidget,\n\t} );\n}\n","import * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport {\n\tinstallAngiePlugin,\n\tisAngieAvailable,\n\tredirectToAppAdmin,\n\tredirectToInstallation,\n\tsaveAngieConsent,\n\tsendPromptToAngie,\n} from '@elementor/editor-mcp';\nimport { ThemeProvider } from '@elementor/editor-ui';\nimport { trackEvent } from '@elementor/events';\nimport { XIcon } from '@elementor/icons';\nimport {\n\tButton,\n\tCheckbox,\n\tCircularProgress,\n\tDialog,\n\tDialogContent,\n\tFormControlLabel,\n\tIconButton,\n\tImage,\n\tStack,\n\tTypography,\n} from '@elementor/ui';\nimport { __, sprintf } from '@wordpress/i18n';\n\nimport { interpolateLinks } from '../interpolate-links';\n\ntype ShowModalEventDetail = {\n\tprompt?: string;\n\tentry_point: string;\n};\n\ntype InstallState = 'idle' | 'installing' | 'error';\n\ntype CreateWidgetModalProps = {\n\tprompt?: string;\n\tentryPoint: string;\n\tonClose: () => void;\n};\n\nconst CREATE_WIDGET_EVENT = 'elementor/editor/create-widget';\nconst ANGIE_MODAL_PROMOTION_IMAGE_URL = 'https://assets.elementor.com/packages/v1/images/angie-modal-promotion.png';\nconst ANGIE_CTA_CLICKED_EVENT = 'ai_widget_cta_clicked' as const;\nconst ANGIE_INSTALL_STARTED_EVENT = 'angie_install_started' as const;\nconst ANGIE_INSTALL_COMPLETED_EVENT = 'angie_install_completed' as const;\nconst ANGIE_INSTALL_ABANDONED_EVENT = 'angie_install_abandoned' as const;\n\nfunction CreateWidgetModal( { prompt, entryPoint, onClose }: CreateWidgetModalProps ) {\n\tconst [ installState, setInstallState ] = useState< InstallState >( 'idle' );\n\tconst [ agreedToTerms, setAgreedToTerms ] = useState( false );\n\n\tconst handleClose = () => {\n\t\tif ( installState === 'installing' ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttrackEvent( {\n\t\t\teventName: ANGIE_INSTALL_ABANDONED_EVENT,\n\t\t\tabandon_step: installState === 'error' ? 'install_error' : 'install_modal',\n\t\t\ttrigger_source: entryPoint,\n\t\t} );\n\n\t\tonClose();\n\t};\n\n\tconst handleInstall = async () => {\n\t\tsetInstallState( 'installing' );\n\n\t\ttrackEvent( {\n\t\t\teventName: ANGIE_INSTALL_STARTED_EVENT,\n\t\t\ttrigger_source: entryPoint,\n\t\t} );\n\n\t\tconst [ result ] = await Promise.all( [ installAngiePlugin(), saveAngieConsent() ] );\n\n\t\tif ( ! result.success ) {\n\t\t\tsetInstallState( 'error' );\n\n\t\t\treturn;\n\t\t}\n\n\t\ttrackEvent( {\n\t\t\teventName: ANGIE_INSTALL_COMPLETED_EVENT,\n\t\t\ttrigger_source: entryPoint,\n\t\t} );\n\n\t\tredirectToAppAdmin( prompt );\n\t};\n\n\tconst handleFallbackInstall = () => {\n\t\tredirectToInstallation( prompt );\n\t};\n\n\treturn (\n\t\t<ThemeProvider>\n\t\t\t<Dialog fullWidth maxWidth=\"md\" open onClose={ handleClose }>\n\t\t\t\t<IconButton\n\t\t\t\t\taria-label={ __( 'Close', 'elementor' ) }\n\t\t\t\t\tonClick={ handleClose }\n\t\t\t\t\tsx={ {\n\t\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t\tright: 8,\n\t\t\t\t\t\ttop: 8,\n\t\t\t\t\t\tzIndex: 1,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<XIcon />\n\t\t\t\t</IconButton>\n\t\t\t\t<DialogContent sx={ { p: 0, overflow: 'hidden' } }>\n\t\t\t\t\t<Stack direction=\"row\" sx={ { height: 400 } }>\n\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\tsx={ {\n\t\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\t\taspectRatio: '1 / 1',\n\t\t\t\t\t\t\t\tobjectFit: 'cover',\n\t\t\t\t\t\t\t\tobjectPosition: 'right center',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsrc={ ANGIE_MODAL_PROMOTION_IMAGE_URL }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Stack justifyContent=\"space-between\" p={ 4 }>\n\t\t\t\t\t\t\t<Stack gap={ 2.5 } justifyContent=\"center\" sx={ { flex: 1, paddingInlineEnd: 2.5 } }>\n\t\t\t\t\t\t\t\t<Typography variant=\"h4\" fontWeight={ 600 } color=\"text.secondary\">\n\t\t\t\t\t\t\t\t\t{ installState === 'error'\n\t\t\t\t\t\t\t\t\t\t? __( 'Installation failed', 'elementor' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Create custom widgets with Angie', 'elementor' ) }\n\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t<Typography variant=\"body2\">\n\t\t\t\t\t\t\t\t\t{ installState === 'error'\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t\"We couldn't install Angie automatically. Click below to install it manually.\",\n\t\t\t\t\t\t\t\t\t\t\t\t'elementor'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Build custom widgets, sections, and code using simple instructions. Install once to start building directly from the editor.',\n\t\t\t\t\t\t\t\t\t\t\t\t'elementor'\n\t\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t{ installState !== 'error' && (\n\t\t\t\t\t\t\t\t\t<FormControlLabel\n\t\t\t\t\t\t\t\t\t\tcontrol={\n\t\t\t\t\t\t\t\t\t\t\t<Checkbox\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\tchecked={ agreedToTerms }\n\t\t\t\t\t\t\t\t\t\t\t\tonChange={ (\n\t\t\t\t\t\t\t\t\t\t\t\t\t_e: React.ChangeEvent< HTMLInputElement >,\n\t\t\t\t\t\t\t\t\t\t\t\t\tchecked: boolean\n\t\t\t\t\t\t\t\t\t\t\t\t) => setAgreedToTerms( checked ) }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\t<Typography variant=\"body2\" color=\"text.secondary\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ interpolateLinks(\n\t\t\t\t\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t// translators: %1$s is the Terms link, %2$s is the Privacy Policy link.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__( 'I agree to the %1$s & %2$s.', 'elementor' ),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{{terms}}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{{privacy}}'\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tterms: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Terms', 'elementor' ),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\thref: 'https://elementor.com/terms/angie-terms-conditions/',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tprivacy: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Privacy Policy', 'elementor' ),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\thref: 'https://elementor.com/about/privacy/',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Stack>\n\t\t\t\t\t\t\t<Stack direction=\"row\" justifyContent=\"flex-end\">\n\t\t\t\t\t\t\t\t{ installState === 'error' ? (\n\t\t\t\t\t\t\t\t\t<Button variant=\"contained\" color=\"accent\" onClick={ handleFallbackInstall }>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Install Manually', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"contained\"\n\t\t\t\t\t\t\t\t\t\tcolor=\"accent\"\n\t\t\t\t\t\t\t\t\t\tonClick={ handleInstall }\n\t\t\t\t\t\t\t\t\t\tdisabled={ installState === 'installing' || ! agreedToTerms }\n\t\t\t\t\t\t\t\t\t\tstartIcon={\n\t\t\t\t\t\t\t\t\t\t\tinstallState === 'installing' ? (\n\t\t\t\t\t\t\t\t\t\t\t\t<CircularProgress size={ 18 } color=\"inherit\" />\n\t\t\t\t\t\t\t\t\t\t\t) : undefined\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ installState === 'installing'\n\t\t\t\t\t\t\t\t\t\t\t? __( 'Installing…', 'elementor' )\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Install & Activate', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Stack>\n\t\t\t\t\t\t</Stack>\n\t\t\t\t\t</Stack>\n\t\t\t\t</DialogContent>\n\t\t\t</Dialog>\n\t\t</ThemeProvider>\n\t);\n}\n\nexport function CreateWidget() {\n\tconst [ modalData, setModalData ] = useState< ShowModalEventDetail | null >( null );\n\n\tuseEffect( () => {\n\t\tconst handleShow = ( event: Event ) => {\n\t\t\tconst customEvent = event as CustomEvent< ShowModalEventDetail >;\n\t\t\tconst hasAngieInstalled = isAngieAvailable();\n\n\t\t\ttrackEvent( {\n\t\t\t\teventName: ANGIE_CTA_CLICKED_EVENT,\n\t\t\t\tentry_point: customEvent.detail.entry_point,\n\t\t\t\thas_angie_installed: hasAngieInstalled,\n\t\t\t} );\n\n\t\t\tif ( hasAngieInstalled ) {\n\t\t\t\tsendPromptToAngie( customEvent.detail?.prompt );\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetModalData( customEvent.detail );\n\t\t};\n\n\t\twindow.addEventListener( CREATE_WIDGET_EVENT, handleShow );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( CREATE_WIDGET_EVENT, handleShow );\n\t\t};\n\t}, [] );\n\n\tif ( ! modalData ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<CreateWidgetModal\n\t\t\tprompt={ modalData.prompt }\n\t\t\tentryPoint={ modalData.entry_point }\n\t\t\tonClose={ () => setModalData( null ) }\n\t\t/>\n\t);\n}\n","import * as React from 'react';\nimport { Link } from '@elementor/ui';\n\ntype LinkConfig = {\n\tlabel: string;\n\thref: string;\n};\n\ntype LinksMap = Record< string, LinkConfig >;\n\nconst LINK_PLACEHOLDER_PATTERN = /\\{\\{(\\w+)}}/g;\n\nexport const interpolateLinks = ( text: string, links: LinksMap ) => {\n\treturn text.split( LINK_PLACEHOLDER_PATTERN ).map( ( part, i ) => {\n\t\tconst link = links[ part ];\n\n\t\tif ( ! link ) {\n\t\t\treturn part;\n\t\t}\n\n\t\treturn (\n\t\t\t<Link key={ i } sx={ { px: 0.5 } } href={ link.href } target=\"_blank\" rel=\"noopener noreferrer\">\n\t\t\t\t{ link.label }\n\t\t\t</Link>\n\t\t);\n\t} );\n};\n"],"mappings":";AAAA,SAAS,qBAAqB;;;ACA9B,YAAYA,YAAW;AACvB,SAAS,WAAW,gBAAgB;AACpC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,IAAI,eAAe;;;ACzB5B,YAAY,WAAW;AACv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EACD,GAAG,CAAC,CAAE;AAEN,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,QAAS,UAAU;AAAA,MACnB,YAAa,UAAU;AAAA,MACvB,SAAU,MAAM,aAAc,IAAK;AAAA;AAAA,EACpC;AAEF;;;ADpPO,SAAS,OAAO;AACtB,gBAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":["React"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-widget-creation",
|
|
3
|
-
"version": "4.2.0-
|
|
3
|
+
"version": "4.2.0-895",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor": "4.2.0-
|
|
43
|
-
"@elementor/editor-mcp": "4.2.0-
|
|
44
|
-
"@elementor/editor-ui": "4.2.0-
|
|
45
|
-
"@elementor/events": "4.2.0-
|
|
42
|
+
"@elementor/editor": "4.2.0-895",
|
|
43
|
+
"@elementor/editor-mcp": "4.2.0-895",
|
|
44
|
+
"@elementor/editor-ui": "4.2.0-895",
|
|
45
|
+
"@elementor/events": "4.2.0-895",
|
|
46
46
|
"@elementor/icons": "~1.75.1",
|
|
47
47
|
"@elementor/ui": "1.37.5",
|
|
48
48
|
"@wordpress/i18n": "^5.13.0"
|
|
@@ -20,11 +20,12 @@ import {
|
|
|
20
20
|
FormControlLabel,
|
|
21
21
|
IconButton,
|
|
22
22
|
Image,
|
|
23
|
-
Link,
|
|
24
23
|
Stack,
|
|
25
24
|
Typography,
|
|
26
25
|
} from '@elementor/ui';
|
|
27
|
-
import { __ } from '@wordpress/i18n';
|
|
26
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
27
|
+
|
|
28
|
+
import { interpolateLinks } from '../interpolate-links';
|
|
28
29
|
|
|
29
30
|
type ShowModalEventDetail = {
|
|
30
31
|
prompt?: string;
|
|
@@ -150,24 +151,24 @@ function CreateWidgetModal( { prompt, entryPoint, onClose }: CreateWidgetModalPr
|
|
|
150
151
|
}
|
|
151
152
|
label={
|
|
152
153
|
<Typography variant="body2" color="text.secondary">
|
|
153
|
-
{
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
{
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
154
|
+
{ interpolateLinks(
|
|
155
|
+
sprintf(
|
|
156
|
+
// translators: %1$s is the Terms link, %2$s is the Privacy Policy link.
|
|
157
|
+
__( 'I agree to the %1$s & %2$s.', 'elementor' ),
|
|
158
|
+
'{{terms}}',
|
|
159
|
+
'{{privacy}}'
|
|
160
|
+
),
|
|
161
|
+
{
|
|
162
|
+
terms: {
|
|
163
|
+
label: __( 'Terms', 'elementor' ),
|
|
164
|
+
href: 'https://elementor.com/terms/angie-terms-conditions/',
|
|
165
|
+
},
|
|
166
|
+
privacy: {
|
|
167
|
+
label: __( 'Privacy Policy', 'elementor' ),
|
|
168
|
+
href: 'https://elementor.com/about/privacy/',
|
|
169
|
+
},
|
|
170
|
+
}
|
|
171
|
+
) }
|
|
171
172
|
</Typography>
|
|
172
173
|
}
|
|
173
174
|
/>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Link } from '@elementor/ui';
|
|
3
|
+
|
|
4
|
+
type LinkConfig = {
|
|
5
|
+
label: string;
|
|
6
|
+
href: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type LinksMap = Record< string, LinkConfig >;
|
|
10
|
+
|
|
11
|
+
const LINK_PLACEHOLDER_PATTERN = /\{\{(\w+)}}/g;
|
|
12
|
+
|
|
13
|
+
export const interpolateLinks = ( text: string, links: LinksMap ) => {
|
|
14
|
+
return text.split( LINK_PLACEHOLDER_PATTERN ).map( ( part, i ) => {
|
|
15
|
+
const link = links[ part ];
|
|
16
|
+
|
|
17
|
+
if ( ! link ) {
|
|
18
|
+
return part;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Link key={ i } sx={ { px: 0.5 } } href={ link.href } target="_blank" rel="noopener noreferrer">
|
|
23
|
+
{ link.label }
|
|
24
|
+
</Link>
|
|
25
|
+
);
|
|
26
|
+
} );
|
|
27
|
+
};
|