googlearchive / code-mirror

BSD 3-Clause "New" or "Revised" License
11 stars 18 forks source link

Make value two-way synced to underlying CodeMirror editor. #2

Closed mbleigh closed 10 years ago

mbleigh commented 10 years ago

While this element is a nice demo, it had a fatal flaw: the value wasn't actually syncing back from the mirror when it was edited! Added a listener on the element so that value gets updated both TO the mirror and FROM the mirror.

sjmiles commented 10 years ago

This is not necessarily a slam-dunk, because the text in the editor is potentially long, and updating a bindable text value on every change may just be a performance footgun.

sorvell commented 10 years ago

To address @sjmiles concern, it may be better to have a "live value" concept distinct from the value property. This "live value" could be done as you have although it looks like it's better to hook CodeMirror's 'changes' event than the 'change' event. The "live value" could be updated when the editor loses focus.

addyosmani commented 10 years ago

@mbleigh would you be interested in refactoring your initial PR to address the live value suggestion from @sorvell above? (this PR currently requires rebasing anyway).

mbleigh commented 10 years ago

Closing this, but will be readdressing momentarily in a different PR.