How to use the Style Editor
I couldn't find documentation on how to us the Style Editor. So, I tried to figure it out myself but without success.
I took it that its purpose is to "edit" existing of styles. But for some reason it seems not to allow me to edit any existing styles. Whenever I make changes to existing styles and close the style editor, my changes just seem to get lost. Without any warning by the way!
What I can do is make changes and then use "Save As..." to create a new style. However, once it is saved, I cannot keep editing that new style. If I close the style editor after further changes, all my changes are lost. Again without any warning!
There seems to be no option to "Save" or "Open" any styles into the editor. So, the only way to in some way "edit" a style with the Style Editor seems to be this:
1. Choose a style from the list of installed styles
2. Make changes in the editor
3. Use "Save As..." to save as another file
4. Install that style into Zotero's style library
Next you have to repeat steps 2-4 for any further "edits".
Probably I have not understood how the Style Editor works. Unfortunately, it is not so intuitive to me.
I could of course edit the styles in some text editor app. But I take it that the nice thing about the editor is that it provides a preview of the style. Unfortunately, so far I could not use it as much more than a style previewer due to the restriction that I encountered.
I would be happy if someone could give me some hints what I am doing wrong. Thanks!
Edit: Using "Save As..." the ending ".csl" is appended automatically only if the file name is not changed (at least on Windows). I take it that is a bug.
Edit 2: I found this documentation now: https://www.zotero.org/support/dev/citation_styles/reference_test_pane. It explicitly states
"Important When you close the test pane, or select a style from the pull-down menu, any edits will be lost. If you are making extensive changes to a CSL style, save your edited code often."
If only people would read documentation (and to the very end). Anyway, I guess it would at least be feasible to have a warning show up about losing changes if they were not saved. Seems common practice.
I took it that its purpose is to "edit" existing of styles. But for some reason it seems not to allow me to edit any existing styles. Whenever I make changes to existing styles and close the style editor, my changes just seem to get lost. Without any warning by the way!
What I can do is make changes and then use "Save As..." to create a new style. However, once it is saved, I cannot keep editing that new style. If I close the style editor after further changes, all my changes are lost. Again without any warning!
There seems to be no option to "Save" or "Open" any styles into the editor. So, the only way to in some way "edit" a style with the Style Editor seems to be this:
1. Choose a style from the list of installed styles
2. Make changes in the editor
3. Use "Save As..." to save as another file
4. Install that style into Zotero's style library
Next you have to repeat steps 2-4 for any further "edits".
Probably I have not understood how the Style Editor works. Unfortunately, it is not so intuitive to me.
I could of course edit the styles in some text editor app. But I take it that the nice thing about the editor is that it provides a preview of the style. Unfortunately, so far I could not use it as much more than a style previewer due to the restriction that I encountered.
I would be happy if someone could give me some hints what I am doing wrong. Thanks!
Edit: Using "Save As..." the ending ".csl" is appended automatically only if the file name is not changed (at least on Windows). I take it that is a bug.
Edit 2: I found this documentation now: https://www.zotero.org/support/dev/citation_styles/reference_test_pane. It explicitly states
"Important When you close the test pane, or select a style from the pull-down menu, any edits will be lost. If you are making extensive changes to a CSL style, save your edited code often."
If only people would read documentation (and to the very end). Anyway, I guess it would at least be feasible to have a warning show up about losing changes if they were not saved. Seems common practice.
Note the part about changing the id. It can't really just let you overwrite installed styles because any built-in styles would be overwritten the time they were updated.
We have an open ticket to add an Install button, though, and we should be able to offer repeated installation of non-built-in styles, as well as a warning to change the id if trying to save over a built-in style.
We'll also look into warning about losing unsaved changes. We should be able to do that when changing the style, but we may not be able to reliably prevent people from closing the window on all platforms.
And thanks for the helpful link. Maybe put it somewhere in the Style Editor dialog.
About the changing id and overwriting. That makes sense. But notice that as it is now, one seemingly straight forward way to change a style is to
1. Edit it with the style editor (but be ignorant about the id part)
2. Save it
3. Install it
Now you have overwritten the installed style. You end up in exactly the same situation that you wanted to avoid. Why not ask the user when trying to overwrite a style and inform about the consequences? Or is that also not possible on all platforms?
What a surprise that such a basic feature as capturing the close of a window/dialog isn't possible on Linux, macOS and Windows. Or did you have some more niche desktop OSs in mind?
But you might have tried it before and I have little knowledge about desktop javascript apps, I take it that is what you are dealing with. Sounds as if this makes javascript on desktop pretty much a non-starter for more complex cross-platform applications.
If it really does not work, an alternative would be to save a copy of the current buffer into a temporary file and show it again when the editor opens. Not great but better than lost work, I take it.
(In any case, "a non-starter for more complex cross-platform applications" is obviously an absurd thing to say. Zotero is a massively complex cross-platform application. This is one esoteric windowing feature.)