|
|
@@ -57,8 +57,9 @@ export default { |
|
|
|
scrollBeyondLastLine: false, |
|
|
|
quickSuggestions: false, //智能提示 |
|
|
|
renderLineHighlight: false, //选中行外部边框 |
|
|
|
lineHeight: 22 |
|
|
|
lineHeight: 22, |
|
|
|
|
|
|
|
renderWhitespace: 'boundary', |
|
|
|
}, |
|
|
|
|
|
|
|
// 编辑器对象 |
|
|
@@ -107,8 +108,9 @@ export default { |
|
|
|
methods: { |
|
|
|
init() { |
|
|
|
|
|
|
|
// 初始化container的内容,销毁之前生成的编辑器 |
|
|
|
this.$refs.container.innerHTML = ""; |
|
|
|
try { |
|
|
|
// 初始化container的内容,销毁之前生成的编辑器 |
|
|
|
this.$refs.container.innerHTML = ""; |
|
|
|
// 生成编辑器配置 |
|
|
|
const editorOptions = Object.assign(this.defaultOpts, this.opts); |
|
|
|
if (!this.isDiff) { |
|
|
@@ -123,6 +125,13 @@ export default { |
|
|
|
}, |
|
|
|
); |
|
|
|
|
|
|
|
if (this.monacaValue) { |
|
|
|
const output = isBase64(this.monacaValue) |
|
|
|
? Buffer.from(this.monacaValue, "base64").toString("utf8") |
|
|
|
: this.monacaValue; |
|
|
|
this.monacoEditor.setValue(output); |
|
|
|
} |
|
|
|
|
|
|
|
// 编辑器内容发生改变时触发 |
|
|
|
} else { |
|
|
|
editorOptions.readOnly = true; |
|
|
@@ -144,13 +153,10 @@ export default { |
|
|
|
), |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
if (this.monacaValue) { |
|
|
|
const output = isBase64(this.monacaValue) |
|
|
|
? Buffer.from(value, "base64").toString("utf8") |
|
|
|
: this.monacaValue; |
|
|
|
this.monacoEditor.setValue(output); |
|
|
|
} |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
console.log("error-init:",error) |
|
|
|
} |
|
|
|
}, |
|
|
|
upDateDiff(val) { |
|
|
|
this.monacoDiffInstance.updateOptions({ |
|
|
@@ -189,7 +195,7 @@ export default { |
|
|
|
}, |
|
|
|
setDiff(oldContent, newContent) { |
|
|
|
this.oldValue = isBase64(oldContent) ? Buffer.from(oldContent, "base64").toString("utf8") : oldContent; |
|
|
|
this.newValue = newContent; |
|
|
|
this.newValue = isBase64(newContent) ? Buffer.from(newContent, "base64").toString("utf8") : newContent; |
|
|
|
this.isDiff = true; |
|
|
|
this.init(); |
|
|
|
}, |
|
|
|