Closed charford closed 8 years ago
Regarding your second question: I'd love to know if there is a better way, but I'm able to grab the codemirror object by creating a file-scoped variable in my client-side js and assigning the codemirror object to it with the onRender hook.
client.html
{{> sharejsCM docid=_id id="editor" onRender=renderEditor }}
client.js
var myEditor;
Template.body.helpers({
renderEditor: function () {
return function(editor) {
myEditor = editor;
}
}
});
I'm able to use myEditor
in my event functions after this.
I'm in the same boat, I want to render the contents in a {{markdown}} template but cant figure oit how to get the current content.
I'm pretty sure you guys should be able to get the contents from the Ace API or the CodeMirror API depending on what you are using.
For Ace
myEditor = null
Template.myTemplate.events
'click .do-something': () ->
console.log(myEditor.getValue())
Template.myTemplate.config = () ->
(editor) ->
editor.setTheme('ace/theme/monokai')
editor.getSession().setMode('ace/mode/javascript')
myEditor = editor
Seems like a really basic question, but I can't figure out how to programmatically get the value of the code mirror editor. Is this possible?
I'm also looking to attach a listening event to the CodeMirror editor, so whenever changes are made, I would get the content of the editor, and render it in a separate div. But to do that, I need to some how have access to the CodeMirror object I think.