@bigmistqke/whiteboard 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +628 -2
  3. package/bin/whiteboard.ts +488 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/taggedTemplateLiteral.js +5 -0
  5. package/dist/bin/whiteboard.js +542 -0
  6. package/dist/client/runtime.js +544 -0
  7. package/dist/define.js +7 -0
  8. package/dist/plugins/callout/README.md +13 -0
  9. package/dist/plugins/callout/index.js +27 -0
  10. package/dist/plugins/callout/style.css +12 -0
  11. package/dist/plugins/chat/README.md +46 -0
  12. package/dist/plugins/chat/client.js +3 -0
  13. package/dist/plugins/chat/index.js +47 -0
  14. package/dist/plugins/chat/style.css +24 -0
  15. package/dist/plugins/claude-code/index.js +120 -0
  16. package/dist/plugins/code/README.md +42 -0
  17. package/dist/plugins/code/diff.js +65 -0
  18. package/dist/plugins/code/index.js +77 -0
  19. package/dist/plugins/code/style.css +29 -0
  20. package/dist/plugins/comments/client.js +10 -0
  21. package/dist/plugins/comments/index.js +54 -0
  22. package/dist/plugins/comments/style.css +40 -0
  23. package/dist/plugins/details/README.md +17 -0
  24. package/dist/plugins/details/index.js +17 -0
  25. package/dist/plugins/details/style.css +3 -0
  26. package/dist/plugins/forge/README.md +12 -0
  27. package/dist/plugins/forge/index.js +83 -0
  28. package/dist/plugins/form/README.md +111 -0
  29. package/dist/plugins/form/index.js +102 -0
  30. package/dist/plugins/form/style.css +41 -0
  31. package/dist/plugins/gallery/README.md +30 -0
  32. package/dist/plugins/gallery/client.js +1 -0
  33. package/dist/plugins/gallery/index.js +74 -0
  34. package/dist/plugins/gallery/style.css +27 -0
  35. package/dist/plugins/grid/README.md +33 -0
  36. package/dist/plugins/grid/index.js +33 -0
  37. package/dist/plugins/grid/style.css +25 -0
  38. package/dist/plugins/iframe/README.md +18 -0
  39. package/dist/plugins/iframe/client.js +1 -0
  40. package/dist/plugins/iframe/index.js +40 -0
  41. package/dist/plugins/iframe/style.css +29 -0
  42. package/dist/plugins/index.js +30 -0
  43. package/dist/plugins/mermaid/README.md +21 -0
  44. package/dist/plugins/mermaid/index.js +35 -0
  45. package/dist/plugins/mermaid/style.css +16 -0
  46. package/dist/plugins/quiet/README.md +26 -0
  47. package/dist/plugins/quiet/index.js +17 -0
  48. package/dist/plugins/terminal/client.js +41 -0
  49. package/dist/plugins/terminal/host.js +332 -0
  50. package/dist/plugins/terminal/index.js +171 -0
  51. package/dist/plugins/terminal/modes.js +32 -0
  52. package/dist/plugins/terminal/server.js +256 -0
  53. package/dist/plugins/terminal/sizes.js +57 -0
  54. package/dist/plugins/terminal/style.css +357 -0
  55. package/dist/solid/index.js +36 -0
  56. package/dist/src/auth.js +54 -0
  57. package/dist/src/client/page/base.css +295 -0
  58. package/dist/src/client/page/main.js +1228 -0
  59. package/dist/src/config.js +76 -0
  60. package/dist/src/events.js +183 -0
  61. package/dist/src/html.js +34 -0
  62. package/dist/src/icons.js +6 -0
  63. package/dist/src/load.js +77 -0
  64. package/dist/src/loader.js +126 -0
  65. package/dist/src/package.js +33 -0
  66. package/dist/src/pages/blocks.js +50 -0
  67. package/dist/src/pages/index.js +15 -0
  68. package/dist/src/pages/markdown.js +410 -0
  69. package/dist/src/pages/render.js +311 -0
  70. package/dist/src/plugins.js +238 -0
  71. package/dist/src/running.js +24 -0
  72. package/dist/src/serve.js +71 -0
  73. package/dist/src/server.js +725 -0
  74. package/dist/src/status.js +71 -0
  75. package/package.json +131 -4
  76. package/plugins/callout/README.md +13 -0
  77. package/plugins/callout/index.ts +25 -0
  78. package/plugins/callout/style.css +12 -0
  79. package/plugins/chat/README.md +46 -0
  80. package/plugins/chat/autosize.ts +101 -0
  81. package/plugins/chat/client.tsx +93 -0
  82. package/plugins/chat/index.ts +61 -0
  83. package/plugins/chat/style.css +24 -0
  84. package/plugins/claude-code/index.ts +136 -0
  85. package/plugins/code/README.md +42 -0
  86. package/plugins/code/diff.ts +64 -0
  87. package/plugins/code/index.ts +94 -0
  88. package/plugins/code/style.css +29 -0
  89. package/plugins/comments/client.ts +492 -0
  90. package/plugins/comments/index.ts +54 -0
  91. package/plugins/comments/style.css +40 -0
  92. package/plugins/details/README.md +17 -0
  93. package/plugins/details/index.ts +21 -0
  94. package/plugins/details/style.css +3 -0
  95. package/plugins/forge/README.md +12 -0
  96. package/plugins/forge/index.ts +71 -0
  97. package/plugins/form/README.md +111 -0
  98. package/plugins/form/index.ts +104 -0
  99. package/plugins/form/style.css +41 -0
  100. package/plugins/gallery/README.md +30 -0
  101. package/plugins/gallery/client.tsx +64 -0
  102. package/plugins/gallery/index.ts +67 -0
  103. package/plugins/gallery/style.css +27 -0
  104. package/plugins/grid/README.md +33 -0
  105. package/plugins/grid/index.ts +36 -0
  106. package/plugins/grid/style.css +25 -0
  107. package/plugins/iframe/README.md +18 -0
  108. package/plugins/iframe/client.ts +46 -0
  109. package/plugins/iframe/index.ts +54 -0
  110. package/plugins/iframe/style.css +29 -0
  111. package/plugins/index.ts +21 -0
  112. package/plugins/mermaid/README.md +21 -0
  113. package/plugins/mermaid/index.ts +40 -0
  114. package/plugins/mermaid/style.css +16 -0
  115. package/plugins/quiet/README.md +26 -0
  116. package/plugins/quiet/index.ts +27 -0
  117. package/plugins/terminal/client.ts +317 -0
  118. package/plugins/terminal/host.ts +326 -0
  119. package/plugins/terminal/index.ts +138 -0
  120. package/plugins/terminal/modes.ts +30 -0
  121. package/plugins/terminal/server.ts +215 -0
  122. package/plugins/terminal/sizes.ts +60 -0
  123. package/plugins/terminal/style.css +71 -0
  124. package/skills/whiteboard/SKILL.md +302 -0
  125. package/solid/index.tsx +59 -0
  126. package/src/auth.ts +66 -0
  127. package/src/client/forms.ts +185 -0
  128. package/src/client/markdown.ts +36 -0
  129. package/src/client/page/base.css +295 -0
  130. package/src/client/page/elsewhere.ts +70 -0
  131. package/src/client/page/fresh.ts +205 -0
  132. package/src/client/page/live.ts +30 -0
  133. package/src/client/page/main.ts +272 -0
  134. package/src/client/page/orphans.ts +46 -0
  135. package/src/client/page/sort.ts +38 -0
  136. package/src/client/page/theme.ts +32 -0
  137. package/src/client/page/view.ts +9 -0
  138. package/src/client/page/waiting.ts +182 -0
  139. package/src/client/read.ts +73 -0
  140. package/src/client/runtime.ts +183 -0
  141. package/src/client/toast.ts +25 -0
  142. package/src/config.ts +96 -0
  143. package/src/define.ts +612 -0
  144. package/src/events.ts +218 -0
  145. package/src/html.ts +40 -0
  146. package/src/icons.ts +8 -0
  147. package/src/load.ts +89 -0
  148. package/src/loader.ts +112 -0
  149. package/src/package.ts +39 -0
  150. package/src/pages/blocks.ts +70 -0
  151. package/src/pages/index.ts +42 -0
  152. package/src/pages/markdown.ts +364 -0
  153. package/src/pages/render.ts +233 -0
  154. package/src/plugins.ts +197 -0
  155. package/src/running.ts +22 -0
  156. package/src/serve.ts +52 -0
  157. package/src/server.ts +667 -0
  158. package/src/status.ts +113 -0
