Files
JiboSDK/lib/atom-react/core/react-editor.js

1 line
3.3 KiB
JavaScript
Raw Normal View History

2026-03-22 03:21:45 +02:00
"use strict";var e=function(e){return e&&e.__esModule?e["default"]:e},t=function(){function e(e,t){for(var i in t){var n=t[i];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(e,t)}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),i=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},n=e(require("path")),o=e(require("fs")),a=e(require("./atom-view-react-bridge")),r=require("atom"),s=r.File,u=r.Emitter,l=function(){function e(t,o){i(this,e);var a=this;this.emitter=new u,this.modifiedStatus=!1,this.shouldScroll=o,this.uri=n.normalize(t),this.tabTitle=n.parse(t).base,this.file=new s(this.uri),this.ignoreFirstReload=!0,this.onDidChangeDisposable=this.file.onDidChange(function(){return a.ignoreFirstReload?void(a.ignoreFirstReload=!1):a.shouldPromptToSave()?void(a.ignoreFirstReload=!0):(a.reload(),void(a.ignoreFirstReload=!0))}),this.onDidRenameDisposable=this.file.onDidRename(function(){a.uri=a.file.getPath(),a.tabTitle=n.parse(a.uri).base,a.emitter.emit("did-change-title")}),this.active=!1,this.container=null}return t(e,{dispose:{value:function(){this.onDidChangeDisposable.dispose(),this.onDidRenameDisposable.dispose()}},isPaneActive:{value:function(){return this.active}},onPaneActivated:{value:function(){}},onPaneDeactivated:{value:function(){}},getTitle:{value:function(){return this.tabTitle}},isModified:{value:function(){return this.modifiedStatus}},shouldPromptToSave:{value:function(){return this.modifiedStatus}},onDidChangeModified:{value:function(e){return this.emitter.on("did-change-modified",e)}},getReactClass:{value:function(){throw new Error("Override ReactEditor.getReactClass()")}},getViewClass:{value:function(){return a(this.getReactClass(),this.constructor.name)}},getURI:{value:function(){return this.uri}},getPath:{value:function(){return this.uri}},onDidChangeTitle:{value:function(e){return this.emitter.on("did-change-title",e)}},setModifiedStatus:{value:function(e){this.modifiedStatus=e,this.emitter.emit("did-change-modified",e)}},serialize:{value:function(){return{filePath:this.uri,tabTitle:this.tabTitle,deserializer:this.constructor.name}}},save:{value:function(){this.saveFile(this.uri)&&(this.ignoreFirstReload=!0,this.setModifiedStatus(!1))}},saveAs:{value:function(e){this.saveFile(e)&&(this.ignoreFirstReload=!0,this.uri=n.normalize(e),this.tabTitle=n.parse(e).base,this.emitter.emit("did-change-title",this.getTitle()))}},saveFile:{value:function(){throw new Error("Override JiboEditor.saveFile()")}},undo:{value:function(){console.log("undo")}},redo:{value:function(){console.log("redo")}},saveUiState:{value:function(e){atom.config.set("jibo-sdk."+this.constructor.name,JSON.stringify(e))}},getUiState:{value:function(){var e=atom.config.get("jibo-sdk."+this.constructor.name);return e?JSON.parse(e):void 0}},reload:{value:function(){}}},{getProjectRoot:{value:function(e){e=n.normalize(e).toLowerCase();for(var t=atom.project.getPaths(),i=0;i<t.length;i++){var o=n.normalize(t[i]).toLowerCase();if("."===e||e.includes(o))return o}return null}},deserialize:{value:function(e){return 0===e.filePath.search("atom:/")||o.existsSync(e.filePath)?new this(e.filePath):void console.warn("Could not deserialize "+this.constructor.name+" for path '"+e.filePath+"' because that file no longer exists")}}}),e}();module.exports=l;