@aj-shadow/z-abs-complayer-codemirror-client 0.0.0-aj-beta.221
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/.gitattributes +26 -0
- package/LICENSE.txt +96 -0
- package/README.md +5 -0
- package/npm-shrinkwrap.json +13 -0
- package/package.json +10 -0
- package/project/client/_build/Bundle-CompLayer-Codemirror-client.bld +32 -0
- package/project/client/_build/Client-CompLayer-Codemirror-client-jsx.bld +10 -0
- package/project/client/_build/Client-CompLayer-Codemirror-client.bld +10 -0
- package/project/client/_build/Client-css-CompLayer-Codemirror-bundle.bld +9 -0
- package/project/client/_build/z-abs-complayer-codemirror-client.prj +36 -0
- package/project/client/code-mirror-debug-variable.jsx +321 -0
- package/project/client/code-mirror-editor.jsx +559 -0
- package/project/client/code-mirror-popover-build.jsx +61 -0
- package/project/client/code-mirror-popover.jsx +93 -0
- package/project/client/css/actor-code-mirror.css +5 -0
- package/project/client/css/breakpoint-marker-dark.css +4 -0
- package/project/client/css/breakpoint-marker-light.css +4 -0
- package/project/client/css/breakpoint-marker.css +11 -0
- package/project/client/css/build-marker-dark.css +0 -0
- package/project/client/css/build-marker.css +25 -0
- package/project/client/css/build-marker_light.css +0 -0
- package/project/client/extensions/extension-breakpoint.js +154 -0
- package/project/client/extensions/extension-build.jsx +212 -0
- package/project/client/extensions/extension-dark-mode.js +63 -0
- package/project/client/extensions/extension-empty-line.js +59 -0
- package/project/client/extensions/extension-line-numbers.js +26 -0
- package/project/client/extensions/extension-lines.js +95 -0
- package/project/client/extensions/extension-read-only.js +12 -0
- package/project/client/extensions/extension-scroller.js +27 -0
- package/project/client/extensions/extension-tab-size.js +48 -0
- package/project/client/extensions/extension-tooltip.js +88 -0
- package/project/client/themes/theme-const.js +140 -0
- package/project/client/themes/theme-dark-mode.js +206 -0
- package/project/client/themes/theme-light-mode.js +206 -0
- package/project/z-abs-complayer-codemirror-client.tree +35 -0
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
import ExtensionBreakpoint from './extensions/extension-breakpoint';
|
|
5
|
+
import ExtensionBuild from './extensions/extension-build';
|
|
6
|
+
import ExtensionDarkMode from './extensions/extension-dark-mode';
|
|
7
|
+
import ExtensionEmptyLine from './extensions/extension-empty-line';
|
|
8
|
+
import ExtensionLineNumbers from './extensions/extension-line-numbers';
|
|
9
|
+
import ExtensionLines from './extensions/extension-lines';
|
|
10
|
+
import ExtensionReadOnly from './extensions/extension-read-only';
|
|
11
|
+
import ExtensionScroller from './extensions/extension-scroller';
|
|
12
|
+
import ExtensionTabSize from './extensions/extension-tab-size';
|
|
13
|
+
import ExtensionTooltip from './extensions/extension-tooltip';
|
|
14
|
+
|
|
15
|
+
import CodeMirrorPopover from './code-mirror-popover';
|
|
16
|
+
|
|
17
|
+
import ReactComponentBase from 'z-abs-corelayer-client/client/react-component/react-component-base';
|
|
18
|
+
import {EditorView, keymap, highlightSpecialChars, drawSelection, highlightActiveLine, dropCursor, rectangularSelection, crosshairCursor, highlightActiveLineGutter} from "@codemirror/view";
|
|
19
|
+
import {EditorState, Compartment} from "@codemirror/state"
|
|
20
|
+
import {defaultKeymap, history, historyKeymap, redo} from "@codemirror/commands"
|
|
21
|
+
import {autocompletion, completionKeymap, closeBrackets, closeBracketsKeymap} from "@codemirror/autocomplete"
|
|
22
|
+
import {searchKeymap, highlightSelectionMatches} from "@codemirror/search"
|
|
23
|
+
import {defaultHighlightStyle, syntaxHighlighting, indentOnInput, bracketMatching, foldGutter, foldKeymap} from "@codemirror/language";
|
|
24
|
+
import {javascript} from "@codemirror/lang-javascript"
|
|
25
|
+
import {css} from "@codemirror/lang-css"
|
|
26
|
+
import {html} from "@codemirror/lang-html"
|
|
27
|
+
import {json} from "@codemirror/lang-json"
|
|
28
|
+
import {markdown} from "@codemirror/lang-markdown"
|
|
29
|
+
import React from 'react';
|
|
30
|
+
import { createRoot } from 'react-dom/client';
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export default class CodeMirrorEditor extends ReactComponentBase {
|
|
34
|
+
static DEBUGGER_RUNNING = 0;
|
|
35
|
+
static DEBUGGER_BREAK = 1;
|
|
36
|
+
static DEBUGGER_NOT_RUNNING = 2;
|
|
37
|
+
|
|
38
|
+
constructor(props) {
|
|
39
|
+
super(props);
|
|
40
|
+
this.codeMirror = null;
|
|
41
|
+
this.code = this.props.code;
|
|
42
|
+
this.focusTrigger = true;
|
|
43
|
+
this.breakpoint = null;
|
|
44
|
+
this.reactDivPopupRoot = null;
|
|
45
|
+
this.reactDiv = null;
|
|
46
|
+
this.currentTarget = null;
|
|
47
|
+
this._code_mirror = null;
|
|
48
|
+
this._id = '';
|
|
49
|
+
this.showTooltip = 0;
|
|
50
|
+
this.lineFunctions = new Map();
|
|
51
|
+
this.extensionBreakpoint = new ExtensionBreakpoint(this.props.docKey);
|
|
52
|
+
this.extensionBuild = new ExtensionBuild();
|
|
53
|
+
this.extensionLinesBreakpoint = new ExtensionLines('Breakpoint', [{type:0,lightMode:{backgroundColor:"#FFA",boxShadow:"0 0 0 1px Orange"},darkMode:{backgroundColor:"#030",boxShadow:"0 0 0 1px Orange"}}]);
|
|
54
|
+
this.lightRules = null;
|
|
55
|
+
this.darkRules = null;
|
|
56
|
+
this.extensionDarkMode = new ExtensionDarkMode((lightRules, darkRules) => {
|
|
57
|
+
this.lightRules = lightRules;
|
|
58
|
+
this.darkRules = darkRules;
|
|
59
|
+
});
|
|
60
|
+
this.extensionEmptyLine = new ExtensionEmptyLine();
|
|
61
|
+
this.extensionLineNumbers = new ExtensionLineNumbers();
|
|
62
|
+
this.extensionScroller = new ExtensionScroller();
|
|
63
|
+
this.extensionTooltip = new ExtensionTooltip(this.lightRules, this.darkRules);
|
|
64
|
+
this.updateListenerExtension = EditorView.updateListener.of((update) => {
|
|
65
|
+
if(update.docChanged) {
|
|
66
|
+
const doc = '\r\n' === this.props.eol ? update.state.doc.toString().replaceAll('\n', '\r\n') : update.state.doc.toString();
|
|
67
|
+
this.props.onChanged && this.props.onChanged(this.props.projectId, this.props.docKey, doc);
|
|
68
|
+
}
|
|
69
|
+
if(update.focusChanged) {
|
|
70
|
+
this.props.onFocusChange && this.props.onFocusChange(this.codeMirror.hasFocus, this.props.docKey);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
didMount() {
|
|
76
|
+
const options = this.props.options ? this.props.options : {};
|
|
77
|
+
const extensions = [];
|
|
78
|
+
defaultKeymap.push({
|
|
79
|
+
key: "Ctrl-Shift-z", run: redo, preventDefault: true
|
|
80
|
+
});
|
|
81
|
+
const keyMaps = [
|
|
82
|
+
...closeBracketsKeymap,
|
|
83
|
+
...defaultKeymap,
|
|
84
|
+
...searchKeymap,
|
|
85
|
+
...historyKeymap,
|
|
86
|
+
...foldKeymap,
|
|
87
|
+
...completionKeymap
|
|
88
|
+
];
|
|
89
|
+
extensions.push(keymap.of(keyMaps));
|
|
90
|
+
extensions.push(this.updateListenerExtension);
|
|
91
|
+
this.extensionScroller.create(extensions, keyMaps, options, this._id);
|
|
92
|
+
// GUTTERS
|
|
93
|
+
this.extensionBreakpoint.create(extensions, keyMaps, options, this.props.name, this.props.dbugger?.breakpoints ? this.props.dbugger.breakpoints : [], !!this.props.darkMode, (lineNumber, breakpoint) => {
|
|
94
|
+
this.props.onGutterChange && this.props.onGutterChange(this.props.docKey, lineNumber, breakpoint);
|
|
95
|
+
});
|
|
96
|
+
this.extensionLinesBreakpoint.create(extensions, keyMaps, options, []);
|
|
97
|
+
this.extensionLineNumbers.create(extensions, keyMaps, options);
|
|
98
|
+
if(options.foldGutter) {
|
|
99
|
+
extensions.push(foldGutter());
|
|
100
|
+
}
|
|
101
|
+
if(options.highlightActiveLineGutter) {
|
|
102
|
+
extensions.push(highlightActiveLineGutter());
|
|
103
|
+
}
|
|
104
|
+
if(options.highlightActiveLine) {
|
|
105
|
+
extensions.push(highlightActiveLine());
|
|
106
|
+
}
|
|
107
|
+
if(options.closeBrackets) {
|
|
108
|
+
extensions.push(closeBrackets());
|
|
109
|
+
}
|
|
110
|
+
if(options.bracketMatching) {
|
|
111
|
+
extensions.push(bracketMatching());
|
|
112
|
+
}
|
|
113
|
+
if(options.drawSelection) {
|
|
114
|
+
extensions.push(EditorState.allowMultipleSelections.of(true));
|
|
115
|
+
extensions.push(rectangularSelection());
|
|
116
|
+
extensions.push(crosshairCursor());
|
|
117
|
+
extensions.push(drawSelection());
|
|
118
|
+
}
|
|
119
|
+
if(options.history) {
|
|
120
|
+
extensions.push(history());
|
|
121
|
+
}
|
|
122
|
+
if(options.autocompletion) {
|
|
123
|
+
extensions.push(autocompletion());
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
this.extensionBuild.create(extensions, keyMaps, options, !!this.props.darkMode);
|
|
127
|
+
//extensions.push(highlightSpecialChars());
|
|
128
|
+
//extensions.push(dropCursor());
|
|
129
|
+
// extensions.push(indentOnInput());
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
extensions.push(highlightSelectionMatches());
|
|
133
|
+
|
|
134
|
+
const themeLight = EditorView.baseTheme({
|
|
135
|
+
"&.cm-editor": {
|
|
136
|
+
height: "100%"
|
|
137
|
+
},
|
|
138
|
+
".cm-gutters": {
|
|
139
|
+
borderRight: "1px Solid #ddd !important"
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
extensions.push(themeLight);
|
|
143
|
+
this.extensionDarkMode.create(extensions, keyMaps, options, !!this.props.darkMode);
|
|
144
|
+
this.extensionEmptyLine.create(extensions, keyMaps, options, !!this.props.emptyLine);
|
|
145
|
+
this.extensionTooltip.create(extensions, keyMaps, options, !!this.props.darkMode, this._onDebugTooltip.bind(this));
|
|
146
|
+
ExtensionReadOnly(extensions, keyMaps, options);
|
|
147
|
+
ExtensionTabSize(extensions, keyMaps, options);
|
|
148
|
+
|
|
149
|
+
//extensions.push(keymap.of(keyMaps));
|
|
150
|
+
extensions.push(syntaxHighlighting(defaultHighlightStyle, { fallback: true }));
|
|
151
|
+
switch(options.type) {
|
|
152
|
+
case 'js':
|
|
153
|
+
extensions.push(javascript());
|
|
154
|
+
break;
|
|
155
|
+
case 'jsx':
|
|
156
|
+
const js = javascript({jsx: true});
|
|
157
|
+
extensions.push(js);
|
|
158
|
+
break;
|
|
159
|
+
case 'css':
|
|
160
|
+
extensions.push(css());
|
|
161
|
+
break;
|
|
162
|
+
case 'json':
|
|
163
|
+
case 'bld':
|
|
164
|
+
case 'prj':
|
|
165
|
+
extensions.push(json());
|
|
166
|
+
break;
|
|
167
|
+
case 'html':
|
|
168
|
+
extensions.push(html());
|
|
169
|
+
break;
|
|
170
|
+
case 'md':
|
|
171
|
+
extensions.push(markdown());
|
|
172
|
+
break;
|
|
173
|
+
};
|
|
174
|
+
if(this.props.lineFunctions) {
|
|
175
|
+
this.props.lineFunctions.forEach((lineFunction) => {
|
|
176
|
+
this.lineFunctions.set(lineFunction.name, lineFunction);
|
|
177
|
+
lineFunction.object = new ExtensionLines(lineFunction.name, lineFunction.types);
|
|
178
|
+
lineFunction.object.create(extensions, keyMaps, options, this._getLines(lineFunction.name));
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
const state = EditorState.create({
|
|
182
|
+
doc: this.props.code.replaceAll('\r\n', '\n'),
|
|
183
|
+
extensions
|
|
184
|
+
});
|
|
185
|
+
this.codeMirror = new EditorView({
|
|
186
|
+
state,
|
|
187
|
+
parent: this._code_mirror
|
|
188
|
+
});
|
|
189
|
+
if(this.props.lineFunctions) {
|
|
190
|
+
setTimeout(() => {
|
|
191
|
+
this.props.lineFunctions.forEach((lineFunction) => {
|
|
192
|
+
const lines = this._getLines(lineFunction.name);
|
|
193
|
+
lineFunction.object.set(this.codeMirror, options, lines);
|
|
194
|
+
if(0 !== lines.length) {
|
|
195
|
+
this.extensionScroller.set(this.codeMirror, this.props.options, this.codeMirror.state.doc.lines, lines[lines.length - 1]);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}, 1);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
shouldUpdate(nextProps, nextState) {
|
|
203
|
+
return this.props !== nextProps;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
didUpdate(prevProps, prevState) {
|
|
207
|
+
if(prevProps.darkMode !== this.props.darkMode) {
|
|
208
|
+
this.extensionDarkMode.set(this.codeMirror, this.props.options, this.props.darkMode);
|
|
209
|
+
}
|
|
210
|
+
if(prevProps.emptyLine !== this.props.emptyLine) {
|
|
211
|
+
this.extensionEmptyLine.set(this.codeMirror, this.props.options, !!this.props.emptyLine);
|
|
212
|
+
}
|
|
213
|
+
if(prevProps.dbugger !== this.props.dbugger) {
|
|
214
|
+
const dbugger = this.props.dbugger;
|
|
215
|
+
if(prevProps.dbugger.breakpoints !== dbugger.breakpoints) {
|
|
216
|
+
this.extensionBreakpoint.set(this.codeMirror, this.props.options, this.props.name, dbugger.breakpoints, this.props.darkMode);
|
|
217
|
+
}
|
|
218
|
+
if(CodeMirrorEditor.DEBUGGER_RUNNING === prevProps.dbugger.state) {
|
|
219
|
+
if(CodeMirrorEditor.DEBUGGER_BREAK === dbugger.state) {
|
|
220
|
+
if((this.props.docKey === dbugger.actor.index) && ((prevProps.dbugger.level !== dbugger.level) || (prevProps.dbugger.scripts !== dbugger.scripts))) {
|
|
221
|
+
this._showDebug();
|
|
222
|
+
}
|
|
223
|
+
if(dbugger.level !== prevProps.dbugger.level || dbugger.objectValues !== prevProps.dbugger.objectValues) {
|
|
224
|
+
this._onRenderTooltip(null);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else if(CodeMirrorEditor.DEBUGGER_NOT_RUNNING === this.props.dbugger.state) {
|
|
228
|
+
const code = this.props.code.replaceAll('\r\n', '\n');
|
|
229
|
+
this.codeMirror.dispatch({changes: {
|
|
230
|
+
from: 0,
|
|
231
|
+
to: this.codeMirror.state.doc.length,
|
|
232
|
+
insert: code
|
|
233
|
+
}});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
else if(CodeMirrorEditor.DEBUGGER_BREAK === prevProps.dbugger.state) {
|
|
237
|
+
if(CodeMirrorEditor.DEBUGGER_RUNNING === this.props.dbugger.state) {
|
|
238
|
+
this.extensionLinesBreakpoint.set(this.codeMirror, this.props.options, []);
|
|
239
|
+
}
|
|
240
|
+
else if(CodeMirrorEditor.DEBUGGER_BREAK === this.props.dbugger.state) {
|
|
241
|
+
if((this.props.docKey === dbugger.actor.index) && ((prevProps.dbugger.level !== dbugger.level) || (prevProps.dbugger.scripts !== dbugger.scripts))) {
|
|
242
|
+
this._showDebug();
|
|
243
|
+
}
|
|
244
|
+
if(dbugger.level !== prevProps.dbugger.level || dbugger.objectValues !== prevProps.dbugger.objectValues) {
|
|
245
|
+
this._onRenderTooltip(null);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if('file' === this.props.currentType) {
|
|
251
|
+
if(prevProps.lines !== this.props.lines) {
|
|
252
|
+
this.lineFunctions.forEach((lineFunction) => {
|
|
253
|
+
const lines = this._getLines(lineFunction.name);
|
|
254
|
+
lineFunction.object.set(this.codeMirror, this.props.options, lines);
|
|
255
|
+
if(0 !== lines.length) {
|
|
256
|
+
this.extensionScroller.set(this.codeMirror, this.props.options, this.codeMirror.state.doc.lines, lines[lines.length - 1]);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if(prevProps.build !== this.props.build) {
|
|
262
|
+
this.extensionBuild.set(this.codeMirror, this.props.options, this.props.build, !!this.props.darkMode);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
_showDebug() {
|
|
267
|
+
const dbugger = this.props.dbugger;
|
|
268
|
+
const stackLevel = dbugger.stack[dbugger.level];
|
|
269
|
+
const codeLevel = dbugger.scripts.get(stackLevel.location.scriptId);
|
|
270
|
+
if(codeLevel) {
|
|
271
|
+
const code = codeLevel.replaceAll('\r\n', '\n');
|
|
272
|
+
this.codeMirror.dispatch({changes: {
|
|
273
|
+
from: 0,
|
|
274
|
+
to: this.codeMirror.state.doc.length,
|
|
275
|
+
insert: code
|
|
276
|
+
}});
|
|
277
|
+
}
|
|
278
|
+
const breakpointLine = this._getBreakpointLine(stackLevel);
|
|
279
|
+
if(breakpointLine) {
|
|
280
|
+
this.extensionScroller.set(this.codeMirror, this.props.options, this.codeMirror.state.doc.lines, breakpointLine);
|
|
281
|
+
this.extensionLinesBreakpoint.set(this.codeMirror, this.props.options, [breakpointLine]);
|
|
282
|
+
}
|
|
283
|
+
this.extensionBreakpoint.set(this.codeMirror, this.props.options, stackLevel.url, dbugger.breakpoints);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
_getBreakpointLine(stackLevel) {
|
|
287
|
+
const dbugger = this.props.dbugger;
|
|
288
|
+
if(dbugger.actor.index === this.props.docKey) {
|
|
289
|
+
return {
|
|
290
|
+
line: stackLevel.location.lineNumber + 1,
|
|
291
|
+
type: 0
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
_getLines(name) {
|
|
300
|
+
if('file' === this.props.currentType) {
|
|
301
|
+
const linesFunction = this.lineFunctions.get(name);
|
|
302
|
+
const l = linesFunction.getLines(`${this.props.currentFile.path}/${this.props.currentFile.title}`);
|
|
303
|
+
return l;
|
|
304
|
+
}
|
|
305
|
+
return [];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
_objectData(texts) {
|
|
309
|
+
for(let i = 0; i < texts.length; ++i) {
|
|
310
|
+
if('this' === texts[i]) {
|
|
311
|
+
const dbugger = this.props.dbugger;
|
|
312
|
+
const debugData = dbugger.stack[dbugger.level];
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
_onRenderTooltip(texts) {
|
|
320
|
+
if(null !== this.reactDivPopupRoot) {
|
|
321
|
+
const dbugger = this.props.dbugger;
|
|
322
|
+
const debugData = dbugger.stack[dbugger.level];
|
|
323
|
+
this._objectData(texts);
|
|
324
|
+
/*if(debugData.this) {
|
|
325
|
+
const name = 'this_' + debugData.this.className;
|
|
326
|
+
const scopesOpen = dbugger.scopesOpen;
|
|
327
|
+
const open = scopesOpen.get(name).open[0];
|
|
328
|
+
return (
|
|
329
|
+
<CodeMirror key="this" name="this" value={debugData.this} objectValues={dbugger.objectValues} open={open}
|
|
330
|
+
onGetMembers={(object, open) => {
|
|
331
|
+
this.dispatch(TestCaseStore, new ActionTestCaseDebugGetMembers(object, open));
|
|
332
|
+
}}
|
|
333
|
+
onOpen={(scope, open) => {
|
|
334
|
+
this.dispatch(TestCaseStore, new ActionTestCaseDebugScopeOpen(name, 0, open));
|
|
335
|
+
}}
|
|
336
|
+
/>
|
|
337
|
+
);
|
|
338
|
+
}*/
|
|
339
|
+
this.reactDivPopupRoot.render(<CodeMirrorPopover currentValue={dbugger.currentValue} objectValues={dbugger.objectValues} texts={texts}
|
|
340
|
+
onGetMembers={(object, open) => {
|
|
341
|
+
console.log('CLICK');
|
|
342
|
+
}}
|
|
343
|
+
onClose={() => {
|
|
344
|
+
this.reactDivPopupRoot.unmount();
|
|
345
|
+
this.reactDivPopupRoot = null;
|
|
346
|
+
this.props.onClearCurrentValue && this.props.onClearCurrentValue();
|
|
347
|
+
}}
|
|
348
|
+
/>);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
_onDebugTooltip(divNode, createOrDestroy, texts) {
|
|
353
|
+
if(createOrDestroy) {
|
|
354
|
+
this.reactDivPopupRoot = createRoot(divNode);
|
|
355
|
+
this._onRenderTooltip(texts);
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
if(this.reactDivPopupRoot) {
|
|
359
|
+
this.reactDivPopupRoot.unmount();
|
|
360
|
+
this.reactDivPopupRoot = null;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/*_mouseOver(event) {
|
|
366
|
+
if(1 === ++this.showTooltip) {
|
|
367
|
+
this.currentTarget = event.currentTarget;
|
|
368
|
+
event.currentTarget.style = 'background-color:Lavender;cursor:pointer';
|
|
369
|
+
this._addPopoverProperty(event);
|
|
370
|
+
this._showTooltip();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
_mouseOut(event) {
|
|
375
|
+
setTimeout(() => {
|
|
376
|
+
if(0 === --this.showTooltip) {
|
|
377
|
+
this._removePopoverProperty();
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
_mouseHandler(event) {
|
|
383
|
+
if(event.cancelable) {
|
|
384
|
+
event.cancelBubble = true;
|
|
385
|
+
}
|
|
386
|
+
if("mouseover" === event.type) {
|
|
387
|
+
this._mouseOver(event);
|
|
388
|
+
}
|
|
389
|
+
else if("mouseout" === event.type) {
|
|
390
|
+
this._mouseOut(event);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
_bindPopover() {
|
|
395
|
+
$("span.cm-def").each((idx, element) => {
|
|
396
|
+
CodeMirror.on(element, "mouseover", this._mouseHandler.bind(this));
|
|
397
|
+
CodeMirror.on(element, "mouseout", this._mouseHandler.bind(this));
|
|
398
|
+
});
|
|
399
|
+
$("span.cm-property").each((idx, element) => {
|
|
400
|
+
CodeMirror.on(element, "mouseover", this._mouseHandler.bind(this));
|
|
401
|
+
CodeMirror.on(element, "mouseout", this._mouseHandler.bind(this));
|
|
402
|
+
});
|
|
403
|
+
$("span.cm-variable").each((idx, element) => {
|
|
404
|
+
CodeMirror.on(element, "mouseover", this._mouseHandler.bind(this));
|
|
405
|
+
CodeMirror.on(element, "mouseout", this._mouseHandler.bind(this));
|
|
406
|
+
});
|
|
407
|
+
$("span.cm-variable-2").each((idx, element) => {
|
|
408
|
+
CodeMirror.on(element, "mouseover", this._mouseHandler.bind(this));
|
|
409
|
+
CodeMirror.on(element, "mouseout", this._mouseHandler.bind(this));
|
|
410
|
+
});
|
|
411
|
+
$("span.cm-keyword").each((idx, element) => {
|
|
412
|
+
CodeMirror.on(element, "mouseover", this._mouseHandler.bind(this));
|
|
413
|
+
CodeMirror.on(element, "mouseout", this._mouseHandler.bind(this));
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
_unbindPopover() {
|
|
418
|
+
$("span.cm-def").each((idx, element) => {
|
|
419
|
+
CodeMirror.off(element, "mouseover", this._mouseHandler.bind(this));
|
|
420
|
+
CodeMirror.off(element, "mouseout", this._mouseHandler.bind(this));
|
|
421
|
+
});
|
|
422
|
+
$("span.cm-property").each((idx, element) => {
|
|
423
|
+
CodeMirror.off(element, "mouseover", this._mouseHandler.bind(this));
|
|
424
|
+
CodeMirror.off(element, "mouseout", this._mouseHandler.bind(this));
|
|
425
|
+
});
|
|
426
|
+
$("span.cm-variable").each((idx, element) => {
|
|
427
|
+
CodeMirror.off(element, "mouseover", this._mouseHandler.bind(this));
|
|
428
|
+
CodeMirror.off(element, "mouseout", this._mouseHandler.bind(this));
|
|
429
|
+
});
|
|
430
|
+
$("span.cm-variable-2").each((idx, element) => {
|
|
431
|
+
CodeMirror.off(element, "mouseover", this._mouseHandler.bind(this));
|
|
432
|
+
CodeMirror.off(element, "mouseout", this._mouseHandler.bind(this));
|
|
433
|
+
});
|
|
434
|
+
$("span.cm-keyword").each((idx, element) => {
|
|
435
|
+
CodeMirror.off(element, "mouseover", this._mouseHandler.bind(this));
|
|
436
|
+
CodeMirror.off(element, "mouseout", this._mouseHandler.bind(this));
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
_addPopoverProperty(event) {
|
|
441
|
+
const memberNameArray = [event.currentTarget.textContent];
|
|
442
|
+
let previousSibling = event.currentTarget.previousSibling;
|
|
443
|
+
while (null !== previousSibling) {
|
|
444
|
+
if('.' !== previousSibling.textContent) {
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
previousSibling = previousSibling.previousSibling;
|
|
448
|
+
if(null !== previousSibling) {
|
|
449
|
+
memberNameArray.unshift(previousSibling.textContent);
|
|
450
|
+
}
|
|
451
|
+
previousSibling = previousSibling.previousSibling;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
this.popoverDiv = document.createElement('div');
|
|
455
|
+
this.reactDiv = this.popoverDiv.appendChild(document.createElement('div'));
|
|
456
|
+
this.reactDiv.setAttribute('id', 'debug_popover');
|
|
457
|
+
this.reactDiv.setAttribute('style', `left:${event.clientX - 10}px;top:${event.clientY}px;`);
|
|
458
|
+
CodeMirror.on(this.reactDiv, "mouseover", this._tooltipMouseHandler.bind(this));
|
|
459
|
+
CodeMirror.on(this.reactDiv, "mouseout", this._tooltipMouseHandler.bind(this));
|
|
460
|
+
document.body.appendChild(this.popoverDiv);
|
|
461
|
+
this._getTooltipValue(memberNameArray, event.currentTarget.className);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
_removePopoverProperty() {
|
|
465
|
+
if(null !== this.popoverDiv) {
|
|
466
|
+
CodeMirror.off(this.reactDiv, "mouseover", this._tooltipMouseHandler.bind(this));
|
|
467
|
+
CodeMirror.off(this.reactDiv, "mouseout", this._tooltipMouseHandler.bind(this));
|
|
468
|
+
this.reactDivRoot.unmount();
|
|
469
|
+
this.reactDivRoot = null;
|
|
470
|
+
this.reactDiv = null;
|
|
471
|
+
document.body.removeChild(this.popoverDiv);
|
|
472
|
+
this.popoverDiv = null;
|
|
473
|
+
}
|
|
474
|
+
if(null !== this.currentTarget) {
|
|
475
|
+
this.currentTarget.style = '';
|
|
476
|
+
this.currentTarget = null;
|
|
477
|
+
}
|
|
478
|
+
this.props.onClearCurrentValue && this.props.onClearCurrentValue();
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
_getTooltipValue(memberNameArray, cmType) {
|
|
482
|
+
if('cm-property' === cmType && 1 <= memberNameArray.length) {
|
|
483
|
+
if('this' === memberNameArray[0]) {
|
|
484
|
+
this.props.onGetCurrentValueByName && this.props.onGetCurrentValueByName(memberNameArray, 'this');
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
this.props.onGetCurrentValueByName && this.props.onGetCurrentValueByName(memberNameArray, 'keyword');
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
else if('cm-keyword' === cmType) {
|
|
491
|
+
if(1 === memberNameArray.length) {
|
|
492
|
+
if('this' === memberNameArray[0]) {
|
|
493
|
+
this.props.onGetCurrentValueByName && this.props.onGetCurrentValueByName(memberNameArray, 'this');
|
|
494
|
+
}
|
|
495
|
+
else if('let' === memberNameArray[0]) {
|
|
496
|
+
this.props.onGetKeyWord && this.props.onGetKeyWord(memberNameArray);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
else if('cm-def' === cmType ||'cm-variable-2' === cmType) {
|
|
501
|
+
this.props.onGetCurrentValueByName && this.props.onGetCurrentValueByName(memberNameArray, 'local');
|
|
502
|
+
}
|
|
503
|
+
}*/
|
|
504
|
+
|
|
505
|
+
/*_showPopup(dbugger) {
|
|
506
|
+
if(this.reactDiv) {
|
|
507
|
+
this.reactDiv = document.getElementById('debug_popover');
|
|
508
|
+
}
|
|
509
|
+
if(null !== this.reactDiv) {
|
|
510
|
+
if(null === this.reactDivRoot) {
|
|
511
|
+
this.reactDivRoot = createRoot(this.reactDiv);
|
|
512
|
+
}
|
|
513
|
+
this.reactDivRoot.render(<CodeMirrorPopover currentValue={dbugger.currentValue} objectValues={dbugger.objectValues}
|
|
514
|
+
onGetMembers={(object, open) => {
|
|
515
|
+
this.props.onGetMembers && this.props.onGetMembers(object, open);
|
|
516
|
+
}}
|
|
517
|
+
onClose={() => {
|
|
518
|
+
this._removePopoverProperty();
|
|
519
|
+
this.showTooltip = 0;
|
|
520
|
+
}}
|
|
521
|
+
/>);
|
|
522
|
+
}
|
|
523
|
+
}*/
|
|
524
|
+
|
|
525
|
+
/*_tooltipMouseHandler(event) {
|
|
526
|
+
if(event.cancelable) {
|
|
527
|
+
event.cancelBubble = true;
|
|
528
|
+
}
|
|
529
|
+
if("mouseover" === event.type) {
|
|
530
|
+
++this.showTooltip;
|
|
531
|
+
}
|
|
532
|
+
else if("mouseout" === event.type) {
|
|
533
|
+
setTimeout(() => {
|
|
534
|
+
if(0 === --this.showTooltip) {
|
|
535
|
+
this._removePopoverProperty();
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
_showTooltip() {
|
|
542
|
+
const dbugger = this.props.dbugger;
|
|
543
|
+
this._showPopup(dbugger);
|
|
544
|
+
const element = $("#debug_popover");
|
|
545
|
+
if(element) {
|
|
546
|
+
CodeMirror.on(element, "mouseover", this._tooltipMouseHandler.bind(this));
|
|
547
|
+
CodeMirror.on(element, "mouseout", this._tooltipMouseHandler.bind(this));
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
*/
|
|
551
|
+
render () {
|
|
552
|
+
this._id = this.props.id ? `${this.props.id}_code_mirror_editor_textarea` : 'code_mirror_editor_textarea';
|
|
553
|
+
return (
|
|
554
|
+
<div className={"code_mirror_editor_view basic_same_size_as_parent"}>
|
|
555
|
+
<div className="code_mirror_editor basic_same_size_as_parent" ref={(ref) => this._code_mirror = ref} id={this._id} />
|
|
556
|
+
</div>
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
import ReactComponentBase from 'z-abs-corelayer-client/client/react-component/react-component-base';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export default class CodeMirrorPopoverBuild extends ReactComponentBase {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
shouldUpdate(nextProps, nextState) {
|
|
14
|
+
return !this.deepCompare(this.props.message, nextProps.message);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
renderTitle(id) {
|
|
18
|
+
return (
|
|
19
|
+
<div id={id}>
|
|
20
|
+
<p id="debug_popover_title_title">
|
|
21
|
+
Build Error
|
|
22
|
+
</p>
|
|
23
|
+
<button type="button" id="debug_popover_title_close" className="close" aria-label="Close"
|
|
24
|
+
onClick={(e) => {
|
|
25
|
+
this.props.onClose && this.props.onClose();
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
×
|
|
29
|
+
</button>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
renderMessage(message) {
|
|
35
|
+
if(Array.isArray(message)) {
|
|
36
|
+
const results = [];
|
|
37
|
+
message.forEach((msg) => {
|
|
38
|
+
results.push(this.renderMessage(msg));
|
|
39
|
+
});
|
|
40
|
+
return results;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return (
|
|
44
|
+
<p className="debug_popover_content">
|
|
45
|
+
{'\u2022 ' + message}
|
|
46
|
+
</p>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
render() {
|
|
52
|
+
return (
|
|
53
|
+
<div id="debug_popover_tooltip">
|
|
54
|
+
{this.renderTitle('debug_popover_title_value')}
|
|
55
|
+
<div id="debug_popover_content">
|
|
56
|
+
{this.renderMessage(this.props.message)}
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|