API 在 monaco-editor 中获取 html 格式的内容?
API to get html formatted content in monaco-editor?
我想以编程方式从 monaco-editor 实例中获取格式化文本。
当我说格式化文本时,我指的是语法突出显示 - 当我从 monaco 复制文本并将其粘贴到 outlook(或任何其他支持粘贴 html 内容的应用程序)时得到的结果。
我的目标是将它与其他一些文本(monaco-editor 无法访问)一起放在剪贴板上。
我怎样才能做到这一点?
据此https://github.com/Microsoft/monaco-editor/issues/866
答案是
var editor = monaco.editor.create(document.getElementById("container"), {
value: "function hello() {\n\talert('Hello world!');\n}",
language: "javascript"
});
setTimeout(function() {
const html = editor.viewModel.getHTMLToCopy([editor.getModel().getFullModelRange()], false);
console.log(html);
}, 2000);
我想以编程方式从 monaco-editor 实例中获取格式化文本。
当我说格式化文本时,我指的是语法突出显示 - 当我从 monaco 复制文本并将其粘贴到 outlook(或任何其他支持粘贴 html 内容的应用程序)时得到的结果。
我的目标是将它与其他一些文本(monaco-editor 无法访问)一起放在剪贴板上。
我怎样才能做到这一点?
据此https://github.com/Microsoft/monaco-editor/issues/866
答案是
var editor = monaco.editor.create(document.getElementById("container"), {
value: "function hello() {\n\talert('Hello world!');\n}",
language: "javascript"
});
setTimeout(function() {
const html = editor.viewModel.getHTMLToCopy([editor.getModel().getFullModelRange()], false);
console.log(html);
}, 2000);