Added to docs: Setting the editor content and refreshing the editor
- If we need to set the content programmatically instead of picking up from text area, we can use
editor.codemirror.setValue(). This is currently not mentioned in the documentation - If there are changes in sizes or hiding/unhiding of editor (eg. using the editor in a modal dialog), the editor content does not show correctly. We need to call
editor.codemirror.refresh()programmatically after the visibility/sizing is complete to make things look correctly. This is also documented in the CodeMirror API documentation - If you are self-hosting the Editor vs. pulling it from the CDN, you additionally need the icon font file if you are using the toolbar. This is not clear in the documentation and added the link.
@srinathh I've added a shortcut for setting and getting values: https://github.com/lepture/editor/blob/master/src/editor.js#L216
@lepture Ok thanks - will use them! However, i still think these shortcuts / commonly used features etc. should be noted in the Readme documentation... else folks have to read through the javascript source to figure out how to use the Editor which is a bit painful for people who don't primarily code in javascript (eg. myself) and just want to use it as a drop-in component with a bit of javascript glue.
The other point on Refresh is something which i encountered yesterday trying to use Editor in a project of mine. I had the editor in a Bootstrap Modal and when the there is any visibility change, unless I do refresh, the contents displayed in the editor is all wrong - so it may be worth calling out.
On Mon Dec 29 2014 at 2:32:39 PM Hsiaoming Yang [email protected] wrote:
@srinathh https://github.com/srinathh I've added a shortcut for setting and getting values: https://github.com/lepture/editor/blob/master/src/editor.js#L216
— Reply to this email directly or view it on GitHub https://github.com/lepture/editor/pull/69#issuecomment-68241591.
@srinathh Yes, you are absolutely right. I'll sort it out soon.
This already helped! Thanks.
Thanks!
On Mon, Dec 29, 2014, 2:32 PM Hsiaoming Yang [email protected] wrote:
@srinathh https://github.com/srinathh I've added a shortcut for setting and getting values: https://github.com/lepture/editor/blob/master/src/editor.js#L216
— Reply to this email directly or view it on GitHub https://github.com/lepture/editor/pull/69#issuecomment-68241591.