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

editor instance accessibility #8

Closed
gyamxxx opened this issue Dec 2, 2016 · 3 comments
Closed

editor instance accessibility #8

gyamxxx opened this issue Dec 2, 2016 · 3 comments

Comments

@gyamxxx
Copy link

gyamxxx commented Dec 2, 2016

Hi, I'm sorry poor English.

I'm using this library. Thank you for making.
so, I want to use "Autoformart" function like this.
https://codemirror.net/2/demo/formatting.html

but, editor instance cannot access parant component.
https://github.com/surmon-china/vue-codemirror/blob/master/codemirror.vue#L69

Could you make editor instance accessible, or add function like calling parent method?

@yahtnif
Copy link

yahtnif commented Dec 4, 2016

@gyamxxx

assign a reference ID to the component using ref

<codemirror v-model="code" ref="codemirror"></codemirror>

then access the editor instance

this.$refs.codemirror.editor

@gyamxxx
Copy link
Author

gyamxxx commented Dec 5, 2016

I did it!
Thank you very much.

@gyamxxx gyamxxx closed this as completed Dec 5, 2016
@jingyuLin1999
Copy link

jingyuLin1999 commented Nov 24, 2021

"vue-codemirror": "^4.0.6",
How to get editor? I wan to get editor like this

var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
        lineNumbers: true,
        mode: "htmlmixed",
        extraKeys:{"Shift-Tab":autoFormatSelection}
      });

however I get 'undefined' by this.$refs.codemirror.editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants