-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add shapes to the sidebar? #707
Comments
This is actually a really nice request. I think it would be useful for users to let them add custom shapes to the menu. There is already a way to design new shapes and export them with Schemio, but I implemented that just for myself, so that I can easily create new shapes for Schemio. I will add it to my backlog but it might be a bit more complicated, since I need to make it work for the cloud version of Schemio (https://schem.io) where any diagram can be made public. |
But isn't the sidebar loaded from a JSON already
Where to find this? Isn't the sidebar loaded from a JSON file? If there already is a way to design new shapes, how can I embed them into the sidebar? If the sidebar really is a JSON, then adding shapes will not require a custom build, right? |
And yes and no. The majority of the shapes are hardcoded in Shape.js file and are loaded in the The Shape.js file loads all hardcoded Schemio shape like However there is a concept of "external shapes". Whenever Schemio loads a diagram document, it traverses through all of its items and loads dynamically any external shape groups that are referenced in the items. These shapes are managed in the https://github.com/ishubin/schemio/blob/master/assets/shapes folder and are registered in the https://github.com/ishubin/schemio/blob/master/assets/shapes/shapes.json index file. So, for example, the Electronic Circuit shape group is stored in https://github.com/ishubin/schemio/blob/master/assets/shapes/electronic-circuit.json and it is not hard-coded in the js code and is not loaded automatically until it is used.
Here is an example of how to use shape designer https://www.youtube.com/watch?v=-NpLN3m6jmY. This is a very quick demo and it does not go in details of how to design custom shape outlines, pins and text slots. Also keep in mind that you can't use any existing shapes (rect, ellipse) inside of it. The only one that is allowed is |
Thank you for the detailed information! I like the idea of having an "external" shape collection like that for electronic cirquits. The idea of loading it on-demand fits really well into my use case. I would probably need multiple sets of such shapes. If I create a regular button, change it's colors, give it a default title, etc. and save it. Can I than copy the saved JSON and place it in a file like |
Unfortunately that is not going to work. The item's JSON structure in the document is different from the one that is used by the shape itself. When you are using a particular shape to create an item, it uses JSON to store the reference to the shape's id and the values of the public properties of that shape. While the structure used in So, for you to use your own shapes, you would first have to design them in Schemio and export into shape group JSON file. Then you would have to store that exported JSON in assets/shapes/ folder and update assets/shapes/shapes.json file, by adding a reference to your shape group. |
Is there a way to add shapes to the left-side menu? I see, there is a way to reuse drawings via "external templates" button. But can I modify the sidebar?
As far as I understand, the sidebar is loaded from a JSON file. Is there a documentation of its structure?
The text was updated successfully, but these errors were encountered: