nuxt-monaco-editor 1.0.3 → 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,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.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
+
17
+ ### [1.0.4](https://github.com/e-chan1007/nuxt-monaco-editor/compare/v1.0.3...v1.0.4) (2022-10-23)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * $editor was always undefined ([ef3a420](https://github.com/e-chan1007/nuxt-monaco-editor/commit/ef3a420d805498e2b47f8b727b5d3b4ca1cb5eaf))
23
+
5
24
  ### [1.0.3](https://github.com/e-chan1007/nuxt-monaco-editor/compare/v1.0.2...v1.0.3) (2022-10-21)
6
25
 
7
26
 
package/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0-rc.9"
6
6
  },
7
- "version": "1.0.3"
7
+ "version": "1.0.5"
8
8
  }
@@ -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,18 +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
47
 
47
48
  watch(() => [props.original, props.modelValue], () => {
48
- if (ignoreWatch) {
49
- ignoreWatch = false
50
- return
49
+ if (originalModel.getValue() !== props.original || modifiedModel.getValue() !== props.modelValue) {
50
+ originalModel.setValue(props.original)
51
+ modifiedModel.setValue(props.modelValue)
51
52
  }
52
- originalModel.setValue(props.original)
53
- modifiedModel.setValue(props.modelValue)
54
53
  })
55
54
 
56
55
  watch(() => props.lang, () => {
@@ -72,12 +71,13 @@ defineExpose({
72
71
  /**
73
72
  * Monaco editor instance
74
73
  */
75
- // @ts-ignore
76
- $editor: editor
74
+ $editor: editorRef
77
75
  })
78
76
 
79
77
  onMounted(() => {
80
78
  editor = monaco.editor.createDiffEditor(editorElement.value!, props.options)
79
+ editorRef.value = editor
80
+ emit('load', editor)
81
81
  originalModel = monaco.editor.createModel(props.original, props.lang)
82
82
  modifiedModel = monaco.editor.createModel(props.modelValue, props.lang)
83
83
  editor.setModel({
@@ -86,7 +86,6 @@ onMounted(() => {
86
86
  })
87
87
 
88
88
  editor.onDidUpdateDiff(() => {
89
- ignoreWatch = true
90
89
  emit('update:modelValue', editor.getModel()!.modified.getValue())
91
90
  })
92
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,16 +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
47
 
47
48
  watch(() => props.modelValue, () => {
48
- if (ignoreWatch) {
49
- ignoreWatch = false
50
- return
51
- }
52
- editor?.setValue(props.modelValue)
49
+ if (editor?.getValue() !== props.modelValue) { editor?.setValue(props.modelValue) }
53
50
  })
54
51
 
55
52
  watch(() => props.lang, () => {
@@ -66,17 +63,17 @@ defineExpose({
66
63
  /**
67
64
  * Monaco editor instance
68
65
  */
69
- // @ts-ignore
70
- $editor: editor
66
+ $editor: editorRef
71
67
  })
72
68
 
73
69
  onMounted(() => {
74
70
  editor = monaco.editor.create(editorElement.value!, props.options)
71
+ editorRef.value = editor
72
+ emit('load', editor)
75
73
  model = monaco.editor.createModel(props.modelValue, lang.value)
76
74
  editor.setModel(model)
77
75
 
78
76
  editor.onDidChangeModelContent(() => {
79
- ignoreWatch = true
80
77
  emit('update:modelValue', editor.getValue())
81
78
  })
82
79
 
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/e-chan1007/nuxt-monaco-editor.git"
13
13
  },
14
- "version": "1.0.3",
14
+ "version": "1.0.5",
15
15
  "type": "module",
16
16
  "license": "MIT",
17
17
  "exports": {
@@ -57,7 +57,7 @@
57
57
  "remark-lint": "^9.1.1",
58
58
  "remark-preset-lint-recommended": "^6.1.2",
59
59
  "standard-version": "^9.5.0",
60
- "vuepress": "next"
60
+ "vuepress": "2.0.0-beta.51"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "monaco-editor": "*"