-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Support for Rendering Excalidraw Diagrams #35532
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
base: main
Are you sure you want to change the base?
Conversation
While issue go-gitea#28903 explored integrating Draw.io, @lunny suggested in a go-gitea#28903 (comment) that Excalidraw would be a better alternative. The primary reasons are its MIT license and its ease of integration into Gitea. The recommended approach is to implement this as a plugin after the work in go-gitea#34917 is completed. Key Changes: * Markdown Rendering: - The Markdown renderer now recognizes excalidraw as a language identifier in code blocks, similar to mermaid. * Configuration: - A new setting `EXCALIDRAW_MAX_SOURCE_CHARACTERS` has been added to control the maximum size of Excalidraw source data. * Dependencies: - The `@excalidraw/utils` package has been added to package.json to handle Excalidraw data processing. * Frontend Features: - A new file view plugin (`excalidraw-view.ts`) is added to render .excalidraw files directly. - The markup content handling (`content.ts`) now initializes Excalidraw rendering for embedded diagrams. - A new module (`excalidraw.ts`) is created to handle the logic of rendering Excalidraw JSON from code blocks into SVG images, including dark mode support. - The main file view feature (`file-view.ts`) now includes the Excalidraw viewer plugin.
Could you provide some screenshots? |
I've reconsidered embedding Excalidraw's JSON directly into Markdown, and I don't believe it's the best approach. Although Excalidraw is great for creating diagrams, its underlying JSON format lacks human readability, which would make the Markdown source difficult to read and maintain. A better solution would be to support rendering .excalidraw files using the standard Markdown image syntax, like this:  This would render the file as an inline vector image, much like how SVGs are handled, keeping the Markdown source clean. |
Can excalidraw render |
Unfortunately, they are not compatible. Excalidraw uses a JSON format, while .drawio uses XML. |
Hmm, that's really a shame, because I think drawio has a huge market share. I wonder if there is maybe a converter that could be used to convert drawio to excalidraw. Excalidraw seems reasonably popular that something like this may exist. I guess it may still be good to support excalidraw standalone, given its popularity. |
drawio files can be rendered by "https://www.draw.io/js/viewer.min.js" Since there are more and more renders, I would reiterate my question: #34794 (comment) Should we keep adding more and more render libraries into the Gitea binary (each one is mega bytes), or use JS CDN as much as possible? |
Is there a example that showcases its use somewhere? |
"@citation-js/plugin-bibtex": "0.7.18", | ||
"@citation-js/plugin-csl": "0.7.18", | ||
"@citation-js/plugin-software-formats": "0.6.1", | ||
"@excalidraw/utils": "0.1.3-test32", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package does not look very popular at all (only a few hundret weekly downloads). Are we sure this is the right interface to convert source to svg? I have a feeling this is not meant for public consumption.
Also it looks like this package brings some PNG-related modules into the dependency tree which would be unused in our case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is from the official Excalidraw mono repo: https://github.com/excalidraw/excalidraw/tree/master/packages/utils
They should have some documents, I haven't taken time to look into it. AI says so: (And some links: jgraph/drawio#3430 ) |
Looks interesting, I guess we could try it, assuming that JS is available on NPM somewhere. |
So, add all render libraries into Gitea binary, or make users download them from JS CDN? |
Excalidraw offers a VS Code plugin[1] that enables you to edit Also excalidraw is very popular among obsidian users with the plugin[2] . |
A full featured plugin system would be a much better approach. |
Imho it's preferable that all assets are served from gitea itself because some users may be in an environment with blocked/restricted/unavailable Internet access. |
While issue #28903 explored integrating Draw.io, @lunny suggested in a #28903 (comment) that Excalidraw would be a better alternative. The primary reasons are its MIT license and its ease of integration into Gitea.
The recommended approach is to implement this as a plugin after the work in #34917 is completed.
Key Changes:
EXCALIDRAW_MAX_SOURCE_CHARACTERS
has been added to control the maximum size of Excalidraw source data.@excalidraw/utils
package has been added to package.json to handle Excalidraw data processing.excalidraw-viewer.ts
) is added to render .excalidraw files directly.content.ts
) now initializes Excalidraw rendering for embedded diagrams.excalidraw.ts
) is created to handle the logic of rendering Excalidraw JSON from code blocks into SVG images, including dark mode support.file-view.ts
) now includes the Excalidraw viewer plugin.