@hpcc-js/codemirror 3.7.2 → 3.7.4
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/LICENSE +43 -43
- package/README.md +66 -66
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +4 -4
- package/src/CSSEditor.ts +22 -22
- package/src/DOTEditor.ts +20 -20
- package/src/ECLEditor.css +49 -49
- package/src/ECLEditor.ts +24 -24
- package/src/Editor.css +29 -29
- package/src/Editor.ts +232 -232
- package/src/HTMLEditor.ts +22 -22
- package/src/JSEditor.ts +22 -22
- package/src/JSONEditor.ts +22 -22
- package/src/SQLEditor.ts +22 -22
- package/src/XMLEditor.ts +22 -22
- package/src/YAMLEditor.ts +22 -22
- package/src/__package__.ts +3 -3
- package/src/codemirror-shim.ts +33 -33
- package/src/mode/dot/dot.ts +94 -94
- package/src/mode/markdown/markdown.ts +879 -879
package/src/Editor.ts
CHANGED
|
@@ -1,232 +1,232 @@
|
|
|
1
|
-
import { CodeMirror } from "./codemirror-shim.ts";
|
|
2
|
-
import { HTMLWidget, Palette } from "@hpcc-js/common";
|
|
3
|
-
|
|
4
|
-
import "../src/Editor.css";
|
|
5
|
-
|
|
6
|
-
export interface IPosition {
|
|
7
|
-
line: number;
|
|
8
|
-
ch: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ICompletion {
|
|
12
|
-
list: string[],
|
|
13
|
-
from: number,
|
|
14
|
-
to: number
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class Editor extends HTMLWidget {
|
|
18
|
-
private _codemirror: CodeMirror.EditorFromTextArea;
|
|
19
|
-
private _markedText = [];
|
|
20
|
-
protected _initialText: string = "";
|
|
21
|
-
|
|
22
|
-
options(): any {
|
|
23
|
-
return {
|
|
24
|
-
gutters: this.guttersOption(),
|
|
25
|
-
readOnly: this.readOnly(),
|
|
26
|
-
lineNumbers: true,
|
|
27
|
-
tabSize: 2
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
private _options = new Map<string, string | number>();
|
|
32
|
-
option(option: string): string | number;
|
|
33
|
-
option(option: string, value: string | number): this;
|
|
34
|
-
option(option: string, value?: string | number): string | number | this {
|
|
35
|
-
if (this._codemirror) {
|
|
36
|
-
if (arguments.length < 2) {
|
|
37
|
-
return this._codemirror.getOption(option);
|
|
38
|
-
}
|
|
39
|
-
this._codemirror.setOption(option, value);
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
if (arguments.length < 2) {
|
|
43
|
-
return this._options.get(option);
|
|
44
|
-
}
|
|
45
|
-
this._options.set(option, value);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
guttersOption(): (string | { className: string, style: string })[] {
|
|
49
|
-
const gutters: (string | { className: string, style: string })[] = ["CodeMirror-linenumbers"];
|
|
50
|
-
if (this.gutterMarkerWidth() > 0) {
|
|
51
|
-
gutters.unshift({
|
|
52
|
-
className: "CodeMirror-guttermarker",
|
|
53
|
-
style: `width:${this.gutterMarkerWidth()}px;`
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return gutters;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
addGutterMarker(lineNumber: number, commentText: string, backgroundColor: string = null, fontFamily: string = null, fontSize: string = null, onmouseenter = () => { }, onmouseleave = () => { }, onclick = (event: MouseEvent) => { }) {
|
|
60
|
-
const line = this._codemirror.getLineHandle(lineNumber);
|
|
61
|
-
const marker = document.createElement("div");
|
|
62
|
-
marker.textContent = commentText;
|
|
63
|
-
marker.style.paddingLeft = "3px";
|
|
64
|
-
marker.style.paddingRight = "3px";
|
|
65
|
-
marker.style.color = Palette.textColor(backgroundColor);
|
|
66
|
-
if (fontFamily !== null) {
|
|
67
|
-
marker.style.fontFamily = fontFamily;
|
|
68
|
-
}
|
|
69
|
-
if (fontSize !== null) {
|
|
70
|
-
marker.style.fontSize = fontSize;
|
|
71
|
-
}
|
|
72
|
-
marker.style.backgroundColor = backgroundColor;
|
|
73
|
-
marker.style.textAlign = this.markerTextAlign();
|
|
74
|
-
this._codemirror.setGutterMarker(line, "CodeMirror-guttermarker", marker);
|
|
75
|
-
marker.onmouseenter = onmouseenter;
|
|
76
|
-
marker.onmouseleave = onmouseleave;
|
|
77
|
-
marker.onclick = onclick;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
removeGutterMarker(lineNumber: number) {
|
|
81
|
-
const line = this._codemirror.getLineHandle(lineNumber);
|
|
82
|
-
this._codemirror.setGutterMarker(line, "CodeMirror-guttermarker", null);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
hasFocus(): boolean {
|
|
86
|
-
return this._codemirror.hasFocus();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
text(): string;
|
|
90
|
-
text(_: string): this;
|
|
91
|
-
text(_?: string): string | this {
|
|
92
|
-
if (this._codemirror) {
|
|
93
|
-
const doc = this._codemirror.getDoc();
|
|
94
|
-
if (!arguments.length) return doc.getValue();
|
|
95
|
-
doc.setValue(_);
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
if (!arguments.length) return this._initialText;
|
|
99
|
-
this._initialText = _;
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
highlight(start: IPosition | number, end: IPosition | number, className = "cm-marked-text"): this {
|
|
104
|
-
if (typeof start === "number") start = this.positionAt(start);
|
|
105
|
-
if (typeof end === "number") end = this.positionAt(end);
|
|
106
|
-
if (this._codemirror) {
|
|
107
|
-
this._markedText.push(this._codemirror.markText(start, end, { className }));
|
|
108
|
-
}
|
|
109
|
-
return this;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
highlightInfo(start: IPosition | number, end: IPosition | number): this {
|
|
113
|
-
this.highlight(start, end, "cm-marked-info");
|
|
114
|
-
return this;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
highlightWarning(start: IPosition | number, end: IPosition | number): this {
|
|
118
|
-
this.highlight(start, end, "cm-marked-warning");
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
highlightError(start: IPosition | number, end: IPosition | number): this {
|
|
123
|
-
this.highlight(start, end, "cm-marked-error");
|
|
124
|
-
return this;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
addLineClass(options: { lineNum: number, where?: "text" | "background" | "gutter", cssClass: string }): this {
|
|
128
|
-
this._codemirror.addLineClass(this._codemirror.getLineHandle(options.lineNum), options.where ?? "background", options.cssClass);
|
|
129
|
-
return this;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
removeLineClass(options: { lineNum: number, where?: "text" | "background" | "gutter", cssClass: string }): this {
|
|
133
|
-
this._codemirror.removeLineClass(this._codemirror.getLineHandle(options.lineNum), options.where ?? "background", options.cssClass);
|
|
134
|
-
return this;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
removeAllHighlight(): this {
|
|
138
|
-
for (const marked of this._markedText) {
|
|
139
|
-
marked.clear();
|
|
140
|
-
}
|
|
141
|
-
this._markedText = [];
|
|
142
|
-
return this;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
positionAt(i: number): IPosition {
|
|
146
|
-
return this._codemirror.posFromIndex(i);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
getLineLength(lineNumber: number): number {
|
|
150
|
-
return this._codemirror.doc.getLine(lineNumber)?.length || 0;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
highlightSubstring(str: string) {
|
|
154
|
-
const splitTextArr = this.text().split(str).slice(0, -1);
|
|
155
|
-
let idx = 0;
|
|
156
|
-
splitTextArr.forEach(splitText => {
|
|
157
|
-
idx += splitText.length;
|
|
158
|
-
this.highlight(
|
|
159
|
-
this.positionAt(idx),
|
|
160
|
-
this.positionAt(idx + str.length)
|
|
161
|
-
);
|
|
162
|
-
idx += str.length;
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
setCursor(row: number, col: number, focus = true) {
|
|
167
|
-
this._codemirror.setCursor(row, col);
|
|
168
|
-
if (focus) {
|
|
169
|
-
setTimeout(() => {
|
|
170
|
-
this._codemirror.focus();
|
|
171
|
-
}, 0);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
enter(domNode, element) {
|
|
176
|
-
super.enter(domNode, element);
|
|
177
|
-
this._codemirror = CodeMirror.fromTextArea(element.append("textarea").node(), this.options());
|
|
178
|
-
this._codemirror.on("changes", (cm: CodeMirror.EditorFromTextArea, changes: object[]) => {
|
|
179
|
-
this.changes(changes);
|
|
180
|
-
});
|
|
181
|
-
this._options.forEach((value, key) => {
|
|
182
|
-
this._codemirror.setOption(key, value);
|
|
183
|
-
});
|
|
184
|
-
this.text(this._initialText);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
update(domNode, Element) {
|
|
188
|
-
super.update(domNode, Element);
|
|
189
|
-
const extraKeys = this._codemirror.getOption("extraKeys") ?? {};
|
|
190
|
-
if (this.showHints()) {
|
|
191
|
-
extraKeys["Ctrl-Space"] = "autocomplete";
|
|
192
|
-
} else {
|
|
193
|
-
delete extraKeys["Ctrl-Space"];
|
|
194
|
-
}
|
|
195
|
-
this._codemirror.setOption("readOnly", this.readOnly());
|
|
196
|
-
this._codemirror.setOption("gutters", this.guttersOption());
|
|
197
|
-
this._codemirror.setOption("extraKeys", extraKeys);
|
|
198
|
-
this._codemirror.setOption("hintOptions", this.showHints() ? { hint: (cm, option) => this.fetchHints(cm, option) } : {});
|
|
199
|
-
this._codemirror.setSize(this.width() - 2, this.height() - 2);
|
|
200
|
-
this._codemirror.refresh();
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Events ---
|
|
204
|
-
changes(changes: object[]) {
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
fetchHints(cm, option): Promise<ICompletion> {
|
|
208
|
-
return Promise.resolve(null);
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* @deprecated Replaced with `option`
|
|
212
|
-
*/
|
|
213
|
-
setOption(option: string, value: any): void {
|
|
214
|
-
this._codemirror.setOption(option, value);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
Editor.prototype._class += " codemirror_Editor";
|
|
218
|
-
|
|
219
|
-
export interface Editor {
|
|
220
|
-
readOnly(): boolean;
|
|
221
|
-
readOnly(_: boolean): this;
|
|
222
|
-
gutterMarkerWidth(): number;
|
|
223
|
-
gutterMarkerWidth(_: number): this;
|
|
224
|
-
markerTextAlign(): string;
|
|
225
|
-
markerTextAlign(_: string): this;
|
|
226
|
-
showHints(): boolean;
|
|
227
|
-
showHints(_: boolean): this;
|
|
228
|
-
}
|
|
229
|
-
Editor.prototype.publish("markerTextAlign", "right", "string", "Gutter marker text alignment", ["left", "center", "right"]);
|
|
230
|
-
Editor.prototype.publish("readOnly", false, "boolean", "If true, the contents will be uneditable");
|
|
231
|
-
Editor.prototype.publish("gutterMarkerWidth", 0, "number", "Width of gutter marker column displayed to the left of line numbers (pixels)");
|
|
232
|
-
Editor.prototype.publish("showHints", false, "boolean", "Show autocomplete hints on ctrl+space");
|
|
1
|
+
import { CodeMirror } from "./codemirror-shim.ts";
|
|
2
|
+
import { HTMLWidget, Palette } from "@hpcc-js/common";
|
|
3
|
+
|
|
4
|
+
import "../src/Editor.css";
|
|
5
|
+
|
|
6
|
+
export interface IPosition {
|
|
7
|
+
line: number;
|
|
8
|
+
ch: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ICompletion {
|
|
12
|
+
list: string[],
|
|
13
|
+
from: number,
|
|
14
|
+
to: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class Editor extends HTMLWidget {
|
|
18
|
+
private _codemirror: CodeMirror.EditorFromTextArea;
|
|
19
|
+
private _markedText = [];
|
|
20
|
+
protected _initialText: string = "";
|
|
21
|
+
|
|
22
|
+
options(): any {
|
|
23
|
+
return {
|
|
24
|
+
gutters: this.guttersOption(),
|
|
25
|
+
readOnly: this.readOnly(),
|
|
26
|
+
lineNumbers: true,
|
|
27
|
+
tabSize: 2
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private _options = new Map<string, string | number>();
|
|
32
|
+
option(option: string): string | number;
|
|
33
|
+
option(option: string, value: string | number): this;
|
|
34
|
+
option(option: string, value?: string | number): string | number | this {
|
|
35
|
+
if (this._codemirror) {
|
|
36
|
+
if (arguments.length < 2) {
|
|
37
|
+
return this._codemirror.getOption(option);
|
|
38
|
+
}
|
|
39
|
+
this._codemirror.setOption(option, value);
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
if (arguments.length < 2) {
|
|
43
|
+
return this._options.get(option);
|
|
44
|
+
}
|
|
45
|
+
this._options.set(option, value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
guttersOption(): (string | { className: string, style: string })[] {
|
|
49
|
+
const gutters: (string | { className: string, style: string })[] = ["CodeMirror-linenumbers"];
|
|
50
|
+
if (this.gutterMarkerWidth() > 0) {
|
|
51
|
+
gutters.unshift({
|
|
52
|
+
className: "CodeMirror-guttermarker",
|
|
53
|
+
style: `width:${this.gutterMarkerWidth()}px;`
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return gutters;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
addGutterMarker(lineNumber: number, commentText: string, backgroundColor: string = null, fontFamily: string = null, fontSize: string = null, onmouseenter = () => { }, onmouseleave = () => { }, onclick = (event: MouseEvent) => { }) {
|
|
60
|
+
const line = this._codemirror.getLineHandle(lineNumber);
|
|
61
|
+
const marker = document.createElement("div");
|
|
62
|
+
marker.textContent = commentText;
|
|
63
|
+
marker.style.paddingLeft = "3px";
|
|
64
|
+
marker.style.paddingRight = "3px";
|
|
65
|
+
marker.style.color = Palette.textColor(backgroundColor);
|
|
66
|
+
if (fontFamily !== null) {
|
|
67
|
+
marker.style.fontFamily = fontFamily;
|
|
68
|
+
}
|
|
69
|
+
if (fontSize !== null) {
|
|
70
|
+
marker.style.fontSize = fontSize;
|
|
71
|
+
}
|
|
72
|
+
marker.style.backgroundColor = backgroundColor;
|
|
73
|
+
marker.style.textAlign = this.markerTextAlign();
|
|
74
|
+
this._codemirror.setGutterMarker(line, "CodeMirror-guttermarker", marker);
|
|
75
|
+
marker.onmouseenter = onmouseenter;
|
|
76
|
+
marker.onmouseleave = onmouseleave;
|
|
77
|
+
marker.onclick = onclick;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
removeGutterMarker(lineNumber: number) {
|
|
81
|
+
const line = this._codemirror.getLineHandle(lineNumber);
|
|
82
|
+
this._codemirror.setGutterMarker(line, "CodeMirror-guttermarker", null);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
hasFocus(): boolean {
|
|
86
|
+
return this._codemirror.hasFocus();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
text(): string;
|
|
90
|
+
text(_: string): this;
|
|
91
|
+
text(_?: string): string | this {
|
|
92
|
+
if (this._codemirror) {
|
|
93
|
+
const doc = this._codemirror.getDoc();
|
|
94
|
+
if (!arguments.length) return doc.getValue();
|
|
95
|
+
doc.setValue(_);
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
if (!arguments.length) return this._initialText;
|
|
99
|
+
this._initialText = _;
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
highlight(start: IPosition | number, end: IPosition | number, className = "cm-marked-text"): this {
|
|
104
|
+
if (typeof start === "number") start = this.positionAt(start);
|
|
105
|
+
if (typeof end === "number") end = this.positionAt(end);
|
|
106
|
+
if (this._codemirror) {
|
|
107
|
+
this._markedText.push(this._codemirror.markText(start, end, { className }));
|
|
108
|
+
}
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
highlightInfo(start: IPosition | number, end: IPosition | number): this {
|
|
113
|
+
this.highlight(start, end, "cm-marked-info");
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
highlightWarning(start: IPosition | number, end: IPosition | number): this {
|
|
118
|
+
this.highlight(start, end, "cm-marked-warning");
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
highlightError(start: IPosition | number, end: IPosition | number): this {
|
|
123
|
+
this.highlight(start, end, "cm-marked-error");
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
addLineClass(options: { lineNum: number, where?: "text" | "background" | "gutter", cssClass: string }): this {
|
|
128
|
+
this._codemirror.addLineClass(this._codemirror.getLineHandle(options.lineNum), options.where ?? "background", options.cssClass);
|
|
129
|
+
return this;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
removeLineClass(options: { lineNum: number, where?: "text" | "background" | "gutter", cssClass: string }): this {
|
|
133
|
+
this._codemirror.removeLineClass(this._codemirror.getLineHandle(options.lineNum), options.where ?? "background", options.cssClass);
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
removeAllHighlight(): this {
|
|
138
|
+
for (const marked of this._markedText) {
|
|
139
|
+
marked.clear();
|
|
140
|
+
}
|
|
141
|
+
this._markedText = [];
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
positionAt(i: number): IPosition {
|
|
146
|
+
return this._codemirror.posFromIndex(i);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
getLineLength(lineNumber: number): number {
|
|
150
|
+
return this._codemirror.doc.getLine(lineNumber)?.length || 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
highlightSubstring(str: string) {
|
|
154
|
+
const splitTextArr = this.text().split(str).slice(0, -1);
|
|
155
|
+
let idx = 0;
|
|
156
|
+
splitTextArr.forEach(splitText => {
|
|
157
|
+
idx += splitText.length;
|
|
158
|
+
this.highlight(
|
|
159
|
+
this.positionAt(idx),
|
|
160
|
+
this.positionAt(idx + str.length)
|
|
161
|
+
);
|
|
162
|
+
idx += str.length;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
setCursor(row: number, col: number, focus = true) {
|
|
167
|
+
this._codemirror.setCursor(row, col);
|
|
168
|
+
if (focus) {
|
|
169
|
+
setTimeout(() => {
|
|
170
|
+
this._codemirror.focus();
|
|
171
|
+
}, 0);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
enter(domNode, element) {
|
|
176
|
+
super.enter(domNode, element);
|
|
177
|
+
this._codemirror = CodeMirror.fromTextArea(element.append("textarea").node(), this.options());
|
|
178
|
+
this._codemirror.on("changes", (cm: CodeMirror.EditorFromTextArea, changes: object[]) => {
|
|
179
|
+
this.changes(changes);
|
|
180
|
+
});
|
|
181
|
+
this._options.forEach((value, key) => {
|
|
182
|
+
this._codemirror.setOption(key, value);
|
|
183
|
+
});
|
|
184
|
+
this.text(this._initialText);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
update(domNode, Element) {
|
|
188
|
+
super.update(domNode, Element);
|
|
189
|
+
const extraKeys = this._codemirror.getOption("extraKeys") ?? {};
|
|
190
|
+
if (this.showHints()) {
|
|
191
|
+
extraKeys["Ctrl-Space"] = "autocomplete";
|
|
192
|
+
} else {
|
|
193
|
+
delete extraKeys["Ctrl-Space"];
|
|
194
|
+
}
|
|
195
|
+
this._codemirror.setOption("readOnly", this.readOnly());
|
|
196
|
+
this._codemirror.setOption("gutters", this.guttersOption());
|
|
197
|
+
this._codemirror.setOption("extraKeys", extraKeys);
|
|
198
|
+
this._codemirror.setOption("hintOptions", this.showHints() ? { hint: (cm, option) => this.fetchHints(cm, option) } : {});
|
|
199
|
+
this._codemirror.setSize(this.width() - 2, this.height() - 2);
|
|
200
|
+
this._codemirror.refresh();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Events ---
|
|
204
|
+
changes(changes: object[]) {
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
fetchHints(cm, option): Promise<ICompletion> {
|
|
208
|
+
return Promise.resolve(null);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @deprecated Replaced with `option`
|
|
212
|
+
*/
|
|
213
|
+
setOption(option: string, value: any): void {
|
|
214
|
+
this._codemirror.setOption(option, value);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
Editor.prototype._class += " codemirror_Editor";
|
|
218
|
+
|
|
219
|
+
export interface Editor {
|
|
220
|
+
readOnly(): boolean;
|
|
221
|
+
readOnly(_: boolean): this;
|
|
222
|
+
gutterMarkerWidth(): number;
|
|
223
|
+
gutterMarkerWidth(_: number): this;
|
|
224
|
+
markerTextAlign(): string;
|
|
225
|
+
markerTextAlign(_: string): this;
|
|
226
|
+
showHints(): boolean;
|
|
227
|
+
showHints(_: boolean): this;
|
|
228
|
+
}
|
|
229
|
+
Editor.prototype.publish("markerTextAlign", "right", "string", "Gutter marker text alignment", ["left", "center", "right"]);
|
|
230
|
+
Editor.prototype.publish("readOnly", false, "boolean", "If true, the contents will be uneditable");
|
|
231
|
+
Editor.prototype.publish("gutterMarkerWidth", 0, "number", "Width of gutter marker column displayed to the left of line numbers (pixels)");
|
|
232
|
+
Editor.prototype.publish("showHints", false, "boolean", "Show autocomplete hints on ctrl+space");
|
package/src/HTMLEditor.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Editor } from "./Editor.ts";
|
|
2
|
-
|
|
3
|
-
export class HTMLEditor extends Editor {
|
|
4
|
-
options(): any {
|
|
5
|
-
return {
|
|
6
|
-
...super.options(),
|
|
7
|
-
mode: "htmlmixed",
|
|
8
|
-
foldGutter: true,
|
|
9
|
-
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
html(): string;
|
|
14
|
-
html(_: string): this;
|
|
15
|
-
html(_?: string): string | this {
|
|
16
|
-
if (!arguments.length) return this.text();
|
|
17
|
-
this.text(_);
|
|
18
|
-
return this;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
HTMLEditor.prototype._class += " codemirror_HTMLEditor";
|
|
1
|
+
import { Editor } from "./Editor.ts";
|
|
2
|
+
|
|
3
|
+
export class HTMLEditor extends Editor {
|
|
4
|
+
options(): any {
|
|
5
|
+
return {
|
|
6
|
+
...super.options(),
|
|
7
|
+
mode: "htmlmixed",
|
|
8
|
+
foldGutter: true,
|
|
9
|
+
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
html(): string;
|
|
14
|
+
html(_: string): this;
|
|
15
|
+
html(_?: string): string | this {
|
|
16
|
+
if (!arguments.length) return this.text();
|
|
17
|
+
this.text(_);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
HTMLEditor.prototype._class += " codemirror_HTMLEditor";
|
package/src/JSEditor.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Editor } from "./Editor.ts";
|
|
2
|
-
|
|
3
|
-
export class JSEditor extends Editor {
|
|
4
|
-
options(): any {
|
|
5
|
-
return {
|
|
6
|
-
...super.options(),
|
|
7
|
-
mode: "text/javascript",
|
|
8
|
-
foldGutter: true,
|
|
9
|
-
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
javascript(): string;
|
|
14
|
-
javascript(_: string): this;
|
|
15
|
-
javascript(_?: string): string | this {
|
|
16
|
-
if (!arguments.length) return this.text();
|
|
17
|
-
this.text(_);
|
|
18
|
-
return this;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
JSEditor.prototype._class += " codemirror_JSEditor";
|
|
1
|
+
import { Editor } from "./Editor.ts";
|
|
2
|
+
|
|
3
|
+
export class JSEditor extends Editor {
|
|
4
|
+
options(): any {
|
|
5
|
+
return {
|
|
6
|
+
...super.options(),
|
|
7
|
+
mode: "text/javascript",
|
|
8
|
+
foldGutter: true,
|
|
9
|
+
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
javascript(): string;
|
|
14
|
+
javascript(_: string): this;
|
|
15
|
+
javascript(_?: string): string | this {
|
|
16
|
+
if (!arguments.length) return this.text();
|
|
17
|
+
this.text(_);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
JSEditor.prototype._class += " codemirror_JSEditor";
|
package/src/JSONEditor.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Editor } from "./Editor.ts";
|
|
2
|
-
|
|
3
|
-
export class JSONEditor extends Editor {
|
|
4
|
-
options(): any {
|
|
5
|
-
return {
|
|
6
|
-
...super.options(),
|
|
7
|
-
mode: "application/json",
|
|
8
|
-
foldGutter: true,
|
|
9
|
-
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
json(): object;
|
|
14
|
-
json(_: object): this;
|
|
15
|
-
json(_?: object): object | this {
|
|
16
|
-
if (!arguments.length) return JSON.parse(this.text());
|
|
17
|
-
this.text(JSON.stringify(_, null, "\t"));
|
|
18
|
-
return this;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
JSONEditor.prototype._class += " codemirror_JSONEditor";
|
|
1
|
+
import { Editor } from "./Editor.ts";
|
|
2
|
+
|
|
3
|
+
export class JSONEditor extends Editor {
|
|
4
|
+
options(): any {
|
|
5
|
+
return {
|
|
6
|
+
...super.options(),
|
|
7
|
+
mode: "application/json",
|
|
8
|
+
foldGutter: true,
|
|
9
|
+
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
json(): object;
|
|
14
|
+
json(_: object): this;
|
|
15
|
+
json(_?: object): object | this {
|
|
16
|
+
if (!arguments.length) return JSON.parse(this.text());
|
|
17
|
+
this.text(JSON.stringify(_, null, "\t"));
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
JSONEditor.prototype._class += " codemirror_JSONEditor";
|
package/src/SQLEditor.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Editor } from "./Editor.ts";
|
|
2
|
-
|
|
3
|
-
export class SQLEditor extends Editor {
|
|
4
|
-
options(): any {
|
|
5
|
-
return {
|
|
6
|
-
...super.options(),
|
|
7
|
-
mode: "text/x-pgsql",
|
|
8
|
-
foldGutter: true,
|
|
9
|
-
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
sql(): string;
|
|
14
|
-
sql(_: string): this;
|
|
15
|
-
sql(_?: string): string | this {
|
|
16
|
-
if (!arguments.length) return this.text();
|
|
17
|
-
this.text(_);
|
|
18
|
-
return this;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
SQLEditor.prototype._class += " codemirror_SQLEditor";
|
|
1
|
+
import { Editor } from "./Editor.ts";
|
|
2
|
+
|
|
3
|
+
export class SQLEditor extends Editor {
|
|
4
|
+
options(): any {
|
|
5
|
+
return {
|
|
6
|
+
...super.options(),
|
|
7
|
+
mode: "text/x-pgsql",
|
|
8
|
+
foldGutter: true,
|
|
9
|
+
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
sql(): string;
|
|
14
|
+
sql(_: string): this;
|
|
15
|
+
sql(_?: string): string | this {
|
|
16
|
+
if (!arguments.length) return this.text();
|
|
17
|
+
this.text(_);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
SQLEditor.prototype._class += " codemirror_SQLEditor";
|