The codemirror editor is an “edit engine” that is selected by the edit-factory and initialized with the edit-text widget.
Additional parameters can only be set, when the editor instance is activated, with code-mirror config tiddlers.
Showing line numbers is a configuration of the codemirror library when the cm-object is instantiated. So it’s not possible to update it dynamically at the moment.
hmmm, I think, that wont probably happen any time soon. The edit-widget is responsible to instantiate the editors depending on the tiddler type-field.
As you can see with the parameters it does not have any idea about cm-options at the moment. .. I does pass on every additional parameter to the “child editors”
But atm the codemirror-editor has no code to evaluate these additional parameters.
I think it would be straight forward to create a new parameter eg: configChanged that would force the the edit-widget to initialize itself again.
I did have a short look at the code and it seems to be a bit tricky There are already some functions that do similar things. …
So care has to be taken since we have 3 text editors at the moment. “simple”, “framed” and “codemirror”. All of them have to implement the change So it triples the work that has to be done.
Perhaps a work around would be to create a button to change the setting, save and reload the wiki. Perhaps with a confirmation before reload using ActionConfirmWidget you may want to set default tiddlers to include retain story tiddlers [list[$:/StoryList]] so the currently open tiddlers appear on reload.
In the past I added an action navigate action to a button, would this do this. If one uses the extended edit buttons plugin to save without closing do something similar?
My intention was, to have a checkbox to enable line numbers.
Initial, I had the issue to see the line numbers:
I found the reason: ( Problem with LineNumbers using CodeMirror )
Changing in $:/ControlPanel -> Advanced -> Editor Type -> text/vnd.tiddlywiki from comptext to codemirror will show the line numbers.
I had no idea, how to change 2 values with 1 checkbox:
Enable line numbers: $:/config/codemirror/lineNumbers from false to true
$:/config/EditorTypeMappings/text/vnd.tiddlywiki from comptext to codemirror
So I decided to remove the plugin " $:/plugins/snowgoon88/edit-comptext" in my wiki.
Now I was able with the checkbox to activate / deactivate the line numbers with all the issues mentioned in this topic - except of the correct CSS for the position of the checkbox.
The following advice is generic and independent from the code mirror issue, but could help you solve it.
Checkboxes by their nature are typically two state toggles, you can now use the additional actions parameter to trigger additional actions on click, checked and unchecked.
However you could also create two buttons, only one showing for each state or with a little coding develop a single button using the toggle or cycle operators.
If you have a working button/pair as mentioned above, tagging it/them with the tag $:/tags/EditToolbar will put it at the top right alongside done and close while in edit mode.