hediet / vscode-drawio

This unofficial extension integrates Draw.io (also known as diagrams.net) into VS Code.
https://marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio
GNU General Public License v3.0
9.02k stars 406 forks source link

User-defined graphics library #182

Open Nitcloud opened 3 years ago

Nitcloud commented 3 years ago

This plug-in is really great, will you add the function of user-defined graphics library in the future? I think it is of great help to the graphical and process-based design of FPGA, looking forward to your reply.

hediet commented 3 years ago

It already is supported! See the settings, you can set a path to custom libraries.

Nitcloud commented 3 years ago

I've found this setting, but I haven't found a specific way to make a custom library, such as how to define graphics properties.

hediet commented 3 years ago

Can you elaborate what you mean with "custom library"? Can you describe exactly what is missing and you would like to see? Do you miss the option create custom libraries?

I've never worked with custom libraries in Draw.io.

Nitcloud commented 3 years ago

image In the figure , 1 point to how the graph is called, 2 to how the library is added, and 3 to the properties of the graph being called. Now, I want to customize what the graph looks like and what the properties are.

hediet commented 3 years ago

How do you add it in "More Shapes..."? Is Electrical / Logic Gates a predefined library or did you import it from some file? Am I right that you want to customize this library?

Is this feature supported by Draw.io (e.g. Draw.io Desktop)? If not, it will be hard to implement this here.

Nitcloud commented 3 years ago

image I've designed a processing module, and now I want to put it in a custom library for the next call.At the same time, this module needs to configure parameters. I want to set the parameters of this module in the property on the right, so that the code can be generated automatically according to the wiring of the graphic property after the wiring is completed.

Nitcloud commented 3 years ago

How do you add it in "More Shapes..."? Is Electrical / Logic Gates a predefined library or did you import it from some file? Am I right that you want to customize this library?

Is this feature supported by Draw.io (e.g. Draw.io Desktop)? If not, it will be hard to implement this here.

Yes, I would like to customize a user library similar to Electrical/Logic Gates. I do not known whether this feature is now supported by the plug-in

nopeslide commented 3 years ago

How do you add it in "More Shapes..."? Is Electrical / Logic Gates a predefined library or did you import it from some file?

It's a predefined one.

Yes, I would like to customize a user library similar to Electrical/Logic Gates. I do not known whether this feature is now supported by the plug-in

  1. You can import any exported library to the scratchpad if you click on the pencil icon in the scratchpad: image

  2. Or add it via File/Import

  3. Otherwise it should be possible to always load an exported library afaik via settings:

    "hediet.vscode-drawio.customLibraries": [
    {"file": "/path/to/lib.xml","libName": "test"}
    ],

    but in my case it wasn't added to the libraries on the left side or was reachable in the + More Shapes dialog. @hediet maybe a bug?

I've designed a processing module, and now I want to put it in a custom library for the next call.At the same time, this module needs to configure parameters. I want to set the parameters of this module in the property on the right, so that the code can be generated automatically according to the wiring of the graphic property after the wiring is completed.

You could use properties as placeholders (not the custom ones on the right, but the ones reachable via Strg+M or Right click/Edit Data). The custom properties on the right are hardcoded into the shape types and can not be modified afaik.

Except if you code your own shapes: I built an RTL extension for building such block diagrams.

hediet commented 3 years ago

How would you create a custom library?

nopeslide commented 3 years ago

How would you create a custom library?

use-custom-libraries work-with-custom-shape-libraries

Nitcloud commented 3 years ago

How do you add it in "More Shapes..."? Is Electrical / Logic Gates a predefined library or did you import it from some file?

It's a predefined one.

Yes, I would like to customize a user library similar to Electrical/Logic Gates. I do not known whether this feature is now supported by the plug-in

  1. You can import any exported library to the scratchpad if you click on the pencil icon in the scratchpad: image
  2. Or add it via File/Import
  3. Otherwise it should be possible to always load an exported library afaik via settings:
"hediet.vscode-drawio.customLibraries": [
    {"file": "/path/to/lib.xml","libName": "test"}
],

but in my case it wasn't added to the libraries on the left side or was reachable in the + More Shapes dialog. @hediet maybe a bug?

I've designed a processing module, and now I want to put it in a custom library for the next call.At the same time, this module needs to configure parameters. I want to set the parameters of this module in the property on the right, so that the code can be generated automatically according to the wiring of the graphic property after the wiring is completed.

You could use properties as placeholders (not the custom ones on the right, but the ones reachable via Strg+M or Right click/Edit Data). The custom properties on the right are hardcoded into the shape types and can not be modified afaik.

Except if you code your own shapes: I built an RTL extension for building such block diagrams.

Thank you for your reply. I will try it

Nitcloud commented 3 years ago

How would you create a custom library?

use-custom-libraries work-with-custom-shape-libraries

Whether the exported XML file can be used in VSCode?

hediet commented 3 years ago

Whether the exported XML file can be used in VSCode?

You can most probably use the exported xml file by referencing it in the "custom libraries" setting!

jonathanwiesel commented 1 year ago

I created a custom library using the standard draw.io webapp then exported it but when importing it using the settings it renders an empty section:

Screenshot 2023-06-05 at 14 36 31
"hediet.vscode-drawio.customLibraries": [
    {"file": "/Users/my_user/testlib.xml", "libName": "test", "entryId": "test"}
]

Am I missing something?

miz-online commented 9 months ago

I was confused as well. The issue seems to be, that the extension only accepts compressed XML content, but draw.io only saves libraries in clear text (not sure why, at one point I read that they switched compressed xml off because of the many problems it created).

You can convert the library xml:

now the library should load.

Of course it would be way easier, if the extension would allow compressed or uncomrpressed xml content in libraries. Would this be possible?