vue-codemirror6 1.0.0 → 1.0.2

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.
@@ -188,6 +188,11 @@ export default defineComponent({
188
188
  type: Boolean,
189
189
  defalt: false,
190
190
  },
191
+ /** Using tag */
192
+ tag: {
193
+ type: String,
194
+ default: 'div',
195
+ },
191
196
  },
192
197
  /** Emits */
193
198
  emits: ['update:modelValue', 'update', 'ready', 'focus', 'changed'],
@@ -199,7 +204,7 @@ export default defineComponent({
199
204
  */
200
205
  setup(props, context: SetupContext<CodeMirrorEmitsOptions>) {
201
206
  /** Editor DOM */
202
- const editor: Ref<Element | undefined> = ref();
207
+ const editor: Ref<HTMLElement | undefined> = ref();
203
208
 
204
209
  /** Internal value */
205
210
  const doc: Ref<string | Text> = ref(props.modelValue);
@@ -273,16 +278,18 @@ export default defineComponent({
273
278
  // for parent-to-child binding.
274
279
  watch(
275
280
  () => props.modelValue,
276
- text => {
281
+ value => {
277
282
  if (!view.value || view.value.composing) {
278
283
  // IME fix
279
284
  return;
280
285
  }
286
+ /** Previous cursor location */
287
+ const previous = view.value.state.selection;
281
288
 
282
289
  // Update
283
290
  view.value.dispatch({
284
- changes: { from: 0, to: view.value.state.doc.length, insert: text },
285
- selection: selection.value,
291
+ changes: { from: 0, to: view.value.state.doc.length, insert: value },
292
+ selection: previous,
286
293
  });
287
294
  },
288
295
  { immediate: true }
@@ -479,7 +486,7 @@ export default defineComponent({
479
486
  // </div>
480
487
  // </template>
481
488
  return h(
482
- 'div',
489
+ this.$props.tag,
483
490
  {
484
491
  ref: 'editor',
485
492
  class: 'vue-codemirror',