deictic 0.0.1 → 0.1.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/LICENSE +21 -0
- package/README.md +144 -0
- package/dist/annotations/client.d.ts +4 -0
- package/dist/annotations/client.d.ts.map +1 -0
- package/dist/annotations/client.js +497 -0
- package/dist/annotations/client.js.map +1 -0
- package/dist/annotations/index.d.ts +110 -0
- package/dist/annotations/index.d.ts.map +1 -0
- package/dist/annotations/index.js +22 -0
- package/dist/annotations/index.js.map +1 -0
- package/dist/astro.d.ts +29 -0
- package/dist/astro.d.ts.map +1 -0
- package/dist/astro.js +24 -0
- package/dist/astro.js.map +1 -0
- package/dist/bun.d.ts +12 -0
- package/dist/bun.d.ts.map +1 -0
- package/dist/bun.js +67 -0
- package/dist/bun.js.map +1 -0
- package/dist/client/index.d.ts +93 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +1329 -0
- package/dist/client/index.js.map +1 -0
- package/dist/endpoints.js +354 -0
- package/dist/endpoints.js.map +1 -0
- package/dist/index.d.ts +220 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/index2.d.ts +23 -0
- package/dist/index3.d.ts +98 -0
- package/dist/index3.d.ts.map +1 -0
- package/dist/index4.d.ts +74 -0
- package/dist/index4.d.ts.map +1 -0
- package/dist/index5.d.ts +70 -0
- package/dist/index5.d.ts.map +1 -0
- package/dist/integration.d.ts +19 -0
- package/dist/integration.d.ts.map +1 -0
- package/dist/integration.js +277 -0
- package/dist/integration.js.map +1 -0
- package/dist/kept.js +23 -0
- package/dist/kept.js.map +1 -0
- package/dist/loader.d.ts +15 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +17 -0
- package/dist/loader.js.map +1 -0
- package/dist/marks.js +14 -0
- package/dist/marks.js.map +1 -0
- package/dist/next.d.ts +17 -0
- package/dist/next.d.ts.map +1 -0
- package/dist/next.js +150 -0
- package/dist/next.js.map +1 -0
- package/dist/playwright.js +105 -0
- package/dist/playwright.js.map +1 -0
- package/dist/recommended/index.d.ts +25 -0
- package/dist/recommended/index.d.ts.map +1 -0
- package/dist/recommended/index.js +19 -0
- package/dist/recommended/index.js.map +1 -0
- package/dist/recordings/client.d.ts +4 -0
- package/dist/recordings/client.d.ts.map +1 -0
- package/dist/recordings/client.js +376 -0
- package/dist/recordings/client.js.map +1 -0
- package/dist/recordings/index.d.ts +2 -0
- package/dist/recordings/index.js +3 -0
- package/dist/recordings.js +235 -0
- package/dist/recordings.js.map +1 -0
- package/dist/screenshots/client.d.ts +23 -0
- package/dist/screenshots/client.d.ts.map +1 -0
- package/dist/screenshots/client.js +76 -0
- package/dist/screenshots/client.js.map +1 -0
- package/dist/screenshots/dom.d.ts +4 -0
- package/dist/screenshots/dom.d.ts.map +1 -0
- package/dist/screenshots/dom.js +92 -0
- package/dist/screenshots/dom.js.map +1 -0
- package/dist/screenshots/index.d.ts +2 -0
- package/dist/screenshots/index.js +98 -0
- package/dist/screenshots/index.js.map +1 -0
- package/dist/screenshots/rrweb.d.ts +9 -0
- package/dist/screenshots/rrweb.d.ts.map +1 -0
- package/dist/screenshots/rrweb.js +60 -0
- package/dist/screenshots/rrweb.js.map +1 -0
- package/dist/shortcut.js +63 -0
- package/dist/shortcut.js.map +1 -0
- package/dist/tailwind/client.d.ts +4 -0
- package/dist/tailwind/client.d.ts.map +1 -0
- package/dist/tailwind/client.js +613 -0
- package/dist/tailwind/client.js.map +1 -0
- package/dist/tailwind/index.d.ts +2 -0
- package/dist/tailwind/index.js +557 -0
- package/dist/tailwind/index.js.map +1 -0
- package/dist/tasks/client.d.ts +6 -0
- package/dist/tasks/client.d.ts.map +1 -0
- package/dist/tasks/client.js +642 -0
- package/dist/tasks/client.js.map +1 -0
- package/dist/tasks/index.d.ts +159 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/index.js +348 -0
- package/dist/tasks/index.js.map +1 -0
- package/dist/vite.d.ts +17 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +44 -0
- package/dist/vite.js.map +1 -0
- package/dist/voice/client.d.ts +4 -0
- package/dist/voice/client.d.ts.map +1 -0
- package/dist/voice/client.js +66 -0
- package/dist/voice/client.js.map +1 -0
- package/dist/voice/index.d.ts +47 -0
- package/dist/voice/index.d.ts.map +1 -0
- package/dist/voice/index.js +74 -0
- package/dist/voice/index.js.map +1 -0
- package/dist/waveform.js +93 -0
- package/dist/waveform.js.map +1 -0
- package/dist/webpack.d.ts +50 -0
- package/dist/webpack.d.ts.map +1 -0
- package/dist/webpack.js +78 -0
- package/dist/webpack.js.map +1 -0
- package/package.json +307 -7
- package/skills/deictic/SKILL.md +47 -0
- package/skills/deictic/references/install.md +81 -0
- package/skills/deictic/references/recordings.md +83 -0
- package/skills/deictic/references/tasks.md +79 -0
- package/skills/deictic/references/watch.md +43 -0
- package/skills/deictic/scripts/frame.mjs +62 -0
- package/skills/deictic/scripts/lib.mjs +193 -0
- package/skills/deictic/scripts/recording.mjs +186 -0
- package/skills/deictic/scripts/task.mjs +84 -0
- package/skills/deictic/scripts/transcribe.mjs +93 -0
- package/skills/deictic/scripts/voice.mjs +50 -0
- package/skills/deictic/scripts/watch.mjs +51 -0
- package/src/astro.ts +34 -0
- package/src/bun.ts +79 -0
- package/src/client/index.ts +833 -0
- package/src/client/lightbox.ts +256 -0
- package/src/client/style.ts +243 -0
- package/src/client/tooltip.ts +78 -0
- package/src/client/waveform.ts +98 -0
- package/src/index.ts +240 -0
- package/src/loader.ts +28 -0
- package/src/next.ts +133 -0
- package/src/plugins/annotations/client.ts +301 -0
- package/src/plugins/annotations/draw.ts +169 -0
- package/src/plugins/annotations/index.ts +105 -0
- package/src/plugins/annotations/svg.ts +61 -0
- package/src/plugins/recommended/index.ts +35 -0
- package/src/plugins/recordings/client.ts +315 -0
- package/src/plugins/recordings/index.ts +174 -0
- package/src/plugins/recordings/marks.ts +11 -0
- package/src/plugins/recordings/ours.ts +70 -0
- package/src/plugins/recordings/replay.ts +139 -0
- package/src/plugins/screenshots/client.ts +63 -0
- package/src/plugins/screenshots/dom.ts +79 -0
- package/src/plugins/screenshots/index.ts +194 -0
- package/src/plugins/screenshots/playwright.ts +119 -0
- package/src/plugins/screenshots/rrweb.ts +45 -0
- package/src/plugins/tailwind/catalog.ts +396 -0
- package/src/plugins/tailwind/client.ts +669 -0
- package/src/plugins/tailwind/index.ts +267 -0
- package/src/plugins/tasks/client.ts +622 -0
- package/src/plugins/tasks/index.ts +513 -0
- package/src/plugins/voice/client.ts +57 -0
- package/src/plugins/voice/index.ts +114 -0
- package/src/shortcut.ts +83 -0
- package/src/tools/astro.ts +81 -0
- package/src/tools/editor.ts +22 -0
- package/src/tools/endpoints.ts +163 -0
- package/src/tools/history.ts +203 -0
- package/src/tools/integration.ts +106 -0
- package/src/tools/kept.ts +21 -0
- package/src/tools/locate.ts +94 -0
- package/src/tools/plugins.ts +41 -0
- package/src/tools/source.ts +72 -0
- package/src/vite.ts +62 -0
- package/src/webpack.ts +107 -0
- package/index.js +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gokhan Kurt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# deictic
|
|
2
|
+
|
|
3
|
+
Point at an element in your running app and leave a task about it, for you, a teammate or an agent to work.
|
|
4
|
+
|
|
5
|
+
Hold **Alt** and point: the element is outlined with its tag and the file and line that rendered it. **Alt-click**,
|
|
6
|
+
say what should change, and attach a screenshot to draw on, a screen recording or a voice note. The task goes to a
|
|
7
|
+
[Vercel Board](https://vercel.com/docs/board) with everything an agent needs to find the code: the element's
|
|
8
|
+
`file:line:column`, the page and the viewport.
|
|
9
|
+
|
|
10
|
+
It runs in your dev server only. A production build has none of it.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -D deictic @vercel/board rrweb rrweb-player rrweb-snapshot playwright-core
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then add it to your bundler. `recommended()` is the plugins for tasks: tasks, screenshots, annotations, recordings
|
|
19
|
+
and voice.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
// vite.config.ts (and anything on Vite: React Router, TanStack Start…)
|
|
23
|
+
import { recommended } from 'deictic/recommended';
|
|
24
|
+
import { deictic } from 'deictic/vite';
|
|
25
|
+
|
|
26
|
+
export default defineConfig({
|
|
27
|
+
plugins: [react(), deictic({ plugins: recommended() })],
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
| Bundler | Setup |
|
|
32
|
+
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
33
|
+
| Next.js (`next dev`) | `export default withDeictic(nextConfig, { plugins: recommended() })`, from `deictic/next` |
|
|
34
|
+
| webpack 5, Rspack | `plugins: [new DeicticPlugin({ plugins: recommended() })]`, from `deictic/webpack` (`launch-editor` to open files) |
|
|
35
|
+
| Astro | `integrations: [deictic({ plugins: recommended() })]`, from `deictic/astro` (`.astro` components with Astro 7; JSX islands with any) |
|
|
36
|
+
| Bun (`Bun.serve`, HTML imports) | `deictic({ plugins: recommended() })` from `deictic/bun`, named in `bunfig.toml`'s `[serve.static] plugins`, its `routes` spread into `Bun.serve`'s |
|
|
37
|
+
|
|
38
|
+
Screenshots render in a Chromium: Playwright's (`npx playwright install chromium`), else Chrome or Edge. React
|
|
39
|
+
Native isn't supported: there's no DOM to point at.
|
|
40
|
+
|
|
41
|
+
## Tasks
|
|
42
|
+
|
|
43
|
+
Tasks go to a board on your machine or your team's:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx vb serve # a board on this machine, kept in .board/
|
|
47
|
+
BOARD_URL=http://127.0.0.1:4100/api/board vite # or no BOARD_URL for your team's board, after `vercel login`
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Whoever works the channel (`deictic` by default) takes it from there. For an agent, deictic comes with a skill that
|
|
51
|
+
watches the channel and works each task as it arrives, with scripts that read a task, turn a recording into a
|
|
52
|
+
timeline, screenshot it at any moment, and transcribe its voice notes:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npx skills add ./node_modules/deictic
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
In the Task tab, **Attach** adds a screenshot of the page, **Annotate** opens it to draw boxes, arrows and notes on,
|
|
59
|
+
**Record** records the page as you use it (drawing as you go, with the mic on if you like), and **Voice** records a
|
|
60
|
+
note. Each is a chip that opens in a lightbox. The panel lists the tasks already about the element: each one's ID opens it
|
|
61
|
+
on the board, and one no one has claimed yet can be edited or deleted there (deleting cancels it on the board). Undo
|
|
62
|
+
takes any of it back. The page hears of each task added as a `deictic:task` event on `window`, its `detail` the task's ID,
|
|
63
|
+
title, element and what was attached.
|
|
64
|
+
|
|
65
|
+
## Options
|
|
66
|
+
|
|
67
|
+
Each plugin takes its options under its name, and `false` leaves one out. Other plugins, your own included, go
|
|
68
|
+
beside the preset:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
deictic({
|
|
72
|
+
shortcut: { modifiers: ['Control', 'Shift'] }, // instead of Alt; `false` for none
|
|
73
|
+
plugins: recommended({
|
|
74
|
+
tasks: { channel: 'ui', project: 'storefront', labels: { team: 'web' } },
|
|
75
|
+
screenshots: { maskAllInputs: true },
|
|
76
|
+
voice: false,
|
|
77
|
+
}),
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
A task is the words typed and its attachments (with none typed, a line naming what's attached); the rest is labels: `deictic.project` (the `project` option, or by
|
|
82
|
+
default your `package.json`'s name, to tell projects apart on one board), `deictic.at`, `deictic.url`,
|
|
83
|
+
`deictic.viewport` and more, and your own `labels` beside them.
|
|
84
|
+
|
|
85
|
+
Screenshots and recordings hide what [rrweb](https://github.com/rrweb-io/rrweb) would, by its names: `rr-block`
|
|
86
|
+
blanks an element, `rr-mask` masks its text, `maskAllInputs` masks every field (passwords always are). Nothing of
|
|
87
|
+
deictic's own UI is in them. What a project keeps (the history, shots, recordings, voice notes) is in `.deictic/`,
|
|
88
|
+
which ignores itself in git.
|
|
89
|
+
|
|
90
|
+
## How it works
|
|
91
|
+
|
|
92
|
+
- A transform that runs before the framework's own adds `data-deictic="src/App.tsx:12:5"` to every host element
|
|
93
|
+
(`div`, `button`) in `.jsx`, `.tsx` and `.js` modules and in `.astro` components, so it works for any framework
|
|
94
|
+
that compiles JSX, server components too, and points at the element's own tag rather than the component around it.
|
|
95
|
+
- Its endpoints are on the dev server's own origin, `/__deictic/*`, and take writes only as same-origin JSON, so no
|
|
96
|
+
other site can make them and no token reaches the page.
|
|
97
|
+
- Every change goes into one history in `.deictic/history.json`. The popup's undo and redo walk the part of it that
|
|
98
|
+
is the open tab's on the element it's open on. A plugin's own change, a task, is undone by the plugin.
|
|
99
|
+
|
|
100
|
+
## Writing a plugin
|
|
101
|
+
|
|
102
|
+
A plugin has a server half, which runs beside the bundler, and a page half, which can draw a tab in the popup.
|
|
103
|
+
Every part is optional but its `name`.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
// my-plugin/index.ts
|
|
107
|
+
import { definePlugin } from 'deictic';
|
|
108
|
+
|
|
109
|
+
export const notes = () =>
|
|
110
|
+
definePlugin<Model, Op>({
|
|
111
|
+
name: 'notes',
|
|
112
|
+
client: 'my-plugin/client', // the page half, which the page imports
|
|
113
|
+
read: ({ element }) => ({ … }), // what the tab shows for the element
|
|
114
|
+
apply: (source, target, op) => [{ start, end, text }], // edits to the file, written by deictic, undoable
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// my-plugin/client.ts
|
|
118
|
+
import { defineClientPlugin } from 'deictic';
|
|
119
|
+
|
|
120
|
+
export default defineClientPlugin<Model, Op>({
|
|
121
|
+
name: 'notes',
|
|
122
|
+
label: 'Notes',
|
|
123
|
+
mount(panel, { model, element, apply }) {
|
|
124
|
+
// draw into `panel`; `apply(op)` writes, and answers the model read again
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Plugins add routes to the dev server (`routes`), set up an API for others (`setup`), and reach each other's with
|
|
130
|
+
`context.use(name)`: that's how tasks attaches screenshots and recordings. A change that isn't to a file answers
|
|
131
|
+
`{ done: record }`, and the plugin's `undo` and `redo` get the record back. The types in `deictic`'s index document
|
|
132
|
+
each part.
|
|
133
|
+
|
|
134
|
+
## Develop
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
bun install
|
|
138
|
+
bun dev # build, then the site on http://localhost:5180, with a board on this machine for its tasks
|
|
139
|
+
bun run test # bun test, on the source
|
|
140
|
+
bun run checks # lint + format check + type check + test
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`examples/` has the same page on Vite, Next, Rspack and Bun (`bun run dev` in each, after a build). `/internal/` on
|
|
144
|
+
the site pins deictic's own popup open at each tab, to leave tasks about deictic itself.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/plugins/annotations/client.ts"],"mappings":";cA+PA,4B"}
|
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
import { defineClientPlugin } from "../index.js";
|
|
2
|
+
const PAD = 6;
|
|
3
|
+
const guess = (text) => text.length * 14 * .6;
|
|
4
|
+
const escape = (text) => text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """);
|
|
5
|
+
const n = (value) => Math.round(value * 10) / 10;
|
|
6
|
+
/** An arrow's path: its line, then its head, two strokes back from the tip either side of the line. */
|
|
7
|
+
function arrow(from, to) {
|
|
8
|
+
const angle = Math.atan2(to.y - from.y, to.x - from.x);
|
|
9
|
+
const at = (p) => `${n(p.x)},${n(p.y)}`;
|
|
10
|
+
const side = (turn) => at({
|
|
11
|
+
x: to.x - 14 * Math.cos(angle + turn),
|
|
12
|
+
y: to.y - 14 * Math.sin(angle + turn)
|
|
13
|
+
});
|
|
14
|
+
return `M${at(from)} L${at(to)} M${side(.45)} L${at(to)} L${side(-.45)}`;
|
|
15
|
+
}
|
|
16
|
+
function shapeOf({ shape, color }, measure) {
|
|
17
|
+
const line = `fill="none" stroke="${escape(color)}" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"`;
|
|
18
|
+
switch (shape.kind) {
|
|
19
|
+
case "box": return `<rect x="${n(shape.x)}" y="${n(shape.y)}" width="${n(shape.width)}" height="${n(shape.height)}" rx="4" ${line}/>`;
|
|
20
|
+
case "arrow": return `<path d="${arrow(shape.from, shape.to)}" ${line}/>`;
|
|
21
|
+
case "pen": return `<polyline points="${shape.points.map((p) => `${n(p.x)},${n(p.y)}`).join(" ")}" ${line}/>`;
|
|
22
|
+
case "note": {
|
|
23
|
+
const lines = shape.text.split("\n");
|
|
24
|
+
const width = Math.max(...lines.map(measure)) + 12;
|
|
25
|
+
const height = lines.length * 14 * 1.3 + 12;
|
|
26
|
+
const text = lines.map((l, i) => `<tspan x="${n(shape.at.x + PAD)}" y="${n(shape.at.y + PAD + 14 * (i + 1) * 1.3 - 4.2)}">${escape(l)}</tspan>`).join("");
|
|
27
|
+
return `<rect x="${n(shape.at.x)}" y="${n(shape.at.y)}" width="${n(width)}" height="${n(height)}" rx="4" fill="${escape(color)}"/><text font-family="system-ui, sans-serif" font-size="14" fill="#fff">${text}</text>`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The annotations over `area` of the viewport, the page scrolled by `scroll`: an SVG `area`'s size,
|
|
33
|
+
* whose view is that part of the page.
|
|
34
|
+
*/
|
|
35
|
+
function toSvg(annotations, area, scroll, measure = guess) {
|
|
36
|
+
const view = `${n(area.x + scroll.x)} ${n(area.y + scroll.y)} ${n(area.width)} ${n(area.height)}`;
|
|
37
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${n(area.width)}" height="${n(area.height)}" viewBox="${view}">${annotations.map((a) => shapeOf(a, measure)).join("")}</svg>`;
|
|
38
|
+
}
|
|
39
|
+
// src/plugins/annotations/draw.ts
|
|
40
|
+
const TOOLS_STYLE = `
|
|
41
|
+
.annotations-tools { display: flex; flex-wrap: wrap; gap: 4px; }
|
|
42
|
+
.annotations-tools .icon { display: inline-flex; align-items: center; justify-content: center; padding: 3px 5px; }
|
|
43
|
+
.annotations-tools .icon svg { width: 16px; height: 16px; }
|
|
44
|
+
.annotations-tools .gap { width: 1px; align-self: stretch; margin: 2px 4px; background: var(--deictic-line); }
|
|
45
|
+
.annotations-tools button[aria-pressed='true'] { background: var(--deictic-accent); border-color: var(--deictic-accent); color: var(--deictic-on-accent); }
|
|
46
|
+
.annotations-tools .end { margin-left: auto; }
|
|
47
|
+
.annotations-hint { margin: 6px 0 0; font-size: 12px; color: var(--deictic-muted); }
|
|
48
|
+
`;
|
|
49
|
+
const TOOLS = [
|
|
50
|
+
"box",
|
|
51
|
+
"arrow",
|
|
52
|
+
"pen",
|
|
53
|
+
"note"
|
|
54
|
+
];
|
|
55
|
+
const NAMES = {
|
|
56
|
+
pointer: "Use the page",
|
|
57
|
+
box: "Draw a box",
|
|
58
|
+
arrow: "Draw an arrow",
|
|
59
|
+
pen: "Draw freehand",
|
|
60
|
+
note: "Add a note"
|
|
61
|
+
};
|
|
62
|
+
/** Each icon's strokes, on a 24-pixel grid: drawn here, so the page half needs nothing to show them. */
|
|
63
|
+
const ICONS = {
|
|
64
|
+
pointer: "<path d=\"M5 3l14 7-6 2-2 6z\"/>",
|
|
65
|
+
box: "<rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"2\"/>",
|
|
66
|
+
arrow: "<path d=\"M6 18 18 6M9 6h9v9\"/>",
|
|
67
|
+
pen: "<path d=\"M4 20l1-4L16 5a2.1 2.1 0 0 1 3 3L8 19z\"/>",
|
|
68
|
+
note: "<path d=\"M4 5h16v11H9l-5 4zM8 9h8M8 12h5\"/>",
|
|
69
|
+
undo: "<path d=\"M9 14 4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3\"/>",
|
|
70
|
+
clear: "<path d=\"M4 7h16M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3\"/>"
|
|
71
|
+
};
|
|
72
|
+
/** A button that shows an icon, with its name as its tooltip and for a screen reader. */
|
|
73
|
+
function iconButton(icon, name, run) {
|
|
74
|
+
const el = button("", name, run);
|
|
75
|
+
el.className = "icon";
|
|
76
|
+
el.setAttribute("aria-label", name);
|
|
77
|
+
el.innerHTML = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${ICONS[icon]}</svg>`;
|
|
78
|
+
return el;
|
|
79
|
+
}
|
|
80
|
+
/** Text's width as the marks draw it, by a canvas's measure, which the guess stands in for without one. */
|
|
81
|
+
function measurer() {
|
|
82
|
+
const ctx = document.createElement("canvas").getContext("2d");
|
|
83
|
+
if (ctx === null) return guess;
|
|
84
|
+
ctx.font = `14px system-ui, sans-serif`;
|
|
85
|
+
return (text) => ctx.measureText(text).width;
|
|
86
|
+
}
|
|
87
|
+
function button(label, title, run) {
|
|
88
|
+
const el = Object.assign(document.createElement("button"), {
|
|
89
|
+
type: "button",
|
|
90
|
+
textContent: label,
|
|
91
|
+
title
|
|
92
|
+
});
|
|
93
|
+
el.addEventListener("click", run);
|
|
94
|
+
return el;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Draws on `surface` with the tool picked: answers the toolbar (the tools, then removing the last mark or all), for the
|
|
98
|
+
* caller to add its own buttons to, and a hint for the tool.
|
|
99
|
+
*/
|
|
100
|
+
function drawing({ surface, at, preview, add, removeLast, clear, drawing: on }) {
|
|
101
|
+
const tools = document.createElement("div");
|
|
102
|
+
tools.className = "annotations-tools";
|
|
103
|
+
const hint = document.createElement("p");
|
|
104
|
+
hint.className = "annotations-hint";
|
|
105
|
+
let tool = on === void 0 ? "box" : "pointer";
|
|
106
|
+
const picks = (on === void 0 ? TOOLS : ["pointer", ...TOOLS]).map((t) => ({
|
|
107
|
+
t,
|
|
108
|
+
el: iconButton(t, NAMES[t], () => pick(t))
|
|
109
|
+
}));
|
|
110
|
+
const pick = (t) => {
|
|
111
|
+
tool = t;
|
|
112
|
+
for (const p of picks) p.el.setAttribute("aria-pressed", String(p.t === t));
|
|
113
|
+
on?.(t !== "pointer");
|
|
114
|
+
hint.textContent = t === "pointer" ? "Use the page; pick a tool to draw." : t === "note" ? "Click where the note goes, type it, Enter to place it." : "Drag to draw.";
|
|
115
|
+
};
|
|
116
|
+
const gap = document.createElement("span");
|
|
117
|
+
gap.className = "gap";
|
|
118
|
+
tools.append(...picks.map((p) => p.el), gap, iconButton("undo", "Remove the last mark", removeLast), iconButton("clear", "Remove every mark", clear));
|
|
119
|
+
pick(tool);
|
|
120
|
+
surface.style.cursor = "crosshair";
|
|
121
|
+
const shapeFrom = (from, to, points) => {
|
|
122
|
+
if (tool === "pen") return points.length > 1 ? {
|
|
123
|
+
kind: "pen",
|
|
124
|
+
points
|
|
125
|
+
} : void 0;
|
|
126
|
+
if (Math.hypot(to.x - from.x, to.y - from.y) < 4) return void 0;
|
|
127
|
+
if (tool === "arrow") return {
|
|
128
|
+
kind: "arrow",
|
|
129
|
+
from,
|
|
130
|
+
to
|
|
131
|
+
};
|
|
132
|
+
return {
|
|
133
|
+
kind: "box",
|
|
134
|
+
x: Math.min(from.x, to.x),
|
|
135
|
+
y: Math.min(from.y, to.y),
|
|
136
|
+
width: Math.abs(to.x - from.x),
|
|
137
|
+
height: Math.abs(to.y - from.y)
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
surface.addEventListener("pointerdown", (e) => {
|
|
141
|
+
if (e.button !== 0 || e.target instanceof HTMLInputElement) return;
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
if (tool === "note") return note(at(e), e);
|
|
144
|
+
const from = at(e);
|
|
145
|
+
const points = [from];
|
|
146
|
+
surface.setPointerCapture(e.pointerId);
|
|
147
|
+
const move = (m) => {
|
|
148
|
+
points.push(at(m));
|
|
149
|
+
preview(shapeFrom(from, at(m), points));
|
|
150
|
+
};
|
|
151
|
+
const up = (u) => {
|
|
152
|
+
surface.removeEventListener("pointermove", move);
|
|
153
|
+
preview(void 0);
|
|
154
|
+
const shape = shapeFrom(from, at(u), points);
|
|
155
|
+
if (shape !== void 0) add(shape);
|
|
156
|
+
};
|
|
157
|
+
surface.addEventListener("pointermove", move);
|
|
158
|
+
surface.addEventListener("pointerup", up, { once: true });
|
|
159
|
+
});
|
|
160
|
+
/** A field where the note goes: Enter places what's typed, leaving it empty or blurring it places nothing. */
|
|
161
|
+
const note = (point, e) => {
|
|
162
|
+
const field = Object.assign(document.createElement("input"), { placeholder: "Note, then Enter" });
|
|
163
|
+
field.style.cssText = `position:fixed;left:${e.clientX}px;top:${e.clientY}px;width:220px;pointer-events:auto;cursor:text;color:var(--deictic-fg);background:var(--deictic-bg);border-color:var(--deictic-accent)`;
|
|
164
|
+
surface.append(field);
|
|
165
|
+
const place = () => {
|
|
166
|
+
const text = field.value.trim();
|
|
167
|
+
field.remove();
|
|
168
|
+
if (text !== "") add({
|
|
169
|
+
kind: "note",
|
|
170
|
+
at: point,
|
|
171
|
+
text
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
field.addEventListener("keydown", (k) => k.key === "Enter" && place());
|
|
175
|
+
field.addEventListener("blur", () => field.isConnected && place());
|
|
176
|
+
field.focus();
|
|
177
|
+
};
|
|
178
|
+
return {
|
|
179
|
+
tools,
|
|
180
|
+
hint
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
// src/plugins/annotations/client.ts
|
|
184
|
+
/**
|
|
185
|
+
* Annotations in the page. `setup` keeps them (in the tab's session storage, per page) and shows them in a
|
|
186
|
+
* layer of deictic's overlay that lets the pointer through; it answers the API other plugins `use`. The
|
|
187
|
+
* panel is annotate mode: a toolbar, and while it's open a surface over the page that takes the pointer, so
|
|
188
|
+
* drawing never clicks the page. Esc or Done leaves it; the marks stay.
|
|
189
|
+
*
|
|
190
|
+
* The layer is deictic's, so a screenshot leaves it out with the rest of the overlay and draws the marks
|
|
191
|
+
* itself from `svg(area)`: one way to draw them, wherever a shot is rendered. `edit` draws on a picture
|
|
192
|
+
* instead, a shot most often, in the same toolbar over everything, and `flatten` makes the PNG of it.
|
|
193
|
+
*/
|
|
194
|
+
/** Under deictic's outline and panels, over the page. */
|
|
195
|
+
const LAYER = 0x7ffffffd;
|
|
196
|
+
/** Over everything of deictic's, the popup too. */
|
|
197
|
+
const TOP = 0x7fffffff;
|
|
198
|
+
const scroll = () => ({
|
|
199
|
+
x: scrollX,
|
|
200
|
+
y: scrollY
|
|
201
|
+
});
|
|
202
|
+
const viewport = () => ({
|
|
203
|
+
x: 0,
|
|
204
|
+
y: 0,
|
|
205
|
+
width: document.documentElement.clientWidth,
|
|
206
|
+
height: document.documentElement.clientHeight
|
|
207
|
+
});
|
|
208
|
+
const mark = (shape, color) => ({
|
|
209
|
+
id: crypto.randomUUID(),
|
|
210
|
+
color,
|
|
211
|
+
shape,
|
|
212
|
+
at: Date.now()
|
|
213
|
+
});
|
|
214
|
+
/** What's kept for this page in the tab's session, read as it can be. */
|
|
215
|
+
function stored(key) {
|
|
216
|
+
try {
|
|
217
|
+
const kept = JSON.parse(sessionStorage.getItem(key) ?? "[]");
|
|
218
|
+
return Array.isArray(kept) ? kept : [];
|
|
219
|
+
} catch {
|
|
220
|
+
return [];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function fixed(z) {
|
|
224
|
+
const el = document.createElement("div");
|
|
225
|
+
el.style.cssText = `position:fixed;inset:0;z-index:${z};pointer-events:none`;
|
|
226
|
+
return el;
|
|
227
|
+
}
|
|
228
|
+
const EDITOR_STYLE = `
|
|
229
|
+
.annotations-editor { position: fixed; inset: 0; z-index: ${TOP}; box-sizing: border-box; padding: 16px; display: flex;
|
|
230
|
+
flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: rgb(0 0 0 / 0.75);
|
|
231
|
+
font: 13px/1.4 system-ui, sans-serif; color: var(--deictic-fg); }
|
|
232
|
+
.annotations-editor .bar { box-sizing: border-box; width: min(100%, 720px); padding: 6px 8px; border: 1px solid var(--deictic-line);
|
|
233
|
+
border-radius: 8px; background: var(--deictic-bg); }
|
|
234
|
+
.annotations-editor .stage { position: relative; line-height: 0; box-shadow: 0 12px 32px rgb(0 0 0 / 0.5); touch-action: none; }
|
|
235
|
+
.annotations-editor img { display: block; max-width: calc(100vw - 32px); max-height: calc(100vh - 120px); user-select: none; }
|
|
236
|
+
.annotations-editor .marks { position: absolute; inset: 0; pointer-events: none; }
|
|
237
|
+
`;
|
|
238
|
+
/** Loads an image, decoded. */
|
|
239
|
+
async function image(src) {
|
|
240
|
+
const el = new Image();
|
|
241
|
+
el.src = src;
|
|
242
|
+
await el.decode();
|
|
243
|
+
return el;
|
|
244
|
+
}
|
|
245
|
+
/** The marks over a whole picture, as an SVG whose view is the picture's CSS pixels. */
|
|
246
|
+
const over = (picture, marks, measure) => toSvg(marks, {
|
|
247
|
+
x: 0,
|
|
248
|
+
y: 0,
|
|
249
|
+
width: picture.width,
|
|
250
|
+
height: picture.height
|
|
251
|
+
}, {
|
|
252
|
+
x: 0,
|
|
253
|
+
y: 0
|
|
254
|
+
}, measure);
|
|
255
|
+
/**
|
|
256
|
+
* The picture over everything, to draw on: the marks on Save, nothing on Cancel, Esc or `signal`. It holds
|
|
257
|
+
* Esc while it's open (`data-deictic-modal`), so Esc leaves it, not the popup under it.
|
|
258
|
+
*/
|
|
259
|
+
function edit(root, picture, start, { color, measure, signal }) {
|
|
260
|
+
return new Promise((resolve) => {
|
|
261
|
+
let marks = [...start];
|
|
262
|
+
const backdrop = document.createElement("div");
|
|
263
|
+
backdrop.className = "annotations-editor";
|
|
264
|
+
backdrop.dataset.deicticModal = "";
|
|
265
|
+
const style = document.createElement("style");
|
|
266
|
+
style.textContent = TOOLS_STYLE + EDITOR_STYLE;
|
|
267
|
+
const bar = document.createElement("div");
|
|
268
|
+
bar.className = "bar";
|
|
269
|
+
const stage = document.createElement("div");
|
|
270
|
+
stage.className = "stage";
|
|
271
|
+
const img = Object.assign(document.createElement("img"), {
|
|
272
|
+
src: picture.url,
|
|
273
|
+
alt: "The screenshot",
|
|
274
|
+
draggable: false
|
|
275
|
+
});
|
|
276
|
+
const layer = document.createElement("div");
|
|
277
|
+
layer.className = "marks";
|
|
278
|
+
stage.append(img, layer);
|
|
279
|
+
const show = (preview) => {
|
|
280
|
+
layer.innerHTML = over(picture, preview === void 0 ? marks : [...marks, mark(preview, color)], measure);
|
|
281
|
+
const svg = layer.firstElementChild;
|
|
282
|
+
svg?.setAttribute("width", "100%");
|
|
283
|
+
svg?.setAttribute("height", "100%");
|
|
284
|
+
};
|
|
285
|
+
const { tools, hint } = drawing({
|
|
286
|
+
surface: stage,
|
|
287
|
+
at: (e) => {
|
|
288
|
+
const r = stage.getBoundingClientRect();
|
|
289
|
+
return {
|
|
290
|
+
x: (e.clientX - r.left) * picture.width / r.width,
|
|
291
|
+
y: (e.clientY - r.top) * picture.height / r.height
|
|
292
|
+
};
|
|
293
|
+
},
|
|
294
|
+
preview: (shape) => show(shape),
|
|
295
|
+
add: (shape) => {
|
|
296
|
+
marks = [...marks, mark(shape, color)];
|
|
297
|
+
show();
|
|
298
|
+
},
|
|
299
|
+
removeLast: () => {
|
|
300
|
+
marks = marks.slice(0, -1);
|
|
301
|
+
show();
|
|
302
|
+
},
|
|
303
|
+
clear: () => {
|
|
304
|
+
marks = [];
|
|
305
|
+
show();
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
const end = (result) => {
|
|
309
|
+
backdrop.remove();
|
|
310
|
+
window.removeEventListener("keydown", onKey, true);
|
|
311
|
+
signal?.removeEventListener("abort", cancel);
|
|
312
|
+
resolve(result);
|
|
313
|
+
};
|
|
314
|
+
const cancel = () => end(void 0);
|
|
315
|
+
const onKey = (e) => {
|
|
316
|
+
if (e.key !== "Escape") return;
|
|
317
|
+
e.stopPropagation();
|
|
318
|
+
cancel();
|
|
319
|
+
};
|
|
320
|
+
const save = button("Save", "Keep these marks", () => end(marks));
|
|
321
|
+
save.classList.add("primary");
|
|
322
|
+
const back = button("Cancel", "Leave it as it was (Esc)", cancel);
|
|
323
|
+
back.classList.add("end");
|
|
324
|
+
tools.append(back, save);
|
|
325
|
+
bar.append(tools, hint);
|
|
326
|
+
backdrop.append(style, bar, stage);
|
|
327
|
+
root.append(backdrop);
|
|
328
|
+
window.addEventListener("keydown", onKey, true);
|
|
329
|
+
signal?.addEventListener("abort", cancel);
|
|
330
|
+
show();
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Marks shown on the page, in a layer of the overlay that lets the pointer through, redrawn as it
|
|
335
|
+
* scrolls. With a `key`, kept in the tab's session storage under it, per page; without, kept by nothing.
|
|
336
|
+
*/
|
|
337
|
+
function marksOnPage(root, color, measure, key) {
|
|
338
|
+
let list = key === void 0 ? [] : stored(key);
|
|
339
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
340
|
+
const layer = fixed(LAYER);
|
|
341
|
+
root.append(layer);
|
|
342
|
+
let frame = 0;
|
|
343
|
+
const draw = () => {
|
|
344
|
+
frame = 0;
|
|
345
|
+
layer.innerHTML = list.length === 0 ? "" : toSvg(list, viewport(), scroll(), measure);
|
|
346
|
+
};
|
|
347
|
+
const redraw = () => {
|
|
348
|
+
if (frame === 0) frame = requestAnimationFrame(draw);
|
|
349
|
+
};
|
|
350
|
+
window.addEventListener("scroll", redraw, {
|
|
351
|
+
capture: true,
|
|
352
|
+
passive: true
|
|
353
|
+
});
|
|
354
|
+
window.addEventListener("resize", redraw, { passive: true });
|
|
355
|
+
const changed = (event) => {
|
|
356
|
+
if (key !== void 0) try {
|
|
357
|
+
sessionStorage.setItem(key, JSON.stringify(list));
|
|
358
|
+
} catch {}
|
|
359
|
+
draw();
|
|
360
|
+
for (const listener of listeners) listener(event);
|
|
361
|
+
};
|
|
362
|
+
draw();
|
|
363
|
+
const marks = {
|
|
364
|
+
list: () => [...list],
|
|
365
|
+
add: (shape, given = color) => {
|
|
366
|
+
const annotation = mark(shape, given);
|
|
367
|
+
list = [...list, annotation];
|
|
368
|
+
changed({
|
|
369
|
+
type: "add",
|
|
370
|
+
annotation
|
|
371
|
+
});
|
|
372
|
+
return annotation;
|
|
373
|
+
},
|
|
374
|
+
remove: (id) => {
|
|
375
|
+
list = list.filter((a) => a.id !== id);
|
|
376
|
+
changed({
|
|
377
|
+
type: "remove",
|
|
378
|
+
id
|
|
379
|
+
});
|
|
380
|
+
},
|
|
381
|
+
clear: () => {
|
|
382
|
+
list = [];
|
|
383
|
+
changed({ type: "clear" });
|
|
384
|
+
},
|
|
385
|
+
subscribe: (listener) => {
|
|
386
|
+
listeners.add(listener);
|
|
387
|
+
return () => listeners.delete(listener);
|
|
388
|
+
},
|
|
389
|
+
svg: (area) => list.length === 0 ? void 0 : toSvg(list, area, scroll(), measure)
|
|
390
|
+
};
|
|
391
|
+
const remove = () => {
|
|
392
|
+
window.removeEventListener("scroll", redraw, { capture: true });
|
|
393
|
+
window.removeEventListener("resize", redraw);
|
|
394
|
+
cancelAnimationFrame(frame);
|
|
395
|
+
layer.remove();
|
|
396
|
+
listeners.clear();
|
|
397
|
+
};
|
|
398
|
+
return {
|
|
399
|
+
marks,
|
|
400
|
+
remove
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Drawing on the page: a surface over it, under the popup, and the toolbar. Where the page stays usable
|
|
405
|
+
* (`usable`), the surface takes the pointer only while a drawing tool is picked.
|
|
406
|
+
*/
|
|
407
|
+
function onPage(root, marks, color, usable) {
|
|
408
|
+
const surface = fixed(0x7ffffffe);
|
|
409
|
+
surface.style.pointerEvents = usable ? "none" : "auto";
|
|
410
|
+
const preview = fixed(0);
|
|
411
|
+
surface.append(preview);
|
|
412
|
+
root.append(surface);
|
|
413
|
+
const { tools, hint } = drawing({
|
|
414
|
+
surface,
|
|
415
|
+
at: (e) => ({
|
|
416
|
+
x: e.clientX + scrollX,
|
|
417
|
+
y: e.clientY + scrollY
|
|
418
|
+
}),
|
|
419
|
+
preview: (shape) => {
|
|
420
|
+
preview.innerHTML = shape === void 0 ? "" : toSvg([mark(shape, color)], viewport(), scroll());
|
|
421
|
+
},
|
|
422
|
+
add: (shape) => marks.add(shape),
|
|
423
|
+
removeLast: () => {
|
|
424
|
+
const last = marks.list().at(-1);
|
|
425
|
+
if (last !== void 0) marks.remove(last.id);
|
|
426
|
+
},
|
|
427
|
+
clear: () => marks.clear(),
|
|
428
|
+
...usable ? { drawing: (on) => surface.style.pointerEvents = on ? "auto" : "none" } : {}
|
|
429
|
+
});
|
|
430
|
+
return {
|
|
431
|
+
tools,
|
|
432
|
+
hint,
|
|
433
|
+
surface
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
/** The picture with the marks drawn over it, as a PNG at the picture's own resolution. */
|
|
437
|
+
async function flatten(picture, marks, measure) {
|
|
438
|
+
const base = await image(picture.url);
|
|
439
|
+
const canvas = document.createElement("canvas");
|
|
440
|
+
canvas.width = base.naturalWidth;
|
|
441
|
+
canvas.height = base.naturalHeight;
|
|
442
|
+
const ctx = canvas.getContext("2d");
|
|
443
|
+
if (ctx === null) throw new Error("annotations: this browser won't draw to a canvas");
|
|
444
|
+
ctx.drawImage(base, 0, 0);
|
|
445
|
+
if (marks.length > 0) {
|
|
446
|
+
const svg = await image(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(over(picture, marks, measure))}`);
|
|
447
|
+
ctx.drawImage(svg, 0, 0, canvas.width, canvas.height);
|
|
448
|
+
}
|
|
449
|
+
return new Promise((done, fail) => canvas.toBlob((blob) => blob === null ? fail(/* @__PURE__ */ new Error("annotations: the picture drew nothing")) : done(blob), "image/png"));
|
|
450
|
+
}
|
|
451
|
+
var client_default = defineClientPlugin({
|
|
452
|
+
name: "annotations",
|
|
453
|
+
label: "Annotate",
|
|
454
|
+
setup: ({ root, options }) => {
|
|
455
|
+
const color = options.color;
|
|
456
|
+
const measure = measurer();
|
|
457
|
+
return {
|
|
458
|
+
...marksOnPage(root, color, measure, `deictic:annotations:${location.pathname}`).marks,
|
|
459
|
+
edit: (picture, marks = [], { signal } = {}) => edit(root, picture, marks, {
|
|
460
|
+
color,
|
|
461
|
+
measure,
|
|
462
|
+
...signal ? { signal } : {}
|
|
463
|
+
}),
|
|
464
|
+
flatten: (picture, marks) => flatten(picture, marks, measure),
|
|
465
|
+
tools: () => {
|
|
466
|
+
const own = marksOnPage(root, color, measure);
|
|
467
|
+
const { tools, surface } = onPage(root, own.marks, color, true);
|
|
468
|
+
const element = document.createElement("div");
|
|
469
|
+
element.append(Object.assign(document.createElement("style"), { textContent: TOOLS_STYLE }), tools);
|
|
470
|
+
return {
|
|
471
|
+
element,
|
|
472
|
+
marks: own.marks,
|
|
473
|
+
close: () => {
|
|
474
|
+
surface.remove();
|
|
475
|
+
own.remove();
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
},
|
|
481
|
+
mount: (panel, { root, use, close, options }) => {
|
|
482
|
+
const { color } = options;
|
|
483
|
+
const marks = use("annotations");
|
|
484
|
+
if (marks === void 0) return;
|
|
485
|
+
const style = document.createElement("style");
|
|
486
|
+
style.textContent = TOOLS_STYLE;
|
|
487
|
+
const { tools, hint, surface } = onPage(root, marks, color, false);
|
|
488
|
+
const done = button("Done", "Leave annotate mode (Esc)", close);
|
|
489
|
+
done.classList.add("primary", "end");
|
|
490
|
+
tools.append(done);
|
|
491
|
+
panel.append(style, tools, hint);
|
|
492
|
+
return () => surface.remove();
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
export { client_default as default };
|
|
496
|
+
|
|
497
|
+
//# sourceMappingURL=client.js.map
|