diff --git a/docs/content/2.references/1.monaco-editor.md b/docs/content/2.references/1.monaco-editor.md index 39d7ef0..8e18e4a 100644 --- a/docs/content/2.references/1.monaco-editor.md +++ b/docs/content/2.references/1.monaco-editor.md @@ -55,6 +55,12 @@ Children of `` will be shown until the editor is loaded. Available options are listed [here](https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IStandaloneEditorConstructionOptions.html){target="_blank"}. :: :: + + ::field{name="modelUri" type="monaco.Uri"} + ::div + The URI that identifies models. + :: + :: :: ## Events diff --git a/docs/content/2.references/2.monaco-diff-editor.md b/docs/content/2.references/2.monaco-diff-editor.md index 1d9f8ae..bc60489 100644 --- a/docs/content/2.references/2.monaco-diff-editor.md +++ b/docs/content/2.references/2.monaco-diff-editor.md @@ -57,11 +57,29 @@ Children of `` will be shown until the editor is loaded. ::field{name="options" type="IStandaloneDiffEditorConstructionOptions" default="{ automaticLayout: true }"} ::div - Options passed to the second argument of `monaco.editor.create`. + Options passed to the second argument of `monaco.editor.create`. You can also change the options after the editor mounted. \ Available options are listed [here](https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IStandaloneDiffEditorConstructionOptions.html){target="_blank"}. :: :: + + ::field{name="original" type="string"} + ::div + Original value showed in the editor. + :: + :: + + ::field{name="modelUri" type="monaco.Uri"} + ::div + The URI that identifies models. + :: + :: + + ::field{name="originalModelUri" type="monaco.Uri"} + ::div + The URI that identifies models. + :: + :: :: ## Events diff --git a/src/runtime/MonacoDiffEditor.client.vue b/src/runtime/MonacoDiffEditor.client.vue index ba63cbc..690803d 100644 --- a/src/runtime/MonacoDiffEditor.client.vue +++ b/src/runtime/MonacoDiffEditor.client.vue @@ -20,6 +20,18 @@ interface Props { * Options passed to the second argument of `monaco.editor.createDiffEditor` */ options?: Monaco.editor.IStandaloneDiffEditorConstructionOptions; + /** + * The URI that identifies models + */ + // eslint-disable-next-line vue/require-default-prop + originalModelUri?: Monaco.Uri; + + /** + * The URI that identifies models + */ + // eslint-disable-next-line vue/require-default-prop + modelUri?: Monaco.Uri; + original?: string; modelValue?: string; } @@ -62,8 +74,8 @@ watch(() => props.lang, () => { const modifiedValue = modifiedModel?.getValue() || props.modelValue if (originalModel) { originalModel.dispose() } if (modifiedModel) { modifiedModel.dispose() } - originalModel = monaco.editor.createModel(originalValue, props.lang) - modifiedModel = monaco.editor.createModel(modifiedValue, props.lang) + originalModel = monaco.editor.createModel(originalValue, props.lang, props.originalModelUri) + modifiedModel = monaco.editor.createModel(modifiedValue, props.lang, props.modelUri) editor.setModel({ original: originalModel, modified: modifiedModel @@ -85,8 +97,8 @@ watch(editorElement, (newValue, oldValue) => { if (!editorElement.value || oldValue) { return } editor = monaco.editor.createDiffEditor(editorElement.value!, defu(props.options, defaultOptions)) editorRef.value = editor - originalModel = monaco.editor.createModel(props.original, props.lang) - modifiedModel = monaco.editor.createModel(props.modelValue, props.lang) + originalModel = monaco.editor.createModel(props.original, props.lang, props.originalModelUri) + modifiedModel = monaco.editor.createModel(props.modelValue, props.lang, props.modelUri) editor.setModel({ original: originalModel, modified: modifiedModel diff --git a/src/runtime/MonacoEditor.client.vue b/src/runtime/MonacoEditor.client.vue index 9e9cc23..aabd8ad 100644 --- a/src/runtime/MonacoEditor.client.vue +++ b/src/runtime/MonacoEditor.client.vue @@ -5,7 +5,7 @@