nuxt-monaco-editor 1.0.4 → 1.0.5
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
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
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.5](https://github.com/e-chan1007/nuxt-monaco-editor/compare/v1.0.4...v1.0.5) (2022-10-26)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* add `load` event for `<Monaco(Diff)Editor>` ([505896a](https://github.com/e-chan1007/nuxt-monaco-editor/commit/505896a35ee8b4a88874b32d8e702e87b67ef754))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* 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))
|
|
16
|
+
|
|
5
17
|
### [1.0.4](https://github.com/e-chan1007/nuxt-monaco-editor/compare/v1.0.3...v1.0.4) (2022-10-23)
|
|
6
18
|
|
|
7
19
|
|
package/dist/module.json
CHANGED
|
@@ -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
|
|