diff --git a/335.74280ace.chunk.js.download b/335.74280ace.chunk.js.download new file mode 100644 index 0000000..110f72a --- /dev/null +++ b/335.74280ace.chunk.js.download @@ -0,0 +1,28 @@ +(this["webpackJsonp@builder.io/app"]=this["webpackJsonp@builder.io/app"]||[]).push([[335],{6329:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__);var _emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1),_builder_io_react__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(19),lodash__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(6),lodash__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_3__),dedent__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(277),dedent__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(dedent__WEBPACK_IMPORTED_MODULE_4__),_functions_async_component_function__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(27),_functions_fast_clone_function__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(25),_material_ui_icons__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(665),_material_ui_icons__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(_material_ui_icons__WEBPACK_IMPORTED_MODULE_7__),_material_ui_core__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(105),_material_ui_core__WEBPACK_IMPORTED_MODULE_8___default=__webpack_require__.n(_material_ui_core__WEBPACK_IMPORTED_MODULE_8__),_designer_components_HelpButton__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(222),mobx_react__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__(90),_components_TextLink__WEBPACK_IMPORTED_MODULE_11__=__webpack_require__(84),_functions_get_code_without_comments__WEBPACK_IMPORTED_MODULE_12__=__webpack_require__(860);const AsyncMonacoEditor=Object(_functions_async_component_function__WEBPACK_IMPORTED_MODULE_5__.a)(async()=>(await Promise.all([__webpack_require__.e(0),__webpack_require__.e(8)]).then(__webpack_require__.t.bind(null,2625,7))).default),defaultCode=dedent__WEBPACK_IMPORTED_MODULE_4___default()(` +/* +* Run custom logic to determine the current preview URL +* +* Be sure to always return a string representing preview url at the end +* +* Available objects: +* content: a json representation of the current state of content. e.g. you can access things like \`content.data.title\` +* space: the current space settings, including properties like \`space.publicKey\` +* targeting: an object representing the content targeting settings, for example: \`targeting.urlPath\` +* fetch: You can run async code with \`fetch\`, such as: \`const settings = await fetch('...');\` +* contentModel: the current content model, including helper properties like \`contentModel.isLive\` +* previewDevice: 'mobile' , 'tablet', or 'desktop' +* locale: the value of the locale in the locale picker +* +* Learn more about dynamic preview URLs: https://www.builder.io/c/docs/dynamic-preview-urls +* +* Example: +* +* return \`https://my-site.com/\${targeting.locales[0]}\${targeting.urlPath}\`; +*/ +`);_builder_io_react__WEBPACK_IMPORTED_MODULE_2__.Builder.register("editor.onLoad",({safeReaction,updatePreviewUrl})=>{safeReaction(()=>{var _a,_b;return _constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.editingContentModel&&((_a=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.user.organization)===null||_a===void 0?void 0:_a.value.settings.editorEnableEditingUrlLogic)&&((_b=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.editingModel)===null||_b===void 0?void 0:_b.editingUrlLogic)},enable=>{var _a,_b;const codeWithoutComments=Object(_functions_get_code_without_comments__WEBPACK_IMPORTED_MODULE_12__.a)((_a=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.editingModel)===null||_a===void 0?void 0:_a.editingUrlLogic);enable&&codeWithoutComments?safeReaction(()=>{if(!_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.editingContentModel)return null;const{data,query,published}=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.editingContentModel,previewDevice=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.artboardSize.previewDevice;return JSON.stringify({data:Object(lodash__WEBPACK_IMPORTED_MODULE_3__.omit)(Object(_functions_fast_clone_function__WEBPACK_IMPORTED_MODULE_6__.b)(data),["jsCode","cssCode","responsiveStyles","blocks","blocksString"]),query,published,previewDevice,locale:_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.locale})},Object(lodash__WEBPACK_IMPORTED_MODULE_3__.debounce)(async()=>{var _a2,_b2,_c,_d,_e;const editingUrlLogic=(_a2=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.editingModel)===null||_a2===void 0?void 0:_a2.editingUrlLogic,content=Object(_functions_fast_clone_function__WEBPACK_IMPORTED_MODULE_6__.b)(_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.editingContentModel),space={siteUrl:(_c=(_b2=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.user.organization)===null||_b2===void 0?void 0:_b2.value)===null||_c===void 0?void 0:_c.siteUrl,publicKey:_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.user.apiKey,name:(_e=(_d=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.user.organization)===null||_d===void 0?void 0:_d.value)===null||_e===void 0?void 0:_e.name},targeting=content.query.reduce((acc,q)=>Object.assign(Object.assign({},acc),{[q.property]:q.value}),{}),fn=new Function("content","targeting","space","contentModel","previewDevice","locale",` + async function code() { + ${editingUrlLogic} + } + + return code(); + `);try{const result=await fn(content,targeting,space,_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.editingContentModel,_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.artboardSize.previewDevice,_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.locale),previewUrl=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.editingContentModel.previewUrl;result!==previewUrl&&updatePreviewUrl(result)}catch(err){console.error(" error running preview logic ",err)}},600)):!((_b=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.editingContentModel)===null||_b===void 0)&&_b.previewUrl&&!codeWithoutComments&&updatePreviewUrl(null)})}),_builder_io_react__WEBPACK_IMPORTED_MODULE_2__.Builder.register("model.editingUrl.action",{tooltip:Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.c)(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.a,{children:["Edit"," ",Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(_components_TextLink__WEBPACK_IMPORTED_MODULE_11__.a,Object.assign({target:"_blank",href:"https://www.builder.io/c/docs/dynamic-preview-urls",css:{color:"var(--primary-color-very-light)"}},{children:"dynamic preview URL"}))]}),icon:()=>Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(mobx_react__WEBPACK_IMPORTED_MODULE_10__.a,{children:()=>{var _a;return Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(_material_ui_icons__WEBPACK_IMPORTED_MODULE_7___default.a,{css:{fontSize:18,color:!((_a=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.designerState.editingModel)===null||_a===void 0)&&_a.dynamicUrlProps.isDynamicUrlAdded?"var(--primary-color)":void 0}})}}),showIf(){var _a;return!!(((_a=_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.user.organization)===null||_a===void 0?void 0:_a.value.settings.editorEnableEditingUrlLogic)&&_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.user.can("editCode"))},async onClick(model){await _constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.globalState.openDialog(Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.c)("div",Object.assign({css:{margin:20}},{children:[Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.c)(_material_ui_core__WEBPACK_IMPORTED_MODULE_8___default.a,Object.assign({variant:"h4",css:{textAlign:"center",marginBottom:10,fontSize:18}},{children:["Dynamic Preview URL"," ",Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(_designer_components_HelpButton__WEBPACK_IMPORTED_MODULE_9__.a,{css:{position:"static",padding:5,marginTop:-4},iconStyle:{color:void 0},link:"https://www.builder.io/c/docs/dynamic-preview-urls",tooltipProps:{interactive:!0,leaveDelay:150},title:Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.c)(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.a,{children:["Dynamically set your preview URL via"," ",Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(_components_TextLink__WEBPACK_IMPORTED_MODULE_11__.a,Object.assign({target:"_blank",href:"https://www.builder.io/c/docs/dynamic-preview-urls",css:{color:_constants_app_state_constant__WEBPACK_IMPORTED_MODULE_1__.appState.theme.colors.primaryLight}},{children:"custom logic"}))]})})]})),Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)("div",Object.assign({css:{height:"80vh",width:"90vw",maxWidth:"100%",border:"var(--border)",borderRadius:4,overflow:"hidden"}},{children:Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)("div",Object.assign({css:{height:"100%",width:"100%"},className:"dark-mode-invert"},{children:Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(AsyncMonacoEditor,{theme:"vs-dark",options:{automaticLayout:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,renderLineHighlight:"none",scrollbar:{horizontal:"hidden",vertical:"hidden"}},language:"javascript",defaultValue:model.editingUrlLogic||defaultCode,onChange:val=>{model.editingUrlLogic=val}})}))}))]})))}})}}]);