Commit 1d48b2b8 authored by Jérome Perrin's avatar Jérome Perrin

monaco_editor: fix typescript errors

parent 2948b0f6
...@@ -3,6 +3,11 @@ ...@@ -3,6 +3,11 @@
(function(window, rJS, monaco) { (function(window, rJS, monaco) {
'use strict'; 'use strict';
// globals
const JSLINT = window['JSLINT'];
const prettier = window['prettier'];
const prettierPlugins = window['prettierPlugins'];
rJS(window) rJS(window)
.declareAcquiredMethod('notifySubmit', 'notifySubmit') .declareAcquiredMethod('notifySubmit', 'notifySubmit')
.declareJob('deferNotifySubmit', function() { .declareJob('deferNotifySubmit', function() {
...@@ -14,15 +19,14 @@ ...@@ -14,15 +19,14 @@
// Ensure error will be correctly handled // Ensure error will be correctly handled
return this.notifyChange(); return this.notifyChange();
}) })
.ready(function() { .ready(function(context) {
var context = this, let editor;
editor;
function deferNotifyChange() { function deferNotifyChange() {
if (!context.state.ignoredChangeDuringInitialization) { if (!context.state.ignoredChangeDuringInitialization) {
return context.deferNotifyChange(); return context.deferNotifyChange();
} }
} }
this.editor = editor = monaco.editor.create( context.editor = editor = monaco.editor.create(
this.element.querySelector('.monaco-container'), this.element.querySelector('.monaco-container'),
{ {
/* because Alt+Click is LeftClick on ChromeOS */ /* because Alt+Click is LeftClick on ChromeOS */
...@@ -154,18 +158,20 @@ ...@@ -154,18 +158,20 @@
}); });
// Type mapping for Nexedi libraries // Type mapping for Nexedi libraries
function addExtraLibrary(script_name, lib_name) { const addExtraLibrary = function(script_name, lib_name) {
return fetch(script_name) return () => {
.then(function(resp) { return fetch(script_name)
return resp.text(); .then(function(resp) {
}) return resp.text();
.then(function(script_code) { })
monaco.languages.typescript.javascriptDefaults.addExtraLib( .then(function(script_code) {
script_code, monaco.languages.typescript.javascriptDefaults.addExtraLib(
lib_name script_code,
); lib_name
}); );
} });
};
};
queue queue
.push(addExtraLibrary('./monaco-rsvp.d.ts', 'rsvp')) .push(addExtraLibrary('./monaco-rsvp.d.ts', 'rsvp'))
.push(addExtraLibrary('./monaco-renderjs.d.ts', 'renderjs')) .push(addExtraLibrary('./monaco-renderjs.d.ts', 'renderjs'))
...@@ -190,4 +196,4 @@ ...@@ -190,4 +196,4 @@
} }
return form_data; return form_data;
}); });
})(window, rJS, monaco); })(window, rJS, window['monaco']);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment