我正在使用monaco-editor,并且希望从多个文件中包含建议。 我不确定最佳方法是什么,但基本上,我希望当我从file2.js导出某些函数时,能够在建议中从另一个file1.js中访问它们。
有什么想法吗?
谢谢!
文件1
var express = require('express');
var pug = require('pug');
var config = require('./config');
var fs = require('fs');
var router = express.Router();
var utils = require('/utils');
// Here I would like to use the function newTest from the other file
but it does not show in the suggestions
router.get('/', function (req, res) {
console.log("ip - ", req.connection.remoteAddress)
res.send(pug.compileFile('views/main.pug')({
config
}))
});
module.exports = router;
文件2
function newTest() {
}
module.exports.newTest = newTest;
编辑文件
$(document).ready(function() {
// I prefetch my models, then I have a callback to create an instance of the editor
preFetchAllModels(function() {
var models = monaco.editor.getModels();
// I check that I have my models (file1 and file2) prefetched before creating the editor
console.log("models", models);
monaco.languages.typescript.javascriptDefaults.setEagerModelSync(true)
monacoEditor = monaco.editor.create(document.getElementById("editor"), {
value: "loading...",
language: "javascript",
theme: 'monokai',
lineHeight: 20,
fontSize: 16,
wordWrap: "bounded",
automaticLayout: true,
wrappingIndent: 'indent'
});
});