@elementor/editor-widget-creation 4.3.0-beta2 → 4.3.0-beta3
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 +8 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/components/create-widget.tsx +18 -8
package/dist/index.js
CHANGED
|
@@ -63,7 +63,7 @@ var interpolateLinks = (text, links) => {
|
|
|
63
63
|
|
|
64
64
|
// src/components/create-widget.tsx
|
|
65
65
|
var CREATE_WIDGET_EVENT = "elementor/editor/create-widget";
|
|
66
|
-
var ANGIE_MODAL_PROMOTION_IMAGE_URL = "https://assets.elementor.com/packages/v1/images/angie-modal-
|
|
66
|
+
var ANGIE_MODAL_PROMOTION_IMAGE_URL = "https://assets.elementor.com/packages/v1/images/angie-top-bar-promotion-modal-0926.png";
|
|
67
67
|
var ANGIE_CTA_CLICKED_EVENT = "ai_widget_cta_clicked";
|
|
68
68
|
var ANGIE_INSTALL_STARTED_EVENT = "angie_install_started";
|
|
69
69
|
var ANGIE_INSTALL_COMPLETED_EVENT = "angie_install_completed";
|
|
@@ -126,11 +126,11 @@ function CreateWidgetModal({ prompt, entryPoint, onClose }) {
|
|
|
126
126
|
},
|
|
127
127
|
src: ANGIE_MODAL_PROMOTION_IMAGE_URL
|
|
128
128
|
}
|
|
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.__)("
|
|
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") : /* @__PURE__ */ React2.createElement(React2.Fragment, null, (0, import_i18n.__)("Pages, layouts,", "elementor"), /* @__PURE__ */ React2.createElement("br", null), (0, import_i18n.__)("widgets and more", "elementor"))), /* @__PURE__ */ React2.createElement(import_ui2.Typography, { variant: "body2", fontWeight: 500 }, installState === "error" ? (0, import_i18n.__)(
|
|
130
130
|
"We couldn't install Angie automatically. Click below to install it manually.",
|
|
131
131
|
"elementor"
|
|
132
132
|
) : (0, import_i18n.__)(
|
|
133
|
-
"
|
|
133
|
+
"Ask Angie to build you full pages, custom widgets, snippets, and code directly in Elementor. Install and activate Angie once on this site to start building.",
|
|
134
134
|
"elementor"
|
|
135
135
|
)), installState !== "error" && /* @__PURE__ */ React2.createElement(
|
|
136
136
|
import_ui2.FormControlLabel,
|
|
@@ -146,7 +146,10 @@ function CreateWidgetModal({ prompt, entryPoint, onClose }) {
|
|
|
146
146
|
label: /* @__PURE__ */ React2.createElement(import_ui2.Typography, { variant: "body2", color: "text.secondary" }, interpolateLinks(
|
|
147
147
|
(0, import_i18n.sprintf)(
|
|
148
148
|
// translators: %1$s is the Terms link, %2$s is the Privacy Policy link.
|
|
149
|
-
(0, import_i18n.__)(
|
|
149
|
+
(0, import_i18n.__)(
|
|
150
|
+
"By installing, you agree to our %1$s & %2$s.",
|
|
151
|
+
"elementor"
|
|
152
|
+
),
|
|
150
153
|
"{{terms}}",
|
|
151
154
|
"{{privacy}}"
|
|
152
155
|
),
|
|
@@ -171,7 +174,7 @@ function CreateWidgetModal({ prompt, entryPoint, onClose }) {
|
|
|
171
174
|
disabled: installState === "installing" || !agreedToTerms,
|
|
172
175
|
startIcon: installState === "installing" ? /* @__PURE__ */ React2.createElement(import_ui2.CircularProgress, { size: 18, color: "inherit" }) : void 0
|
|
173
176
|
},
|
|
174
|
-
installState === "installing" ? (0, import_i18n.__)("Installing\u2026", "elementor") : (0, import_i18n.__)("Install
|
|
177
|
+
installState === "installing" ? (0, import_i18n.__)("Installing\u2026", "elementor") : (0, import_i18n.__)("Install and activate", "elementor")
|
|
175
178
|
)))))));
|
|
176
179
|
}
|
|
177
180
|
function CreateWidget() {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,YAAuB;AACvB,gBAAqB;AASrB,IAAM,2BAA2B;AAE1B,IAAM,mBAAmB,CAAE,MAAc,UAAqB;AACpE,SAAO,KAAK,MAAO,wBAAyB,EAAE,IAAK,CAAE,MAAM,MAAO;AACjE,UAAM,OAAO,MAAO,IAAK;AAEzB,QAAK,CAAE,MAAO;AACb,aAAO;AAAA,IACR;AAEA,WACC,oCAAC,kBAAK,KAAM,GAAI,IAAK,EAAE,IAAI,IAAI,GAAI,MAAO,KAAK,MAAO,QAAO,UAAS,KAAI,yBACvE,KAAK,KACR;AAAA,EAEF,CAAE;AACH;;;ADgBA,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,QAAI,uBAA0B,MAAO;AAC3E,QAAM,CAAE,eAAe,gBAAiB,QAAI,uBAAU,KAAM;AAE5D,QAAM,cAAc,MAAM;AACzB,QAAK,iBAAiB,cAAe;AACpC;AAAA,IACD;AAEA,kCAAY;AAAA,MACX,WAAW;AAAA,MACX,cAAc,iBAAiB,UAAU,kBAAkB;AAAA,MA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,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;;;ADpPO,SAAS,OAAO;AACtB,mCAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":["React","import_ui"]}
|
|
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 =\n\t'https://assets.elementor.com/packages/v1/images/angie-top-bar-promotion-modal-0926.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) : (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Pages, layouts,', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'widgets and more', 'elementor' ) }\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</Typography>\n\t\t\t\t\t\t\t\t<Typography variant=\"body2\" fontWeight={ 500 }>\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'Ask Angie to build you full pages, custom widgets, snippets, and code directly in Elementor. Install and activate Angie once on this site to start building.',\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__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'By installing, you agree to our %1$s & %2$s.',\n\t\t\t\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\t\t),\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 and 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;A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E9C;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;;;AD9PO,SAAS,OAAO;AACtB,mCAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":["React","import_ui"]}
|
package/dist/index.mjs
CHANGED
|
@@ -45,7 +45,7 @@ var interpolateLinks = (text, links) => {
|
|
|
45
45
|
|
|
46
46
|
// src/components/create-widget.tsx
|
|
47
47
|
var CREATE_WIDGET_EVENT = "elementor/editor/create-widget";
|
|
48
|
-
var ANGIE_MODAL_PROMOTION_IMAGE_URL = "https://assets.elementor.com/packages/v1/images/angie-modal-
|
|
48
|
+
var ANGIE_MODAL_PROMOTION_IMAGE_URL = "https://assets.elementor.com/packages/v1/images/angie-top-bar-promotion-modal-0926.png";
|
|
49
49
|
var ANGIE_CTA_CLICKED_EVENT = "ai_widget_cta_clicked";
|
|
50
50
|
var ANGIE_INSTALL_STARTED_EVENT = "angie_install_started";
|
|
51
51
|
var ANGIE_INSTALL_COMPLETED_EVENT = "angie_install_completed";
|
|
@@ -108,11 +108,11 @@ function CreateWidgetModal({ prompt, entryPoint, onClose }) {
|
|
|
108
108
|
},
|
|
109
109
|
src: ANGIE_MODAL_PROMOTION_IMAGE_URL
|
|
110
110
|
}
|
|
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") : __("
|
|
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") : /* @__PURE__ */ React2.createElement(React2.Fragment, null, __("Pages, layouts,", "elementor"), /* @__PURE__ */ React2.createElement("br", null), __("widgets and more", "elementor"))), /* @__PURE__ */ React2.createElement(Typography, { variant: "body2", fontWeight: 500 }, installState === "error" ? __(
|
|
112
112
|
"We couldn't install Angie automatically. Click below to install it manually.",
|
|
113
113
|
"elementor"
|
|
114
114
|
) : __(
|
|
115
|
-
"
|
|
115
|
+
"Ask Angie to build you full pages, custom widgets, snippets, and code directly in Elementor. Install and activate Angie once on this site to start building.",
|
|
116
116
|
"elementor"
|
|
117
117
|
)), installState !== "error" && /* @__PURE__ */ React2.createElement(
|
|
118
118
|
FormControlLabel,
|
|
@@ -128,7 +128,10 @@ function CreateWidgetModal({ prompt, entryPoint, onClose }) {
|
|
|
128
128
|
label: /* @__PURE__ */ React2.createElement(Typography, { variant: "body2", color: "text.secondary" }, interpolateLinks(
|
|
129
129
|
sprintf(
|
|
130
130
|
// translators: %1$s is the Terms link, %2$s is the Privacy Policy link.
|
|
131
|
-
__(
|
|
131
|
+
__(
|
|
132
|
+
"By installing, you agree to our %1$s & %2$s.",
|
|
133
|
+
"elementor"
|
|
134
|
+
),
|
|
132
135
|
"{{terms}}",
|
|
133
136
|
"{{privacy}}"
|
|
134
137
|
),
|
|
@@ -153,7 +156,7 @@ function CreateWidgetModal({ prompt, entryPoint, onClose }) {
|
|
|
153
156
|
disabled: installState === "installing" || !agreedToTerms,
|
|
154
157
|
startIcon: installState === "installing" ? /* @__PURE__ */ React2.createElement(CircularProgress, { size: 18, color: "inherit" }) : void 0
|
|
155
158
|
},
|
|
156
|
-
installState === "installing" ? __("Installing\u2026", "elementor") : __("Install
|
|
159
|
+
installState === "installing" ? __("Installing\u2026", "elementor") : __("Install and activate", "elementor")
|
|
157
160
|
)))))));
|
|
158
161
|
}
|
|
159
162
|
function CreateWidget() {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;AACvB,SAAS,YAAY;AASrB,IAAM,2BAA2B;AAE1B,IAAM,mBAAmB,CAAE,MAAc,UAAqB;AACpE,SAAO,KAAK,MAAO,wBAAyB,EAAE,IAAK,CAAE,MAAM,MAAO;AACjE,UAAM,OAAO,MAAO,IAAK;AAEzB,QAAK,CAAE,MAAO;AACb,aAAO;AAAA,IACR;AAEA,WACC,oCAAC,QAAK,KAAM,GAAI,IAAK,EAAE,IAAI,IAAI,GAAI,MAAO,KAAK,MAAO,QAAO,UAAS,KAAI,yBACvE,KAAK,KACR;AAAA,EAEF,CAAE;AACH;;;ADgBA,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,cAAc,M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Ae,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;;;ADpPO,SAAS,OAAO;AACtB,gBAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;","names":["React"]}
|
|
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 =\n\t'https://assets.elementor.com/packages/v1/images/angie-top-bar-promotion-modal-0926.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) : (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Pages, layouts,', 'elementor' ) }\n\t\t\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'widgets and more', 'elementor' ) }\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</Typography>\n\t\t\t\t\t\t\t\t<Typography variant=\"body2\" fontWeight={ 500 }>\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'Ask Angie to build you full pages, custom widgets, snippets, and code directly in Elementor. Install and activate Angie once on this site to start building.',\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__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'By installing, you agree to our %1$s & %2$s.',\n\t\t\t\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\t\t),\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 and 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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AAc;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;;;AD9PO,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.3.0-
|
|
3
|
+
"version": "4.3.0-beta3",
|
|
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.3.0-
|
|
43
|
-
"@elementor/editor-mcp": "4.3.0-
|
|
44
|
-
"@elementor/editor-ui": "4.3.0-
|
|
45
|
-
"@elementor/events": "4.3.0-
|
|
42
|
+
"@elementor/editor": "4.3.0-beta3",
|
|
43
|
+
"@elementor/editor-mcp": "4.3.0-beta3",
|
|
44
|
+
"@elementor/editor-ui": "4.3.0-beta3",
|
|
45
|
+
"@elementor/events": "4.3.0-beta3",
|
|
46
46
|
"@elementor/icons": "~1.75.1",
|
|
47
47
|
"@elementor/ui": "1.37.5",
|
|
48
48
|
"@wordpress/i18n": "^5.13.0"
|
|
@@ -41,7 +41,8 @@ type CreateWidgetModalProps = {
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
const CREATE_WIDGET_EVENT = 'elementor/editor/create-widget';
|
|
44
|
-
const ANGIE_MODAL_PROMOTION_IMAGE_URL =
|
|
44
|
+
const ANGIE_MODAL_PROMOTION_IMAGE_URL =
|
|
45
|
+
'https://assets.elementor.com/packages/v1/images/angie-top-bar-promotion-modal-0926.png';
|
|
45
46
|
const ANGIE_CTA_CLICKED_EVENT = 'ai_widget_cta_clicked' as const;
|
|
46
47
|
const ANGIE_INSTALL_STARTED_EVENT = 'angie_install_started' as const;
|
|
47
48
|
const ANGIE_INSTALL_COMPLETED_EVENT = 'angie_install_completed' as const;
|
|
@@ -122,18 +123,24 @@ function CreateWidgetModal( { prompt, entryPoint, onClose }: CreateWidgetModalPr
|
|
|
122
123
|
<Stack justifyContent="space-between" p={ 4 }>
|
|
123
124
|
<Stack gap={ 2.5 } justifyContent="center" sx={ { flex: 1, paddingInlineEnd: 2.5 } }>
|
|
124
125
|
<Typography variant="h4" fontWeight={ 600 } color="text.secondary">
|
|
125
|
-
{ installState === 'error'
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
{ installState === 'error' ? (
|
|
127
|
+
__( 'Installation failed', 'elementor' )
|
|
128
|
+
) : (
|
|
129
|
+
<>
|
|
130
|
+
{ __( 'Pages, layouts,', 'elementor' ) }
|
|
131
|
+
<br />
|
|
132
|
+
{ __( 'widgets and more', 'elementor' ) }
|
|
133
|
+
</>
|
|
134
|
+
) }
|
|
128
135
|
</Typography>
|
|
129
|
-
<Typography variant="body2">
|
|
136
|
+
<Typography variant="body2" fontWeight={ 500 }>
|
|
130
137
|
{ installState === 'error'
|
|
131
138
|
? __(
|
|
132
139
|
"We couldn't install Angie automatically. Click below to install it manually.",
|
|
133
140
|
'elementor'
|
|
134
141
|
)
|
|
135
142
|
: __(
|
|
136
|
-
'
|
|
143
|
+
'Ask Angie to build you full pages, custom widgets, snippets, and code directly in Elementor. Install and activate Angie once on this site to start building.',
|
|
137
144
|
'elementor'
|
|
138
145
|
) }
|
|
139
146
|
</Typography>
|
|
@@ -154,7 +161,10 @@ function CreateWidgetModal( { prompt, entryPoint, onClose }: CreateWidgetModalPr
|
|
|
154
161
|
{ interpolateLinks(
|
|
155
162
|
sprintf(
|
|
156
163
|
// translators: %1$s is the Terms link, %2$s is the Privacy Policy link.
|
|
157
|
-
__(
|
|
164
|
+
__(
|
|
165
|
+
'By installing, you agree to our %1$s & %2$s.',
|
|
166
|
+
'elementor'
|
|
167
|
+
),
|
|
158
168
|
'{{terms}}',
|
|
159
169
|
'{{privacy}}'
|
|
160
170
|
),
|
|
@@ -193,7 +203,7 @@ function CreateWidgetModal( { prompt, entryPoint, onClose }: CreateWidgetModalPr
|
|
|
193
203
|
>
|
|
194
204
|
{ installState === 'installing'
|
|
195
205
|
? __( 'Installing…', 'elementor' )
|
|
196
|
-
: __( 'Install
|
|
206
|
+
: __( 'Install and activate', 'elementor' ) }
|
|
197
207
|
</Button>
|
|
198
208
|
) }
|
|
199
209
|
</Stack>
|