dootask/public/js/build/AceEditor.aec2f4a1.js
2025-11-30 12:18:18 +08:00

2 lines
5.6 KiB
JavaScript
Vendored

import{m as p}from"./vuex.cc7cb26e.js";import{n as h}from"./app.1c2a0fa1.js";import"./jquery.ce39e51d.js";import"./@babel.f9bcab46.js";import"./dayjs.23d8b964.js";import"./localforage.f1b1079d.js";import"./markdown-it.bda97caf.js";import"./mdurl.ce6c1dd8.js";import"./uc.micro.8d343c98.js";import"./entities.48a44fec.js";import"./linkify-it.c5e8196e.js";import"./punycode.js.4b3f125a.js";import"./highlight.js.ab8aeea4.js";import"./markdown-it-link-attributes.e1d5d151.js";import"./@traptitech.897ae552.js";import"./vue.fd9b772e.js";import"./openpgp_hi.15f91b1d.js";import"./axios.79c8b3d5.js";import"./mitt.1ea0a2a3.js";import"./quill-hi.654cb53d.js";import"./parchment.d5c5924e.js";import"./quill-delta.f1b7ce48.js";import"./fast-diff.f17881f3.js";import"./lodash.clonedeep.e8ef3f14.js";import"./lodash.isequal.d6a986d0.js";import"./eventemitter3.78b735ad.js";import"./lodash-es.df04b444.js";import"./quill-mention-hi.41f02fd4.js";import"./view-design-hi.75f80746.js";import"./html-to-md.8a9a8796.js";import"./vue-router.2d566cd7.js";import"./vue-clipboard2.50be9c5e.js";import"./clipboard.058ef547.js";import"./vuedraggable.9fd6afed.js";import"./sortablejs.d74243d9.js";import"./vue-resize-observer.c3c9ca4e.js";import"./element-sea.1d49e96e.js";import"./deepmerge.cecf392e.js";import"./resize-observer-polyfill.0bdc1850.js";import"./throttle-debounce.7c3948b2.js";import"./babel-helper-vue-jsx-merge-props.5ed215c3.js";import"./normalize-wheel.2a034b9f.js";import"./async-validator.49abba38.js";import"./babel-runtime.4773988a.js";import"./core-js.314b4a1d.js";const m={name:"AceEditor",props:{value:{default:""},options:{type:Object,default:()=>({})},theme:{type:String,default:"auto"},ext:{type:String,default:"txt"},height:{type:Number||null,default:null},width:{type:Number||null,default:null},wrap:{type:Boolean,default:!1},readOnly:{type:Boolean,default:!1}},render(t){return t("div",{class:"no-dark-content"})},data:()=>({code:"",editor:null,cursorPosition:{row:0,column:0},supportedModes:{Apache_Conf:["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],BatchFile:["bat|cmd"],C_Cpp:["cpp|c|cc|cxx|h|hh|hpp|ino"],CSharp:["cs"],CSS:["css"],Dockerfile:["^Dockerfile"],golang:["go|golang"],HTML:["html|htm|xhtml|vue|we|wpy"],Java:["java"],JavaScript:["js|jsm|jsx"],JSON:["json"],JSP:["jsp"],LESS:["less"],Lua:["lua"],Makefile:["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],Markdown:["md|markdown"],MySQL:["mysql"],Nginx:["nginx|conf"],INI:["ini|conf|cfg|prefs"],ObjectiveC:["m|mm"],Perl:["pl|pm"],Perl6:["p6|pl6|pm6"],pgSQL:["pgsql"],PHP_Laravel_blade:["blade.php"],PHP:["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],Powershell:["ps1"],Python:["py"],R:["r"],Ruby:["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],Rust:["rs"],SASS:["sass"],SCSS:["scss"],SH:["sh|bash|^.bashrc"],SQL:["sql"],SQLServer:["sqlserver"],Swift:["swift"],Text:["txt"],Typescript:["ts|typescript|str"],VBScript:["vbs|vb"],Verilog:["v|vh|sv|svh"],XML:["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml|plist"],YAML:["yaml|yml"],Compress:["tar|zip|7z|rar|gz|arj|z"],images:["icon|jpg|jpeg|webp|png|bmp|gif|tif|emf"]}}),mounted(){$A.loadScriptS(["js/ace/ace.js","js/ace/mode-json.js"]).then(t=>{this.setSize(this.$el,{height:this.height,width:this.width}),this.editor=window.ace.edit(this.$el,{wrap:this.wrap,showPrintMargin:!1,readOnly:this.readOnly,keyboardHandler:"vscode"}),this.editor.session.setMode(`ace/mode/${this.getFileMode()}`),this.$emit("mounted",this.editor),this.editor.session.$worker&&this.editor.session.$worker.addEventListener("annotate",this.workerMessage,!1),this.setValue(this.value),this.editor.setOptions(this.options),this.editTheme&&this.editor.setTheme(`ace/theme/${this.editTheme}`),this.editor.commands.addCommand({name:"\u4FDD\u5B58\u6587\u4EF6",bindKey:{win:"Ctrl-S",mac:"Command-S"},exec:()=>{this.$emit("saveData")},readOnly:!1}),this.editor.getSession().on("change",()=>{this.code=this.editor.getValue(),this.$emit("input",this.code)})})},methods:{workerMessage({data:t}){this.cursorPosition=this.editor.selection.getCursor();const[e]=t;e&&e.type==="error"?this.$emit("validationFailed",e):this.$emit("change",this.editor.getValue())},setSize(t,{width:e=this.width,height:i=this.height}){t.style.width=e&&typeof e=="number"?`${e}px`:"100%",t.style.height=i&&typeof i=="number"?`${i}px`:"100%",this.$nextTick(()=>this.editor&&this.editor.resize())},setValue(t){typeof t=="string"&&this.editor&&(this.editor.setValue(t),this.editor.clearSelection())},getFileMode(){var t=this.ext||"text";for(var e in this.supportedModes)for(var i=this.supportedModes[e],r=i[0].split("|"),a=e.toLowerCase(),s=0;s<r.length;s++)if(t==r[s])return a;return"text"}},computed:{...p(["themeName"]),editTheme(){return this.theme=="auto"?this.themeName==="dark"?"dracula-dark":"chrome":this.theme}},watch:{options(t){t&&typeof t=="object"&&this.editor&&this.editor.setOptions(t)},editTheme(t){t&&typeof t=="string"&&this.editor&&this.editor.setTheme(`ace/theme/${t}`)},ext(t){t&&typeof t=="string"&&this.editor&&this.editor.session.setMode(`ace/mode/${this.getFileMode()}`)},width(t){this.setSize(this.el,{width:t})},height(t){this.setSize(this.el,{height:t})},readOnly(t){typeof t=="boolean"&&this.editor&&this.editor.setReadOnly(t)},value(t){if(!this.editor||t==this.code)return;this.setValue(t);const{row:e,column:i}=this.cursorPosition;this.editor.selection.moveCursorTo(e,i)}},beforeDestroy(){this.editor&&(this.editor.session.$worker&&this.editor.session.$worker.removeEventListener("message",this.workerMessage,!1),this.editor.destroy(),this.editor.container.remove())}};let l,d;const o={};var n=h(m,l,d,!1,c,null,null,null);function c(t){for(let e in o)this[e]=o[e]}var ot=function(){return n.exports}();export{ot as default};