openscd / open-scd-core

Apache License 2.0
5 stars 8 forks source link

OpenEvent should be more robust #129

Open pascalwilbrink opened 1 year ago

pascalwilbrink commented 1 year ago

As a Engineer I want to be able to open non SCL files while keeping the current SCL file open

Background If we want to make use of helper documents (Like XSD, NSD, NSDOC files), we need to make the OpenEvent more robust. Currently, if the OpenEvent is emitted and is picked up by OpenSCD Core, The "docName" is set directly as the docName. This means that Docs that are opened via the OpenEvent, will always be the current document that is being edited. This is a side effect that causes problems.

For helper Files, this should not be the case.

We can have multiple solutions for this

ca-d commented 11 months ago

Another possibility would be to have an array of editable file types as an attribute on the editor itself and let the distribution choose which opened files should be editable, then only switch to the opened file if it has an extension listed in the array. I have no strong preference for any of these solutions.

In the meantime, a hacky work-around solution for loading support documents would consist in checking if a document with that file name has already been loaded, and if not, add the document directly to the docs object.

Either way, well-known file names seem vital to dealing with supporting documents. Coming up with suitable conventions, especially as regards versioned files like schema and nsd files, would be an important task to solve.