@@ -0,0 +1,27 @@
1
+ .wb-gallery {
2
+ display: grid; gap: 40px 24px; margin: 4em 0;
3
+ grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--wb-gallery-min, 240px)), 1fr));
4
+ }
5
+ .wb-gallery-item {
6
+ margin: 0; overflow: hidden; display: flex; flex-direction: column; min-width: 0;
7
+ }
8
+ .wb-gallery-thumb { padding: 0; border: 0; border-radius: var(--radius); overflow: hidden; background: var(--code-bg); cursor: zoom-in; display: block; }
9
+ .wb-gallery-thumb img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 0; }
10
+ .wb-gallery-item figcaption { padding: 14px 2px 0; font: .88rem/1.5 var(--serif); color: var(--text); }
11
+ .wb-gallery-item figcaption h3 { margin: 0 0 .25em; font-size: 1rem; }
12
+ .wb-gallery-item figcaption > div > :first-child { margin-top: 0; }
13
+ .wb-gallery-item figcaption > div > :last-child { margin-bottom: 0; }
14
+
15
+ .wb-lightbox {
16
+ position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / .86);
17
+ display: grid; place-items: center; grid-template-rows: 1fr auto; padding: 24px 16px;
18
+ }
19
+ .wb-lightbox img { max-width: 100%; max-height: calc(100vh - 110px); object-fit: contain; border-radius: 4px; }
20
+ .wb-lightbox-caption { color: #eee; text-align: center; padding-top: 10px; }
21
+ .wb-lightbox button {
22
+ position: absolute; background: rgb(255 255 255 / .12); color: #fff; border: 0; font-size: 1.6rem; line-height: 1;
23
+ width: 44px; height: 44px; border-radius: 50%; padding: 0;
24
+ }
25
+ .wb-lightbox-prev { left: 12px; top: 50%; }
26
+ .wb-lightbox-next { right: 12px; top: 50%; }
27
+ .wb-lightbox-close { right: 12px; top: 12px; }
@@ -0,0 +1,33 @@
1
+ Cards in a responsive grid. Each heading at the shallowest level inside the
2
+ block starts a card; everything under it is the card body (any markdown,
3
+ including other blocks). Without headings, each paragraph is a card.
4
+
5
+ A heading that ends in `{word}` gets a badge. `done ok yes good` are green,
6
+ `active new info` blue, `open todo maybe warning` amber,
7
+ `blocked no bad error` red; any other word is grey.
8
+
9
+ Attributes: `cols` (target column count on a wide screen, default 3).
10
+
11
+ ```markdown
12
+ :::grid{cols=3}
13
+ ### Parser {done}
14
+ remark + remark-directive.
15
+
16
+ ### Islands {active}
17
+ Solid components mounted per block.
18
+
19
+ ### Docs {todo}
20
+ Live examples on `/_/docs`.
21
+ :::
22
+ ```
23
+
24
+ :::grid{cols=3}
25
+ ### Parser {done}
26
+ remark + remark-directive.
27
+
28
+ ### Islands {active}
29
+ Solid components mounted per block.
30
+
31
+ ### Docs {todo}
32
+ Live examples on `/_/docs`.
33
+ :::
@@ -0,0 +1,33 @@
1
+ import fs from "node:fs";
2
+ import { definePlugin, html, raw } from "@bigmistqke/whiteboard";
3
+ // plugins/grid/index.ts
4
+ const slug = (s) => s.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
5
+ async function render(ctx) {
6
+ const { intro, sections } = await ctx.sections();
7
+ const cols = Number(ctx.attrs.cols);
8
+ const style = cols ? html` style="--wb-grid-cols:${cols}"` : null;
9
+ const cards = sections.map((s) => {
10
+ let title = s.title;
11
+ let badge = null;
12
+ const m = title ? /^(.*?)\s*\{([^}]+)\}\s*$/s.exec(title) : null;
13
+ if (m) {
14
+ title = m[1];
15
+ badge = m[2].trim();
16
+ }
17
+ const b = badge && html`<span class="wb-badge" data-badge="${slug(badge)}">${badge}</span>`;
18
+ const head = (title || b) && html`<header>${title && html`<h3>${raw(title)}</h3>`}${b}</header>`;
19
+ return html`<article class="wb-card"${badge && html` data-badge="${slug(badge)}"`}>${head}<div class="wb-card-body">${raw(s.html)}</div></article>`;
20
+ });
21
+ return html`${raw(intro)}<div class="wb-grid${"narrow" in ctx.attrs ? "" : " wb-wide"}"${style}>${cards}</div>`;
22
+ }
23
+ function grid() {
24
+ return definePlugin({
25
+ name: "grid",
26
+ blocks: { grid: {
27
+ html: render,
28
+ style: new URL("./style.css", import.meta.url)
29
+ } },
30
+ docs: () => fs.readFileSync(new URL("./README.md", import.meta.url), "utf8")
31
+ });
32
+ }
33
+ export { grid as default, render };
@@ -0,0 +1,25 @@
1
+ .wb-grid {
2
+ display: grid; gap: 22px; margin: 4em 0;
3
+ grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(var(--wide, 1040px) / var(--wb-grid-cols, 3) - 16px)), 1fr));
4
+ }
5
+ .wb-grid:not(.wb-wide) { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
6
+ .wb-card {
7
+ background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
8
+ padding: 18px 20px 20px; min-width: 0;
9
+ }
10
+ .wb-card > header { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; margin-bottom: .55em; }
11
+ .wb-card h3 { margin: 0; font-size: 1.02rem; }
12
+ .wb-card-body { font-size: .9rem; line-height: 1.6; }
13
+ .wb-card-body > :first-child { margin-top: 0; }
14
+ .wb-card-body > :last-child { margin-bottom: 0; }
15
+
16
+ /* badge: a coloured dot and a word, not a pill */
17
+ .wb-badge {
18
+ --c: var(--muted); flex: none; display: inline-flex; align-items: center; gap: 6px;
19
+ font: 500 .74rem/1 var(--sans); color: var(--muted); white-space: nowrap;
20
+ }
21
+ .wb-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
22
+ .wb-badge:is([data-badge=done], [data-badge=ok], [data-badge=yes], [data-badge=good]) { --c: var(--ok); }
23
+ .wb-badge:is([data-badge=active], [data-badge=new], [data-badge=info]) { --c: var(--info); }
24
+ .wb-badge:is([data-badge=open], [data-badge=todo], [data-badge=maybe], [data-badge=warning]) { --c: var(--warn); }
25
+ .wb-badge:is([data-badge=blocked], [data-badge=no], [data-badge=bad], [data-badge=error]) { --c: var(--bad); }
@@ -0,0 +1,18 @@
1
+ Another page inside this one: a running app (a dev server), a deployed
2
+ site, or an HTML file next to the pages. A header like a browser window's
3
+ shows its label (or, without one, its address), opens it on its own, and fills the window with
4
+ it (the same button, or Esc, puts it back). Drag the frame's bottom edge to
5
+ make it taller.
6
+
7
+ Attributes: `src` (required: an http(s) URL, or a path such as `demo.html`
8
+ for `.whiteboard/pages/demo.html`), `height` (a number of pixels or a CSS
9
+ length, default 480), `wide` (wider than the text column), `bare` (no
10
+ header: the frame alone).
11
+
12
+ ```markdown
13
+ ::iframe[The app as it runs now]{src="http://localhost:5173" height=600 wide}
14
+ ```
15
+
16
+ A site that forbids being framed (most large ones do, with
17
+ `X-Frame-Options` or `frame-ancestors`) shows as a blank or refused frame;
18
+ link to it instead.
@@ -0,0 +1 @@
1
+ const e=()=>[...document.querySelectorAll(`#wb-main div.wb-iframe`)];let t=null;function n(){let n=e(),r=null;n.forEach((e,n)=>{let i=!!t&&n===t.index&&e.querySelector(`iframe`)?.getAttribute(`src`)===t.src;e.toggleAttribute(`data-maximized`,i);let a=e.querySelector(`[data-wb-maximize]`);a&&(a.title=i?`Back into the page (Esc)`:`Fill the window`,a.setAttribute(`aria-label`,a.title),a.setAttribute(`aria-pressed`,String(i))),i&&(r=e)}),t&&!r&&(t=null),document.documentElement.toggleAttribute(`data-wb-iframe-maximized`,!!r)}function r(r){let i=e().indexOf(r),a=r.querySelector(`iframe`)?.getAttribute(`src`)??``;t=t&&t.index===i?null:{index:i,src:a},n()}const i=(e,i,a)=>{document.addEventListener(`click`,e=>{let t=(e.target.closest?.(`[data-wb-maximize]`))?.closest(`div.wb-iframe`);t&&r(t)}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&t&&(t=null,n())}),a.onRendered(n)};export{i as default};
@@ -0,0 +1,40 @@
1
+ import { packagePath } from "../../src/package.js";
2
+ import fs from "node:fs";
3
+ import { definePlugin, html, raw } from "@bigmistqke/whiteboard";
4
+ // plugins/iframe/index.ts
5
+ /** http(s), protocol-relative, or a path on this server; never `javascript:` or `data:`. */
6
+ const safeSrc = (src) => /^(https?:)?\/\//i.test(src) || !/^[a-z][a-z0-9+.-]*:/i.test(src);
7
+ /** A height in px (a bare number) or a CSS length; else the default. */
8
+ function height(value) {
9
+ if (value && /^\d+(\.\d+)?$/.test(value)) return `${value}px`;
10
+ if (value && /^\d+(\.\d+)?(px|em|rem|vh|svh|dvh)$/.test(value)) return value;
11
+ return "480px";
12
+ }
13
+ const svg = (d) => raw(`<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">${d}</svg>`);
14
+ const OPEN = svg("<path d=\"M9 2.5h4.5V7M13.5 2.5 7.5 8.5M11.5 9.5v3a1 1 0 0 1-1 1h-7a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1h3\"/>");
15
+ const MAXIMIZE = svg("<path d=\"M2.5 6V2.5H6M10 2.5h3.5V6M13.5 10v3.5H10M6 13.5H2.5V10\"/>");
16
+ const RESTORE = svg("<path d=\"M6 2.5V6H2.5M13.5 6H10V2.5M10 13.5V10h3.5M2.5 10H6v3.5\"/>");
17
+ async function render(ctx) {
18
+ const src = (ctx.attrs.src ?? "").trim();
19
+ if (!src) return html`<pre class="wb-error">iframe: needs a src, like ::iframe{src="http://localhost:5173"}</pre>`;
20
+ if (!safeSrc(src)) return html`<pre class="wb-error">iframe: src must be an http(s) URL or a path, not ${src.split(":")[0]}:</pre>`;
21
+ const title = ctx.labelText ?? ctx.attrs.title ?? src;
22
+ const header = !("bare" in ctx.attrs) && html`<div class="wb-iframe-bar">
23
+ <span class="wb-iframe-name" title="${src}">${ctx.label ? html`<span class="wb-iframe-title">${raw(ctx.label)}</span>` : html`<span class="wb-iframe-url">${src}</span>`}</span>
24
+ <a class="wb-iframe-button" href="${src}" target="_blank" rel="noopener" title="Open on its own" aria-label="Open on its own">${OPEN}</a>
25
+ <button type="button" class="wb-iframe-button" data-wb-maximize title="Fill the window" aria-label="Fill the window"><span class="wb-iframe-max">${MAXIMIZE}</span><span class="wb-iframe-restore">${RESTORE}</span></button>
26
+ </div>`;
27
+ return html`<div class="wb-iframe${"wide" in ctx.attrs && raw(" wb-wide")}">${header}<div class="wb-iframe-frame" style="height: ${height(ctx.attrs.height)}"><iframe src="${src}" title="${title}" loading="lazy" referrerpolicy="no-referrer"></iframe></div></div>`;
28
+ }
29
+ function iframe() {
30
+ return definePlugin({
31
+ name: "iframe",
32
+ blocks: { iframe: {
33
+ html: render,
34
+ style: new URL("./style.css", import.meta.url)
35
+ } },
36
+ setup: () => ({ client: packagePath("dist/plugins/iframe/client.js") }),
37
+ docs: () => fs.readFileSync(new URL("./README.md", import.meta.url), "utf8")
38
+ });
39
+ }
40
+ export { iframe as default, height, render, safeSrc };
@@ -0,0 +1,29 @@
1
+ /* a page inside the page, framed like a browser window; its bottom edge drags it taller */
2
+ .wb-iframe { margin: 1.6em 0; border: 1px solid var(--border); border-radius: var(--radius, 6px); overflow: hidden; background: var(--bg); }
3
+ .wb-iframe-frame { resize: vertical; overflow: hidden; min-height: 120px; background: #fff; }
4
+ .wb-iframe iframe { display: block; width: 100%; height: 100%; border: 0; }
5
+
6
+ .wb-iframe-bar {
7
+ display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 12px; min-height: 32px; box-sizing: border-box;
8
+ border-bottom: 1px solid var(--border); background: var(--tint, var(--bg)); font: .8rem/1.4 var(--sans); color: var(--muted);
9
+ }
10
+ .wb-iframe-name { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: baseline; overflow: hidden; white-space: nowrap; }
11
+ .wb-iframe-title { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
12
+ .wb-iframe-url { font-family: var(--mono, monospace); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; }
13
+ .wb-iframe-button {
14
+ flex: none; display: inline-grid; place-items: center; width: 26px; height: 24px; padding: 0; border: 0; border-radius: 5px;
15
+ background: none; color: var(--muted); cursor: pointer;
16
+ }
17
+ .wb-iframe-button:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
18
+ .wb-iframe-restore, .wb-iframe[data-maximized] .wb-iframe-max { display: none; }
19
+ .wb-iframe[data-maximized] .wb-iframe-restore { display: contents; }
20
+ .wb-iframe-max { display: contents; }
21
+
22
+ /* filling the window, above the page and its header; the terminal drawer stays below it. The
23
+ margin is !important: the page indents its blocks with a rule more specific than any here */
24
+ .wb-iframe[data-maximized] {
25
+ position: fixed; inset: 0 0 var(--wb-inset-bottom, 0px) 0; z-index: 40; margin: 0 !important; border-radius: 0; border: 0;
26
+ display: flex; flex-direction: column; width: auto; left: 0; transform: none;
27
+ }
28
+ .wb-iframe[data-maximized] .wb-iframe-frame { flex: 1; height: auto !important; resize: none; }
29
+ :root[data-wb-iframe-maximized] { overflow: hidden; }
@@ -0,0 +1,30 @@
1
+ import callout from "./callout/index.js";
2
+ import chatPlugin from "./chat/index.js";
3
+ import code from "./code/index.js";
4
+ import comments from "./comments/index.js";
5
+ import details from "./details/index.js";
6
+ import forge from "./forge/index.js";
7
+ import formPlugin from "./form/index.js";
8
+ import gallery from "./gallery/index.js";
9
+ import grid from "./grid/index.js";
10
+ import iframe from "./iframe/index.js";
11
+ import mermaid from "./mermaid/index.js";
12
+ import quiet from "./quiet/index.js";
13
+ // plugins/index.ts
14
+ function builtins() {
15
+ return [
16
+ callout(),
17
+ chatPlugin(),
18
+ code(),
19
+ comments(),
20
+ details(),
21
+ forge(),
22
+ formPlugin(),
23
+ gallery(),
24
+ grid(),
25
+ iframe(),
26
+ mermaid(),
27
+ quiet()
28
+ ];
29
+ }
30
+ export { builtins };
@@ -0,0 +1,21 @@
1
+ A [Mermaid](https://mermaid.js.org) diagram from a fence: flowcharts,
2
+ sequence, state, class, ER, gantt, pie and the other Mermaid types. Rendered
3
+ to SVG on the server by [Pele](https://pele.run), so no script runs on the
4
+ page; colours follow the page theme. A syntax error shows the line and
5
+ column in place of the diagram.
6
+
7
+ ````markdown
8
+ ```mermaid
9
+ flowchart LR
10
+ agent[agent writes .md] --> page[page in browser]
11
+ page -- form submit --> log[(events.ndjson)]
12
+ log -- whiteboard wait --> agent
13
+ ```
14
+ ````
15
+
16
+ ```mermaid
17
+ flowchart LR
18
+ agent[agent writes .md] --> page[page in browser]
19
+ page -- form submit --> log[(events.ndjson)]
20
+ log -- whiteboard wait --> agent
21
+ ```
@@ -0,0 +1,35 @@
1
+ import fs from "node:fs";
2
+ import crypto from "node:crypto";
3
+ import { definePlugin, html, raw } from "@bigmistqke/whiteboard";
4
+ // plugins/mermaid/index.ts
5
+ let pele;
6
+ const FONT = "ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif";
7
+ async function render(ctx) {
8
+ pele ??= await import("pele");
9
+ const idPrefix = `wbm-${crypto.createHash("sha1").update(ctx.text).digest("hex").slice(0, 8)}-`;
10
+ try {
11
+ const { svg } = pele.render(ctx.text, {
12
+ idPrefix,
13
+ fontFamily: FONT,
14
+ responsive: true
15
+ });
16
+ return html`<figure class="wb-diagram wb-figure">${raw(svg)}</figure>`;
17
+ } catch (err) {
18
+ if (!(err instanceof pele.PeleError)) throw err;
19
+ const where = err.line ? ` (line ${err.line}${err.column ? `, column ${err.column}` : ""})` : "";
20
+ const snippet = err.snippet ? `\n\n${err.snippet}` : "";
21
+ return html`<pre class="wb-error">mermaid: ${err.message}${where}${snippet}</pre>`;
22
+ }
23
+ }
24
+ function mermaid() {
25
+ return definePlugin({
26
+ name: "mermaid",
27
+ blocks: { mermaid: {
28
+ fence: true,
29
+ html: render,
30
+ style: new URL("./style.css", import.meta.url)
31
+ } },
32
+ docs: () => fs.readFileSync(new URL("./README.md", import.meta.url), "utf8")
33
+ });
34
+ }
35
+ export { mermaid as default, render };
@@ -0,0 +1,16 @@
1
+ /* Pele reads its colours from --pele-* variables; map them onto the page's tokens so diagrams
2
+ follow the theme without being re-rendered. */
3
+ .wb-diagram {
4
+ margin: 4em 0; overflow-x: auto; text-align: center;
5
+ --pele-bg: transparent;
6
+ --pele-fg: var(--text);
7
+ --pele-muted: var(--muted);
8
+ --pele-line: var(--muted);
9
+ --pele-surface: var(--surface);
10
+ --pele-surface-alt: var(--code-bg);
11
+ --pele-border: var(--border);
12
+ --pele-accent: var(--accent);
13
+ --pele-font: var(--sans);
14
+ --pele-radius: 6px;
15
+ }
16
+ .wb-diagram svg { max-width: 100%; height: auto; }
@@ -0,0 +1,26 @@
1
+ Content that is never marked as new. Changed blocks get a red bar until the
2
+ reader has seen them; what is inside `quiet` does not count as a change. Use
3
+ it for what changes without being news to the reader: repeating back what
4
+ they answered, a status line, a timestamp. Anything with substance (an
5
+ explanation, a question back, a different reading of their answer) belongs
6
+ outside it, so it is marked.
7
+
8
+ A whole block, a line, or a few words:
9
+
10
+ ```markdown
11
+ :::quiet
12
+ Decided: **this week**, as you answered.
13
+ :::
14
+
15
+ ::quiet[Last checked 12:04]
16
+
17
+ The build is green :quiet[(as of 12:04)].
18
+ ```
19
+
20
+ Inside a larger block, such as a card, only the quiet part is ignored: other
21
+ changes in the block still mark it. Hand-written HTML can do the same with a
22
+ `data-wb-quiet` attribute.
23
+
24
+ :::quiet
25
+ This block is quiet: editing it never marks it as new.
26
+ :::
@@ -0,0 +1,17 @@
1
+ import fs from "node:fs";
2
+ import { definePlugin, html, raw } from "@bigmistqke/whiteboard";
3
+ // plugins/quiet/index.ts
4
+ async function render(ctx) {
5
+ const label = ctx.label && raw(ctx.label);
6
+ if (ctx.kind === "textDirective") return html`<span data-wb-quiet>${label}</span>`;
7
+ if (ctx.kind === "leafDirective") return html`<div data-wb-quiet>${label && html`<p>${label}</p>`}</div>`;
8
+ return html`<div data-wb-quiet>${raw(await ctx.toHtml(ctx.children))}</div>`;
9
+ }
10
+ function quiet() {
11
+ return definePlugin({
12
+ name: "quiet",
13
+ blocks: { quiet: { html: render } },
14
+ docs: () => fs.readFileSync(new URL("./README.md", import.meta.url), "utf8")
15
+ });
16
+ }
17
+ export { quiet as default, render };