@difizen/libro-codemirror 0.0.2-alpha.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/LICENSE +21 -0
- package/README.md +0 -0
- package/es/auto-complete/closebrackets.d.ts +12 -0
- package/es/auto-complete/closebrackets.d.ts.map +1 -0
- package/es/auto-complete/closebrackets.js +408 -0
- package/es/auto-complete/completion.d.ts +57 -0
- package/es/auto-complete/completion.d.ts.map +1 -0
- package/es/auto-complete/completion.js +265 -0
- package/es/auto-complete/config.d.ts +22 -0
- package/es/auto-complete/config.d.ts.map +1 -0
- package/es/auto-complete/config.js +44 -0
- package/es/auto-complete/filter.d.ts +13 -0
- package/es/auto-complete/filter.d.ts.map +1 -0
- package/es/auto-complete/filter.js +191 -0
- package/es/auto-complete/index.d.ts +17 -0
- package/es/auto-complete/index.d.ts.map +1 -0
- package/es/auto-complete/index.js +107 -0
- package/es/auto-complete/snippet.d.ts +14 -0
- package/es/auto-complete/snippet.d.ts.map +1 -0
- package/es/auto-complete/snippet.js +447 -0
- package/es/auto-complete/state.d.ts +63 -0
- package/es/auto-complete/state.d.ts.map +1 -0
- package/es/auto-complete/state.js +452 -0
- package/es/auto-complete/theme.d.ts +6 -0
- package/es/auto-complete/theme.d.ts.map +1 -0
- package/es/auto-complete/theme.js +151 -0
- package/es/auto-complete/tooltip.d.ts +5 -0
- package/es/auto-complete/tooltip.d.ts.map +1 -0
- package/es/auto-complete/tooltip.js +365 -0
- package/es/auto-complete/view.d.ts +43 -0
- package/es/auto-complete/view.d.ts.map +1 -0
- package/es/auto-complete/view.js +372 -0
- package/es/auto-complete/word.d.ts +3 -0
- package/es/auto-complete/word.d.ts.map +1 -0
- package/es/auto-complete/word.js +119 -0
- package/es/completion.d.ts +6 -0
- package/es/completion.d.ts.map +1 -0
- package/es/completion.js +84 -0
- package/es/config.d.ts +184 -0
- package/es/config.d.ts.map +1 -0
- package/es/config.js +473 -0
- package/es/editor.d.ts +361 -0
- package/es/editor.d.ts.map +1 -0
- package/es/editor.js +1126 -0
- package/es/factory.d.ts +3 -0
- package/es/factory.d.ts.map +1 -0
- package/es/factory.js +12 -0
- package/es/hyperlink.d.ts +15 -0
- package/es/hyperlink.d.ts.map +1 -0
- package/es/hyperlink.js +120 -0
- package/es/indent.d.ts +8 -0
- package/es/indent.d.ts.map +1 -0
- package/es/indent.js +58 -0
- package/es/indentation-markers/config.d.ts +17 -0
- package/es/indentation-markers/config.d.ts.map +1 -0
- package/es/indentation-markers/config.js +10 -0
- package/es/indentation-markers/index.d.ts +3 -0
- package/es/indentation-markers/index.d.ts.map +1 -0
- package/es/indentation-markers/index.js +160 -0
- package/es/indentation-markers/map.d.ts +77 -0
- package/es/indentation-markers/map.d.ts.map +1 -0
- package/es/indentation-markers/map.js +265 -0
- package/es/indentation-markers/utils.d.ts +27 -0
- package/es/indentation-markers/utils.d.ts.map +1 -0
- package/es/indentation-markers/utils.js +91 -0
- package/es/index.d.ts +11 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +10 -0
- package/es/libro-icon.d.ts +3 -0
- package/es/libro-icon.d.ts.map +1 -0
- package/es/libro-icon.js +2 -0
- package/es/mimetype.d.ts +22 -0
- package/es/mimetype.d.ts.map +1 -0
- package/es/mimetype.js +59 -0
- package/es/mode.d.ts +86 -0
- package/es/mode.d.ts.map +1 -0
- package/es/mode.js +284 -0
- package/es/monitor.d.ts +32 -0
- package/es/monitor.d.ts.map +1 -0
- package/es/monitor.js +129 -0
- package/es/python-lang.d.ts +3 -0
- package/es/python-lang.d.ts.map +1 -0
- package/es/python-lang.js +7 -0
- package/es/style/base.css +131 -0
- package/es/style/theme.css +12 -0
- package/es/style/variables.css +403 -0
- package/es/theme.d.ts +35 -0
- package/es/theme.d.ts.map +1 -0
- package/es/theme.js +225 -0
- package/es/tooltip.d.ts +10 -0
- package/es/tooltip.d.ts.map +1 -0
- package/es/tooltip.js +170 -0
- package/package.json +74 -0
- package/src/auto-complete/README.md +71 -0
- package/src/auto-complete/closebrackets.ts +423 -0
- package/src/auto-complete/completion.ts +345 -0
- package/src/auto-complete/config.ts +101 -0
- package/src/auto-complete/filter.ts +215 -0
- package/src/auto-complete/index.ts +112 -0
- package/src/auto-complete/snippet.ts +394 -0
- package/src/auto-complete/state.ts +472 -0
- package/src/auto-complete/theme.ts +126 -0
- package/src/auto-complete/tooltip.ts +386 -0
- package/src/auto-complete/view.ts +343 -0
- package/src/auto-complete/word.ts +118 -0
- package/src/completion.ts +61 -0
- package/src/config.ts +689 -0
- package/src/editor.ts +1078 -0
- package/src/factory.ts +10 -0
- package/src/hyperlink.ts +95 -0
- package/src/indent.ts +69 -0
- package/src/indentation-markers/config.ts +31 -0
- package/src/indentation-markers/index.ts +192 -0
- package/src/indentation-markers/map.ts +273 -0
- package/src/indentation-markers/utils.ts +84 -0
- package/src/index.ts +11 -0
- package/src/libro-icon.ts +4 -0
- package/src/mimetype.ts +49 -0
- package/src/mode.ts +269 -0
- package/src/monitor.ts +105 -0
- package/src/python-lang.ts +7 -0
- package/src/style/base.css +129 -0
- package/src/style/theme.css +12 -0
- package/src/style/variables.css +405 -0
- package/src/theme.ts +231 -0
- package/src/tooltip.ts +145 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
9
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
10
|
+
import { indentationMarkerConfig } from "./config.js";
|
|
11
|
+
import { getCurrentLine, numColumns } from "./utils.js";
|
|
12
|
+
/**
|
|
13
|
+
* Indentation map for a set of lines.
|
|
14
|
+
*
|
|
15
|
+
* This map will contain the indentation for lines that are not a part of the given set,
|
|
16
|
+
* but this is because calculating the indentation for those lines was necessary to
|
|
17
|
+
* calculate the indentation for the lines provided to the constructor.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link IndentEntry}
|
|
20
|
+
*/
|
|
21
|
+
export var IndentationMap = /*#__PURE__*/function () {
|
|
22
|
+
/** The {@link EditorState} indentation is derived from. */
|
|
23
|
+
|
|
24
|
+
/** The set of lines that are used as an entrypoint. */
|
|
25
|
+
|
|
26
|
+
/** The internal mapping of line numbers to {@link IndentEntry} objects. */
|
|
27
|
+
|
|
28
|
+
/** The width of the editor's indent unit. */
|
|
29
|
+
|
|
30
|
+
/** The type of indentation to use (terminate at end of scope vs last non-empty line in scope) */
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param lines - The set of lines to get the indentation map for.
|
|
34
|
+
* @param state - The {@link EditorState} to derive the indentation map from.
|
|
35
|
+
* @param unitWidth - The width of the editor's indent unit.
|
|
36
|
+
* @param markerType - The type of indentation to use (terminate at end of scope vs last line of code in scope)
|
|
37
|
+
*/
|
|
38
|
+
function IndentationMap(lines, state, unitWidth, markerType) {
|
|
39
|
+
_classCallCheck(this, IndentationMap);
|
|
40
|
+
this.lines = lines;
|
|
41
|
+
this.state = state;
|
|
42
|
+
this.map = new Map();
|
|
43
|
+
this.unitWidth = unitWidth;
|
|
44
|
+
this.markerType = markerType;
|
|
45
|
+
var _iterator = _createForOfIteratorHelper(this.lines),
|
|
46
|
+
_step;
|
|
47
|
+
try {
|
|
48
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
49
|
+
var line = _step.value;
|
|
50
|
+
this.add(line);
|
|
51
|
+
}
|
|
52
|
+
} catch (err) {
|
|
53
|
+
_iterator.e(err);
|
|
54
|
+
} finally {
|
|
55
|
+
_iterator.f();
|
|
56
|
+
}
|
|
57
|
+
if (this.state.facet(indentationMarkerConfig).highlightActiveBlock) {
|
|
58
|
+
this.findAndSetActiveLines();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Checks if the indentation map has an entry for the given line.
|
|
64
|
+
*
|
|
65
|
+
* @param line - The {@link Line} or line number to check for.
|
|
66
|
+
*/
|
|
67
|
+
_createClass(IndentationMap, [{
|
|
68
|
+
key: "has",
|
|
69
|
+
value: function has(line) {
|
|
70
|
+
return this.map.has(typeof line === 'number' ? line : line.number);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Returns the {@link IndentEntry} for the given line.
|
|
75
|
+
*
|
|
76
|
+
* Note that this function will throw an error if the line does not exist in the map.
|
|
77
|
+
*
|
|
78
|
+
* @param line - The {@link Line} or line number to get the entry for.
|
|
79
|
+
*/
|
|
80
|
+
}, {
|
|
81
|
+
key: "get",
|
|
82
|
+
value: function get(line) {
|
|
83
|
+
var entry = this.map.get(typeof line === 'number' ? line : line.number);
|
|
84
|
+
if (!entry) {
|
|
85
|
+
throw new Error('Line not found in indentation map');
|
|
86
|
+
}
|
|
87
|
+
return entry;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Sets the {@link IndentEntry} for the given line.
|
|
92
|
+
*
|
|
93
|
+
* @param line - The {@link Line} to set the entry for.
|
|
94
|
+
* @param col - The visual beginning whitespace width of the line.
|
|
95
|
+
* @param level - The indentation level of the line.
|
|
96
|
+
*/
|
|
97
|
+
}, {
|
|
98
|
+
key: "set",
|
|
99
|
+
value: function set(line, col, level) {
|
|
100
|
+
var empty = !line.text.trim().length;
|
|
101
|
+
var entry = {
|
|
102
|
+
line: line,
|
|
103
|
+
col: col,
|
|
104
|
+
level: level,
|
|
105
|
+
empty: empty
|
|
106
|
+
};
|
|
107
|
+
this.map.set(entry.line.number, entry);
|
|
108
|
+
return entry;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Adds a line to the indentation map.
|
|
113
|
+
*
|
|
114
|
+
* @param line - The {@link Line} to add to the map.
|
|
115
|
+
*/
|
|
116
|
+
}, {
|
|
117
|
+
key: "add",
|
|
118
|
+
value: function add(line) {
|
|
119
|
+
if (this.has(line)) {
|
|
120
|
+
return this.get(line);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// empty lines continue their indentation from surrounding lines
|
|
124
|
+
if (!line.length || !line.text.trim().length) {
|
|
125
|
+
// the very first line, if empty, is just ignored and set as a 0 indent level
|
|
126
|
+
if (line.number === 1) {
|
|
127
|
+
return this.set(line, 0, 0);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// if we're at the end, we'll just use the previous line's indentation
|
|
131
|
+
if (line.number === this.state.doc.lines) {
|
|
132
|
+
var _prev = this.closestNonEmpty(line, -1);
|
|
133
|
+
return this.set(line, 0, _prev.level);
|
|
134
|
+
}
|
|
135
|
+
var prev = this.closestNonEmpty(line, -1);
|
|
136
|
+
var next = this.closestNonEmpty(line, 1);
|
|
137
|
+
|
|
138
|
+
// if the next line ends the block and the marker type is not set to codeOnly,
|
|
139
|
+
// we'll just use the previous line's indentation
|
|
140
|
+
if (prev.level >= next.level && this.markerType !== 'codeOnly') {
|
|
141
|
+
return this.set(line, 0, prev.level);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// having an indent marker that starts from an empty line looks weird
|
|
145
|
+
if (prev.empty && prev.level === 0 && next.level !== 0) {
|
|
146
|
+
return this.set(line, 0, 0);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// if the next indentation level is greater than the previous,
|
|
150
|
+
// we'll only increment up to the next indentation level. this prevents
|
|
151
|
+
// a weirdly "backwards propagating" indentation.
|
|
152
|
+
if (next.level > prev.level) {
|
|
153
|
+
return this.set(line, 0, prev.level + 1);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// else, we default to the next line's indentation
|
|
157
|
+
return this.set(line, 0, next.level);
|
|
158
|
+
}
|
|
159
|
+
var col = numColumns(line.text, this.state.tabSize);
|
|
160
|
+
var level = Math.floor(col / this.unitWidth);
|
|
161
|
+
return this.set(line, col, level);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Finds the closest non-empty line, starting from the given line.
|
|
166
|
+
*
|
|
167
|
+
* @param from - The {@link Line} to start from.
|
|
168
|
+
* @param dir - The direction to search in. Either `1` or `-1`.
|
|
169
|
+
*/
|
|
170
|
+
}, {
|
|
171
|
+
key: "closestNonEmpty",
|
|
172
|
+
value: function closestNonEmpty(from, dir) {
|
|
173
|
+
var lineNo = from.number + dir;
|
|
174
|
+
while (dir === -1 ? lineNo >= 1 : lineNo <= this.state.doc.lines) {
|
|
175
|
+
if (this.has(lineNo)) {
|
|
176
|
+
var entry = this.get(lineNo);
|
|
177
|
+
if (!entry.empty) {
|
|
178
|
+
return entry;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// we can check if the line is empty, if it's not, we can
|
|
183
|
+
// just create a new entry for it and return it.
|
|
184
|
+
// this prevents us from hitting the beginning/end of the document unnecessarily.
|
|
185
|
+
|
|
186
|
+
var _line = this.state.doc.line(lineNo);
|
|
187
|
+
if (_line.text.trim().length) {
|
|
188
|
+
var col = numColumns(_line.text, this.state.tabSize);
|
|
189
|
+
var level = Math.floor(col / this.unitWidth);
|
|
190
|
+
return this.set(_line, col, level);
|
|
191
|
+
}
|
|
192
|
+
lineNo += dir;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// if we're here, we didn't find anything.
|
|
196
|
+
// that means we're at the beginning/end of the document,
|
|
197
|
+
// and the first/last line is empty.
|
|
198
|
+
|
|
199
|
+
var line = this.state.doc.line(dir === -1 ? 1 : this.state.doc.lines);
|
|
200
|
+
return this.set(line, 0, 0);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Finds the state's active block (via the current selection) and sets all
|
|
205
|
+
* the active indent level for the lines in the block.
|
|
206
|
+
*/
|
|
207
|
+
}, {
|
|
208
|
+
key: "findAndSetActiveLines",
|
|
209
|
+
value: function findAndSetActiveLines() {
|
|
210
|
+
var currentLine = getCurrentLine(this.state);
|
|
211
|
+
if (!this.has(currentLine)) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
var current = this.get(currentLine);
|
|
215
|
+
|
|
216
|
+
// check if the current line is starting a new block, if yes, we want to
|
|
217
|
+
// start from inside the block.
|
|
218
|
+
if (this.has(current.line.number + 1)) {
|
|
219
|
+
var next = this.get(current.line.number + 1);
|
|
220
|
+
if (next.level > current.level) {
|
|
221
|
+
current = next;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// same, but if the current line is ending a block
|
|
226
|
+
if (this.has(current.line.number - 1)) {
|
|
227
|
+
var prev = this.get(current.line.number - 1);
|
|
228
|
+
if (prev.level > current.level) {
|
|
229
|
+
current = prev;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (current.level === 0) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
current.active = current.level;
|
|
236
|
+
var start;
|
|
237
|
+
var end;
|
|
238
|
+
|
|
239
|
+
// iterate to the start of the block
|
|
240
|
+
for (start = current.line.number; start > 1; start--) {
|
|
241
|
+
if (!this.has(start - 1)) {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
var _prev2 = this.get(start - 1);
|
|
245
|
+
if (_prev2.level < current.level) {
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
_prev2.active = current.level;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// iterate to the end of the block
|
|
252
|
+
for (end = current.line.number; end < this.state.doc.lines; end++) {
|
|
253
|
+
if (!this.has(end + 1)) {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
var _next = this.get(end + 1);
|
|
257
|
+
if (_next.level < current.level) {
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
_next.active = current.level;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}]);
|
|
264
|
+
return IndentationMap;
|
|
265
|
+
}();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { EditorState, Line } from '@codemirror/state';
|
|
2
|
+
import type { EditorView } from '@codemirror/view';
|
|
3
|
+
/**
|
|
4
|
+
* Gets the visible lines in the editor. Lines will not be repeated.
|
|
5
|
+
*
|
|
6
|
+
* @param view - The editor view to get the visible lines from.
|
|
7
|
+
* @param state - The editor state. Defaults to the view's current one.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getVisibleLines(view: EditorView, state?: EditorState): Set<Line>;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the line at the position of the primary cursor.
|
|
12
|
+
*
|
|
13
|
+
* @param state - The editor state from which to extract the line.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getCurrentLine(state: EditorState): Line;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the number of columns that a string is indented, controlling for
|
|
18
|
+
* tabs. This is useful for determining the indentation level of a line.
|
|
19
|
+
*
|
|
20
|
+
* Note that this only returns the number of _visible_ columns, not the number
|
|
21
|
+
* of whitespace characters at the start of the string.
|
|
22
|
+
*
|
|
23
|
+
* @param str - The string to check.
|
|
24
|
+
* @param tabSize - The size of a tab character. Usually 2 or 4.
|
|
25
|
+
*/
|
|
26
|
+
export declare function numColumns(str: string, tabSize: number): number;
|
|
27
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/indentation-markers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,cAAa,aAkBnE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,QAGhD;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAkCtD"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
|
+
/**
|
|
5
|
+
* Gets the visible lines in the editor. Lines will not be repeated.
|
|
6
|
+
*
|
|
7
|
+
* @param view - The editor view to get the visible lines from.
|
|
8
|
+
* @param state - The editor state. Defaults to the view's current one.
|
|
9
|
+
*/
|
|
10
|
+
export function getVisibleLines(view) {
|
|
11
|
+
var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : view.state;
|
|
12
|
+
var lines = new Set();
|
|
13
|
+
var _iterator = _createForOfIteratorHelper(view.visibleRanges),
|
|
14
|
+
_step;
|
|
15
|
+
try {
|
|
16
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
17
|
+
var _step$value = _step.value,
|
|
18
|
+
from = _step$value.from,
|
|
19
|
+
to = _step$value.to;
|
|
20
|
+
var pos = from;
|
|
21
|
+
while (pos <= to) {
|
|
22
|
+
var line = state.doc.lineAt(pos);
|
|
23
|
+
if (!lines.has(line)) {
|
|
24
|
+
lines.add(line);
|
|
25
|
+
}
|
|
26
|
+
pos = line.to + 1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
} catch (err) {
|
|
30
|
+
_iterator.e(err);
|
|
31
|
+
} finally {
|
|
32
|
+
_iterator.f();
|
|
33
|
+
}
|
|
34
|
+
return lines;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Gets the line at the position of the primary cursor.
|
|
39
|
+
*
|
|
40
|
+
* @param state - The editor state from which to extract the line.
|
|
41
|
+
*/
|
|
42
|
+
export function getCurrentLine(state) {
|
|
43
|
+
var currentPos = state.selection.main.head;
|
|
44
|
+
return state.doc.lineAt(currentPos);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Returns the number of columns that a string is indented, controlling for
|
|
49
|
+
* tabs. This is useful for determining the indentation level of a line.
|
|
50
|
+
*
|
|
51
|
+
* Note that this only returns the number of _visible_ columns, not the number
|
|
52
|
+
* of whitespace characters at the start of the string.
|
|
53
|
+
*
|
|
54
|
+
* @param str - The string to check.
|
|
55
|
+
* @param tabSize - The size of a tab character. Usually 2 or 4.
|
|
56
|
+
*/
|
|
57
|
+
export function numColumns(str, tabSize) {
|
|
58
|
+
// as far as I can tell, this is pretty much the fastest way to do this,
|
|
59
|
+
// at least involving iteration. `str.length - str.trimStart().length` is
|
|
60
|
+
// much faster, but it has some edge cases that are hard to deal with.
|
|
61
|
+
|
|
62
|
+
var col = 0;
|
|
63
|
+
|
|
64
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
65
|
+
loop: for (var i = 0; i < str.length; i++) {
|
|
66
|
+
switch (str[i]) {
|
|
67
|
+
case ' ':
|
|
68
|
+
{
|
|
69
|
+
col += 1;
|
|
70
|
+
continue loop;
|
|
71
|
+
}
|
|
72
|
+
case '\t':
|
|
73
|
+
{
|
|
74
|
+
// if the current column is a multiple of the tab size, we can just
|
|
75
|
+
// add the tab size to the column. otherwise, we need to add the
|
|
76
|
+
// difference between the tab size and the current column.
|
|
77
|
+
col += tabSize - col % tabSize;
|
|
78
|
+
continue loop;
|
|
79
|
+
}
|
|
80
|
+
case '\r':
|
|
81
|
+
{
|
|
82
|
+
continue loop;
|
|
83
|
+
}
|
|
84
|
+
default:
|
|
85
|
+
{
|
|
86
|
+
break loop;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return col;
|
|
91
|
+
}
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import './style/base.css';
|
|
2
|
+
import './style/theme.css';
|
|
3
|
+
import './style/variables.css';
|
|
4
|
+
export * from './config.js';
|
|
5
|
+
export * from './editor.js';
|
|
6
|
+
export * from './mode.js';
|
|
7
|
+
export * from './theme.js';
|
|
8
|
+
export * from './factory.js';
|
|
9
|
+
export * from './monitor.js';
|
|
10
|
+
export * from './auto-complete/index.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,uBAAuB,CAAC;AAE/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC"}
|
package/es/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./style/base.css";
|
|
2
|
+
import "./style/theme.css";
|
|
3
|
+
import "./style/variables.css";
|
|
4
|
+
export * from "./config.js";
|
|
5
|
+
export * from "./editor.js";
|
|
6
|
+
export * from "./mode.js";
|
|
7
|
+
export * from "./theme.js";
|
|
8
|
+
export * from "./factory.js";
|
|
9
|
+
export * from "./monitor.js";
|
|
10
|
+
export * from "./auto-complete/index.js";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const FoldIcon = "<svg width=\"8px\" height=\"6px\" viewBox=\"0 0 8 6\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><title>1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down</title><g id=\"0424\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fillRule=\"evenodd\"><g id=\"Notebook-cell-\u8272\u9636\" transform=\"translate(-2015.000000, -434.000000)\" fill=\"#A4AECB\"><g id=\"\u7F16\u7EC4-15\" transform=\"translate(2004.000000, 407.000000)\"><g id=\"1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down\" transform=\"translate(11.250000, 27.500000)\"><path d=\"M7.34387369,0 L6.61145181,0 C6.56164712,0 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,0 0.81067056,0 L0.0782486852,0 C0.0147721227,0 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023437 C7.44445962,0.072265625 7.40735025,0 7.34387369,0 Z\" id=\"Down\"></path></g></g></g></g></svg>";
|
|
2
|
+
export declare const UnFoldIcon = "<svg width=\"6px\" height=\"8px\" viewBox=\"0 0 6 8\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><title>1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down\u6536\u8D77</title><g id=\"0424\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fillRule=\"evenodd\"><g id=\"Notebook-cell-\u8272\u9636\" transform=\"translate(-2094.000000, -433.000000)\" fill=\"#A4AECB\"><g id=\"\u7F16\u7EC4-15\u5907\u4EFD\" transform=\"translate(2082.000000, 407.000000)\"><g id=\"1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down\" transform=\"translate(15.000000, 30.039124) rotate(270.000000) translate(-15.000000, -30.039124) translate(11.289124, 27.539124)\"><path d=\"M7.34387369,1.77635684e-15 L6.61145181,1.77635684e-15 C6.56164712,1.77635684e-15 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,1.77635684e-15 0.81067056,1.77635684e-15 L0.0782486852,1.77635684e-15 C0.0147721227,1.77635684e-15 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023438 C7.44445962,0.072265625 7.40735025,1.77635684e-15 7.34387369,1.77635684e-15 Z\" id=\"Down\"></path></g></g></g></g></svg>";
|
|
3
|
+
//# sourceMappingURL=libro-icon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libro-icon.d.ts","sourceRoot":"","sources":["../src/libro-icon.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,8iCACo7B,CAAC;AAC18B,eAAO,MAAM,UAAU,gxCACgoC,CAAC"}
|
package/es/libro-icon.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export var FoldIcon = '<svg width="8px" height="6px" viewBox="0 0 8 6" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>1.通用/2.Icon图标/Line/Down</title><g id="0424" stroke="none" stroke-width="1" fill="none" fillRule="evenodd"><g id="Notebook-cell-色阶" transform="translate(-2015.000000, -434.000000)" fill="#A4AECB"><g id="编组-15" transform="translate(2004.000000, 407.000000)"><g id="1.通用/2.Icon图标/Line/Down" transform="translate(11.250000, 27.500000)"><path d="M7.34387369,0 L6.61145181,0 C6.56164712,0 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,0 0.81067056,0 L0.0782486852,0 C0.0147721227,0 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023437 C7.44445962,0.072265625 7.40735025,0 7.34387369,0 Z" id="Down"></path></g></g></g></g></svg>';
|
|
2
|
+
export var UnFoldIcon = '<svg width="6px" height="8px" viewBox="0 0 6 8" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>1.通用/2.Icon图标/Line/Down收起</title><g id="0424" stroke="none" stroke-width="1" fill="none" fillRule="evenodd"><g id="Notebook-cell-色阶" transform="translate(-2094.000000, -433.000000)" fill="#A4AECB"><g id="编组-15备份" transform="translate(2082.000000, 407.000000)"><g id="1.通用/2.Icon图标/Line/Down" transform="translate(15.000000, 30.039124) rotate(270.000000) translate(-15.000000, -30.039124) translate(11.289124, 27.539124)"><path d="M7.34387369,1.77635684e-15 L6.61145181,1.77635684e-15 C6.56164712,1.77635684e-15 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,1.77635684e-15 0.81067056,1.77635684e-15 L0.0782486852,1.77635684e-15 C0.0147721227,1.77635684e-15 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023438 C7.44445962,0.072265625 7.40735025,1.77635684e-15 7.34387369,1.77635684e-15 Z" id="Down"></path></g></g></g></g></svg>';
|
package/es/mimetype.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IEditorMimeTypeService } from '@difizen/libro-code-editor';
|
|
2
|
+
import type { ILanguageInfoMetadata } from '@difizen/libro-common';
|
|
3
|
+
/**
|
|
4
|
+
* The mime type service for CodeMirror.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CodeMirrorMimeTypeService implements IEditorMimeTypeService {
|
|
7
|
+
/**
|
|
8
|
+
* Returns a mime type for the given language info.
|
|
9
|
+
*
|
|
10
|
+
* #### Notes
|
|
11
|
+
* If a mime type cannot be found returns the default mime type `text/plain`, never `null`.
|
|
12
|
+
*/
|
|
13
|
+
getMimeTypeByLanguage(info: ILanguageInfoMetadata): string;
|
|
14
|
+
/**
|
|
15
|
+
* Returns a mime type for the given file path.
|
|
16
|
+
*
|
|
17
|
+
* #### Notes
|
|
18
|
+
* If a mime type cannot be found returns the default mime type `text/plain`, never `null`.
|
|
19
|
+
*/
|
|
20
|
+
getMimeTypeByFilePath(path: string): string;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=mimetype.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mimetype.d.ts","sourceRoot":"","sources":["../src/mimetype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAQnE;;GAEG;AACH,qBAAa,yBAA0B,YAAW,sBAAsB;IACtE;;;;;OAKG;IACH,qBAAqB,CAAC,IAAI,EAAE,qBAAqB,GAAG,MAAM;IAY1D;;;;;OAKG;IACH,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAU5C"}
|
package/es/mimetype.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import { defaultMimeType } from '@difizen/libro-code-editor';
|
|
8
|
+
import { findBest, findByFileName } from "./mode.js";
|
|
9
|
+
var extname = function extname(path) {
|
|
10
|
+
return path.split('.').pop();
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The mime type service for CodeMirror.
|
|
15
|
+
*/
|
|
16
|
+
export var CodeMirrorMimeTypeService = /*#__PURE__*/function () {
|
|
17
|
+
function CodeMirrorMimeTypeService() {
|
|
18
|
+
_classCallCheck(this, CodeMirrorMimeTypeService);
|
|
19
|
+
}
|
|
20
|
+
_createClass(CodeMirrorMimeTypeService, [{
|
|
21
|
+
key: "getMimeTypeByLanguage",
|
|
22
|
+
value:
|
|
23
|
+
/**
|
|
24
|
+
* Returns a mime type for the given language info.
|
|
25
|
+
*
|
|
26
|
+
* #### Notes
|
|
27
|
+
* If a mime type cannot be found returns the default mime type `text/plain`, never `null`.
|
|
28
|
+
*/
|
|
29
|
+
function getMimeTypeByLanguage(info) {
|
|
30
|
+
var ext = info.file_extension || '';
|
|
31
|
+
var mode = findBest(info.codemirror_mode || {
|
|
32
|
+
mimetype: info.mimetype,
|
|
33
|
+
name: info.name,
|
|
34
|
+
ext: [ext.split('.').slice(-1)[0]]
|
|
35
|
+
});
|
|
36
|
+
return mode ? mode.mime : defaultMimeType;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Returns a mime type for the given file path.
|
|
41
|
+
*
|
|
42
|
+
* #### Notes
|
|
43
|
+
* If a mime type cannot be found returns the default mime type `text/plain`, never `null`.
|
|
44
|
+
*/
|
|
45
|
+
}, {
|
|
46
|
+
key: "getMimeTypeByFilePath",
|
|
47
|
+
value: function getMimeTypeByFilePath(path) {
|
|
48
|
+
var ext = extname(path);
|
|
49
|
+
if (ext === '.ipy') {
|
|
50
|
+
return 'text/x-python';
|
|
51
|
+
} else if (ext === '.md') {
|
|
52
|
+
return 'text/x-ipythongfm';
|
|
53
|
+
}
|
|
54
|
+
var mode = findByFileName(path) || findBest('');
|
|
55
|
+
return mode ? mode.mime : defaultMimeType;
|
|
56
|
+
}
|
|
57
|
+
}]);
|
|
58
|
+
return CodeMirrorMimeTypeService;
|
|
59
|
+
}();
|
package/es/mode.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { LanguageSupport } from '@codemirror/language';
|
|
2
|
+
/**
|
|
3
|
+
* The interface of a codemirror language spec.
|
|
4
|
+
*/
|
|
5
|
+
export interface ISpec {
|
|
6
|
+
name: string;
|
|
7
|
+
alias?: readonly string[];
|
|
8
|
+
mime: string | readonly string[];
|
|
9
|
+
load?: () => Promise<LanguageSupport>;
|
|
10
|
+
extensions?: readonly string[];
|
|
11
|
+
filename?: RegExp;
|
|
12
|
+
support?: LanguageSupport;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get the raw list of available modes specs.
|
|
16
|
+
*
|
|
17
|
+
* @alpha
|
|
18
|
+
* @returns The available modes
|
|
19
|
+
*/
|
|
20
|
+
export declare function getModeInfo(): ISpec[];
|
|
21
|
+
/**
|
|
22
|
+
* Find a codemirror mode by MIME.
|
|
23
|
+
*
|
|
24
|
+
* @alpha
|
|
25
|
+
* @param mime Mime type to look for
|
|
26
|
+
* @returns The mode or null
|
|
27
|
+
*/
|
|
28
|
+
export declare function findByMIME(mime: string | readonly string[]): ISpec | null;
|
|
29
|
+
/**
|
|
30
|
+
* Find a codemirror mode by name.
|
|
31
|
+
*
|
|
32
|
+
* @alpha
|
|
33
|
+
* @param name The mode name
|
|
34
|
+
* @returns The mode or null
|
|
35
|
+
*/
|
|
36
|
+
export declare function findByName(name: string): ISpec | null;
|
|
37
|
+
/**
|
|
38
|
+
* Find a codemirror mode by extension.
|
|
39
|
+
*
|
|
40
|
+
* @alpha
|
|
41
|
+
* @param ext The extension name
|
|
42
|
+
* @returns The mode or null
|
|
43
|
+
*/
|
|
44
|
+
export declare function findByExtension(ext: string | readonly string[]): ISpec | null;
|
|
45
|
+
/**
|
|
46
|
+
* Find a codemirror mode by filename.
|
|
47
|
+
*
|
|
48
|
+
* @param name File name
|
|
49
|
+
* @returns The mode or null
|
|
50
|
+
*/
|
|
51
|
+
export declare function findByFileName(name: string): ISpec | null;
|
|
52
|
+
/**
|
|
53
|
+
* Find a codemirror mode by name or CodeMirror spec.
|
|
54
|
+
*
|
|
55
|
+
* @alpha
|
|
56
|
+
* @param mode The CodeMirror mode
|
|
57
|
+
* @param fallback Whether to fallback to default mimetype spec or not
|
|
58
|
+
* @returns The mode or null
|
|
59
|
+
*/
|
|
60
|
+
export declare function findBest(mode: string | ISpec, fallback?: boolean): ISpec | null;
|
|
61
|
+
/**
|
|
62
|
+
* Ensure a codemirror mode is available by name or Codemirror spec.
|
|
63
|
+
*
|
|
64
|
+
* @param mode - The mode to ensure. If it is a string, uses [findBest]
|
|
65
|
+
* to get the appropriate spec.
|
|
66
|
+
*
|
|
67
|
+
* @returns A promise that resolves when the mode is available.
|
|
68
|
+
*/
|
|
69
|
+
export declare function ensure(mode: string | ISpec): Promise<ISpec | null>;
|
|
70
|
+
/**
|
|
71
|
+
* Register a new mode for CodeMirror
|
|
72
|
+
*
|
|
73
|
+
* @alpha
|
|
74
|
+
* @param mode Mode to register
|
|
75
|
+
*/
|
|
76
|
+
export declare function registerModeInfo(mode: ISpec): void;
|
|
77
|
+
/**
|
|
78
|
+
* Parse and style a string.
|
|
79
|
+
*
|
|
80
|
+
* @alpha
|
|
81
|
+
* @param code Code to highlight
|
|
82
|
+
* @param mode Code mode
|
|
83
|
+
* @param el HTML element into which the highlighted code will be inserted
|
|
84
|
+
*/
|
|
85
|
+
export declare function run(code: string, mode: ISpec, el: HTMLElement): void;
|
|
86
|
+
//# sourceMappingURL=mode.d.ts.map
|
package/es/mode.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mode.d.ts","sourceRoot":"","sources":["../src/mode.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAc5D;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AA+BD;;;;;GAKG;AACH,wBAAgB,WAAW,IAAI,KAAK,EAAE,CAErC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,KAAK,GAAG,IAAI,CA8BzE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAgBrD;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,KAAK,GAAG,IAAI,CAoB7E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAczD;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,QAAQ,UAAO,GAAG,KAAK,GAAG,IAAI,CAW5E;AAED;;;;;;;GAOG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAOxE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,CAMlD;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,CAyBpE"}
|