@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
package/es/mode.js
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
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 _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
import { markdown } from '@codemirror/lang-markdown';
|
|
6
|
+
import { LanguageDescription } from '@codemirror/language';
|
|
7
|
+
import { defaultMimeType } from '@difizen/libro-code-editor';
|
|
8
|
+
|
|
9
|
+
// This ensures the language spec for python will be loaded when
|
|
10
|
+
// we instantiate a new editor instance, which is required since
|
|
11
|
+
// python is the default language and we don't want to split
|
|
12
|
+
// the editor constructor because of asynchronous loading.
|
|
13
|
+
import { PathExt } from '@difizen/libro-common';
|
|
14
|
+
import { highlightTree } from '@lezer/highlight';
|
|
15
|
+
import { python } from "./python-lang.js";
|
|
16
|
+
import { jupyterHighlightStyle } from "./theme.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The interface of a codemirror language spec.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
// Code mirror uses two similar structures, a plain object with optional fields,
|
|
23
|
+
// and a class with the same fields but all mandatory. Maybe adopting the same
|
|
24
|
+
// pattern would be less confusing (although far more verbose)
|
|
25
|
+
function makeSpec(spec) {
|
|
26
|
+
var res = LanguageDescription.of(spec);
|
|
27
|
+
res.mime = spec.mime;
|
|
28
|
+
return res;
|
|
29
|
+
}
|
|
30
|
+
var modeList = [makeSpec({
|
|
31
|
+
name: 'Python',
|
|
32
|
+
mime: 'text/x-python',
|
|
33
|
+
extensions: ['BUILD', 'bzl', 'py', 'pyw'],
|
|
34
|
+
filename: /^(BUCK|BUILD)$/,
|
|
35
|
+
load: function load() {
|
|
36
|
+
return Promise.resolve(python());
|
|
37
|
+
}
|
|
38
|
+
}), makeSpec({
|
|
39
|
+
name: 'Markdown',
|
|
40
|
+
mime: 'text/x-markdown',
|
|
41
|
+
extensions: ['md', 'markdown', 'mkd'],
|
|
42
|
+
load: function load() {
|
|
43
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
44
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
45
|
+
while (1) switch (_context.prev = _context.next) {
|
|
46
|
+
case 0:
|
|
47
|
+
return _context.abrupt("return", Promise.resolve(markdown()));
|
|
48
|
+
case 1:
|
|
49
|
+
case "end":
|
|
50
|
+
return _context.stop();
|
|
51
|
+
}
|
|
52
|
+
}, _callee);
|
|
53
|
+
}))();
|
|
54
|
+
}
|
|
55
|
+
})];
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get the raw list of available modes specs.
|
|
59
|
+
*
|
|
60
|
+
* @alpha
|
|
61
|
+
* @returns The available modes
|
|
62
|
+
*/
|
|
63
|
+
export function getModeInfo() {
|
|
64
|
+
return modeList;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Find a codemirror mode by MIME.
|
|
69
|
+
*
|
|
70
|
+
* @alpha
|
|
71
|
+
* @param mime Mime type to look for
|
|
72
|
+
* @returns The mode or null
|
|
73
|
+
*/
|
|
74
|
+
export function findByMIME(mime) {
|
|
75
|
+
if (Array.isArray(mime)) {
|
|
76
|
+
for (var i = 0; i < mime.length; i++) {
|
|
77
|
+
var spec = findByMIME(mime[i]);
|
|
78
|
+
if (spec) {
|
|
79
|
+
return spec;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
var _mime = mime.toLowerCase();
|
|
85
|
+
for (var _i = 0; _i < modeList.length; _i++) {
|
|
86
|
+
var info = modeList[_i];
|
|
87
|
+
if (Array.isArray(info.mime)) {
|
|
88
|
+
for (var j = 0; j < info.mime.length; j++) {
|
|
89
|
+
if (info.mime[j] === _mime) {
|
|
90
|
+
return info;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
} else if (info.mime === _mime) {
|
|
94
|
+
return info;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (/\+xml$/.test(_mime)) {
|
|
98
|
+
return findByMIME('application/xml');
|
|
99
|
+
}
|
|
100
|
+
if (/\+json$/.test(_mime)) {
|
|
101
|
+
return findByMIME('application/json');
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Find a codemirror mode by name.
|
|
108
|
+
*
|
|
109
|
+
* @alpha
|
|
110
|
+
* @param name The mode name
|
|
111
|
+
* @returns The mode or null
|
|
112
|
+
*/
|
|
113
|
+
export function findByName(name) {
|
|
114
|
+
var _name = name.toLowerCase();
|
|
115
|
+
for (var i = 0; i < modeList.length; i++) {
|
|
116
|
+
var info = modeList[i];
|
|
117
|
+
if (info.name.toLowerCase() === _name) {
|
|
118
|
+
return info;
|
|
119
|
+
}
|
|
120
|
+
if (info.alias) {
|
|
121
|
+
for (var j = 0; j < info.alias.length; j++) {
|
|
122
|
+
if (info.alias[j].toLowerCase() === _name) {
|
|
123
|
+
return info;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Find a codemirror mode by extension.
|
|
133
|
+
*
|
|
134
|
+
* @alpha
|
|
135
|
+
* @param ext The extension name
|
|
136
|
+
* @returns The mode or null
|
|
137
|
+
*/
|
|
138
|
+
export function findByExtension(ext) {
|
|
139
|
+
if (Array.isArray(ext)) {
|
|
140
|
+
for (var i = 0; i < ext.length; i++) {
|
|
141
|
+
var spec = findByExtension(ext[i]);
|
|
142
|
+
if (spec) {
|
|
143
|
+
return spec;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
var _ext = ext.toLowerCase();
|
|
149
|
+
for (var _i2 = 0; _i2 < modeList.length; _i2++) {
|
|
150
|
+
var info = modeList[_i2];
|
|
151
|
+
for (var j = 0; j < info.extensions.length; j++) {
|
|
152
|
+
if (info.extensions[j].toLowerCase() === _ext) {
|
|
153
|
+
return info;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Find a codemirror mode by filename.
|
|
162
|
+
*
|
|
163
|
+
* @param name File name
|
|
164
|
+
* @returns The mode or null
|
|
165
|
+
*/
|
|
166
|
+
export function findByFileName(name) {
|
|
167
|
+
var basename = PathExt.basename(name);
|
|
168
|
+
for (var i = 0; i < modeList.length; i++) {
|
|
169
|
+
var info = modeList[i];
|
|
170
|
+
if (info.filename && info.filename.test(basename)) {
|
|
171
|
+
return info;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
var dot = basename.lastIndexOf('.');
|
|
175
|
+
var ext = dot > -1 && basename.substring(dot + 1, basename.length);
|
|
176
|
+
if (ext) {
|
|
177
|
+
return findByExtension(ext);
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Find a codemirror mode by name or CodeMirror spec.
|
|
184
|
+
*
|
|
185
|
+
* @alpha
|
|
186
|
+
* @param mode The CodeMirror mode
|
|
187
|
+
* @param fallback Whether to fallback to default mimetype spec or not
|
|
188
|
+
* @returns The mode or null
|
|
189
|
+
*/
|
|
190
|
+
export function findBest(mode) {
|
|
191
|
+
var _mode$extensions, _ref, _ref2, _ref3;
|
|
192
|
+
var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
193
|
+
var modename = typeof mode === 'string' ? mode : mode.name;
|
|
194
|
+
var mimetype = typeof mode !== 'string' ? mode.mime : modename;
|
|
195
|
+
var ext = typeof mode !== 'string' ? (_mode$extensions = mode.extensions) !== null && _mode$extensions !== void 0 ? _mode$extensions : [] : [];
|
|
196
|
+
return (_ref = (_ref2 = (_ref3 = modename ? findByName(modename) : null) !== null && _ref3 !== void 0 ? _ref3 : mimetype ? findByMIME(mimetype) : null) !== null && _ref2 !== void 0 ? _ref2 : findByExtension(ext)) !== null && _ref !== void 0 ? _ref : fallback ? findByMIME(defaultMimeType) : null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Ensure a codemirror mode is available by name or Codemirror spec.
|
|
201
|
+
*
|
|
202
|
+
* @param mode - The mode to ensure. If it is a string, uses [findBest]
|
|
203
|
+
* to get the appropriate spec.
|
|
204
|
+
*
|
|
205
|
+
* @returns A promise that resolves when the mode is available.
|
|
206
|
+
*/
|
|
207
|
+
export function ensure(_x) {
|
|
208
|
+
return _ensure.apply(this, arguments);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Register a new mode for CodeMirror
|
|
213
|
+
*
|
|
214
|
+
* @alpha
|
|
215
|
+
* @param mode Mode to register
|
|
216
|
+
*/
|
|
217
|
+
function _ensure() {
|
|
218
|
+
_ensure = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(mode) {
|
|
219
|
+
var spec;
|
|
220
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
221
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
222
|
+
case 0:
|
|
223
|
+
spec = findBest(mode);
|
|
224
|
+
if (!spec) {
|
|
225
|
+
_context2.next = 6;
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
_context2.next = 4;
|
|
229
|
+
return spec.load();
|
|
230
|
+
case 4:
|
|
231
|
+
spec.support = _context2.sent;
|
|
232
|
+
return _context2.abrupt("return", spec);
|
|
233
|
+
case 6:
|
|
234
|
+
return _context2.abrupt("return", null);
|
|
235
|
+
case 7:
|
|
236
|
+
case "end":
|
|
237
|
+
return _context2.stop();
|
|
238
|
+
}
|
|
239
|
+
}, _callee2);
|
|
240
|
+
}));
|
|
241
|
+
return _ensure.apply(this, arguments);
|
|
242
|
+
}
|
|
243
|
+
export function registerModeInfo(mode) {
|
|
244
|
+
var info = findBest(mode, false);
|
|
245
|
+
if (info) {
|
|
246
|
+
throw new Error("".concat(mode.mime, " already registered"));
|
|
247
|
+
}
|
|
248
|
+
modeList.push(makeSpec(mode));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Parse and style a string.
|
|
253
|
+
*
|
|
254
|
+
* @alpha
|
|
255
|
+
* @param code Code to highlight
|
|
256
|
+
* @param mode Code mode
|
|
257
|
+
* @param el HTML element into which the highlighted code will be inserted
|
|
258
|
+
*/
|
|
259
|
+
export function run(code, mode, el) {
|
|
260
|
+
var _mode$support;
|
|
261
|
+
var language = (_mode$support = mode.support) === null || _mode$support === void 0 ? void 0 : _mode$support.language;
|
|
262
|
+
if (!language) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
var tree = language.parser.parse(code);
|
|
266
|
+
// position state required because unstyled tokens are not emitted
|
|
267
|
+
// in highlightTree
|
|
268
|
+
var pos = 0;
|
|
269
|
+
highlightTree(tree, jupyterHighlightStyle, function (from, to, classes) {
|
|
270
|
+
if (from > pos) {
|
|
271
|
+
// No style applied to the token between pos and from
|
|
272
|
+
el.appendChild(document.createTextNode(code.slice(pos, from)));
|
|
273
|
+
}
|
|
274
|
+
var sp = el.appendChild(document.createElement('span'));
|
|
275
|
+
sp.className = classes;
|
|
276
|
+
sp.appendChild(document.createTextNode(code.slice(from, to)));
|
|
277
|
+
pos = to;
|
|
278
|
+
});
|
|
279
|
+
if (pos < tree.length - 1) {
|
|
280
|
+
// No style applied on the trailing text
|
|
281
|
+
el.appendChild(document.createTextNode(code.slice(pos, tree.length)));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// }
|
package/es/monitor.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Emitter } from '@difizen/mana-app';
|
|
2
|
+
interface DocStatus {
|
|
3
|
+
source: string[];
|
|
4
|
+
cursor: number;
|
|
5
|
+
changes?: string;
|
|
6
|
+
}
|
|
7
|
+
interface CompletionChange {
|
|
8
|
+
start?: DocStatus;
|
|
9
|
+
accept?: DocStatus;
|
|
10
|
+
close?: DocStatus;
|
|
11
|
+
selectIndex?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class CompletionMonitor {
|
|
14
|
+
protected static instance: CompletionMonitor;
|
|
15
|
+
static getInstance(): CompletionMonitor;
|
|
16
|
+
protected completionChangeEmitter: Emitter<CompletionChange>;
|
|
17
|
+
get compeltionChange(): import("@difizen/mana-app").Event<CompletionChange>;
|
|
18
|
+
protected tooltipChangeEmitter: Emitter<boolean>;
|
|
19
|
+
get onTooltipChange(): import("@difizen/mana-app").Event<boolean>;
|
|
20
|
+
protected currentChange: CompletionChange | undefined;
|
|
21
|
+
start(doc: DocStatus): void;
|
|
22
|
+
accept(doc: DocStatus): void;
|
|
23
|
+
close(doc: DocStatus): void;
|
|
24
|
+
updateIndex(index: number): void;
|
|
25
|
+
emitChange(change: CompletionChange): void;
|
|
26
|
+
}
|
|
27
|
+
export interface MonitorPluginOptions {
|
|
28
|
+
onTooltipChange?: (visible: boolean) => void;
|
|
29
|
+
}
|
|
30
|
+
export declare const monitorPlugin: (options: MonitorPluginOptions) => import("@codemirror/state").Extension;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=monitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../src/monitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAQ5C,UAAU,SAAS;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,iBAAiB;IAC5B,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IAE7C,MAAM,CAAC,WAAW;IAOlB,SAAS,CAAC,uBAAuB,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAiB;IAE7E,IAAI,gBAAgB,wDAEnB;IAED,SAAS,CAAC,oBAAoB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAiB;IAEjE,IAAI,eAAe,+CAElB;IAED,SAAS,CAAC,aAAa,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAEtD,KAAK,CAAC,GAAG,EAAE,SAAS;IAIpB,MAAM,CAAC,GAAG,EAAE,SAAS;IAKrB,KAAK,CAAC,GAAG,EAAE,SAAS;IAKpB,WAAW,CAAC,KAAK,EAAE,MAAM;IAIzB,UAAU,CAAC,MAAM,EAAE,gBAAgB;CAGpC;AAED,MAAM,WAAW,oBAAoB;IACnC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C;AAED,eAAO,MAAM,aAAa,YAAa,oBAAoB,0CA+BvD,CAAC"}
|
package/es/monitor.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
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); } }
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
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); }
|
|
13
|
+
import { EditorView, hasHoverTooltips } from '@codemirror/view';
|
|
14
|
+
import { Emitter } from '@difizen/mana-app';
|
|
15
|
+
import { closeCompletionEffect, setSelectedEffect, startCompletionEffect } from "./auto-complete/state.js";
|
|
16
|
+
export var CompletionMonitor = /*#__PURE__*/function () {
|
|
17
|
+
function CompletionMonitor() {
|
|
18
|
+
_classCallCheck(this, CompletionMonitor);
|
|
19
|
+
this.completionChangeEmitter = new Emitter();
|
|
20
|
+
this.tooltipChangeEmitter = new Emitter();
|
|
21
|
+
}
|
|
22
|
+
_createClass(CompletionMonitor, [{
|
|
23
|
+
key: "compeltionChange",
|
|
24
|
+
get: function get() {
|
|
25
|
+
return this.completionChangeEmitter.event;
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
key: "onTooltipChange",
|
|
29
|
+
get: function get() {
|
|
30
|
+
return this.tooltipChangeEmitter.event;
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
key: "start",
|
|
34
|
+
value: function start(doc) {
|
|
35
|
+
this.currentChange = {
|
|
36
|
+
start: doc,
|
|
37
|
+
selectIndex: 0
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
key: "accept",
|
|
42
|
+
value: function accept(doc) {
|
|
43
|
+
this.currentChange = _objectSpread(_objectSpread({}, this.currentChange), {
|
|
44
|
+
accept: doc
|
|
45
|
+
});
|
|
46
|
+
this.emitChange(this.currentChange);
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
key: "close",
|
|
50
|
+
value: function close(doc) {
|
|
51
|
+
this.currentChange = _objectSpread(_objectSpread({}, this.currentChange), {
|
|
52
|
+
close: doc,
|
|
53
|
+
selectIndex: -1
|
|
54
|
+
});
|
|
55
|
+
this.emitChange(this.currentChange);
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
key: "updateIndex",
|
|
59
|
+
value: function updateIndex(index) {
|
|
60
|
+
this.currentChange = _objectSpread(_objectSpread({}, this.currentChange), {
|
|
61
|
+
selectIndex: index
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "emitChange",
|
|
66
|
+
value: function emitChange(change) {
|
|
67
|
+
this.completionChangeEmitter.fire(change);
|
|
68
|
+
}
|
|
69
|
+
}], [{
|
|
70
|
+
key: "getInstance",
|
|
71
|
+
value: function getInstance() {
|
|
72
|
+
if (!CompletionMonitor.instance) {
|
|
73
|
+
CompletionMonitor.instance = new CompletionMonitor();
|
|
74
|
+
}
|
|
75
|
+
return CompletionMonitor.instance;
|
|
76
|
+
}
|
|
77
|
+
}]);
|
|
78
|
+
return CompletionMonitor;
|
|
79
|
+
}();
|
|
80
|
+
export var monitorPlugin = function monitorPlugin(options) {
|
|
81
|
+
return EditorView.updateListener.of(function (update) {
|
|
82
|
+
var _iterator = _createForOfIteratorHelper(update.transactions),
|
|
83
|
+
_step;
|
|
84
|
+
try {
|
|
85
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
86
|
+
var _options$onTooltipCha;
|
|
87
|
+
var trans = _step.value;
|
|
88
|
+
var effects = trans.effects;
|
|
89
|
+
options === null || options === void 0 ? void 0 : (_options$onTooltipCha = options.onTooltipChange) === null || _options$onTooltipCha === void 0 ? void 0 : _options$onTooltipCha.call(options, hasHoverTooltips(update.state));
|
|
90
|
+
if (trans.isUserEvent('input.complete')) {
|
|
91
|
+
CompletionMonitor.getInstance().accept({
|
|
92
|
+
changes: JSON.stringify(trans.changes.toJSON()),
|
|
93
|
+
cursor: update.state.selection.main.head,
|
|
94
|
+
source: update.state.doc.toJSON()
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
var _iterator2 = _createForOfIteratorHelper(effects),
|
|
98
|
+
_step2;
|
|
99
|
+
try {
|
|
100
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
101
|
+
var effect = _step2.value;
|
|
102
|
+
if (effect.is(startCompletionEffect)) {
|
|
103
|
+
CompletionMonitor.getInstance().start({
|
|
104
|
+
cursor: update.state.selection.main.head,
|
|
105
|
+
source: update.state.doc.toJSON()
|
|
106
|
+
});
|
|
107
|
+
} else if (effect.is(closeCompletionEffect)) {
|
|
108
|
+
CompletionMonitor.getInstance().close({
|
|
109
|
+
cursor: update.state.selection.main.head,
|
|
110
|
+
source: update.state.doc.toJSON()
|
|
111
|
+
});
|
|
112
|
+
} else if (effect.is(setSelectedEffect)) {
|
|
113
|
+
CompletionMonitor.getInstance().updateIndex(effect.value);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
} catch (err) {
|
|
117
|
+
_iterator2.e(err);
|
|
118
|
+
} finally {
|
|
119
|
+
_iterator2.f();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} catch (err) {
|
|
123
|
+
_iterator.e(err);
|
|
124
|
+
} finally {
|
|
125
|
+
_iterator.f();
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
});
|
|
129
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python-lang.d.ts","sourceRoot":"","sources":["../src/python-lang.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,wBAAgB,MAAM,oBAErB"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
.cm-editor {
|
|
2
|
+
line-height: var(--jp-code-line-height);
|
|
3
|
+
font-size: var(--jp-code-font-size);
|
|
4
|
+
font-family: var(--jp-code-font-family);
|
|
5
|
+
border: 0;
|
|
6
|
+
border-radius: 4px;
|
|
7
|
+
height: auto;
|
|
8
|
+
background: var(--mana-libro-input-background);
|
|
9
|
+
padding: 12px 0 18px;
|
|
10
|
+
|
|
11
|
+
/* Changed to auto to autogrow */
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.cm-editor pre {
|
|
15
|
+
padding: 0 var(--jp-code-padding);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.cm-selectionMatch {
|
|
19
|
+
background-color: #e3ebff !important;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.jp-CodeMirrorEditor[data-type='inline'] .cm-dialog {
|
|
23
|
+
background-color: var(--jp-layout-color0);
|
|
24
|
+
color: var(--jp-content-font-color1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.jp-CodeMirrorEditor {
|
|
28
|
+
cursor: text;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* When zoomed out 67% and 33% on a screen of 1440 width x 900 height */
|
|
32
|
+
@media screen and (min-width: 2138px) and (max-width: 4319px) {
|
|
33
|
+
.jp-CodeMirrorEditor[data-type='inline'] .cm-cursor {
|
|
34
|
+
border-left: var(--jp-code-cursor-width1) solid var(--jp-editor-cursor-color);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* When zoomed out less than 33% */
|
|
39
|
+
@media screen and (min-width: 4320px) {
|
|
40
|
+
.jp-CodeMirrorEditor[data-type='inline'] .cm-cursor {
|
|
41
|
+
border-left: var(--jp-code-cursor-width2) solid var(--jp-editor-cursor-color);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.cm-editor.jp-mod-readOnly .cm-cursor {
|
|
46
|
+
display: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.jp-CollaboratorCursor {
|
|
50
|
+
border-left: 5px solid transparent;
|
|
51
|
+
border-right: 5px solid transparent;
|
|
52
|
+
border-top: none;
|
|
53
|
+
border-bottom: 3px solid;
|
|
54
|
+
background-clip: content-box;
|
|
55
|
+
margin-left: -5px;
|
|
56
|
+
margin-right: -5px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.cm-searching,
|
|
60
|
+
.cm-searching span {
|
|
61
|
+
background-color: var(--jp-search-unselected-match-background-color);
|
|
62
|
+
color: var(--jp-search-unselected-match-color);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.cm-searching span::selection {
|
|
66
|
+
background-color: var(--jp-search-selected-match-background-color) !important;
|
|
67
|
+
color: var(--jp-search-selected-match-color) !important;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.cm-trailingspace {
|
|
71
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAsElEQVQIHQGlAFr/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7+r3zKmT0/+pk9P/7+r3zAAAAAAAAAAABAAAAAAAAAAA6OPzM+/q9wAAAAAA6OPzMwAAAAAAAAAAAgAAAAAAAAAAGR8NiRQaCgAZIA0AGR8NiQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQyoYJ/SY80UAAAAASUVORK5CYII=);
|
|
72
|
+
background-position: center left;
|
|
73
|
+
background-repeat: repeat-x;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.jp-CollaboratorCursor-hover {
|
|
77
|
+
position: absolute;
|
|
78
|
+
z-index: 1;
|
|
79
|
+
transform: translateX(-50%);
|
|
80
|
+
color: white;
|
|
81
|
+
border-radius: 3px;
|
|
82
|
+
padding-left: 4px;
|
|
83
|
+
padding-right: 4px;
|
|
84
|
+
padding-top: 1px;
|
|
85
|
+
padding-bottom: 1px;
|
|
86
|
+
text-align: center;
|
|
87
|
+
font-size: var(--jp-ui-font-size1);
|
|
88
|
+
white-space: nowrap;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.jp-CodeMirror-ruler {
|
|
92
|
+
border-left: 1px dashed var(--jp-border-color2);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* Styles for shared cursors (remote cursor locations and selected ranges) */
|
|
96
|
+
.jp-CodeMirrorEditor .remote-caret {
|
|
97
|
+
position: relative;
|
|
98
|
+
border-left: 2px solid black;
|
|
99
|
+
margin-left: -1px;
|
|
100
|
+
margin-right: -1px;
|
|
101
|
+
box-sizing: border-box;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.jp-CodeMirrorEditor .remote-caret > div {
|
|
105
|
+
white-space: nowrap;
|
|
106
|
+
position: absolute;
|
|
107
|
+
top: -1.15em;
|
|
108
|
+
padding-bottom: 0.05em;
|
|
109
|
+
left: -2px;
|
|
110
|
+
font-size: 0.95em;
|
|
111
|
+
background-color: rgb(250, 129, 0);
|
|
112
|
+
font-family: var(--jp-ui-font-family);
|
|
113
|
+
font-weight: bold;
|
|
114
|
+
line-height: normal;
|
|
115
|
+
user-select: none;
|
|
116
|
+
color: white;
|
|
117
|
+
padding-left: 2px;
|
|
118
|
+
padding-right: 2px;
|
|
119
|
+
z-index: 3;
|
|
120
|
+
transition: opacity 0.3s ease-in-out;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.jp-CodeMirrorEditor .remote-caret.hide-name > div {
|
|
124
|
+
transition-delay: 0.7s;
|
|
125
|
+
opacity: 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.jp-CodeMirrorEditor .remote-caret:hover > div {
|
|
129
|
+
opacity: 1;
|
|
130
|
+
transition-delay: 0s;
|
|
131
|
+
}
|