@bigmistqke/whiteboard 0.5.0 → 0.6.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.
- package/README.md +125 -25
- package/bin/whiteboard.ts +299 -16
- package/dist/bin/whiteboard.js +247 -17
- package/dist/client/runtime.js +22 -10
- package/dist/plugins/ansi/README.md +36 -0
- package/dist/plugins/ansi/index.js +64 -0
- package/dist/plugins/ansi/public/style.css +28 -0
- package/dist/plugins/badge/README.md +28 -0
- package/dist/plugins/badge/index.js +24 -0
- package/dist/plugins/badge/public/style.css +30 -0
- package/dist/plugins/chat/public/style.css +7 -2
- package/dist/plugins/code/README.md +4 -2
- package/dist/plugins/code/diff.js +12 -2
- package/dist/plugins/grid/README.md +12 -12
- package/dist/plugins/grid/index.js +7 -19
- package/dist/plugins/grid/public/style.css +4 -33
- package/dist/plugins/iframe/README.md +7 -7
- package/dist/plugins/iframe/index.js +11 -11
- package/dist/plugins/iframe/public/style.css +15 -0
- package/dist/plugins/index.js +7 -3
- package/dist/plugins/lightbox/README.md +22 -0
- package/dist/plugins/lightbox/index.js +20 -0
- package/dist/plugins/lightbox/public/client.js +4 -0
- package/dist/plugins/lightbox/public/style.css +66 -0
- package/dist/plugins/steps/README.md +3 -3
- package/dist/plugins/steps/index.js +3 -42
- package/dist/plugins/steps/public/client.js +1 -1
- package/dist/plugins/terminal/host.js +1 -1
- package/dist/plugins/terminal/public/client.js +1 -1
- package/dist/plugins/window/README.md +34 -14
- package/dist/plugins/window/index.js +21 -13
- package/dist/src/auth.js +4 -3
- package/dist/src/client/page/base.css +61 -1
- package/dist/src/client/page/main.js +60 -14
- package/dist/src/entries.js +211 -0
- package/dist/src/events.js +1 -1
- package/dist/src/hub.js +272 -0
- package/dist/src/loader.js +4 -1
- package/dist/src/package.js +23 -1
- package/dist/src/pages/blocks.js +1 -0
- package/dist/src/pages/index.js +1 -1
- package/dist/src/pages/markdown.js +87 -33
- package/dist/src/pages/render.js +116 -14
- package/dist/src/pages/window.js +16 -18
- package/dist/src/running.js +37 -2
- package/dist/src/serve.js +111 -2
- package/dist/src/server.js +49 -14
- package/package.json +1 -1
- package/plugins/ansi/README.md +36 -0
- package/plugins/ansi/index.ts +95 -0
- package/plugins/ansi/public/style.css +28 -0
- package/plugins/badge/README.md +28 -0
- package/plugins/badge/index.ts +35 -0
- package/plugins/badge/public/style.css +30 -0
- package/plugins/chat/public/style.css +7 -2
- package/plugins/code/README.md +4 -2
- package/plugins/code/diff.ts +14 -2
- package/plugins/grid/README.md +12 -12
- package/plugins/grid/index.ts +11 -26
- package/plugins/grid/public/style.css +4 -33
- package/plugins/iframe/README.md +7 -7
- package/plugins/iframe/index.ts +15 -15
- package/plugins/iframe/public/style.css +15 -0
- package/plugins/index.ts +6 -2
- package/plugins/lightbox/README.md +22 -0
- package/plugins/lightbox/client.ts +99 -0
- package/plugins/lightbox/index.ts +25 -0
- package/plugins/lightbox/public/style.css +66 -0
- package/plugins/steps/README.md +3 -3
- package/plugins/steps/client.ts +15 -6
- package/plugins/steps/index.ts +3 -46
- package/plugins/terminal/client.ts +16 -7
- package/plugins/window/README.md +34 -14
- package/plugins/window/index.ts +20 -13
- package/skills/whiteboard/SKILL.md +18 -10
- package/src/auth.ts +5 -3
- package/src/client/base.ts +19 -0
- package/src/client/forms.ts +2 -1
- package/src/client/markdown.ts +2 -1
- package/src/client/page/base.css +61 -1
- package/src/client/page/elsewhere.ts +72 -16
- package/src/client/page/fresh.ts +2 -1
- package/src/client/page/sort.ts +2 -1
- package/src/client/runtime.ts +11 -9
- package/src/define.ts +66 -7
- package/src/entries.ts +258 -0
- package/src/events.ts +2 -1
- package/src/hub.ts +355 -0
- package/src/loader.ts +7 -1
- package/src/package.ts +22 -0
- package/src/pages/blocks.ts +3 -0
- package/src/pages/index.ts +4 -2
- package/src/pages/markdown.ts +89 -32
- package/src/pages/render.ts +134 -13
- package/src/pages/window.ts +16 -25
- package/src/running.ts +47 -1
- package/src/serve.ts +114 -1
- package/src/server.ts +80 -14
- package/dist/plugins/gallery/README.md +0 -30
- package/dist/plugins/gallery/index.js +0 -75
- package/dist/plugins/gallery/public/client.js +0 -1
- package/dist/plugins/gallery/public/style.css +0 -90
- package/plugins/gallery/README.md +0 -30
- package/plugins/gallery/client.tsx +0 -70
- package/plugins/gallery/index.ts +0 -89
- package/plugins/gallery/public/style.css +0 -90
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { createSignal, For, Show, onSettled } from 'solid-js'
|
|
2
|
-
import { solid } from '@bigmistqke/whiteboard/solid'
|
|
3
|
-
import type { Item } from './index'
|
|
4
|
-
|
|
5
|
-
function Gallery(props: { items: Item[]; min: string | null; narrow: boolean }) {
|
|
6
|
-
const [open, setOpen] = createSignal<number | null>(null)
|
|
7
|
-
const current = () => {
|
|
8
|
-
const i = open()
|
|
9
|
-
return i == null ? undefined : props.items[i]
|
|
10
|
-
}
|
|
11
|
-
const step = (d: number) => setOpen(i => (i == null ? i : (i + d + props.items.length) % props.items.length))
|
|
12
|
-
|
|
13
|
-
onSettled(() => {
|
|
14
|
-
const onKey = (e: KeyboardEvent) => {
|
|
15
|
-
if (open() == null) return
|
|
16
|
-
if (e.key === 'Escape') setOpen(null)
|
|
17
|
-
else if (e.key === 'ArrowRight') step(1)
|
|
18
|
-
else if (e.key === 'ArrowLeft') step(-1)
|
|
19
|
-
}
|
|
20
|
-
addEventListener('keydown', onKey)
|
|
21
|
-
return () => removeEventListener('keydown', onKey)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<>
|
|
26
|
-
<div class={['wb-gallery', { 'wb-wide': !props.narrow }]} style={{ '--wb-gallery-min': props.min ?? '240px' }}>
|
|
27
|
-
<For each={props.items}>
|
|
28
|
-
{(item, i) => (
|
|
29
|
-
<figure class="wb-gallery-item">
|
|
30
|
-
<Show when={item.src}>
|
|
31
|
-
<button type="button" class="wb-gallery-thumb" onClick={() => setOpen(i())}>
|
|
32
|
-
<img src={item.src!} alt={item.alt} loading="lazy" />
|
|
33
|
-
</button>
|
|
34
|
-
</Show>
|
|
35
|
-
<Show when={item.title || item.html}>
|
|
36
|
-
<figcaption>
|
|
37
|
-
<Show when={item.title}>
|
|
38
|
-
<h3 innerHTML={item.title!} />
|
|
39
|
-
</Show>
|
|
40
|
-
<div innerHTML={item.html} />
|
|
41
|
-
</figcaption>
|
|
42
|
-
</Show>
|
|
43
|
-
</figure>
|
|
44
|
-
)}
|
|
45
|
-
</For>
|
|
46
|
-
</div>
|
|
47
|
-
<Show when={current()}>
|
|
48
|
-
{item => (
|
|
49
|
-
<div class="wb-lightbox" onClick={e => e.target === e.currentTarget && setOpen(null)}>
|
|
50
|
-
<img src={item().src ?? ''} alt={item().alt} />
|
|
51
|
-
<div class="wb-lightbox-caption" innerHTML={item().title ?? ''} />
|
|
52
|
-
<Show when={props.items.length > 1}>
|
|
53
|
-
<button type="button" class="wb-lightbox-prev" aria-label="Previous" onClick={() => step(-1)}>
|
|
54
|
-
‹
|
|
55
|
-
</button>
|
|
56
|
-
<button type="button" class="wb-lightbox-next" aria-label="Next" onClick={() => step(1)}>
|
|
57
|
-
›
|
|
58
|
-
</button>
|
|
59
|
-
</Show>
|
|
60
|
-
<button type="button" class="wb-lightbox-close" aria-label="Close" onClick={() => setOpen(null)}>
|
|
61
|
-
×
|
|
62
|
-
</button>
|
|
63
|
-
</div>
|
|
64
|
-
)}
|
|
65
|
-
</Show>
|
|
66
|
-
</>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default solid(Gallery)
|
package/plugins/gallery/index.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
import { definePlugin, type Plugin } from '@bigmistqke/whiteboard'
|
|
3
|
-
// Turns the block's content into gallery items: one per heading (first image in the section is
|
|
4
|
-
// its picture), or one per image when there are no headings.
|
|
5
|
-
import { escape, type DirectiveContext } from '@bigmistqke/whiteboard'
|
|
6
|
-
import { builtinPublic } from '../../src/package.ts'
|
|
7
|
-
|
|
8
|
-
interface Node {
|
|
9
|
-
type: string
|
|
10
|
-
depth?: number
|
|
11
|
-
url?: string
|
|
12
|
-
alt?: string
|
|
13
|
-
children?: Node[]
|
|
14
|
-
}
|
|
15
|
-
export interface Item {
|
|
16
|
-
src: string | null
|
|
17
|
-
alt: string
|
|
18
|
-
title: string | null
|
|
19
|
-
html: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** Remove and return the first image in a list of nodes (searching inside paragraphs). */
|
|
23
|
-
function takeImage(nodes: Node[]): Node | null {
|
|
24
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
25
|
-
const n = nodes[i]
|
|
26
|
-
if (n.type === 'image') {
|
|
27
|
-
nodes.splice(i, 1)
|
|
28
|
-
return n
|
|
29
|
-
}
|
|
30
|
-
if (n.children) {
|
|
31
|
-
const found = takeImage(n.children)
|
|
32
|
-
if (found) {
|
|
33
|
-
if (n.type === 'paragraph' && n.children.every(c => c.type === 'text' && !String((c as any).value).trim()))
|
|
34
|
-
nodes.splice(i, 1)
|
|
35
|
-
return found
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return null
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export async function props(ctx: DirectiveContext) {
|
|
43
|
-
const children = ctx.children as Node[]
|
|
44
|
-
const heads = children.filter(n => n.type === 'heading')
|
|
45
|
-
const items: Item[] = []
|
|
46
|
-
if (heads.length) {
|
|
47
|
-
const depth = Math.min(...heads.map(h => h.depth!))
|
|
48
|
-
let current: { heading: Node; body: Node[] } | null = null
|
|
49
|
-
const groups: { heading: Node; body: Node[] }[] = []
|
|
50
|
-
for (const n of children) {
|
|
51
|
-
if (n.type === 'heading' && n.depth === depth) groups.push((current = { heading: n, body: [] }))
|
|
52
|
-
else current?.body.push(n)
|
|
53
|
-
}
|
|
54
|
-
for (const g of groups) {
|
|
55
|
-
const img = takeImage(g.body)
|
|
56
|
-
items.push({
|
|
57
|
-
src: img?.url ?? null,
|
|
58
|
-
alt: img?.alt ?? '',
|
|
59
|
-
title: await ctx.toHtml(g.heading.children ?? []),
|
|
60
|
-
html: await ctx.toHtml(g.body),
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
const walk = (nodes: Node[]) => {
|
|
65
|
-
for (const n of nodes) {
|
|
66
|
-
if (n.type === 'image')
|
|
67
|
-
items.push({ src: n.url!, alt: n.alt ?? '', title: n.alt ? escape(n.alt) : null, html: '' })
|
|
68
|
-
else if (n.children) walk(n.children)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
walk(children)
|
|
72
|
-
}
|
|
73
|
-
return { items, min: ctx.attrs.min ?? null, narrow: 'narrow' in ctx.attrs }
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export default function gallery(): Plugin {
|
|
77
|
-
return definePlugin({
|
|
78
|
-
name: 'gallery',
|
|
79
|
-
public: builtinPublic('gallery'),
|
|
80
|
-
blocks: {
|
|
81
|
-
gallery: {
|
|
82
|
-
props,
|
|
83
|
-
client: 'client.js',
|
|
84
|
-
style: 'style.css',
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
docs: () => fs.readFileSync(new URL('./README.md', import.meta.url), 'utf8'),
|
|
88
|
-
})
|
|
89
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
.wb-gallery {
|
|
2
|
-
display: grid;
|
|
3
|
-
gap: 40px var(--space-3xl);
|
|
4
|
-
margin: 4em 0;
|
|
5
|
-
grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--wb-gallery-min, 240px)), 1fr));
|
|
6
|
-
}
|
|
7
|
-
.wb-gallery-item {
|
|
8
|
-
margin: 0;
|
|
9
|
-
overflow: hidden;
|
|
10
|
-
display: flex;
|
|
11
|
-
flex-direction: column;
|
|
12
|
-
min-width: 0;
|
|
13
|
-
}
|
|
14
|
-
.wb-gallery-thumb {
|
|
15
|
-
padding: 0;
|
|
16
|
-
border: 0;
|
|
17
|
-
border-radius: var(--radius);
|
|
18
|
-
overflow: hidden;
|
|
19
|
-
background: var(--code-bg);
|
|
20
|
-
cursor: zoom-in;
|
|
21
|
-
display: block;
|
|
22
|
-
}
|
|
23
|
-
.wb-gallery-thumb img {
|
|
24
|
-
display: block;
|
|
25
|
-
width: 100%;
|
|
26
|
-
aspect-ratio: 4 / 3;
|
|
27
|
-
object-fit: cover;
|
|
28
|
-
border-radius: 0;
|
|
29
|
-
}
|
|
30
|
-
.wb-gallery-item figcaption {
|
|
31
|
-
padding: var(--space-xl) var(--space-2xs) 0;
|
|
32
|
-
font: var(--ui-text)/var(--ui-line-height) var(--serif);
|
|
33
|
-
color: var(--text);
|
|
34
|
-
}
|
|
35
|
-
.wb-gallery-item figcaption h3 {
|
|
36
|
-
margin: 0 0 0.25em;
|
|
37
|
-
font-size: 1rem;
|
|
38
|
-
}
|
|
39
|
-
.wb-gallery-item figcaption > div > :first-child {
|
|
40
|
-
margin-top: 0;
|
|
41
|
-
}
|
|
42
|
-
.wb-gallery-item figcaption > div > :last-child {
|
|
43
|
-
margin-bottom: 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.wb-lightbox {
|
|
47
|
-
position: fixed;
|
|
48
|
-
inset: 0;
|
|
49
|
-
z-index: var(--layer-top);
|
|
50
|
-
background: rgb(0 0 0 / 0.86);
|
|
51
|
-
display: grid;
|
|
52
|
-
place-items: center;
|
|
53
|
-
grid-template-rows: 1fr auto;
|
|
54
|
-
padding: var(--space-3xl) var(--space-2xl);
|
|
55
|
-
}
|
|
56
|
-
.wb-lightbox img {
|
|
57
|
-
max-width: 100%;
|
|
58
|
-
max-height: calc(100vh - 110px);
|
|
59
|
-
object-fit: contain;
|
|
60
|
-
border-radius: var(--radius-sm);
|
|
61
|
-
}
|
|
62
|
-
.wb-lightbox-caption {
|
|
63
|
-
color: #eee;
|
|
64
|
-
text-align: center;
|
|
65
|
-
padding-top: var(--space-lg);
|
|
66
|
-
}
|
|
67
|
-
.wb-lightbox button {
|
|
68
|
-
position: absolute;
|
|
69
|
-
background: rgb(255 255 255 / 0.12);
|
|
70
|
-
color: #fff;
|
|
71
|
-
border: 0;
|
|
72
|
-
font-size: 1.6rem;
|
|
73
|
-
line-height: 1;
|
|
74
|
-
width: 44px;
|
|
75
|
-
height: 44px;
|
|
76
|
-
border-radius: 50%;
|
|
77
|
-
padding: 0;
|
|
78
|
-
}
|
|
79
|
-
.wb-lightbox-prev {
|
|
80
|
-
left: 12px;
|
|
81
|
-
top: 50%;
|
|
82
|
-
}
|
|
83
|
-
.wb-lightbox-next {
|
|
84
|
-
right: 12px;
|
|
85
|
-
top: 50%;
|
|
86
|
-
}
|
|
87
|
-
.wb-lightbox-close {
|
|
88
|
-
right: 12px;
|
|
89
|
-
top: 12px;
|
|
90
|
-
}
|