1 line
14 KiB
JavaScript
1 line
14 KiB
JavaScript
|
|
"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 a=t[i];a.configurable=!0,a.value&&(a.writable=!0)}Object.defineProperties(e,t)}return function(t,i,a){return i&&e(t.prototype,i),a&&e(t,a),t}}(),i=function v(e,t,i){var a=Object.getOwnPropertyDescriptor(e,t);if(void 0===a){var r=Object.getPrototypeOf(e);return null===r?void 0:v(r,t,i)}if("value"in a&&a.writable)return a.value;var n=a.get;if(void 0!==n)return n.call(i)},a=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)},r=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},n=e(require("./event-emitter")),o=e(require("react")),s=e(require("../atom-react/core/react-editor")),d=e(require("./description-editor")),c=e(require("fs")),l=e(require("../common/clipboard")),h=e(require("path")),u=function(e){function n(e,t,a){r(this,n),i(Object.getPrototypeOf(n.prototype),"constructor",this).call(this),this.schema=t,this.uri=a,this.selectionState={},this.selectedElement=void 0,this.selectedDecorator=void 0,this._clearDescription(),this.reload(e,t)}return a(n,e),t(n,{getSchemaByElement:{value:function(e){if(!e["asset-pack"]){var t=this.schema.core.schema[e["class"]];return t||(t=this.schema.project.schema[e["class"]]),t}var i=e["asset-pack"];return this.schema[i].schema[e["class"]]}},addRedoUndoEntry:{value:function(){}},getMutationFunctionNames:{value:function(){return["moveUp","moveDown","addRedoUndoEntry"]}},reload:{value:function(e){var t=this;this.data=e,this.projectRoot=s.getProjectRoot(this.uri);var i=h.join(this.projectRoot,"node_modules","jibo");if(!c.existsSync(i))return void(this.installJibo=!0);this.installJibo=!1,this.nextId=0;var a=void 0===e?[]:Object.keys(e);a.forEach(function(i){var a=e[i];t.nextId=Math.max(t.nextId,a.id)});for(var r=0;r<a.length;r++){var n=e[a[r]],o=this.getSchemaByElement(n).type;if("leaf"===o||"composite"===o){for(this.root=n;this.root.parent;)this.root=e[this.root.parent];break}}this._clearDescription(),this._validateSelections()}},_validateSelections:{value:function(){var e=this,t=Object.keys(this.selectionState);if(t.forEach(function(t){var i=e.data[t],a=e.data[e.selectionState[t]];(void 0===i||void 0===a)&&(e.selectionState[i]=void 0)}),void 0!==this.selectedElement){var i=this.data[this.selectedElement.id];if(void 0===i)this.setSelectedElement(this.getRoot());else if(this.setSelectedElement(i),void 0!==this.selectedDecorator&&void 0===this.data[this.selectedDecorator.id]){var a=this._getFirstDecorator(this.selectedElement);this.setSelectedDecorator(a)}}}},getData:{value:function(){return this.data}},setSelectedElement:{value:function(e){this.selectedElement=e;var t=void 0;void 0!==e&&(t=void 0!==this.selectionState[e.id]?this.selectionState[e.id]:this._getFirstDecorator(e)),this.setSelectedDecorator(t)}},getSelectedBehavior:{value:function(){return this.selectedElement}},setSelectedDecorator:{value:function(e){this.selectedDecorator=e,this._setSelectionState(this.selectedElement,e)&&this.emit("ondatachanged")}},getSelectedDecorator:{value:function(){return this.selectedDecorator}},_getFirstDecorator:{value:function(e){if(void 0!==e){var t=void 0;if(this.data[e.id].decorators&&this.data[e.id].decorators.length>0){var i=this.data[e.id].decorators[0];t=this.data[i]}return t}}},_setSelectionState:{value:function(e,t){return void 0!==e&&this.selectionState[e.id]!==t?(this.selectionState[e.id]=t,!0):!1}},setRenderDescription:{value:function(e){this._setAndClearDescriptionElement(),this.description.element=e,this.description.newValue=void 0}},_setAndClearDescriptionElement:{value:function(){this.description.element&&this.description.newValue&&(this.description.element.name=this.description.newValue,this.addRedoUndoEntry()),this._clearDescription()}},_clearDescription:{value:function(){this.description={element:void 0,newValue:voi
|