UNPKG

alm

Version:

The best IDE for TypeScript

157 lines (156 loc) 5.99 kB
"use strict"; /** * The ts flow features. Allowing you to write code in a `flow` mode */ var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); /** imports */ var ui = require("../../ui"); var csx = require("../../base/csx"); var React = require("react"); var socketClient_1 = require("../../../socket/socketClient"); var commands = require("../../commands/commands"); var utils = require("../../../common/utils"); var styles = require("../../styles/styles"); var typestyle = require("typestyle"); var DocumentationViewStyles; (function (DocumentationViewStyles) { DocumentationViewStyles.header = typestyle.style({ cursor: 'pointer', $nest: { '&:hover': { textDecoration: 'underline' } } }); DocumentationViewStyles.folderName = typestyle.style({ padding: "2px", fontSize: '.5em', '-webkit-user-select': 'none', maxWidth: '200px', overflow: 'hidden', textOverflow: 'ellipsis' }); })(DocumentationViewStyles = exports.DocumentationViewStyles || (exports.DocumentationViewStyles = {})); var TsFlowView = /** @class */ (function (_super) { __extends(TsFlowView, _super); function TsFlowView(props) { var _this = _super.call(this, props) || this; _this.handleKey = function (e) { var unicode = e.charCode; if (String.fromCharCode(unicode).toLowerCase() === "r") { _this.loadData(); } }; _this.filter = function () { // TODO: }; _this.loadData = function () { // TODO: // server.getTopLevelModuleNames({}).then(res => { // this.setState({files:res.files, selected: null}); // this.filter(); // }) }; /** * TAB implementation */ _this.resize = function () { // Not needed }; _this.focus = function () { _this.refs.root.focus(); }; _this.save = function () { }; _this.close = function () { }; _this.gotoPosition = function (position) { }; _this.search = { doSearch: function (options) { _this.setState({ filter: options.query }); }, hideSearch: function () { _this.setState({ filter: '' }); }, findNext: function (options) { }, findPrevious: function (options) { }, replaceNext: function (_a) { var newText = _a.newText; }, replacePrevious: function (_a) { var newText = _a.newText; }, replaceAll: function (_a) { var newText = _a.newText; } }; _this.filePath = utils.getFilePathFromUrl(props.url); _this.state = { filter: '' }; return _this; } TsFlowView.prototype.componentDidMount = function () { var _this = this; /** * Initial load + load on project change */ this.loadData(); this.disposible.add(socketClient_1.cast.activeProjectFilePathsUpdated.on(function () { _this.loadData(); })); /** * If a file is selected and it gets edited, reload the file module information */ var loadDataDebounced = utils.debounce(this.loadData, 3000); this.disposible.add(commands.fileContentsChanged.on(function (res) { if (_this.filePath !== res.filePath) return; loadDataDebounced(); })); /** * Handle focus to inform tab container */ var focused = function () { _this.props.onFocused(); }; this.refs.root.addEventListener('focus', focused); this.disposible.add({ dispose: function () { _this.refs.root.removeEventListener('focus', focused); } }); // Listen to tab events var api = this.props.api; this.disposible.add(api.resize.on(this.resize)); this.disposible.add(api.focus.on(this.focus)); this.disposible.add(api.save.on(this.save)); this.disposible.add(api.close.on(this.close)); this.disposible.add(api.gotoPosition.on(this.gotoPosition)); // Listen to search tab events this.disposible.add(api.search.doSearch.on(this.search.doSearch)); this.disposible.add(api.search.hideSearch.on(this.search.hideSearch)); this.disposible.add(api.search.findNext.on(this.search.findNext)); this.disposible.add(api.search.findPrevious.on(this.search.findPrevious)); this.disposible.add(api.search.replaceNext.on(this.search.replaceNext)); this.disposible.add(api.search.replacePrevious.on(this.search.replacePrevious)); this.disposible.add(api.search.replaceAll.on(this.search.replaceAll)); }; TsFlowView.prototype.render = function () { return (React.createElement("div", { ref: "root", tabIndex: 0, style: csx.extend(csx.vertical, csx.flex, csx.newLayerParent, styles.someChildWillScroll, { color: styles.textColor }), onKeyPress: this.handleKey }, React.createElement("div", { style: { overflow: 'hidden', padding: '10px', display: 'flex' } }))); }; return TsFlowView; }(ui.BaseComponent)); exports.TsFlowView = TsFlowView;