forked from bombastictranz/demo-editor
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
270.c17dd13d.chunk.js.download
1 lines (1 loc) · 8.87 KB
/
270.c17dd13d.chunk.js.download
1
(this["webpackJsonp@builder.io/app"]=this["webpackJsonp@builder.io/app"]||[]).push([[270],{2650:function(module,exports,__webpack_require__){"use strict";var _interopRequireDefault=__webpack_require__(49);Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _react=_interopRequireDefault(__webpack_require__(3)),_createSvgIcon=_interopRequireDefault(__webpack_require__(51)),_default=(0,_createSvgIcon.default)(_react.default.createElement("g",null,_react.default.createElement("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})),"Fullscreen");exports.default=_default},3551:function(module,exports,__webpack_require__){module.exports=__webpack_require__.p+"static/media/code.0effbf87.svg"},4734:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"CodeEditor",function(){return CodeEditor});var _emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),_builder_io_react__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(19),_material_ui_core__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(131),_material_ui_core__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_material_ui_core__WEBPACK_IMPORTED_MODULE_2__),_material_ui_core__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(113),_material_ui_core__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(_material_ui_core__WEBPACK_IMPORTED_MODULE_3__),_material_ui_core__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(130),_material_ui_core__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(_material_ui_core__WEBPACK_IMPORTED_MODULE_4__),_material_ui_core__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(105),_material_ui_core__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(_material_ui_core__WEBPACK_IMPORTED_MODULE_5__),_material_ui_core__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(126),_material_ui_core__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(_material_ui_core__WEBPACK_IMPORTED_MODULE_6__),_material_ui_icons__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(2650),_material_ui_icons__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(_material_ui_icons__WEBPACK_IMPORTED_MODULE_7__),_material_ui_icons__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(573),_material_ui_icons__WEBPACK_IMPORTED_MODULE_8___default=__webpack_require__.n(_material_ui_icons__WEBPACK_IMPORTED_MODULE_8__),mobx_react__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(90),_constants_theme_constant__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__(7),_functions_async_component_function__WEBPACK_IMPORTED_MODULE_11__=__webpack_require__(27),_assets_code_svg__WEBPACK_IMPORTED_MODULE_12__=__webpack_require__(3551),_assets_code_svg__WEBPACK_IMPORTED_MODULE_12___default=__webpack_require__.n(_assets_code_svg__WEBPACK_IMPORTED_MODULE_12__);const AsyncMonacoEditor=Object(_functions_async_component_function__WEBPACK_IMPORTED_MODULE_11__.a)(async()=>(await Promise.all([__webpack_require__.e(0),__webpack_require__.e(8)]).then(__webpack_require__.t.bind(null,2625,7))).default);function LanguageOptions(){return Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.c)(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.a,{children:[Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)("option",Object.assign({value:"javascript"},{children:"Javascript"})),Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)("option",Object.assign({value:"html"},{children:"HTML"})),Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)("option",Object.assign({value:"css"},{children:"CSS"})),Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)("option",Object.assign({value:""},{children:"Other"}))]})}function guessLanguage(value){if(!value?.trim())return"";if(value.trim().startsWith("<"))return"html";const cssRegex=/(?:^|[\s\S]*{)\s*[\w-]+\s*:\s*[\w\s-]+(?:;|$)/i;if(value.match(cssRegex))return"css";if(value.includes("function"))return"javascript"}function CodeEditor(props){const state=Object(mobx_react__WEBPACK_IMPORTED_MODULE_9__.f)(()=>({editFullScreen:!1,overrideLanguage:""}));return Object(mobx_react__WEBPACK_IMPORTED_MODULE_9__.g)(()=>{var _a,_b,_c;const language=((_b=(_a=props.field.options)===null||_a===void 0?void 0:_a.get)===null||_b===void 0?void 0:_b.call(_a,"language"))||((_c=props.field.options)===null||_c===void 0?void 0:_c.language),getEditor=()=>Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(AsyncMonacoEditor,{theme:"vs-dark",language:language||state.overrideLanguage||guessLanguage(props.value),options:Object.assign({},!state.editFullScreen&&{lineNumbers:"off",minimap:{enabled:!1},folding:!1,renderLineHighlight:"none",scrollBeyondLastLine:!1,scrollbar:{horizontal:"hidden",vertical:"hidden"}}),editorDidMount:editor=>{var _a2;(_a2=editor.getModel())===null||_a2===void 0||_a2.updateOptions({tabSize:2})},value:props.value,onChange:props.onChange});return Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.c)("div",Object.assign({css:{borderRadius:4,position:"relative",marginBottom:10}},{children:[Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.c)("div",Object.assign({css:{display:"flex",alignItems:"center",marginTop:-10}},{children:[Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)("div",{css:{flexGrow:1}}),!language&&Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)("select",Object.assign({css:{border:"none",opacity:.7,background:"transparent"},value:state.overrideLanguage||guessLanguage(props.value),onChange:e=>state.overrideLanguage=e.target.value},{children:Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(LanguageOptions,{})})),Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(_material_ui_core__WEBPACK_IMPORTED_MODULE_2___default.a,Object.assign({title:"Edit full screen",placement:"left"},{children:Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(_material_ui_core__WEBPACK_IMPORTED_MODULE_3___default.a,Object.assign({css:{color:state.editFullScreen?_constants_theme_constant__WEBPACK_IMPORTED_MODULE_10__.a.colors.primary:"#555",padding:10},onClick:()=>state.editFullScreen=!state.editFullScreen},{children:Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(_material_ui_icons__WEBPACK_IMPORTED_MODULE_7___default.a,{css:{fontSize:18}})}))}))]})),Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(_material_ui_core__WEBPACK_IMPORTED_MODULE_4___default.a,Object.assign({maxWidth:!1,open:state.editFullScreen},{children:Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.c)("div",Object.assign({css:{padding:20,backgroundColor:"var(--off-background)"}},{children:[Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.c)("div",Object.assign({css:{position:"relative",marginTop:-10,marginBottom:10}},{children:[Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(_material_ui_core__WEBPACK_IMPORTED_MODULE_5___default.a,Object.assign({css:{textAlign:"center"},variant:"subheading"},{children:"Edit code"})),!language&&Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)("select",Object.assign({css:{border:"none",position:"absolute",top:5,right:40,background:"transparent",color:"var(--text-light)"},value:state.overrideLanguage,onChange:e=>state.overrideLanguage=e.target.value},{children:Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(LanguageOptions,{})}))]})),Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(_material_ui_core__WEBPACK_IMPORTED_MODULE_3___default.a,Object.assign({css:{position:"absolute",right:0,top:0},onClick:()=>state.editFullScreen=!1},{children:Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(_material_ui_icons__WEBPACK_IMPORTED_MODULE_8___default.a,{css:{color:"var(--text-caption)"}})})),Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(_material_ui_core__WEBPACK_IMPORTED_MODULE_6___default.a,Object.assign({css:{display:"flex",flexDirection:"column",alignItems:"stretch",overflow:"hidden",width:"80vw",height:"80vh"}},{children:Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)("div",Object.assign({className:"dark-mode-invert",css:{height:"100%",width:"100%"}},{children:getEditor()}))}))]}))})),Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)(_material_ui_core__WEBPACK_IMPORTED_MODULE_6___default.a,Object.assign({css:{overflow:"hidden"}},{children:Object(_emotion_react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.b)("div",Object.assign({className:"dark-mode-invert",css:{height:300,width:"100%"}},{children:getEditor()}))}))]}))})}_builder_io_react__WEBPACK_IMPORTED_MODULE_1__.Builder.registerEditor({name:"code",description:"Custom code field",icon:_assets_code_svg__WEBPACK_IMPORTED_MODULE_12___default.a,inputs:[{"@type":"@builder.io/core:Field",name:"language",type:"string"}],component:CodeEditor,hideFromTargeting:!0})}}]);