nuxt-monaco-editor 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -2
- package/dist/runtime/MonacoDiffEditor.vue +6 -9
- package/dist/runtime/MonacoEditor.vue +4 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.0.6](https://github.com/e-chan1007/nuxt-monaco-editor/compare/v1.0.5...v1.0.6) (2022-10-26)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* destination where monaco-editor is copied was wrong ([f3a839e](https://github.com/e-chan1007/nuxt-monaco-editor/commit/f3a839eab2a6602aa582d772e7a54d8573237f81))
|
|
11
|
+
|
|
12
|
+
### [1.0.5](https://github.com/e-chan1007/nuxt-monaco-editor/compare/v1.0.4...v1.0.5) (2022-10-26)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* add `load` event for `<Monaco(Diff)Editor>` ([505896a](https://github.com/e-chan1007/nuxt-monaco-editor/commit/505896a35ee8b4a88874b32d8e702e87b67ef754))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* changing v-model is sometimes ignored ([#13](https://github.com/e-chan1007/nuxt-monaco-editor/issues/13)) ([7a9a3d6](https://github.com/e-chan1007/nuxt-monaco-editor/commit/7a9a3d6e6305ec3ce1a2e9ed0fe317a7211781e3))
|
|
23
|
+
|
|
5
24
|
### [1.0.4](https://github.com/e-chan1007/nuxt-monaco-editor/compare/v1.0.3...v1.0.4) (2022-10-23)
|
|
6
25
|
|
|
7
26
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -36,11 +36,11 @@ const module = defineNuxtModule({
|
|
|
36
36
|
nuxt.options.runtimeConfig.app.__MONACO_EDITOR_LOCALE__ = options.locale;
|
|
37
37
|
nuxt.options.runtimeConfig.app.__MONACO_EDITOR_LOCATION__ = monacoEditorLocation;
|
|
38
38
|
extendViteConfig(async (config) => {
|
|
39
|
-
const shouldAppendURLPrefix = await checkNuxtCompatibility({ nuxt: "^3.0.0-rc.12" })
|
|
39
|
+
const shouldAppendURLPrefix = await checkNuxtCompatibility({ nuxt: "^3.0.0-rc.12" });
|
|
40
40
|
const viteStaticCopyPlugin = viteStaticCopy({
|
|
41
41
|
targets: [{
|
|
42
42
|
src: require.resolve("monaco-editor/min/vs/loader.js").replace(/\\/g, "/").replace(/\/vs\/loader\.js$/, "/*"),
|
|
43
|
-
dest: (shouldAppendURLPrefix ? "__url/" : "") + monacoEditorLocation.slice(1)
|
|
43
|
+
dest: nuxt.options.dev ? (shouldAppendURLPrefix ? "__url/" : "") + monacoEditorLocation.slice(1) : options.dest
|
|
44
44
|
}]
|
|
45
45
|
});
|
|
46
46
|
config.plugins.push(...viteStaticCopyPlugin);
|
|
@@ -25,6 +25,7 @@ interface Props {
|
|
|
25
25
|
|
|
26
26
|
interface Emits {
|
|
27
27
|
(event: 'update:modelValue', value: string): void
|
|
28
|
+
(event: 'load', editor: Monaco.editor.IStandaloneDiffEditor): void
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -39,19 +40,16 @@ const isLoading = ref(true)
|
|
|
39
40
|
const editorElement = ref<HTMLDivElement>()
|
|
40
41
|
const monaco = useMonaco()!
|
|
41
42
|
|
|
42
|
-
let ignoreWatch = false
|
|
43
43
|
let editor: Monaco.editor.IStandaloneDiffEditor
|
|
44
44
|
let originalModel: Monaco.editor.ITextModel
|
|
45
45
|
let modifiedModel: Monaco.editor.ITextModel
|
|
46
|
-
const editorRef = ref(
|
|
46
|
+
const editorRef = ref()
|
|
47
47
|
|
|
48
48
|
watch(() => [props.original, props.modelValue], () => {
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
if (originalModel.getValue() !== props.original || modifiedModel.getValue() !== props.modelValue) {
|
|
50
|
+
originalModel.setValue(props.original)
|
|
51
|
+
modifiedModel.setValue(props.modelValue)
|
|
52
52
|
}
|
|
53
|
-
originalModel.setValue(props.original)
|
|
54
|
-
modifiedModel.setValue(props.modelValue)
|
|
55
53
|
})
|
|
56
54
|
|
|
57
55
|
watch(() => props.lang, () => {
|
|
@@ -73,13 +71,13 @@ defineExpose({
|
|
|
73
71
|
/**
|
|
74
72
|
* Monaco editor instance
|
|
75
73
|
*/
|
|
76
|
-
// @ts-ignore
|
|
77
74
|
$editor: editorRef
|
|
78
75
|
})
|
|
79
76
|
|
|
80
77
|
onMounted(() => {
|
|
81
78
|
editor = monaco.editor.createDiffEditor(editorElement.value!, props.options)
|
|
82
79
|
editorRef.value = editor
|
|
80
|
+
emit('load', editor)
|
|
83
81
|
originalModel = monaco.editor.createModel(props.original, props.lang)
|
|
84
82
|
modifiedModel = monaco.editor.createModel(props.modelValue, props.lang)
|
|
85
83
|
editor.setModel({
|
|
@@ -88,7 +86,6 @@ onMounted(() => {
|
|
|
88
86
|
})
|
|
89
87
|
|
|
90
88
|
editor.onDidUpdateDiff(() => {
|
|
91
|
-
ignoreWatch = true
|
|
92
89
|
emit('update:modelValue', editor.getModel()!.modified.getValue())
|
|
93
90
|
})
|
|
94
91
|
|
|
@@ -25,6 +25,7 @@ interface Props {
|
|
|
25
25
|
|
|
26
26
|
interface Emits {
|
|
27
27
|
(event: 'update:modelValue', value: string): void
|
|
28
|
+
(event: 'load', editor: Monaco.editor.IStandaloneCodeEditor): void
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -40,17 +41,12 @@ const lang = computed(() => props.lang || props.options.language)
|
|
|
40
41
|
const editorElement = ref<HTMLDivElement>()
|
|
41
42
|
const monaco = useMonaco()!
|
|
42
43
|
|
|
43
|
-
let ignoreWatch = false
|
|
44
44
|
let editor: Monaco.editor.IStandaloneCodeEditor
|
|
45
45
|
let model: Monaco.editor.ITextModel
|
|
46
|
-
const editorRef = ref(
|
|
46
|
+
const editorRef = ref()
|
|
47
47
|
|
|
48
48
|
watch(() => props.modelValue, () => {
|
|
49
|
-
if (
|
|
50
|
-
ignoreWatch = false
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
editor?.setValue(props.modelValue)
|
|
49
|
+
if (editor?.getValue() !== props.modelValue) { editor?.setValue(props.modelValue) }
|
|
54
50
|
})
|
|
55
51
|
|
|
56
52
|
watch(() => props.lang, () => {
|
|
@@ -67,18 +63,17 @@ defineExpose({
|
|
|
67
63
|
/**
|
|
68
64
|
* Monaco editor instance
|
|
69
65
|
*/
|
|
70
|
-
// @ts-ignore
|
|
71
66
|
$editor: editorRef
|
|
72
67
|
})
|
|
73
68
|
|
|
74
69
|
onMounted(() => {
|
|
75
70
|
editor = monaco.editor.create(editorElement.value!, props.options)
|
|
76
71
|
editorRef.value = editor
|
|
72
|
+
emit('load', editor)
|
|
77
73
|
model = monaco.editor.createModel(props.modelValue, lang.value)
|
|
78
74
|
editor.setModel(model)
|
|
79
75
|
|
|
80
76
|
editor.onDidChangeModelContent(() => {
|
|
81
|
-
ignoreWatch = true
|
|
82
77
|
emit('update:modelValue', editor.getValue())
|
|
83
78
|
})
|
|
84
79
|
|