Saving of a custom editor

I read ‘https://github.com/typefox/theia-workshop/tree/exercise-1, but the form editor doesn’t seem to be able to save it. I want to press’ Ctrl + s’ in formeditor to save the file. What should I do

[original thread by yangyangyihao]

Hi @xiaoxiaochengxuyuan I believe it was answered already that a widget should implement SaveableSource and Saveable to be saveable. You can reuse MonacoEditorModel which already implements Saveable. It is actually a good idea if you want to have dirty changes in the model to be synchronized with different widgets, i.e. code editor and your custom editor.

That’s how the code editor implements SaveableSource: https://github.com/eclipse-theia/theia/blob/master/packages/editor/src/browser/editor-widget.ts#L22

[yangyangyihao]

[yangyangyihao]

I have two problems. I am very upset. 1 when I execute yarn completely and correctly, I report an error: “”.When I delete such a library, it’s OK (not only this library sometimes because of other libraries)

[yangyangyihao]

2 I wanted to try to save it, but I didn’t know where I modified it, which led me to think that other unmodified extensions had changed (similar to onchange = > save). As long as there was a change, they would be saved automatically. I don’t know where I changed them, and there was no such extension It will be the same (I haven’t modified anything in other extensions, but it will be the same)

The first error you see occurs since the example is a bit dated and has some deprecated extensions such as https://github.com/TypeFox/theia-workshop/blob/a233275b288df2cda2eccd172d26a6b9cc155791/browser-app/package.json#L17. Removing such extensions from the package.json will get you passed the error. You can see the list of deprecated extensions here which should not be included: https://github.com/eclipse-theia/theia/pull/6933

[yangyangyihao]

I’ve seen ‘https://github.com/eclipse-theia/theia/blob/master/packages/editor/src/browser/editor-frontend-module.ts/
is not ‘bind (widgetfactory). Todynamicvalue (({container}) = > ({}));’
Instead, ‘bind (editorwidgetfactory). Toself(). Insingletonscope(); bind (widgetfactory). Toservice (editorwidgetfactory);’
Cause me ‘https://github.com/eclipse-theia/theia/blob/master/packages/editor/src/browser/editor-widget-factory.ts :47’ no excute.
I think that’s why the editor of my widget is undefined Now I want to use bind(). Todynamicvalue() to customize my interface. At the same time, I also want to get the parameter of editor in the same function as’ editor widget '. What should I do

[yangyangyihao]

Thank you very much for your reply. When I read the document you said and tried,
is not ‘bind (widgetfactory). Todynamicvalue (({container}) = > ({}));’
Instead, ‘bind (editorwidgetfactory). Toself(). Insingletonscope(); bind (widgetfactory). Toservice (editorwidgetfactory);’
Cause me ‘https://github.com/eclipse-theia/theia/blob/master/packages/editor/src/browser/editor-widget-factory.ts :47’ no excute.
I think that’s why the editor of my widget is undefined Now I want to use bind(). Todynamicvalue() to customize my interface. At the same time, I also want to get the parameter of editor in the same function as’ editor widget '. What should I do

[yangyangyihao]

[yangyangyihao]

f I use ‘bind (widgetfactory). Toservice (editorwidgetfactory)’;Will report an error ‘’

https://github.com/TypeFox/theia-workshop/issues/12 if someone wants to help. I do it once a year before EclipseCon, i.e. somewhen in September this year.