diff --git a/client/codemirror/lua_widget.ts b/client/codemirror/lua_widget.ts index 84629054..41927fbc 100644 --- a/client/codemirror/lua_widget.ts +++ b/client/codemirror/lua_widget.ts @@ -248,10 +248,18 @@ export class LuaWidget extends WidgetType { if (wc.html) { if (typeof wc.html === "string") { html = parseHtmlString(wc.html); - if (!copyContent) copyContent = wc.html; } else { html = wc.html; - if (!copyContent) copyContent = wc.html.outerHTML; + } + + // When a widget provides both `html` and `markdown`, the `html` is the + // display and the `markdown` is what the Copy button should copy (e.g. a + // diagram renders to an SVG via `html` while exposing its source block via + // `markdown`). Only fall back to the html itself when no markdown is given. + if (!copyContent) { + copyContent = typeof wc.html === "string" + ? (wc.markdown ?? wc.html) + : (wc.markdown ?? wc.html.outerHTML); } block = wc.display === "block"; @@ -261,7 +269,9 @@ export class LuaWidget extends WidgetType { div.className += " sb-lua-directive-inline"; } } - if (wc.markdown) { + // `markdown` is only used for display when there is no `html` to show; when + // both are present `markdown` is reserved for the Copy button (handled above). + if (!html && wc.markdown) { const syntaxExtensions = this.syntaxExtensions; let mdTree = parse( buildExtendedMarkdownLanguage(syntaxExtensions), diff --git a/website/Library/silverbullet-mermaid.md b/website/Library/silverbullet-mermaid.md deleted file mode 100644 index e89c39c9..00000000 --- a/website/Library/silverbullet-mermaid.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -name: "Library/silverbullet-mermaid" -tags: meta/library -files: -- mermaid.plug.js -share.uri: "https://github.com/silverbulletmd/silverbullet-mermaid/blob/main/PLUG.md" -share.hash: 357c5dc6 -share.mode: pull ---- -This plug adds basic [Mermaid](https://mermaid.js.org/) support to Silver Bullet. - -For example: - -```mermaid -flowchart LR - -A[Hard] -->|Text| B(Round) -B --> C{Decision} -C -->|One| D[Result 1] -C -->|Two| E[Result 2] -``` - -**Note:** The Mermaid library itself is not bundled with this plug, it pulls the JavaScript from the JSDelivr CDN. This means _this plug will not work without an Internet connection_. The reason for this is primarily plug size (bundling the library would amount to 1.1MB). This way Mermaid is only loaded on pages with actual Mermaid diagrams rather than on every SB load. - -## Configuration -You can use the `mermaid` config to tweak a few things: - - ```space-lua - config.set("mermaid", { - version = "11.4.0", - integrity = "new integrity hash", - -- or disable integrity checking - integrity_disabled = true - -- optional: register icon packs - icon_packs = { - { - name = "logos", - url = "https://unpkg.com/@iconify-json/logos@1/icons.json", - }, - }, - }) - ``` -