Repository navigation
Conversation
com.glyph.excalidraw views and edits Excalidraw drawings: .excalidraw files, excalidraw code blocks, and Obsidian Excalidraw notes. Drawings render offline in the app theme, zoom in the lightbox, and print and export light. Edit opens the Excalidraw editor over the app and saves the drawing back in the format it came from through updateCode (plugin API 0.28.0); older apps still view drawings. The API reference documents updateCode, and the bundling guide covers loading a large library as an asset and bundling React for a root of the plugin's own. Closes hamidfzm/glyph#996
4 of 14 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the official Excalidraw plugin (
com.glyph.excalidraw), which views and edits Excalidraw drawings, and documents the plugin API 0.28.0 addition it saves through (updateCode, hamidfzm/glyph#1000).Closes hamidfzm/glyph#996
Changes
plugins/com.glyph.excalidraw/:.excalidrawfiles open as the drawing (a plugin file type),```excalidrawblocks holding scene JSON render as the drawing, and an Obsidian Excalidraw note (excalidraw-pluginin the frontmatter) shows its drawing in place of the boilerplate around it, read from itscompressed-jsonorjsonblock by a remark plugin. Drawings follow the light or dark theme, open in the lightbox, andrenderStaticputs a light render into print, PDF, and website export. An empty block or file shows an "Empty drawing" placeholder, and invalid data an error label with the source.updateCode) opens the Excalidraw editor in actx.ui.openOverlayoverlay. Done saves while the editor is still open; Escape, the close button, and the window closing save from the cleanup. Saves keep the source format: pretty scene JSON, or LZ-stringcompressed-jsonchunked exactly as Obsidian writes it, and an Obsidian note changes only inside its drawing block. A refused save (the note changed or closed) keeps the editor open and turns Done into Copy and close; a refusal on the other ways out tries the clipboard and says what happened. A close without changes writes nothing.assets/excalidraw.js(4.0 MB, loaded on the first drawing through a blob URL import, like Slides loads reveal.js), built fromsrc/bybuild.mjswith esbuild. Excalidraw's fonts are inlined asdata:URLs, and the 13 MB CJK font gets Excalidraw's ownlocal:marker, so nothing falls back to its CDN; a bundle-localfetchdecodesdata:URLs (the app'sconnect-srchas none) and refuses everything else. Scene files that are notdata:image/are dropped, links in the editor never navigate the window, and the rendered SVG is sanitized (anchors andforeignObjectremoved, images inlined in place of the<use>sanitizers drop). Mermaid-to-drawing conversion is stubbed out (about 3 MB; Glyph renders Mermaid itself), and only Glyph's five languages are bundled.LICENSEis written bybuild.mjsfrom the packages esbuild put in the bundle, plus the fonts' notices (src/licenses/), so it cannot fall behind a dependency update. The build is reproducible: two runs give byte-identicalassets/excalidraw.jsandLICENSE.plugin.jsoncarries the placeholdersha256; the release job rewritespackageUrland the digest.index.json,index/, anddocs/plugin-catalog.mdregenerated withscripts/build-index.mjs.docs/api-reference.md:updateCode(API 0.28), and plugin file types open in the viewer and can be saved through it.docs/bundling.md: loading a large library as an asset, and bundling React only for a root of the plugin's own.Testing
node --testin the plugin folder: 15 passing (Obsidian detection and the remark transform, the compressed round trip and chunking, the close-path save and its refusals, registrations and locale key parity).node scripts/check-plugins.mjs, the schema validation forplugin.jsonandindex.json, and the repo's script tests pass. A freshscripts/build-index.mjsleaves the committed index unchanged.main.jsthe way the app does, with a fake plugin context: drawings, dark and light SVG, compressed drawings, embedded images, the empty and invalid states, andrenderStatic; the Edit button present only withupdateCode; Done after drawing a rectangle saves pretty JSON once, a close without changes saves nothing, Escape while typing a label keeps the text, and a refused save keeps the editor open with Copy and close; a scene file naming an outside URL is never requested. Zero requests left the page and no page errors were raised.updateCode.