Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: RangeError: Selection points outside of document #27

Open
jonkad opened this issue Nov 29, 2023 · 2 comments
Open

Bug: RangeError: Selection points outside of document #27

jonkad opened this issue Nov 29, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@jonkad
Copy link

jonkad commented Nov 29, 2023

Hello,

When I update the v-model value from another function, then I got this error:
Uncaught (in promise) RangeError: Selection points outside of document

image

Versions:
vue: 3.3.4
codemirror: 6.0.1
vue-codemirror6: 1.1.31
@codemirror/lang-css: 6.2.1

Maybe someone have an Idea?

<template>
  <button @click="restoreCustomStyleCss()">restore</button>
  <button @click="cearCustomStyleCss()">clear</button>
  <code-mirror
    v-model="customStyleCss"
    :lang="[lang]"
    :basic="true"
    :gutter="true"
  />
</template>

<script lang="ts">
import { defineComponent, defineAsyncComponent } from "vue";

import CodeMirror from "vue-codemirror6";
import { css } from "@codemirror/lang-css";
export default defineComponent({
  name: "EventStyle",
  components: {
    CodeMirror,
  },
  setup() {
    const lang = css();
    return { lang };
  },
  data() {
    return {
      customStyleCss: "",
      restoreCustomStyleCss = "body {color: red;}",
    };
  },
  methods: {
    restoreCustomStyleCss() {
      this.customStyleCss = this.restoreCustomStyleCss;
    },
    cearCustomStyleCss() {
      this.customStyleCss = "";
    },
  },
});
</script>

@jonkad
Copy link
Author

jonkad commented Nov 30, 2023

I have temporarily solved the error as follows:
this.$refs.cm.setCursor(0);

<template>
  <button @click="restoreCustomStyleCss()">restore</button>
  <button @click="cearCustomStyleCss()">clear</button>
  <code-mirror
    v-model="customStyleCss"
    :lang="[lang]"
    :basic="true"
    :gutter="true"
    ref="cm"
  />
</template>

<script lang="ts">
import { defineComponent, defineAsyncComponent } from "vue";

import CodeMirror from "vue-codemirror6";
import { css } from "@codemirror/lang-css";
export default defineComponent({
  name: "EventStyle",
  components: {
    CodeMirror,
  },
  setup() {
    const lang = css();
    return { lang };
  },
  data() {
    return {
      customStyleCss: "",
      restoreCustomStyleCss = "body {color: red;}",
    };
  },
  methods: {
    restoreCustomStyleCss() {
      //@ts-expect-error
      this.$refs.cm.setCursor(0);
      this.customStyleCss = this.restoreCustomStyleCss;
    },
    cearCustomStyleCss() {
      //@ts-expect-error
      this.$refs.cm.setCursor(0);
      this.customStyleCss = "";
    },
  },
});
</script>

@logue logue added the bug Something isn't working label Feb 22, 2024
@redisviewer
Copy link

josdejong/svelte-jsoneditor#423

refer to this issues? @logue

logue added a commit that referenced this issue May 20, 2024
Add range fix. (#27)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants