-
Notifications
You must be signed in to change notification settings - Fork 103
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
[FR]: Publish canvas files #578
Comments
Definitely interested in this feature! |
@saviorand thanks for adding the encouragement 🙏 |
@mohamedsalem401 can you look at this? |
@rufuspollock The canvas files in Obsidian have their unique structure, which requires studying for a while. (It consists of connected nodes, which can be of 3 types, one of which can be a whole embedded
This needs to be converted to an SVG, which requires researching SVG syntax. (The code in the article https://janikvonrotz.ch/2023/06/07/convert-obsidian-canvas-to-svg/ has some deficits, so I have to edit it.) Also, adding the |
@mohamedsalem401 ok, good progress. It sounds like we want to update the description of the issue with the tasks as you now understand it. It sounds like it breaks into two parts:
|
It seems like a backbreaking task 😬 In the current apporach, i.e. converting Obsidian canvases to SVGs, how are we going to:
@mohamedsalem401 before continuing with the code, can you please write out how you would solve the above issues (all but the styling)? Note 1: |
What features does Obsidian Canvas have? (see https://obsidian.md/canvas)Card types (color)
Old solutionIn the first approach, we used an SVG file, which had the following issues:
New approachA better approach would be to use HTML canvas elements. We can use a library called Konva.js, which supports drawing rectangles (will be the card skeleton) and lines (will be the edges). To solve the issue with embedding other things (PDF, other notes, webpages, nested canvas), we can leave an empty space in the canvas, which will be filled by an iframe element by moving it using CSS Note
{
"nodes":[
{"id":"b3eedc7de503c3c7","type":"text","text":"","x":-677,"y":-905,"width":250,"height":60},
{"id":"7af03c59336d7e50","type":"file","file":"Asset 21332.png","x":-650,"y":-174,"width":400,"height":378},
{"id":"407e8252f3b3037d","type":"text","text":"","x":-561,"y":-597,"width":250,"height":60},
{"id":"1a414e25a4598008","type":"file","file":"hello world.md","x":-160,"y":80,"width":400,"height":400},
{"id":"0eaf1351bf30e4d9","type":"text","text":"Text Box ","x":-85,"y":-65,"width":250,"height":80,"color":"5"},
{"id":"21212ab79f0be1a6","type":"text","text":"","x":-120,"y":-280,"width":250,"height":106},
{"id":"c56951957feba5c0","type":"text","text":"Hello there welcome to my Blog ","x":-575,"y":-380,"width":250,"height":100}
],
"edges":[
{"id":"c9a78200b99497ea","fromNode":"21212ab79f0be1a6","fromSide":"left","toNode":"c56951957feba5c0","toSide":"right","fromEnd":"arrow"},
{"id":"b28a187d6fae9315","fromNode":"21212ab79f0be1a6","fromSide":"bottom","toNode":"0eaf1351bf30e4d9","toSide":"top"},
{"id":"3dfab590c6fb36e6","fromNode":"c56951957feba5c0","fromSide":"bottom","toNode":"7af03c59336d7e50","toSide":"top"},
{"id":"b67215fa4fb833eb","fromNode":"0eaf1351bf30e4d9","fromSide":"bottom","toNode":"1a414e25a4598008","toSide":"top"}
]
} |
@mohamedsalem401 I thought it through and I think the best (if not the only) solution that would allow us to support all or at least most of Obsidian canvas features is to create a react Here is the outline of the approach for rendering canvas pages (not canvas embeds): In
For zoom and pinch behavior you could probably use this package https://github.com/BetterTyped/react-zoom-pan-pinch?tab=readme-ov-file As for negative coordinate values, you're correct, we need to normalize them, and the easiest way to do this is probably the way you do it, i.e. add I wanted to test this approach and here is the quick and dirty implementation: https://github.com/datopian/flowershow/tree/canvas-2 Here is how it renders atm (without any styles at all): As you can see, it does render both cards and note embeds with all the syntax elements supported, and not just rendered as plain text. Note: If you want to try it out, remember to manually add the |
This is a similar approach to mine but the main difference is that I am using a |
@mohamedsalem401 @olayway this originally started as a quick investigation - to see if the code i had linked worked for a "quick and dirty" solution. If there is a decent 80/20 solution we can quickly ship then let's do it ... But if is a big hassle i would strongly recommend leaving this and focusing on other better value/cost things. |
Maybe it is (although I don't think they have much in common), but I have also managed to get embeds and cards with Obsidian syntax elements to render correctly...
It doesn't sound like my approach to me 🤔 I'm not using canvas at all, no additional library is needed, and I'm not using iframes for embeds. |
@rufuspollock as you can see in my previous comment, we already have a working version, so let's maybe not ditch it at this point. We'll put a few more hours into it and ship it even if not perfect, and we'll iterate in the future. |
Very impressive, how fast y'all did it! 👏👏 |
Request - see #538 (comment) @yuri-karpovich
Implementation
Noticed in this thread about svg export for canvas that someone has written a converter https://forum.obsidian.md/t/add-svg-export-feature-to-canvas/54379/7
He has written it in JS and documented it here https://janikvonrotz.ch/2023/06/07/convert-obsidian-canvas-to-svg/
This could definitely be run at build time ...
Acceptance
Notes
What features does Obsidian Canvas have? (see https://obsidian.md/canvas)
Card types (color)
The text was updated successfully, but these errors were encountered: