yh-codemirror 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.
Files changed (2) hide show
  1. package/CodeMirror.vue +14 -8
  2. package/package.json +1 -1
package/CodeMirror.vue CHANGED
@@ -107,7 +107,7 @@ const codeMirrorEditorStyle = computed(() => {
107
107
  watch(
108
108
  () => props.modelValue,
109
109
  (val) => {
110
- if (view && state && val != view.state.doc.toString()) {
110
+ if (view && state && typeof val === 'string' && val != view.state.doc.toString()) {
111
111
  let end = view.state.doc.toString().length;
112
112
  view.dispatch({
113
113
  changes: [
@@ -119,6 +119,10 @@ watch(
119
119
  ],
120
120
  });
121
121
  }
122
+ },
123
+ {
124
+ deep: true,
125
+ immediate: true,
122
126
  }
123
127
  );
124
128
 
@@ -210,14 +214,16 @@ onMounted(() => {
210
214
  }
211
215
  }
212
216
  }
213
- let doc = props.modelValue;
214
- if (typeof doc !== 'string') {
215
- doc = '';
217
+ if (!state) {
218
+ let doc = props.modelValue;
219
+ if (typeof doc !== 'string') {
220
+ doc = '';
221
+ }
222
+ state = EditorState.create({
223
+ doc,
224
+ extensions,
225
+ });
216
226
  }
217
- state = EditorState.create({
218
- doc,
219
- extensions,
220
- });
221
227
  if (state) {
222
228
  view = new EditorView({
223
229
  state: state,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yh-codemirror",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "wraper codemirror with vue3",
5
5
  "main": "index.js",
6
6
  "scripts": {