本文整理汇总了TypeScript中codemirror.modeInfo类的典型用法代码示例。如果您正苦于以下问题:TypeScript modeInfo类的具体用法?TypeScript modeInfo怎么用?TypeScript modeInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了modeInfo类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should add a spec loader', async () => {
let called = 0;
let loaded = 0;
Mode.addSpecLoader(async spec => {
called++;
if (spec.mode !== 'bar') {
return false;
}
loaded++;
return true;
}, 42);
CodeMirror.modeInfo.push(fakeMode('bar'));
let spec = await Mode.ensure('bar');
expect(called).to.equal(1);
expect(loaded).to.equal(1);
expect(spec.name).to.equal('BAR');
spec = await Mode.ensure('python');
expect(called).to.equal(1);
expect(loaded).to.equal(1);
try {
spec = await Mode.ensure('APL');
} catch (err) {
// apparently one cannot use webpack `require` in jest
}
expect(called).to.equal(2);
expect(loaded).to.equal(1);
});
示例2: RegExp
* Define an IPython codemirror mode.
*
* It is a slightly altered Python Mode with a `?` operator.
*/
CodeMirror.defineMode(
'ipython',
(config: CodeMirror.EditorConfiguration, modeOptions?: any) => {
let pythonConf: any = {};
for (let prop in modeOptions) {
if (modeOptions.hasOwnProperty(prop)) {
pythonConf[prop] = modeOptions[prop];
}
}
pythonConf.name = 'python';
pythonConf.singleOperators = new RegExp('^[\\+\\-\\*/%&|@\\^~<>!\\?]');
pythonConf.identifiers = new RegExp(
'^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*'
);
return CodeMirror.getMode(config, pythonConf);
},
'python'
);
CodeMirror.defineMIME('text/x-ipython', 'ipython');
CodeMirror.modeInfo.push({
ext: [],
mime: 'text/x-ipython',
mode: 'ipython',
name: 'ipython'
});
示例3:
import 'codemirror/lib/codemirror';
import 'codemirror/mode/haskell/haskell';
CodeMirror.defineMode("ihaskell", (config) => {
let hmode = CodeMirror.getMode(config, "haskell");
return CodeMirror.multiplexingMode(
hmode,
{
open: /:(?=!)/, // Matches : followed by !, but doesn't consume !
close: /^(?!!)/, // Matches start of line not followed by !, doesn't consume character
mode: CodeMirror.getMode(config, "text/plain"),
delimStyle: "delimit"
},
{
open: /\[r\||\[rprint\||\[rgraph\|/,
close: /\|\]/ ,
mode: CodeMirror.getMode(config, "text/x-rsrc"),
delimStyle: "delimit"}
);
});
CodeMirror.defineMIME("text/x-ihaskell", "ihaskell");
CodeMirror.modeInfo.push({
ext: ['hs'],
mime: "text/x-ihaskell",
mode: 'ihaskell',
name: 'ihaskell'
});