@deephaven/console 0.5.2-matplotlib.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Console.d.ts +3 -0
- package/dist/Console.d.ts.map +1 -1
- package/dist/Console.js +807 -871
- package/dist/Console.js.map +1 -1
- package/dist/ConsoleInput.d.ts +1 -38
- package/dist/ConsoleInput.d.ts.map +1 -1
- package/dist/ConsoleInput.js +331 -436
- package/dist/ConsoleInput.js.map +1 -1
- package/dist/ConsoleMenu.js +159 -215
- package/dist/ConsoleMenu.js.map +1 -1
- package/dist/ConsolePropTypes.js +1 -1
- package/dist/ConsolePropTypes.js.map +1 -1
- package/dist/ConsoleShortcuts.js +2 -2
- package/dist/ConsoleShortcuts.js.map +1 -1
- package/dist/ConsoleStatusBar.js +85 -125
- package/dist/ConsoleStatusBar.js.map +1 -1
- package/dist/StoragePropTypes.js +2 -2
- package/dist/StoragePropTypes.js.map +1 -1
- package/dist/command-history/CommandHistory.css +5 -2
- package/dist/command-history/CommandHistory.css.map +1 -1
- package/dist/command-history/CommandHistory.d.ts +5 -0
- package/dist/command-history/CommandHistory.d.ts.map +1 -1
- package/dist/command-history/CommandHistory.js +303 -391
- package/dist/command-history/CommandHistory.js.map +1 -1
- package/dist/command-history/CommandHistoryActions.css +4 -0
- package/dist/command-history/CommandHistoryActions.css.map +1 -1
- package/dist/command-history/CommandHistoryActions.d.ts.map +1 -1
- package/dist/command-history/CommandHistoryActions.js +40 -79
- package/dist/command-history/CommandHistoryActions.js.map +1 -1
- package/dist/command-history/CommandHistoryItem.css +1 -1
- package/dist/command-history/CommandHistoryItem.d.ts +5 -0
- package/dist/command-history/CommandHistoryItem.d.ts.map +1 -1
- package/dist/command-history/CommandHistoryItem.js +15 -9
- package/dist/command-history/CommandHistoryItem.js.map +1 -1
- package/dist/command-history/CommandHistoryItemTooltip.d.ts +1 -40
- package/dist/command-history/CommandHistoryItemTooltip.d.ts.map +1 -1
- package/dist/command-history/CommandHistoryItemTooltip.js +139 -189
- package/dist/command-history/CommandHistoryItemTooltip.js.map +1 -1
- package/dist/command-history/CommandHistoryViewportUpdater.js +30 -35
- package/dist/command-history/CommandHistoryViewportUpdater.js.map +1 -1
- package/dist/command-history/index.js +5 -5
- package/dist/command-history/index.js.map +1 -1
- package/dist/common/Code.js +34 -70
- package/dist/common/Code.js.map +1 -1
- package/dist/common/ConsoleConstants.js +3 -24
- package/dist/common/ConsoleConstants.js.map +1 -1
- package/dist/common/ConsoleUtils.d.ts +1 -3
- package/dist/common/ConsoleUtils.d.ts.map +1 -1
- package/dist/common/ConsoleUtils.js +60 -94
- package/dist/common/ConsoleUtils.js.map +1 -1
- package/dist/common/ObjectIcon.js +4 -2
- package/dist/common/ObjectIcon.js.map +1 -1
- package/dist/common/index.d.js +1 -34
- package/dist/common/index.d.js.map +1 -1
- package/dist/common/index.js +4 -4
- package/dist/common/index.js.map +1 -1
- package/dist/console-history/ConsoleHistory.js +27 -63
- package/dist/console-history/ConsoleHistory.js.map +1 -1
- package/dist/console-history/ConsoleHistoryItem.js +116 -154
- package/dist/console-history/ConsoleHistoryItem.js.map +1 -1
- package/dist/console-history/ConsoleHistoryItemResult.js +4 -2
- package/dist/console-history/ConsoleHistoryItemResult.js.map +1 -1
- package/dist/console-history/ConsoleHistoryResultErrorMessage.js +94 -132
- package/dist/console-history/ConsoleHistoryResultErrorMessage.js.map +1 -1
- package/dist/console-history/ConsoleHistoryResultInProgress.js +42 -76
- package/dist/console-history/ConsoleHistoryResultInProgress.js.map +1 -1
- package/dist/console-history/index.js +5 -5
- package/dist/console-history/index.js.map +1 -1
- package/dist/csv/CsvFormats.js +14 -28
- package/dist/csv/CsvFormats.js.map +1 -1
- package/dist/csv/CsvInputBar.css +25 -23
- package/dist/csv/CsvInputBar.css.map +1 -1
- package/dist/csv/CsvInputBar.d.ts +2 -45
- package/dist/csv/CsvInputBar.d.ts.map +1 -1
- package/dist/csv/CsvInputBar.js +298 -372
- package/dist/csv/CsvInputBar.js.map +1 -1
- package/dist/csv/CsvOverlay.js +197 -243
- package/dist/csv/CsvOverlay.js.map +1 -1
- package/dist/csv/CsvParser.js +186 -209
- package/dist/csv/CsvParser.js.map +1 -1
- package/dist/csv/CsvTypeParser.js +185 -210
- package/dist/csv/CsvTypeParser.js.map +1 -1
- package/dist/csv/NewTableColumnTypes.js +1 -5
- package/dist/csv/NewTableColumnTypes.js.map +1 -1
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/log/LogLevelMenuItem.js +24 -58
- package/dist/log/LogLevelMenuItem.js.map +1 -1
- package/dist/log/LogView.js +429 -484
- package/dist/log/LogView.js.map +1 -1
- package/dist/monaco/MonacoCompletionProvider.js +92 -124
- package/dist/monaco/MonacoCompletionProvider.js.map +1 -1
- package/dist/monaco/MonacoUtils.js +315 -331
- package/dist/monaco/MonacoUtils.js.map +1 -1
- package/dist/monaco/index.js +2 -2
- package/dist/monaco/index.js.map +1 -1
- package/dist/monaco/lang/db.js +3 -3
- package/dist/monaco/lang/db.js.map +1 -1
- package/dist/monaco/lang/groovy.js +3 -3
- package/dist/monaco/lang/groovy.js.map +1 -1
- package/dist/monaco/lang/log.js +3 -3
- package/dist/monaco/lang/log.js.map +1 -1
- package/dist/monaco/lang/python.js +3 -3
- package/dist/monaco/lang/python.js.map +1 -1
- package/dist/monaco/lang/scala.js +5 -5
- package/dist/monaco/lang/scala.js.map +1 -1
- package/dist/notebook/Editor.js +101 -141
- package/dist/notebook/Editor.js.map +1 -1
- package/dist/notebook/ScriptEditor.js +261 -301
- package/dist/notebook/ScriptEditor.js.map +1 -1
- package/dist/notebook/ScriptEditorUtils.js +26 -42
- package/dist/notebook/ScriptEditorUtils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -22
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
|
-
|
|
3
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
|
|
5
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
6
|
-
|
|
7
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
8
|
-
|
|
9
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
10
|
-
|
|
11
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
-
|
|
13
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
-
|
|
15
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
16
|
-
|
|
17
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
-
|
|
19
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
-
|
|
21
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
-
|
|
23
1
|
/**
|
|
24
2
|
* Script editor for large blocks of code
|
|
25
3
|
*/
|
|
@@ -28,325 +6,307 @@ import PropTypes from 'prop-types';
|
|
|
28
6
|
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
29
7
|
import { LoadingOverlay } from '@deephaven/components';
|
|
30
8
|
import Log from '@deephaven/log';
|
|
31
|
-
import Editor from
|
|
32
|
-
import { MonacoCompletionProvider, MonacoUtils } from
|
|
9
|
+
import Editor from "./Editor.js";
|
|
10
|
+
import { MonacoCompletionProvider, MonacoUtils } from "../monaco/index.js";
|
|
33
11
|
import "./ScriptEditor.css";
|
|
34
12
|
var log = Log.module('ScriptEditor');
|
|
35
13
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
_this.handleEditorWillDestroy = _this.handleEditorWillDestroy.bind(_assertThisInitialized(_this));
|
|
49
|
-
_this.handleRun = _this.handleRun.bind(_assertThisInitialized(_this));
|
|
50
|
-
_this.handleRunSelected = _this.handleRunSelected.bind(_assertThisInitialized(_this));
|
|
51
|
-
_this.contextActionCleanups = [];
|
|
52
|
-
_this.completionCleanup = null;
|
|
53
|
-
_this.editor = null;
|
|
54
|
-
_this.editorComponent = /*#__PURE__*/React.createRef();
|
|
55
|
-
_this.state = {
|
|
14
|
+
class ScriptEditor extends Component {
|
|
15
|
+
constructor(props) {
|
|
16
|
+
super(props);
|
|
17
|
+
this.handleEditorInitialized = this.handleEditorInitialized.bind(this);
|
|
18
|
+
this.handleEditorWillDestroy = this.handleEditorWillDestroy.bind(this);
|
|
19
|
+
this.handleRun = this.handleRun.bind(this);
|
|
20
|
+
this.handleRunSelected = this.handleRunSelected.bind(this);
|
|
21
|
+
this.contextActionCleanups = [];
|
|
22
|
+
this.completionCleanup = null;
|
|
23
|
+
this.editor = null;
|
|
24
|
+
this.editorComponent = /*#__PURE__*/React.createRef();
|
|
25
|
+
this.state = {
|
|
56
26
|
model: null
|
|
57
27
|
};
|
|
58
|
-
return _this;
|
|
59
28
|
}
|
|
60
29
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
30
|
+
componentDidUpdate(prevProps) {
|
|
31
|
+
var {
|
|
32
|
+
sessionLanguage,
|
|
33
|
+
settings
|
|
34
|
+
} = this.props;
|
|
35
|
+
var {
|
|
36
|
+
language
|
|
37
|
+
} = settings;
|
|
38
|
+
var languageChanged = language !== prevProps.settings.language;
|
|
39
|
+
|
|
40
|
+
if (languageChanged) {
|
|
41
|
+
log.debug('Set language', language);
|
|
42
|
+
this.setLanguage(language);
|
|
43
|
+
}
|
|
74
44
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
45
|
+
var sessionDisconnected = sessionLanguage == null && prevProps.sessionLanguage != null;
|
|
46
|
+
var languageMatch = language === sessionLanguage;
|
|
47
|
+
var prevLanguageMatch = prevProps.settings.language === prevProps.sessionLanguage;
|
|
78
48
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
49
|
+
if (sessionDisconnected || sessionLanguage && prevLanguageMatch && !languageMatch) {
|
|
50
|
+
// Session disconnected or language changed from matching the session language to non-matching
|
|
51
|
+
log.debug('De-init completion and context actions');
|
|
52
|
+
this.deInitContextActions();
|
|
53
|
+
this.deInitCodeCompletion();
|
|
54
|
+
}
|
|
85
55
|
|
|
86
|
-
|
|
56
|
+
var sessionConnected = sessionLanguage != null && prevProps.sessionLanguage == null;
|
|
87
57
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
58
|
+
if (sessionConnected && languageMatch || sessionLanguage && !prevLanguageMatch && languageMatch) {
|
|
59
|
+
// Session connected with a matching language or notebook language changed to matching
|
|
60
|
+
log.debug('Init completion and context actions');
|
|
61
|
+
this.initContextActions();
|
|
62
|
+
this.initCodeCompletion();
|
|
94
63
|
}
|
|
95
|
-
}
|
|
96
|
-
key: "getValue",
|
|
97
|
-
value: function getValue() {
|
|
98
|
-
if (this.editor) {
|
|
99
|
-
return this.editor.getValue();
|
|
100
|
-
}
|
|
64
|
+
}
|
|
101
65
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}, {
|
|
106
|
-
key: "getSelectedCommand",
|
|
107
|
-
value: function getSelectedCommand() {
|
|
108
|
-
var range = this.editor.getSelection();
|
|
109
|
-
var model = this.editor.getModel();
|
|
110
|
-
var startLineNumber = range.startLineNumber,
|
|
111
|
-
endLineNumber = range.endLineNumber;
|
|
112
|
-
var startLineMinColumn = model.getLineMinColumn(startLineNumber);
|
|
113
|
-
var endLineMaxColumn = model.getLineMaxColumn(endLineNumber);
|
|
114
|
-
var wholeLineRange = range.setStartPosition(startLineNumber, startLineMinColumn).setEndPosition(endLineNumber, endLineMaxColumn);
|
|
115
|
-
return model.getValueInRange(wholeLineRange);
|
|
66
|
+
getValue() {
|
|
67
|
+
if (this.editor) {
|
|
68
|
+
return this.editor.getValue();
|
|
116
69
|
}
|
|
117
|
-
}, {
|
|
118
|
-
key: "handleEditorInitialized",
|
|
119
|
-
value: function handleEditorInitialized(editor) {
|
|
120
|
-
var _this$props2 = this.props,
|
|
121
|
-
focusOnMount = _this$props2.focusOnMount,
|
|
122
|
-
onChange = _this$props2.onChange,
|
|
123
|
-
settings = _this$props2.settings,
|
|
124
|
-
session = _this$props2.session,
|
|
125
|
-
sessionLanguage = _this$props2.sessionLanguage;
|
|
126
|
-
log.debug('handleEditorInitialized', sessionLanguage, session, settings);
|
|
127
|
-
this.editor = editor;
|
|
128
|
-
this.setState({
|
|
129
|
-
model: this.editor.getModel()
|
|
130
|
-
});
|
|
131
|
-
MonacoUtils.setEOL(editor);
|
|
132
|
-
MonacoUtils.registerPasteHandler(editor);
|
|
133
|
-
|
|
134
|
-
if (session && settings && sessionLanguage === settings.language) {
|
|
135
|
-
this.initContextActions();
|
|
136
|
-
this.initCodeCompletion();
|
|
137
|
-
}
|
|
138
70
|
|
|
139
|
-
|
|
71
|
+
log.error('Editor not initialized');
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
140
74
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
75
|
+
getSelectedCommand() {
|
|
76
|
+
var range = this.editor.getSelection();
|
|
77
|
+
var model = this.editor.getModel();
|
|
78
|
+
var {
|
|
79
|
+
startLineNumber,
|
|
80
|
+
endLineNumber
|
|
81
|
+
} = range;
|
|
82
|
+
var startLineMinColumn = model.getLineMinColumn(startLineNumber);
|
|
83
|
+
var endLineMaxColumn = model.getLineMaxColumn(endLineNumber);
|
|
84
|
+
var wholeLineRange = range.setStartPosition(startLineNumber, startLineMinColumn).setEndPosition(endLineNumber, endLineMaxColumn);
|
|
85
|
+
return model.getValueInRange(wholeLineRange);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
handleEditorInitialized(editor) {
|
|
89
|
+
var {
|
|
90
|
+
focusOnMount,
|
|
91
|
+
onChange,
|
|
92
|
+
settings,
|
|
93
|
+
session,
|
|
94
|
+
sessionLanguage
|
|
95
|
+
} = this.props;
|
|
96
|
+
log.debug('handleEditorInitialized', sessionLanguage, session, settings);
|
|
97
|
+
this.editor = editor;
|
|
98
|
+
this.setState({
|
|
99
|
+
model: this.editor.getModel()
|
|
100
|
+
});
|
|
101
|
+
MonacoUtils.setEOL(editor);
|
|
102
|
+
MonacoUtils.registerPasteHandler(editor);
|
|
103
|
+
|
|
104
|
+
if (session && settings && sessionLanguage === settings.language) {
|
|
105
|
+
this.initContextActions();
|
|
106
|
+
this.initCodeCompletion();
|
|
144
107
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.deInitCodeCompletion();
|
|
151
|
-
this.setState({
|
|
152
|
-
model: null
|
|
153
|
-
});
|
|
154
|
-
this.editor = null;
|
|
108
|
+
|
|
109
|
+
editor.onDidChangeModelContent(onChange);
|
|
110
|
+
|
|
111
|
+
if (focusOnMount) {
|
|
112
|
+
editor.focus();
|
|
155
113
|
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
handleEditorWillDestroy() {
|
|
117
|
+
log.debug('handleEditorWillDestroy');
|
|
118
|
+
this.deInitContextActions();
|
|
119
|
+
this.deInitCodeCompletion();
|
|
120
|
+
this.setState({
|
|
121
|
+
model: null
|
|
122
|
+
});
|
|
123
|
+
this.editor = null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
handleRun() {
|
|
127
|
+
var {
|
|
128
|
+
onRunCommand
|
|
129
|
+
} = this.props;
|
|
130
|
+
var command = this.getValue();
|
|
131
|
+
onRunCommand(command);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
handleRunSelected() {
|
|
135
|
+
var {
|
|
136
|
+
onRunCommand
|
|
137
|
+
} = this.props;
|
|
138
|
+
var command = this.getSelectedCommand();
|
|
139
|
+
onRunCommand(command);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
initContextActions() {
|
|
143
|
+
if (this.contextActionCleanups.length > 0) {
|
|
144
|
+
log.error('Context actions already initialized.');
|
|
145
|
+
return;
|
|
162
146
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
var onRunCommand = this.props.onRunCommand;
|
|
167
|
-
var command = this.getSelectedCommand();
|
|
168
|
-
onRunCommand(command);
|
|
147
|
+
|
|
148
|
+
if (!this.editor) {
|
|
149
|
+
return;
|
|
169
150
|
}
|
|
170
|
-
}, {
|
|
171
|
-
key: "initContextActions",
|
|
172
|
-
value: function initContextActions() {
|
|
173
|
-
var _this2 = this;
|
|
174
|
-
|
|
175
|
-
if (this.contextActionCleanups.length > 0) {
|
|
176
|
-
log.error('Context actions already initialized.');
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
151
|
|
|
180
|
-
|
|
181
|
-
|
|
152
|
+
var cleanups = [];
|
|
153
|
+
cleanups.push(this.editor.addAction({
|
|
154
|
+
id: 'run-code',
|
|
155
|
+
label: 'Run',
|
|
156
|
+
// eslint-disable-next-line no-bitwise
|
|
157
|
+
keybindings: [monaco.KeyMod.Alt | monaco.KeyCode.KEY_R],
|
|
158
|
+
precondition: null,
|
|
159
|
+
keybindingContext: null,
|
|
160
|
+
contextMenuGroupId: 'navigation',
|
|
161
|
+
contextMenuOrder: 1.5,
|
|
162
|
+
run: () => {
|
|
163
|
+
this.handleRun();
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}));
|
|
167
|
+
cleanups.push(this.editor.addAction({
|
|
168
|
+
id: 'run-selected-code',
|
|
169
|
+
label: 'Run Selected',
|
|
170
|
+
keybindings: [// eslint-disable-next-line no-bitwise
|
|
171
|
+
monaco.KeyMod.Alt | monaco.KeyMod.Shift | monaco.KeyCode.KEY_R],
|
|
172
|
+
precondition: null,
|
|
173
|
+
keybindingContext: null,
|
|
174
|
+
contextMenuGroupId: 'navigation',
|
|
175
|
+
contextMenuOrder: 1.5,
|
|
176
|
+
run: () => {
|
|
177
|
+
this.handleRunSelected();
|
|
178
|
+
return null;
|
|
182
179
|
}
|
|
180
|
+
}));
|
|
181
|
+
this.contextActionCleanups = cleanups;
|
|
182
|
+
}
|
|
183
183
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
// eslint-disable-next-line no-bitwise
|
|
189
|
-
keybindings: [monaco.KeyMod.Alt | monaco.KeyCode.KEY_R],
|
|
190
|
-
precondition: null,
|
|
191
|
-
keybindingContext: null,
|
|
192
|
-
contextMenuGroupId: 'navigation',
|
|
193
|
-
contextMenuOrder: 1.5,
|
|
194
|
-
run: function run() {
|
|
195
|
-
_this2.handleRun();
|
|
196
|
-
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
}));
|
|
200
|
-
cleanups.push(this.editor.addAction({
|
|
201
|
-
id: 'run-selected-code',
|
|
202
|
-
label: 'Run Selected',
|
|
203
|
-
keybindings: [// eslint-disable-next-line no-bitwise
|
|
204
|
-
monaco.KeyMod.Alt | monaco.KeyMod.Shift | monaco.KeyCode.KEY_R],
|
|
205
|
-
precondition: null,
|
|
206
|
-
keybindingContext: null,
|
|
207
|
-
contextMenuGroupId: 'navigation',
|
|
208
|
-
contextMenuOrder: 1.5,
|
|
209
|
-
run: function run() {
|
|
210
|
-
_this2.handleRunSelected();
|
|
211
|
-
|
|
212
|
-
return null;
|
|
213
|
-
}
|
|
214
|
-
}));
|
|
215
|
-
this.contextActionCleanups = cleanups;
|
|
184
|
+
deInitContextActions() {
|
|
185
|
+
if (this.contextActionCleanups.length > 0) {
|
|
186
|
+
this.contextActionCleanups.forEach(cleanup => cleanup.dispose());
|
|
187
|
+
this.contextActionCleanups = [];
|
|
216
188
|
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
});
|
|
224
|
-
this.contextActionCleanups = [];
|
|
225
|
-
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
initCodeCompletion() {
|
|
192
|
+
if (this.completionCleanup != null) {
|
|
193
|
+
log.error('Code completion already initialized.');
|
|
194
|
+
return;
|
|
226
195
|
}
|
|
227
|
-
}, {
|
|
228
|
-
key: "initCodeCompletion",
|
|
229
|
-
value: function initCodeCompletion() {
|
|
230
|
-
if (this.completionCleanup != null) {
|
|
231
|
-
log.error('Code completion already initialized.');
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
196
|
|
|
235
|
-
|
|
236
|
-
|
|
197
|
+
var {
|
|
198
|
+
session
|
|
199
|
+
} = this.props;
|
|
200
|
+
log.debug('initCodeCompletion', this.editor, session);
|
|
237
201
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
202
|
+
if (this.editor && session) {
|
|
203
|
+
this.completionCleanup = MonacoUtils.openDocument(this.editor, session);
|
|
241
204
|
}
|
|
242
|
-
}
|
|
243
|
-
key: "deInitCodeCompletion",
|
|
244
|
-
value: function deInitCodeCompletion() {
|
|
245
|
-
var session = this.props.session;
|
|
246
|
-
log.debug('deInitCodeCompletion', this.editor, session);
|
|
247
|
-
|
|
248
|
-
if (this.completionCleanup) {
|
|
249
|
-
this.completionCleanup.dispose();
|
|
250
|
-
this.completionCleanup = null;
|
|
251
|
-
}
|
|
205
|
+
}
|
|
252
206
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
207
|
+
deInitCodeCompletion() {
|
|
208
|
+
var {
|
|
209
|
+
session
|
|
210
|
+
} = this.props;
|
|
211
|
+
log.debug('deInitCodeCompletion', this.editor, session);
|
|
212
|
+
|
|
213
|
+
if (this.completionCleanup) {
|
|
214
|
+
this.completionCleanup.dispose();
|
|
215
|
+
this.completionCleanup = null;
|
|
256
216
|
}
|
|
257
|
-
}, {
|
|
258
|
-
key: "append",
|
|
259
|
-
value: function append(text) {
|
|
260
|
-
var focus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
261
|
-
var model = this.editor.getModel();
|
|
262
|
-
var currentText = model.getValue();
|
|
263
|
-
|
|
264
|
-
if (currentText) {
|
|
265
|
-
model.setValue("".concat(currentText, "\n").concat(text));
|
|
266
|
-
} else {
|
|
267
|
-
model.setValue("".concat(text));
|
|
268
|
-
}
|
|
269
217
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
column: column
|
|
275
|
-
});
|
|
218
|
+
if (this.editor && session) {
|
|
219
|
+
MonacoUtils.closeDocument(this.editor, session);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
276
222
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
223
|
+
append(text) {
|
|
224
|
+
var focus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
225
|
+
var model = this.editor.getModel();
|
|
226
|
+
var currentText = model.getValue();
|
|
227
|
+
|
|
228
|
+
if (currentText) {
|
|
229
|
+
model.setValue("".concat(currentText, "\n").concat(text));
|
|
230
|
+
} else {
|
|
231
|
+
model.setValue("".concat(text));
|
|
280
232
|
}
|
|
281
|
-
}, {
|
|
282
|
-
key: "updateDimensions",
|
|
283
|
-
value: function updateDimensions() {
|
|
284
|
-
log.debug('updateDimensions');
|
|
285
233
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
234
|
+
var lastLine = model.getLineCount();
|
|
235
|
+
var column = model.getLineLength(lastLine) + 1;
|
|
236
|
+
this.editor.setPosition({
|
|
237
|
+
lineNumber: lastLine,
|
|
238
|
+
column
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
if (focus) {
|
|
242
|
+
this.editor.focus();
|
|
289
243
|
}
|
|
290
|
-
}
|
|
291
|
-
key: "focus",
|
|
292
|
-
value: function focus() {
|
|
293
|
-
log.debug('focus');
|
|
244
|
+
}
|
|
294
245
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
246
|
+
updateDimensions() {
|
|
247
|
+
log.debug('updateDimensions');
|
|
248
|
+
|
|
249
|
+
if (this.editor) {
|
|
250
|
+
this.editor.layout();
|
|
298
251
|
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
focus() {
|
|
255
|
+
log.debug('focus');
|
|
256
|
+
|
|
257
|
+
if (this.editor) {
|
|
258
|
+
this.editor.focus();
|
|
305
259
|
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
toggleFind() {
|
|
263
|
+
if (this.editorComponent.current) {
|
|
264
|
+
this.editorComponent.current.toggleFind();
|
|
312
265
|
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
isLoaded = _this$props3.isLoaded,
|
|
319
|
-
isLoading = _this$props3.isLoading,
|
|
320
|
-
session = _this$props3.session,
|
|
321
|
-
sessionLanguage = _this$props3.sessionLanguage,
|
|
322
|
-
settings = _this$props3.settings;
|
|
323
|
-
var model = this.state.model;
|
|
324
|
-
var errorMessage = error ? "Unable to open document. ".concat(error) : null;
|
|
325
|
-
var editorLanguage = settings ? settings.language : null;
|
|
326
|
-
var completionProviderEnabled = model && session && editorLanguage === sessionLanguage;
|
|
327
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, (error || isLoading) && /*#__PURE__*/React.createElement("div", {
|
|
328
|
-
className: "h-100 w-100 position-relative"
|
|
329
|
-
}, /*#__PURE__*/React.createElement(LoadingOverlay, {
|
|
330
|
-
errorMessage: errorMessage,
|
|
331
|
-
isLoading: isLoading,
|
|
332
|
-
isLoaded: isLoaded
|
|
333
|
-
})), isLoaded && /*#__PURE__*/React.createElement("div", {
|
|
334
|
-
className: "h-100 w-100 script-editor"
|
|
335
|
-
}, settings && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Editor, {
|
|
336
|
-
ref: this.editorComponent,
|
|
337
|
-
settings: settings,
|
|
338
|
-
onEditorInitialized: this.handleEditorInitialized,
|
|
339
|
-
onEditorWillDestroy: this.handleEditorWillDestroy
|
|
340
|
-
}), completionProviderEnabled && /*#__PURE__*/React.createElement(MonacoCompletionProvider, {
|
|
341
|
-
model: model,
|
|
342
|
-
language: editorLanguage,
|
|
343
|
-
session: session
|
|
344
|
-
}))));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
setLanguage(language) {
|
|
269
|
+
if (this.editorComponent.current) {
|
|
270
|
+
this.editorComponent.current.setLanguage(language);
|
|
345
271
|
}
|
|
346
|
-
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
render() {
|
|
275
|
+
var {
|
|
276
|
+
error,
|
|
277
|
+
isLoaded,
|
|
278
|
+
isLoading,
|
|
279
|
+
session,
|
|
280
|
+
sessionLanguage,
|
|
281
|
+
settings
|
|
282
|
+
} = this.props;
|
|
283
|
+
var {
|
|
284
|
+
model
|
|
285
|
+
} = this.state;
|
|
286
|
+
var errorMessage = error ? "Unable to open document. ".concat(error) : null;
|
|
287
|
+
var editorLanguage = settings ? settings.language : null;
|
|
288
|
+
var completionProviderEnabled = model && session && editorLanguage === sessionLanguage;
|
|
289
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, (error || isLoading) && /*#__PURE__*/React.createElement("div", {
|
|
290
|
+
className: "h-100 w-100 position-relative"
|
|
291
|
+
}, /*#__PURE__*/React.createElement(LoadingOverlay, {
|
|
292
|
+
errorMessage: errorMessage,
|
|
293
|
+
isLoading: isLoading,
|
|
294
|
+
isLoaded: isLoaded
|
|
295
|
+
})), isLoaded && /*#__PURE__*/React.createElement("div", {
|
|
296
|
+
className: "h-100 w-100 script-editor"
|
|
297
|
+
}, settings && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Editor, {
|
|
298
|
+
ref: this.editorComponent,
|
|
299
|
+
settings: settings,
|
|
300
|
+
onEditorInitialized: this.handleEditorInitialized,
|
|
301
|
+
onEditorWillDestroy: this.handleEditorWillDestroy
|
|
302
|
+
}), completionProviderEnabled && /*#__PURE__*/React.createElement(MonacoCompletionProvider, {
|
|
303
|
+
model: model,
|
|
304
|
+
language: editorLanguage,
|
|
305
|
+
session: session
|
|
306
|
+
}))));
|
|
307
|
+
}
|
|
347
308
|
|
|
348
|
-
|
|
349
|
-
}(Component);
|
|
309
|
+
}
|
|
350
310
|
|
|
351
311
|
ScriptEditor.propTypes = {
|
|
352
312
|
error: PropTypes.shape({
|
|
@@ -369,7 +329,7 @@ ScriptEditor.defaultProps = {
|
|
|
369
329
|
isLoading: false,
|
|
370
330
|
isLoaded: false,
|
|
371
331
|
focusOnMount: true,
|
|
372
|
-
onChange:
|
|
332
|
+
onChange: () => {},
|
|
373
333
|
session: null,
|
|
374
334
|
sessionLanguage: null,
|
|
375
335
|
settings: null
|