strata-react 2.1.7 → 2.1.9
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 +1 -0
- package/UPGRADING.md +4 -0
- package/dist/index.d.ts +253 -3
- package/dist/index.js +1220 -21
- package/dist/index.js.map +1 -1
- package/dist/{microphone-xGKxcK6p.d.ts → microphone-DWh4OaMH.d.ts} +2 -2
- package/dist/testing.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { a as fieldErrorsOf, i as errorPayload, n as describeActionError, o as r
|
|
|
10
10
|
import { a as PaletteChoice, c as paletteScript, d as usePalette, f as useSystemColorScheme, i as PALETTE_STORAGE_KEY, l as palettes, n as ColorSchemeChoice, o as ThemeProvider, p as Density, r as DEFAULT_PALETTE, s as colorSchemeScript, t as COLOR_SCHEME_STORAGE_KEY, u as useColorScheme } from "./theme-5Mb1ydlA.js";
|
|
11
11
|
import * as React from "react";
|
|
12
12
|
import { Autocomplete, Button as Button$1, Cell, Checkbox as Checkbox$1, Collection, Column, Dialog as Dialog$1, DialogTrigger, Disclosure as Disclosure$1, DisclosurePanel, DropIndicator, DropZone, FileTrigger, GridLayout, GridList, GridListItem, Header, Heading, Input as Input$1, Keyboard, Link, ListBox, ListBoxItem, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, Popover as Popover$1, RouterProvider, Row, SearchField, Select, SelectValue, Separator, Slider as Slider$1, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Tree as Tree$1, TreeItem, TreeItemContent, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
|
|
13
|
-
import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronsUp, CircleAlert, CircleCheck, CircleDashed, Clock, CloudOff, Columns2, Ellipsis, Eye, EyeOff, FastForward, FileQuestion, Flag, Folder, FolderOpen, FolderX, GripVertical, ImageOff, Info, KeyRound, LayoutGrid, List, Loader, LoaderCircle, Lock, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Pencil, Play, Redo2, Rewind, RotateCcw, RotateCw, Scan, Search, Send, SkipBack, SkipForward, SlidersHorizontal, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
13
|
+
import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Brush, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronsUp, CircleAlert, CircleCheck, CircleDashed, Clock, CloudOff, Columns2, Ellipsis, Eraser, Eye, EyeOff, FastForward, FileQuestion, Flag, Folder, FolderOpen, FolderX, GripVertical, Hand, Highlighter, ImageOff, Info, KeyRound, LayoutGrid, List, Loader, LoaderCircle, Lock, Maximize, Maximize2, Minimize, Minus, MousePointer2, Paintbrush, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, PenLine, Pencil, Play, Redo2, Rewind, RotateCcw, RotateCw, Scan, Search, Send, SkipBack, SkipForward, SlidersHorizontal, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
14
14
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
15
|
import { Link as Link$1, NavLink, useHref, useNavigate, useSearchParams } from "react-router";
|
|
16
16
|
import { hashKey, useInfiniteQuery, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
@@ -12001,7 +12001,7 @@ const CLICK_MAX_MS = 500;
|
|
|
12001
12001
|
/** A click counts only once this long has passed with no second press: a double click zooms instead. */
|
|
12002
12002
|
const DOUBLE_CLICK_MS = 300;
|
|
12003
12003
|
/** A clipped frame whose children zoom and pan together; the viewport is the caller's, so frames can share one. */
|
|
12004
|
-
const ViewportFrame = React.forwardRef(function ViewportFrame({ label, aspect, viewport, setViewport, children, cover, overlay, maxHeight, onBox, outline, pick, className }, forwardedRef) {
|
|
12004
|
+
const ViewportFrame = React.forwardRef(function ViewportFrame({ label, aspect, viewport, setViewport, children, cover, markup, overlay, maxHeight, onBox, outline, pick, className }, forwardedRef) {
|
|
12005
12005
|
const ref = React.useRef(null);
|
|
12006
12006
|
React.useImperativeHandle(forwardedRef, () => ref.current);
|
|
12007
12007
|
const latest = React.useRef(viewport);
|
|
@@ -12213,6 +12213,14 @@ const ViewportFrame = React.forwardRef(function ViewportFrame({ label, aspect, v
|
|
|
12213
12213
|
children: cover.content
|
|
12214
12214
|
})
|
|
12215
12215
|
}),
|
|
12216
|
+
markup != null && /* @__PURE__ */ jsx("div", {
|
|
12217
|
+
className: "pointer-events-none absolute inset-0",
|
|
12218
|
+
style: {
|
|
12219
|
+
transform: viewportTransform(viewport),
|
|
12220
|
+
transformOrigin: "center"
|
|
12221
|
+
},
|
|
12222
|
+
children: markup
|
|
12223
|
+
}),
|
|
12216
12224
|
outline && viewport.scale === 1 && /* @__PURE__ */ jsx("div", {
|
|
12217
12225
|
"aria-hidden": true,
|
|
12218
12226
|
className: "pointer-events-none absolute border-2 border-foreground ring-1 ring-background",
|
|
@@ -12867,9 +12875,19 @@ function useBeckon(on, open, ms) {
|
|
|
12867
12875
|
className: lit.beat % 2 ? "beckon" : "beckon-again"
|
|
12868
12876
|
} : null;
|
|
12869
12877
|
}
|
|
12878
|
+
const TILE = "min(var(--type-picture-size, 4.5rem), 75cqi)";
|
|
12879
|
+
const WORD$1 = /^\p{L}[\p{L}\p{M}' -]*$/u;
|
|
12880
|
+
const WORD_SHARE = 140;
|
|
12881
|
+
const letters = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
12870
12882
|
/** A tile's picture: the `type-picture` step, but never more than 75% of the tile it sits in (the tile is a size
|
|
12871
|
-
* container), so an app that grows the step on a wide screen does not push a picture out of a small tile.
|
|
12872
|
-
|
|
12883
|
+
* container), so an app that grows the step on a wide screen does not push a picture out of a small tile. A word of
|
|
12884
|
+
* three letters or more (`content` a string of letters) is made smaller still, so the whole word fits across the tile:
|
|
12885
|
+
* the longer the word, the smaller. */
|
|
12886
|
+
function pictureInTile(content) {
|
|
12887
|
+
if (typeof content !== "string" || !WORD$1.test(content)) return { fontSize: TILE };
|
|
12888
|
+
const n = [...letters.segment(content)].length;
|
|
12889
|
+
return n <= 2 ? { fontSize: TILE } : { fontSize: `min(var(--type-picture-size, 4.5rem), 75cqi, ${Math.round(WORD_SHARE / n * 10) / 10}cqi)` };
|
|
12890
|
+
}
|
|
12873
12891
|
|
|
12874
12892
|
// src/components/choice-grid.tsx
|
|
12875
12893
|
const minSide = {
|
|
@@ -12906,12 +12924,15 @@ function ChoiceGrid({ label, items, itemKey, itemLabel, renderPicture, state, ma
|
|
|
12906
12924
|
"data-choice": s,
|
|
12907
12925
|
"data-beckon": key === lit?.key || void 0,
|
|
12908
12926
|
className: cn("@container flex aspect-square min-w-0 cursor-pointer flex-col items-center justify-center gap-1 rounded-overlay border-2 border-border bg-card p-2 text-card-foreground select-none outline-offset-2 transition-state press", "hover:border-primary disabled:cursor-default disabled:hover:border-border", key === lit?.key && cn(lit.className, "border-primary"), (s === "right" || s === "answer") && "border-4 border-success bg-success-subtle disabled:hover:border-success", s === "picked" && "border-4 border-primary bg-surface-sunken disabled:hover:border-primary"),
|
|
12909
|
-
children: [
|
|
12910
|
-
|
|
12911
|
-
|
|
12912
|
-
|
|
12913
|
-
|
|
12914
|
-
|
|
12927
|
+
children: [(() => {
|
|
12928
|
+
const drawn = renderPicture(item);
|
|
12929
|
+
return /* @__PURE__ */ jsx("span", {
|
|
12930
|
+
"aria-hidden": true,
|
|
12931
|
+
className: cn("type-picture transition-state", s === "wrong" && "opacity-40"),
|
|
12932
|
+
style: pictureInTile(drawn),
|
|
12933
|
+
children: drawn
|
|
12934
|
+
});
|
|
12935
|
+
})(), mark && /* @__PURE__ */ jsx(Status, {
|
|
12915
12936
|
tone: s === "wrong" || s === "picked" ? "neutral" : "success",
|
|
12916
12937
|
className: "max-w-full truncate",
|
|
12917
12938
|
children: mark
|
|
@@ -13063,15 +13084,18 @@ function PlaceBoard({ label, pieces, pieceKey, pieceLabel, renderPiece, places,
|
|
|
13063
13084
|
else buttons.current.delete(key);
|
|
13064
13085
|
};
|
|
13065
13086
|
const pieceClass = (key) => cn("@container relative flex aspect-square w-full min-w-0 cursor-pointer flex-col items-center justify-center gap-1 rounded-overlay border-2 border-border bg-card p-1 text-card-foreground select-none outline-offset-2 transition-state press", "hover:border-primary disabled:cursor-default disabled:hover:border-border", "selected:border-info selected:bg-info-subtle selected:ring-4 selected:ring-info", key === lit?.key && cn(lit.className, "border-primary"));
|
|
13066
|
-
const picture = (p, placed) =>
|
|
13067
|
-
|
|
13068
|
-
|
|
13069
|
-
|
|
13070
|
-
|
|
13071
|
-
|
|
13072
|
-
|
|
13073
|
-
|
|
13074
|
-
|
|
13087
|
+
const picture = (p, placed) => {
|
|
13088
|
+
const drawn = renderPiece(p);
|
|
13089
|
+
return /* @__PURE__ */ jsx("span", {
|
|
13090
|
+
"aria-hidden": true,
|
|
13091
|
+
className: "type-picture",
|
|
13092
|
+
style: placed ? {
|
|
13093
|
+
...placedPicture,
|
|
13094
|
+
...pictureInTile(drawn)
|
|
13095
|
+
} : pictureInTile(drawn),
|
|
13096
|
+
children: drawn
|
|
13097
|
+
});
|
|
13098
|
+
};
|
|
13075
13099
|
const piece = (p, placed) => {
|
|
13076
13100
|
const key = pieceKey(p);
|
|
13077
13101
|
const isHeld = held !== void 0 && pieceKey(held) === key;
|
|
@@ -16510,7 +16534,7 @@ function inkWords(m, a, b) {
|
|
|
16510
16534
|
return `${format.share(m.agreement)} of the ink agrees. Ink only in ${a}: ${only(m.matchedA, m.inkA)} of its ink; only in ${b}: ${only(m.matchedB, m.inkB)}.`;
|
|
16511
16535
|
}
|
|
16512
16536
|
/** Two pictures to judge, side by side or laid over each other, zoomed and panned together, and full screen. */
|
|
16513
|
-
function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_MODES, regions, onPick, pick = true, pickWords, keys = true, extraShortcuts = [], footer, maxHeight, reserve, cannotCompare = "Could not read these pictures to compare their pixels.", readPixels, defaultDifference = "brightness", className }) {
|
|
16537
|
+
function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_MODES, regions, onPick, pick = true, pickWords, keys = true, extraShortcuts = [], markup, footer, maxHeight, reserve, cannotCompare = "Could not read these pictures to compare their pixels.", readPixels, defaultDifference = "brightness", className }) {
|
|
16514
16538
|
const { viewport, setViewport } = useViewport();
|
|
16515
16539
|
const [full, setFull] = React.useState(false);
|
|
16516
16540
|
const pairKey = `${a.media.src}|${b.media.src}`;
|
|
@@ -16581,6 +16605,10 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
16581
16605
|
size: [w, h]
|
|
16582
16606
|
});
|
|
16583
16607
|
const picker = pick && onPick ? makePicker(a, b, onPick, pickWords) : null;
|
|
16608
|
+
const layer = (primary) => markup && natural ? markup({
|
|
16609
|
+
size: natural,
|
|
16610
|
+
primary
|
|
16611
|
+
}) : void 0;
|
|
16584
16612
|
const frameProps = {
|
|
16585
16613
|
viewport,
|
|
16586
16614
|
setViewport: rg.setViewport,
|
|
@@ -16602,6 +16630,7 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
16602
16630
|
label: blind ? `Picture ${c.label}` : `${c.label}`,
|
|
16603
16631
|
ref: i === 0 ? frameRef : void 0,
|
|
16604
16632
|
pick: picker?.one(i === 0 ? "a" : "b"),
|
|
16633
|
+
markup: layer(i === 0),
|
|
16605
16634
|
children: pane(c, i === 0 ? imgRef : void 0, i === 0 ? learn : void 0)
|
|
16606
16635
|
})]
|
|
16607
16636
|
}, i))
|
|
@@ -16627,6 +16656,7 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
16627
16656
|
}), /* @__PURE__ */ jsx(ViewportFrame, {
|
|
16628
16657
|
...frameProps,
|
|
16629
16658
|
ref: frameRef,
|
|
16659
|
+
markup: layer(true),
|
|
16630
16660
|
label: `Difference between ${a.label} and ${b.label}`,
|
|
16631
16661
|
children: style === "brightness" ? /* @__PURE__ */ jsxs("div", {
|
|
16632
16662
|
className: "absolute inset-0 isolate",
|
|
@@ -16677,6 +16707,7 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
16677
16707
|
}), /* @__PURE__ */ jsxs(ViewportFrame, {
|
|
16678
16708
|
...frameProps,
|
|
16679
16709
|
ref: frameRef,
|
|
16710
|
+
markup: layer(true),
|
|
16680
16711
|
label: `Ink of ${a.label} matched against ${b.label}`,
|
|
16681
16712
|
children: [
|
|
16682
16713
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -16717,6 +16748,7 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
16717
16748
|
}), /* @__PURE__ */ jsxs(ViewportFrame, {
|
|
16718
16749
|
...frameProps,
|
|
16719
16750
|
ref: frameRef,
|
|
16751
|
+
markup: layer(true),
|
|
16720
16752
|
cover: mode === "swipe" ? {
|
|
16721
16753
|
content: pane(a, imgRef, learn),
|
|
16722
16754
|
shown: divider,
|
|
@@ -19198,6 +19230,1173 @@ function useHistoryState(initial, options) {
|
|
|
19198
19230
|
};
|
|
19199
19231
|
}
|
|
19200
19232
|
|
|
19233
|
+
// src/lib/drawing.ts
|
|
19234
|
+
/** A drawing with nothing on it. */
|
|
19235
|
+
function emptyDrawing(width, height) {
|
|
19236
|
+
return {
|
|
19237
|
+
width,
|
|
19238
|
+
height,
|
|
19239
|
+
strokes: []
|
|
19240
|
+
};
|
|
19241
|
+
}
|
|
19242
|
+
/** The tools' starting brushes. The widths are for a drawing about 1000 units wide; scale them for another. */
|
|
19243
|
+
const BRUSHES = {
|
|
19244
|
+
pen: {
|
|
19245
|
+
kind: "pen",
|
|
19246
|
+
colour: "#1b1b1f",
|
|
19247
|
+
width: 3,
|
|
19248
|
+
opacity: 1,
|
|
19249
|
+
hardness: 1,
|
|
19250
|
+
nib: "round",
|
|
19251
|
+
pressure: true
|
|
19252
|
+
},
|
|
19253
|
+
pencil: {
|
|
19254
|
+
kind: "pencil",
|
|
19255
|
+
colour: "#3a3a40",
|
|
19256
|
+
width: 2.5,
|
|
19257
|
+
opacity: .85,
|
|
19258
|
+
hardness: .7,
|
|
19259
|
+
nib: "round",
|
|
19260
|
+
pressure: true
|
|
19261
|
+
},
|
|
19262
|
+
marker: {
|
|
19263
|
+
kind: "marker",
|
|
19264
|
+
colour: "#e5156b",
|
|
19265
|
+
width: 10,
|
|
19266
|
+
opacity: .9,
|
|
19267
|
+
hardness: .9,
|
|
19268
|
+
nib: "round",
|
|
19269
|
+
pressure: false
|
|
19270
|
+
},
|
|
19271
|
+
highlighter: {
|
|
19272
|
+
kind: "highlighter",
|
|
19273
|
+
colour: "#ffe600",
|
|
19274
|
+
width: 22,
|
|
19275
|
+
opacity: .4,
|
|
19276
|
+
hardness: 1,
|
|
19277
|
+
nib: "chisel",
|
|
19278
|
+
nibAngle: 60,
|
|
19279
|
+
pressure: false,
|
|
19280
|
+
blend: "multiply"
|
|
19281
|
+
},
|
|
19282
|
+
brush: {
|
|
19283
|
+
kind: "brush",
|
|
19284
|
+
colour: "#1f5fbf",
|
|
19285
|
+
width: 14,
|
|
19286
|
+
opacity: .8,
|
|
19287
|
+
hardness: .4,
|
|
19288
|
+
nib: "round",
|
|
19289
|
+
pressure: true
|
|
19290
|
+
}
|
|
19291
|
+
};
|
|
19292
|
+
/**
|
|
19293
|
+
* The feedback marker: thick, half see-through, a strong bright colour, so it shows on a white page,
|
|
19294
|
+
* a yellowed scan and black type alike and is never mistaken for the page's own ink. `scale` is the
|
|
19295
|
+
* drawing's width over 1000.
|
|
19296
|
+
*/
|
|
19297
|
+
function feedbackMarker(scale = 1) {
|
|
19298
|
+
return {
|
|
19299
|
+
kind: "marker",
|
|
19300
|
+
colour: "#ff1493",
|
|
19301
|
+
width: 24 * scale,
|
|
19302
|
+
opacity: .45,
|
|
19303
|
+
hardness: 1,
|
|
19304
|
+
nib: "round",
|
|
19305
|
+
pressure: false
|
|
19306
|
+
};
|
|
19307
|
+
}
|
|
19308
|
+
/** The drawing after one operation. Pure: the drawing given is not changed. An op that does not apply (an unknown id) gives the drawing back as it was. */
|
|
19309
|
+
function applyOp(d, op) {
|
|
19310
|
+
if (op.op === "add") {
|
|
19311
|
+
const strokes = d.strokes.slice();
|
|
19312
|
+
strokes.splice(Math.min(Math.max(op.index, 0), strokes.length), 0, op.stroke);
|
|
19313
|
+
return {
|
|
19314
|
+
...d,
|
|
19315
|
+
strokes
|
|
19316
|
+
};
|
|
19317
|
+
}
|
|
19318
|
+
if (op.op === "remove") {
|
|
19319
|
+
const at = d.strokes.findIndex((s) => s.id === op.stroke.id);
|
|
19320
|
+
if (at < 0) return d;
|
|
19321
|
+
return {
|
|
19322
|
+
...d,
|
|
19323
|
+
strokes: d.strokes.filter((_, i) => i !== at)
|
|
19324
|
+
};
|
|
19325
|
+
}
|
|
19326
|
+
const at = d.strokes.findIndex((s) => s.id === op.id);
|
|
19327
|
+
if (at < 0) return d;
|
|
19328
|
+
const strokes = d.strokes.slice();
|
|
19329
|
+
strokes[at] = withChange(strokes[at], op.after);
|
|
19330
|
+
return {
|
|
19331
|
+
...d,
|
|
19332
|
+
strokes
|
|
19333
|
+
};
|
|
19334
|
+
}
|
|
19335
|
+
function withChange(s, c) {
|
|
19336
|
+
const next = {
|
|
19337
|
+
...s,
|
|
19338
|
+
...c
|
|
19339
|
+
};
|
|
19340
|
+
if ("note" in c && !c.note) delete next.note;
|
|
19341
|
+
return next;
|
|
19342
|
+
}
|
|
19343
|
+
/** The operation that undoes `op`. Needs no document: every op carries what it replaced. */
|
|
19344
|
+
function invertOp(op) {
|
|
19345
|
+
if (op.op === "add") return {
|
|
19346
|
+
op: "remove",
|
|
19347
|
+
stroke: op.stroke,
|
|
19348
|
+
index: op.index
|
|
19349
|
+
};
|
|
19350
|
+
if (op.op === "remove") return {
|
|
19351
|
+
op: "add",
|
|
19352
|
+
stroke: op.stroke,
|
|
19353
|
+
index: op.index
|
|
19354
|
+
};
|
|
19355
|
+
return {
|
|
19356
|
+
op: "change",
|
|
19357
|
+
id: op.id,
|
|
19358
|
+
before: op.after,
|
|
19359
|
+
after: op.before
|
|
19360
|
+
};
|
|
19361
|
+
}
|
|
19362
|
+
/** Applies each operation in turn: the log from `useDrawing` rebuilds the drawing it made. */
|
|
19363
|
+
function replay(d, ops) {
|
|
19364
|
+
return ops.reduce(applyOp, d);
|
|
19365
|
+
}
|
|
19366
|
+
/** The fields of `s` that `change` would replace, as they are now: the `before` of a change op. */
|
|
19367
|
+
function currentOf(s, change) {
|
|
19368
|
+
const before = {};
|
|
19369
|
+
if ("points" in change) before.points = s.points;
|
|
19370
|
+
if ("brush" in change) before.brush = s.brush;
|
|
19371
|
+
if ("note" in change) before.note = s.note ?? "";
|
|
19372
|
+
return before;
|
|
19373
|
+
}
|
|
19374
|
+
/** A drawing scaled into another coordinate space (the same picture served at another size). Widths scale with the mean of the two factors. */
|
|
19375
|
+
function rescaleDrawing(d, width, height) {
|
|
19376
|
+
if (d.width === width && d.height === height) return d;
|
|
19377
|
+
const sx = d.width ? width / d.width : 1;
|
|
19378
|
+
const sy = d.height ? height / d.height : 1;
|
|
19379
|
+
const sw = (sx + sy) / 2;
|
|
19380
|
+
return {
|
|
19381
|
+
width,
|
|
19382
|
+
height,
|
|
19383
|
+
strokes: d.strokes.map((s) => ({
|
|
19384
|
+
...s,
|
|
19385
|
+
brush: {
|
|
19386
|
+
...s.brush,
|
|
19387
|
+
width: s.brush.width * sw
|
|
19388
|
+
},
|
|
19389
|
+
points: s.points.map((p) => scalePoint(p, 0, 0, sx, sy))
|
|
19390
|
+
}))
|
|
19391
|
+
};
|
|
19392
|
+
}
|
|
19393
|
+
function scalePoint(p, ox, oy, sx, sy) {
|
|
19394
|
+
const x = ox + (p[0] - ox) * sx;
|
|
19395
|
+
const y = oy + (p[1] - oy) * sy;
|
|
19396
|
+
return p[2] === void 0 ? [x, y] : [
|
|
19397
|
+
x,
|
|
19398
|
+
y,
|
|
19399
|
+
p[2]
|
|
19400
|
+
];
|
|
19401
|
+
}
|
|
19402
|
+
/** The box a stroke's points span, not counting its width. */
|
|
19403
|
+
function pointsBox(points) {
|
|
19404
|
+
let x0 = Infinity;
|
|
19405
|
+
let y0 = Infinity;
|
|
19406
|
+
let x1 = -Infinity;
|
|
19407
|
+
let y1 = -Infinity;
|
|
19408
|
+
for (const [x, y] of points) {
|
|
19409
|
+
if (x < x0) x0 = x;
|
|
19410
|
+
if (y < y0) y0 = y;
|
|
19411
|
+
if (x > x1) x1 = x;
|
|
19412
|
+
if (y > y1) y1 = y;
|
|
19413
|
+
}
|
|
19414
|
+
return points.length ? [
|
|
19415
|
+
x0,
|
|
19416
|
+
y0,
|
|
19417
|
+
x1,
|
|
19418
|
+
y1
|
|
19419
|
+
] : [
|
|
19420
|
+
0,
|
|
19421
|
+
0,
|
|
19422
|
+
0,
|
|
19423
|
+
0
|
|
19424
|
+
];
|
|
19425
|
+
}
|
|
19426
|
+
/** The box a stroke covers, ink and all: its points' box grown by half its width. */
|
|
19427
|
+
function strokeBox(s) {
|
|
19428
|
+
const [x0, y0, x1, y1] = pointsBox(s.points);
|
|
19429
|
+
const h = s.brush.width / 2;
|
|
19430
|
+
return [
|
|
19431
|
+
x0 - h,
|
|
19432
|
+
y0 - h,
|
|
19433
|
+
x1 + h,
|
|
19434
|
+
y1 + h
|
|
19435
|
+
];
|
|
19436
|
+
}
|
|
19437
|
+
/** The stroke's points moved by `dx`, `dy`. */
|
|
19438
|
+
function movePoints(points, dx, dy) {
|
|
19439
|
+
return points.map((p) => p[2] === void 0 ? [p[0] + dx, p[1] + dy] : [
|
|
19440
|
+
p[0] + dx,
|
|
19441
|
+
p[1] + dy,
|
|
19442
|
+
p[2]
|
|
19443
|
+
]);
|
|
19444
|
+
}
|
|
19445
|
+
/** The stroke's points mapped from the box `from` onto the box `to` (a resize by a corner). A box with no width or height keeps that axis. */
|
|
19446
|
+
function fitPoints(points, from, to) {
|
|
19447
|
+
const fw = from[2] - from[0];
|
|
19448
|
+
const fh = from[3] - from[1];
|
|
19449
|
+
const sx = fw ? (to[2] - to[0]) / fw : 1;
|
|
19450
|
+
const sy = fh ? (to[3] - to[1]) / fh : 1;
|
|
19451
|
+
const dx = fw ? to[0] - from[0] : (to[0] + to[2]) / 2 - (from[0] + from[2]) / 2;
|
|
19452
|
+
const dy = fh ? to[1] - from[1] : (to[1] + to[3]) / 2 - (from[1] + from[3]) / 2;
|
|
19453
|
+
return points.map((p) => {
|
|
19454
|
+
const x = from[0] + (p[0] - from[0]) * sx + dx;
|
|
19455
|
+
const y = from[1] + (p[1] - from[1]) * sy + dy;
|
|
19456
|
+
return p[2] === void 0 ? [x, y] : [
|
|
19457
|
+
x,
|
|
19458
|
+
y,
|
|
19459
|
+
p[2]
|
|
19460
|
+
];
|
|
19461
|
+
});
|
|
19462
|
+
}
|
|
19463
|
+
/** Distance from a point to the segment a-b. */
|
|
19464
|
+
function segmentDistance(px, py, a, b) {
|
|
19465
|
+
const dx = b[0] - a[0];
|
|
19466
|
+
const dy = b[1] - a[1];
|
|
19467
|
+
const len = dx * dx + dy * dy;
|
|
19468
|
+
const t = len ? Math.min(1, Math.max(0, ((px - a[0]) * dx + (py - a[1]) * dy) / len)) : 0;
|
|
19469
|
+
return Math.hypot(px - (a[0] + t * dx), py - (a[1] + t * dy));
|
|
19470
|
+
}
|
|
19471
|
+
/** Whether the point lies on the stroke's ink, or within `slop` units of it. */
|
|
19472
|
+
function hitsStroke(s, x, y, slop = 0) {
|
|
19473
|
+
const reach = s.brush.width / 2 + slop;
|
|
19474
|
+
const pts = curvePoints(s.points);
|
|
19475
|
+
if (pts.length === 1) return Math.hypot(x - pts[0][0], y - pts[0][1]) <= reach;
|
|
19476
|
+
for (let i = 1; i < pts.length; i++) if (segmentDistance(x, y, pts[i - 1], pts[i]) <= reach) return true;
|
|
19477
|
+
return false;
|
|
19478
|
+
}
|
|
19479
|
+
/** The points of the path `smoothPath` draws, its curves cut into eight straight pieces each: what hit tests measure against. */
|
|
19480
|
+
function curvePoints(points) {
|
|
19481
|
+
if (points.length < 3) return points.slice();
|
|
19482
|
+
const out = [points[0]];
|
|
19483
|
+
let from = [points[0][0], points[0][1]];
|
|
19484
|
+
for (let i = 1; i < points.length - 1; i++) {
|
|
19485
|
+
const c = points[i];
|
|
19486
|
+
const n = points[i + 1];
|
|
19487
|
+
const to = [(c[0] + n[0]) / 2, (c[1] + n[1]) / 2];
|
|
19488
|
+
for (let k = 1; k <= 8; k++) {
|
|
19489
|
+
const t = k / 8;
|
|
19490
|
+
const u = 1 - t;
|
|
19491
|
+
out.push([u * u * from[0] + 2 * u * t * c[0] + t * t * to[0], u * u * from[1] + 2 * u * t * c[1] + t * t * to[1]]);
|
|
19492
|
+
}
|
|
19493
|
+
from = to;
|
|
19494
|
+
}
|
|
19495
|
+
out.push(points[points.length - 1]);
|
|
19496
|
+
return out;
|
|
19497
|
+
}
|
|
19498
|
+
/** The topmost stroke under the point, or undefined. */
|
|
19499
|
+
function strokeAt(d, x, y, slop = 0) {
|
|
19500
|
+
for (let i = d.strokes.length - 1; i >= 0; i--) if (hitsStroke(d.strokes[i], x, y, slop)) return d.strokes[i];
|
|
19501
|
+
}
|
|
19502
|
+
/**
|
|
19503
|
+
* Fewer points along the same line (Ramer-Douglas-Peucker, within `tolerance` units), so a stroke
|
|
19504
|
+
* saved is a few dozen points, not one per pointer event. A point where the pressure changes by more
|
|
19505
|
+
* than a tenth is kept, so a pressed line keeps its swell.
|
|
19506
|
+
*/
|
|
19507
|
+
function simplifyPoints(points, tolerance) {
|
|
19508
|
+
if (points.length < 3) return points.slice();
|
|
19509
|
+
const keep = new Uint8Array(points.length);
|
|
19510
|
+
keep[0] = keep[points.length - 1] = 1;
|
|
19511
|
+
const stack = [[0, points.length - 1]];
|
|
19512
|
+
while (stack.length) {
|
|
19513
|
+
const [a, b] = stack.pop();
|
|
19514
|
+
let worst = -1;
|
|
19515
|
+
let at = -1;
|
|
19516
|
+
for (let i = a + 1; i < b; i++) {
|
|
19517
|
+
const d = segmentDistance(points[i][0], points[i][1], points[a], points[b]);
|
|
19518
|
+
const score = Math.abs((points[i][2] ?? .5) - ((points[a][2] ?? .5) + (points[b][2] ?? .5)) / 2) > .1 ? Infinity : d;
|
|
19519
|
+
if (score > worst) {
|
|
19520
|
+
worst = score;
|
|
19521
|
+
at = i;
|
|
19522
|
+
}
|
|
19523
|
+
}
|
|
19524
|
+
if (at >= 0 && worst > tolerance) {
|
|
19525
|
+
keep[at] = 1;
|
|
19526
|
+
stack.push([a, at], [at, b]);
|
|
19527
|
+
}
|
|
19528
|
+
}
|
|
19529
|
+
return points.filter((_, i) => keep[i]);
|
|
19530
|
+
}
|
|
19531
|
+
/** The width of the stroke at each of its points: the brush's width, times its pressure where it follows it, times a chisel's angle against the stroke's direction. */
|
|
19532
|
+
function widthsOf(s) {
|
|
19533
|
+
const { brush, points } = s;
|
|
19534
|
+
const angle = (brush.nibAngle ?? 45) * Math.PI / 180;
|
|
19535
|
+
return points.map((p, i) => {
|
|
19536
|
+
let w = brush.width;
|
|
19537
|
+
if (brush.pressure) w *= .25 + .75 * (p[2] ?? .5);
|
|
19538
|
+
if (brush.nib === "chisel" && points.length > 1) {
|
|
19539
|
+
const a = points[Math.max(0, i - 1)];
|
|
19540
|
+
const b = points[Math.min(points.length - 1, i + 1)];
|
|
19541
|
+
const dir = Math.atan2(b[1] - a[1], b[0] - a[0]);
|
|
19542
|
+
w *= .2 + .8 * Math.abs(Math.sin(dir - angle));
|
|
19543
|
+
}
|
|
19544
|
+
return w;
|
|
19545
|
+
});
|
|
19546
|
+
}
|
|
19547
|
+
const fix = (n) => Math.round(n * 100) / 100;
|
|
19548
|
+
/** Quadratic curves through `points`: to the first midpoint, through each point to the next midpoint, then to the last. `start` is "M" to begin a path, "L" to join one. */
|
|
19549
|
+
function curveThrough(points, start) {
|
|
19550
|
+
let d = `${start}${fix(points[0][0])} ${fix(points[0][1])}`;
|
|
19551
|
+
for (let i = 1; i < points.length - 1; i++) {
|
|
19552
|
+
const [x, y] = points[i];
|
|
19553
|
+
const [nx, ny] = points[i + 1];
|
|
19554
|
+
d += `Q${fix(x)} ${fix(y)} ${fix((x + nx) / 2)} ${fix((y + ny) / 2)}`;
|
|
19555
|
+
}
|
|
19556
|
+
if (points.length > 1) {
|
|
19557
|
+
const last = points[points.length - 1];
|
|
19558
|
+
d += `L${fix(last[0])} ${fix(last[1])}`;
|
|
19559
|
+
}
|
|
19560
|
+
return d;
|
|
19561
|
+
}
|
|
19562
|
+
/** A smooth path through the points. One point is a zero-length line, which a round or square cap draws as a dot. */
|
|
19563
|
+
function smoothPath(points) {
|
|
19564
|
+
if (!points.length) return "";
|
|
19565
|
+
if (points.length === 1) {
|
|
19566
|
+
const [x, y] = points[0];
|
|
19567
|
+
return `M${fix(x)} ${fix(y)}L${fix(x)} ${fix(y)}`;
|
|
19568
|
+
}
|
|
19569
|
+
return curveThrough(points, "M");
|
|
19570
|
+
}
|
|
19571
|
+
/** The outline of a stroke whose width varies: the left side forward, a cap, the right side back, a cap. */
|
|
19572
|
+
function outlinePath(s, widths) {
|
|
19573
|
+
const pts = s.points;
|
|
19574
|
+
const left = [];
|
|
19575
|
+
const right = [];
|
|
19576
|
+
for (let i = 0; i < pts.length; i++) {
|
|
19577
|
+
const a = pts[Math.max(0, i - 1)];
|
|
19578
|
+
const b = pts[Math.min(pts.length - 1, i + 1)];
|
|
19579
|
+
let nx = -(b[1] - a[1]);
|
|
19580
|
+
let ny = b[0] - a[0];
|
|
19581
|
+
const len = Math.hypot(nx, ny) || 1;
|
|
19582
|
+
nx /= len;
|
|
19583
|
+
ny /= len;
|
|
19584
|
+
const h = widths[i] / 2;
|
|
19585
|
+
left.push([pts[i][0] + nx * h, pts[i][1] + ny * h]);
|
|
19586
|
+
right.push([pts[i][0] - nx * h, pts[i][1] - ny * h]);
|
|
19587
|
+
}
|
|
19588
|
+
const back = right.reverse();
|
|
19589
|
+
const cap = (i, to) => {
|
|
19590
|
+
const r = fix(widths[i] / 2);
|
|
19591
|
+
return s.brush.nib === "round" ? `A${r} ${r} 0 0 1 ${fix(to[0])} ${fix(to[1])}` : `L${fix(to[0])} ${fix(to[1])}`;
|
|
19592
|
+
};
|
|
19593
|
+
return `${curveThrough(left, "M")}${cap(pts.length - 1, back[0])}${curveThrough(back, "L")}${cap(0, left[0])}Z`;
|
|
19594
|
+
}
|
|
19595
|
+
/** How a stroke is drawn: the one rendering used on screen and in export. */
|
|
19596
|
+
function strokeShape(s) {
|
|
19597
|
+
const { brush } = s;
|
|
19598
|
+
const widths = widthsOf(s);
|
|
19599
|
+
const varies = s.points.length > 1 && widths.some((w) => Math.abs(w - widths[0]) > 1e-6);
|
|
19600
|
+
const base = {
|
|
19601
|
+
colour: brush.colour,
|
|
19602
|
+
width: fix(brush.width),
|
|
19603
|
+
cap: brush.nib === "round" ? "round" : "square",
|
|
19604
|
+
opacity: brush.opacity,
|
|
19605
|
+
blend: brush.blend ?? "normal",
|
|
19606
|
+
soften: fix(Math.max(0, 1 - brush.hardness) * brush.width * .25),
|
|
19607
|
+
grain: brush.kind === "pencil" ? fix(1.2 / Math.max(1, brush.width)) : 0
|
|
19608
|
+
};
|
|
19609
|
+
if (varies) return {
|
|
19610
|
+
...base,
|
|
19611
|
+
kind: "fill",
|
|
19612
|
+
d: outlinePath(s, widths)
|
|
19613
|
+
};
|
|
19614
|
+
return {
|
|
19615
|
+
...base,
|
|
19616
|
+
kind: "line",
|
|
19617
|
+
width: fix(widths[0] ?? brush.width),
|
|
19618
|
+
d: smoothPath(s.points.map((p) => [p[0], p[1]]))
|
|
19619
|
+
};
|
|
19620
|
+
}
|
|
19621
|
+
const escapeXml = (t) => t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
19622
|
+
/**
|
|
19623
|
+
* The SVG filter for a soft edge or a pencil's grain, or "" when the stroke needs none. `id` must be
|
|
19624
|
+
* unique in the document. The region is in the drawing's units around the stroke's ink (`box`), not
|
|
19625
|
+
* the default share of its bounding box, which is zero high for a level line and would hide it.
|
|
19626
|
+
*/
|
|
19627
|
+
function filterMarkup(shape, id, box) {
|
|
19628
|
+
if (!shape.soften && !shape.grain) return "";
|
|
19629
|
+
const pad = shape.soften * 3 + 1;
|
|
19630
|
+
const region = `x="${fix(box[0] - pad)}" y="${fix(box[1] - pad)}" width="${fix(box[2] - box[0] + 2 * pad)}" height="${fix(box[3] - box[1] + 2 * pad)}"`;
|
|
19631
|
+
const parts = [];
|
|
19632
|
+
if (shape.soften) parts.push(`<feGaussianBlur in="SourceGraphic" stdDeviation="${shape.soften}" result="soft"/>`);
|
|
19633
|
+
if (shape.grain) parts.push(`<feTurbulence type="fractalNoise" baseFrequency="${shape.grain}" numOctaves="2" seed="3" result="noise"/>`, `<feColorMatrix in="noise" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2 1.6" result="grain"/>`, `<feComposite in="${shape.soften ? "soft" : "SourceGraphic"}" in2="grain" operator="in"/>`);
|
|
19634
|
+
return `<filter id="${id}" filterUnits="userSpaceOnUse" ${region}>${parts.join("")}</filter>`;
|
|
19635
|
+
}
|
|
19636
|
+
/** The drawing as a standalone SVG document, drawn as `DrawingLayer` draws it; each stroke's note is its `<title>`. */
|
|
19637
|
+
function drawingToSvg(d, { idPrefix = "s" } = {}) {
|
|
19638
|
+
const defs = [];
|
|
19639
|
+
const body = d.strokes.map((s, i) => {
|
|
19640
|
+
const shape = strokeShape(s);
|
|
19641
|
+
const fid = `${idPrefix}-f${i}`;
|
|
19642
|
+
const filter = filterMarkup(shape, fid, strokeBox(s));
|
|
19643
|
+
if (filter) defs.push(filter);
|
|
19644
|
+
const paint = shape.kind === "line" ? `<path d="${shape.d}" fill="none" stroke="${shape.colour}" stroke-width="${shape.width}" stroke-linecap="${shape.cap}" stroke-linejoin="round"/>` : `<path d="${shape.d}" fill="${shape.colour}"/>`;
|
|
19645
|
+
const title = s.note ? `<title>${escapeXml(s.note)}</title>` : "";
|
|
19646
|
+
const blend = shape.blend === "multiply" ? ` style="mix-blend-mode:multiply"` : "";
|
|
19647
|
+
return `<g id="${escapeXml(s.id)}" opacity="${shape.opacity}"${blend}${filter ? ` filter="url(#${fid})"` : ""}>${title}${paint}</g>`;
|
|
19648
|
+
});
|
|
19649
|
+
const defsMarkup = defs.length ? `<defs>${defs.join("")}</defs>` : "";
|
|
19650
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${d.width} ${d.height}" width="${d.width}" height="${d.height}">${defsMarkup}${body.join("")}</svg>`;
|
|
19651
|
+
}
|
|
19652
|
+
let counter = 0;
|
|
19653
|
+
/** A stroke id unique in this page's life: time and a counter, so two tabs drawing on one document rarely clash. */
|
|
19654
|
+
function newStrokeId() {
|
|
19655
|
+
counter += 1;
|
|
19656
|
+
return `s${Date.now().toString(36)}${counter.toString(36)}`;
|
|
19657
|
+
}
|
|
19658
|
+
|
|
19659
|
+
// src/components/drawing.tsx
|
|
19660
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
19661
|
+
/** A vector drawing with every change an operation, its log, a selection and undo. Pass the returned state to `DrawingLayer` and `DrawingToolbar`. */
|
|
19662
|
+
function useDrawing({ initial, history: shared, limit }) {
|
|
19663
|
+
const own = useHistory({ limit });
|
|
19664
|
+
const history = shared ?? own;
|
|
19665
|
+
const [state, setState] = React.useState(() => ({
|
|
19666
|
+
drawing: typeof initial === "function" ? initial() : initial,
|
|
19667
|
+
log: []
|
|
19668
|
+
}));
|
|
19669
|
+
const [selected, setSelected] = React.useState(null);
|
|
19670
|
+
const latest = React.useRef(state.drawing);
|
|
19671
|
+
const run = React.useCallback((ops) => {
|
|
19672
|
+
if (!ops.length) return;
|
|
19673
|
+
latest.current = ops.reduce(applyOp, latest.current);
|
|
19674
|
+
const drawing = latest.current;
|
|
19675
|
+
setState((s) => ({
|
|
19676
|
+
drawing,
|
|
19677
|
+
log: [...s.log, ...ops]
|
|
19678
|
+
}));
|
|
19679
|
+
setSelected((id) => id && drawing.strokes.some((s) => s.id === id) ? id : null);
|
|
19680
|
+
}, []);
|
|
19681
|
+
const step = React.useCallback((ops, label, key) => {
|
|
19682
|
+
if (!ops.length) return;
|
|
19683
|
+
run(ops);
|
|
19684
|
+
const undo = ops.map(invertOp).reverse();
|
|
19685
|
+
history.push({
|
|
19686
|
+
label,
|
|
19687
|
+
key,
|
|
19688
|
+
undo: () => run(undo),
|
|
19689
|
+
redo: () => run(ops)
|
|
19690
|
+
});
|
|
19691
|
+
}, [history, run]);
|
|
19692
|
+
return {
|
|
19693
|
+
drawing: state.drawing,
|
|
19694
|
+
log: state.log,
|
|
19695
|
+
history,
|
|
19696
|
+
selected,
|
|
19697
|
+
select: setSelected,
|
|
19698
|
+
add: (stroke, label = "draw mark") => step([{
|
|
19699
|
+
op: "add",
|
|
19700
|
+
stroke,
|
|
19701
|
+
index: latest.current.strokes.length
|
|
19702
|
+
}], label),
|
|
19703
|
+
remove: (ids, label = "delete mark") => {
|
|
19704
|
+
const want = new Set(typeof ids === "string" ? [ids] : ids);
|
|
19705
|
+
const ops = latest.current.strokes.map((stroke, index) => ({
|
|
19706
|
+
stroke,
|
|
19707
|
+
index
|
|
19708
|
+
})).filter(({ stroke }) => want.has(stroke.id)).reverse().map(({ stroke, index }) => ({
|
|
19709
|
+
op: "remove",
|
|
19710
|
+
stroke,
|
|
19711
|
+
index
|
|
19712
|
+
}));
|
|
19713
|
+
step(ops, label);
|
|
19714
|
+
},
|
|
19715
|
+
change: (id, change, label, key) => {
|
|
19716
|
+
const s = latest.current.strokes.find((x) => x.id === id);
|
|
19717
|
+
if (!s) return;
|
|
19718
|
+
const before = currentOf(s, change);
|
|
19719
|
+
if (same(before, change)) return;
|
|
19720
|
+
step([{
|
|
19721
|
+
op: "change",
|
|
19722
|
+
id,
|
|
19723
|
+
before,
|
|
19724
|
+
after: change
|
|
19725
|
+
}], label, key);
|
|
19726
|
+
},
|
|
19727
|
+
apply: (ops, label) => step(ops.slice(), label),
|
|
19728
|
+
clear: (label = "clear marks") => {
|
|
19729
|
+
const ops = latest.current.strokes.map((stroke, index) => ({
|
|
19730
|
+
op: "remove",
|
|
19731
|
+
stroke,
|
|
19732
|
+
index
|
|
19733
|
+
})).reverse();
|
|
19734
|
+
step(ops, label);
|
|
19735
|
+
},
|
|
19736
|
+
fit: (width, height) => {
|
|
19737
|
+
const d = latest.current;
|
|
19738
|
+
if (d.strokes.length || d.width === width && d.height === height) return;
|
|
19739
|
+
latest.current = emptyDrawing(width, height);
|
|
19740
|
+
const drawing = latest.current;
|
|
19741
|
+
setState((s) => ({
|
|
19742
|
+
...s,
|
|
19743
|
+
drawing
|
|
19744
|
+
}));
|
|
19745
|
+
}
|
|
19746
|
+
};
|
|
19747
|
+
}
|
|
19748
|
+
/** Screen pixels within which a press still counts as on a thin stroke or a handle. */
|
|
19749
|
+
const SLOP_PX = 6;
|
|
19750
|
+
const HANDLE_PX = 9;
|
|
19751
|
+
/** The SVG layer a drawing is made on, laid over a picture of the same shape (inside a `ViewportFrame` it zooms and pans with it). */
|
|
19752
|
+
function DrawingLayer({ state, tool, brush, label, size, onDrawn, noteFor = null, onNoteClose, onNoteRequest, noteWords = { label: "Note" }, noun = "Mark", className }) {
|
|
19753
|
+
const { drawing, selected } = state;
|
|
19754
|
+
const svgRef = React.useRef(null);
|
|
19755
|
+
const anchorRef = React.useRef(null);
|
|
19756
|
+
const prefix = React.useId().replace(/:/g, "");
|
|
19757
|
+
const [drag, setDrag] = React.useState(null);
|
|
19758
|
+
const dragRef = React.useRef(drag);
|
|
19759
|
+
dragRef.current = drag;
|
|
19760
|
+
const fitRef = React.useRef(state.fit);
|
|
19761
|
+
fitRef.current = state.fit;
|
|
19762
|
+
const [sw, sh] = size ?? [0, 0];
|
|
19763
|
+
React.useEffect(() => {
|
|
19764
|
+
if (sw && sh) fitRef.current(sw, sh);
|
|
19765
|
+
}, [sw, sh]);
|
|
19766
|
+
const unitsPerPx = () => {
|
|
19767
|
+
const r = svgRef.current?.getBoundingClientRect();
|
|
19768
|
+
return r && r.width > 0 ? drawing.width / r.width : 1;
|
|
19769
|
+
};
|
|
19770
|
+
const toUnits = (e) => {
|
|
19771
|
+
const r = svgRef.current.getBoundingClientRect();
|
|
19772
|
+
return {
|
|
19773
|
+
x: r.width > 0 ? (e.clientX - r.left) / r.width * drawing.width : 0,
|
|
19774
|
+
y: r.height > 0 ? (e.clientY - r.top) / r.height * drawing.height : 0
|
|
19775
|
+
};
|
|
19776
|
+
};
|
|
19777
|
+
const chosen = selected ? drawing.strokes.find((s) => s.id === selected) : void 0;
|
|
19778
|
+
const handleAt = (x, y) => {
|
|
19779
|
+
if (!chosen) return null;
|
|
19780
|
+
const [x0, y0, x1, y1] = strokeBox(chosen);
|
|
19781
|
+
const reach = HANDLE_PX * unitsPerPx();
|
|
19782
|
+
for (const [hx, hy, ox, oy] of [
|
|
19783
|
+
[
|
|
19784
|
+
x0,
|
|
19785
|
+
y0,
|
|
19786
|
+
x1,
|
|
19787
|
+
y1
|
|
19788
|
+
],
|
|
19789
|
+
[
|
|
19790
|
+
x1,
|
|
19791
|
+
y0,
|
|
19792
|
+
x0,
|
|
19793
|
+
y1
|
|
19794
|
+
],
|
|
19795
|
+
[
|
|
19796
|
+
x0,
|
|
19797
|
+
y1,
|
|
19798
|
+
x1,
|
|
19799
|
+
y0
|
|
19800
|
+
],
|
|
19801
|
+
[
|
|
19802
|
+
x1,
|
|
19803
|
+
y1,
|
|
19804
|
+
x0,
|
|
19805
|
+
y0
|
|
19806
|
+
]
|
|
19807
|
+
]) if (Math.abs(x - hx) <= reach && Math.abs(y - hy) <= reach) return {
|
|
19808
|
+
x: ox,
|
|
19809
|
+
y: oy
|
|
19810
|
+
};
|
|
19811
|
+
return null;
|
|
19812
|
+
};
|
|
19813
|
+
const pressureOf = (e, at, prev) => {
|
|
19814
|
+
if (e.pointerType === "pen" && e.pressure > 0) return e.pressure;
|
|
19815
|
+
if (!prev) return .5;
|
|
19816
|
+
const dt = Math.max(1, e.timeStamp - prev.last.t);
|
|
19817
|
+
const speed = Math.hypot(at.x - prev.last.x, at.y - prev.last.y) / unitsPerPx() / dt;
|
|
19818
|
+
const target = Math.max(.2, Math.min(1, 1.1 - speed / 2.5));
|
|
19819
|
+
return prev.last.p + (target - prev.last.p) * .3;
|
|
19820
|
+
};
|
|
19821
|
+
const onPointerDown = (e) => {
|
|
19822
|
+
if (tool === "none" || e.button !== 0) return;
|
|
19823
|
+
e.stopPropagation();
|
|
19824
|
+
e.preventDefault();
|
|
19825
|
+
e.currentTarget.setPointerCapture?.(e.pointerId);
|
|
19826
|
+
const at = toUnits(e);
|
|
19827
|
+
const slop = SLOP_PX * unitsPerPx();
|
|
19828
|
+
if (tool === "draw") {
|
|
19829
|
+
const p = pressureOf(e, at);
|
|
19830
|
+
setDrag({
|
|
19831
|
+
kind: "draw",
|
|
19832
|
+
id: e.pointerId,
|
|
19833
|
+
points: [[
|
|
19834
|
+
at.x,
|
|
19835
|
+
at.y,
|
|
19836
|
+
p
|
|
19837
|
+
]],
|
|
19838
|
+
last: {
|
|
19839
|
+
...at,
|
|
19840
|
+
t: e.timeStamp,
|
|
19841
|
+
p
|
|
19842
|
+
}
|
|
19843
|
+
});
|
|
19844
|
+
} else if (tool === "erase") {
|
|
19845
|
+
const hit = /* @__PURE__ */ new Set();
|
|
19846
|
+
const s = strokeAt(drawing, at.x, at.y, slop);
|
|
19847
|
+
if (s) hit.add(s.id);
|
|
19848
|
+
setDrag({
|
|
19849
|
+
kind: "erase",
|
|
19850
|
+
id: e.pointerId,
|
|
19851
|
+
hit,
|
|
19852
|
+
last: at
|
|
19853
|
+
});
|
|
19854
|
+
} else {
|
|
19855
|
+
const fixed = handleAt(at.x, at.y);
|
|
19856
|
+
if (chosen && fixed) {
|
|
19857
|
+
setDrag({
|
|
19858
|
+
kind: "resize",
|
|
19859
|
+
id: e.pointerId,
|
|
19860
|
+
stroke: chosen,
|
|
19861
|
+
fixed,
|
|
19862
|
+
points: chosen.points
|
|
19863
|
+
});
|
|
19864
|
+
return;
|
|
19865
|
+
}
|
|
19866
|
+
const s = strokeAt(drawing, at.x, at.y, slop);
|
|
19867
|
+
state.select(s?.id ?? null);
|
|
19868
|
+
if (s) setDrag({
|
|
19869
|
+
kind: "move",
|
|
19870
|
+
id: e.pointerId,
|
|
19871
|
+
stroke: s,
|
|
19872
|
+
from: at,
|
|
19873
|
+
points: s.points
|
|
19874
|
+
});
|
|
19875
|
+
}
|
|
19876
|
+
};
|
|
19877
|
+
const onPointerMove = (e) => {
|
|
19878
|
+
const d = dragRef.current;
|
|
19879
|
+
if (!d || d.id !== e.pointerId) return;
|
|
19880
|
+
e.stopPropagation();
|
|
19881
|
+
const events = e.nativeEvent.getCoalescedEvents?.() ?? [];
|
|
19882
|
+
const all = events.length ? events : [e.nativeEvent];
|
|
19883
|
+
if (d.kind === "draw") {
|
|
19884
|
+
let next = d;
|
|
19885
|
+
for (const ev of all) {
|
|
19886
|
+
const at = toUnits(ev);
|
|
19887
|
+
const p = pressureOf({
|
|
19888
|
+
...e,
|
|
19889
|
+
pressure: ev.pressure,
|
|
19890
|
+
timeStamp: ev.timeStamp
|
|
19891
|
+
}, at, next);
|
|
19892
|
+
next = {
|
|
19893
|
+
...next,
|
|
19894
|
+
points: [...next.points, [
|
|
19895
|
+
at.x,
|
|
19896
|
+
at.y,
|
|
19897
|
+
p
|
|
19898
|
+
]],
|
|
19899
|
+
last: {
|
|
19900
|
+
...at,
|
|
19901
|
+
t: ev.timeStamp,
|
|
19902
|
+
p
|
|
19903
|
+
}
|
|
19904
|
+
};
|
|
19905
|
+
}
|
|
19906
|
+
setDrag(next);
|
|
19907
|
+
} else if (d.kind === "erase") {
|
|
19908
|
+
const slop = SLOP_PX * unitsPerPx();
|
|
19909
|
+
const hit = new Set(d.hit);
|
|
19910
|
+
let last = d.last;
|
|
19911
|
+
for (const ev of all) {
|
|
19912
|
+
const at = toUnits(ev);
|
|
19913
|
+
const steps = Math.max(1, Math.ceil(Math.hypot(at.x - last.x, at.y - last.y) / Math.max(slop, 1e-6)));
|
|
19914
|
+
for (let k = 1; k <= steps; k++) {
|
|
19915
|
+
const x = last.x + (at.x - last.x) * k / steps;
|
|
19916
|
+
const y = last.y + (at.y - last.y) * k / steps;
|
|
19917
|
+
for (const s of drawing.strokes) if (hitsStroke(s, x, y, slop)) hit.add(s.id);
|
|
19918
|
+
}
|
|
19919
|
+
last = at;
|
|
19920
|
+
}
|
|
19921
|
+
setDrag({
|
|
19922
|
+
...d,
|
|
19923
|
+
hit,
|
|
19924
|
+
last
|
|
19925
|
+
});
|
|
19926
|
+
} else if (d.kind === "move") {
|
|
19927
|
+
const at = toUnits(e);
|
|
19928
|
+
setDrag({
|
|
19929
|
+
...d,
|
|
19930
|
+
points: movePoints(d.stroke.points, at.x - d.from.x, at.y - d.from.y)
|
|
19931
|
+
});
|
|
19932
|
+
} else {
|
|
19933
|
+
const at = toUnits(e);
|
|
19934
|
+
const from = pointsBox(d.stroke.points);
|
|
19935
|
+
const h = d.stroke.brush.width / 2;
|
|
19936
|
+
const x0 = Math.min(at.x, d.fixed.x);
|
|
19937
|
+
const x1 = Math.max(at.x, d.fixed.x);
|
|
19938
|
+
const y0 = Math.min(at.y, d.fixed.y);
|
|
19939
|
+
const y1 = Math.max(at.y, d.fixed.y);
|
|
19940
|
+
const to = [
|
|
19941
|
+
x0 + h,
|
|
19942
|
+
y0 + h,
|
|
19943
|
+
Math.max(x0 + h, x1 - h),
|
|
19944
|
+
Math.max(y0 + h, y1 - h)
|
|
19945
|
+
];
|
|
19946
|
+
setDrag({
|
|
19947
|
+
...d,
|
|
19948
|
+
points: fitPoints(d.stroke.points, from, to)
|
|
19949
|
+
});
|
|
19950
|
+
}
|
|
19951
|
+
};
|
|
19952
|
+
const finish = (e, cancelled) => {
|
|
19953
|
+
const d = dragRef.current;
|
|
19954
|
+
if (!d || d.id !== e.pointerId) return;
|
|
19955
|
+
e.stopPropagation();
|
|
19956
|
+
setDrag(null);
|
|
19957
|
+
if (cancelled) return;
|
|
19958
|
+
if (d.kind === "draw") {
|
|
19959
|
+
const stroke = {
|
|
19960
|
+
id: newStrokeId(),
|
|
19961
|
+
brush,
|
|
19962
|
+
points: simplifyPoints(d.points, .4 * unitsPerPx())
|
|
19963
|
+
};
|
|
19964
|
+
state.add(stroke, `draw ${noun.toLowerCase()}`);
|
|
19965
|
+
onDrawn?.(stroke);
|
|
19966
|
+
} else if (d.kind === "erase") {
|
|
19967
|
+
if (d.hit.size) state.remove([...d.hit], d.hit.size > 1 ? `erase ${d.hit.size} marks` : "erase mark");
|
|
19968
|
+
} else if (d.points !== d.stroke.points) state.change(d.stroke.id, { points: d.points }, d.kind === "move" ? "move mark" : "resize mark");
|
|
19969
|
+
};
|
|
19970
|
+
const onKeyDown = (e, s) => {
|
|
19971
|
+
const step = (e.shiftKey ? .1 : .01) * drawing.width;
|
|
19972
|
+
const move = (dx, dy) => state.change(s.id, { points: movePoints(s.points, dx, dy) }, "move mark", `key-move-${s.id}`);
|
|
19973
|
+
const scale = (k) => {
|
|
19974
|
+
const b = pointsBox(s.points);
|
|
19975
|
+
const cx = (b[0] + b[2]) / 2;
|
|
19976
|
+
const cy = (b[1] + b[3]) / 2;
|
|
19977
|
+
const to = [
|
|
19978
|
+
cx + (b[0] - cx) * k,
|
|
19979
|
+
cy + (b[1] - cy) * k,
|
|
19980
|
+
cx + (b[2] - cx) * k,
|
|
19981
|
+
cy + (b[3] - cy) * k
|
|
19982
|
+
];
|
|
19983
|
+
state.change(s.id, { points: fitPoints(s.points, b, to) }, "resize mark", `key-size-${s.id}`);
|
|
19984
|
+
};
|
|
19985
|
+
if (e.key === "Enter" || e.key === " ") state.select(s.id);
|
|
19986
|
+
else if (e.key === "ArrowLeft") move(-step, 0);
|
|
19987
|
+
else if (e.key === "ArrowRight") move(step, 0);
|
|
19988
|
+
else if (e.key === "ArrowUp") move(0, -step);
|
|
19989
|
+
else if (e.key === "ArrowDown") move(0, step);
|
|
19990
|
+
else if (e.key === "[") scale(1 / 1.1);
|
|
19991
|
+
else if (e.key === "]") scale(1.1);
|
|
19992
|
+
else if (e.key === "Delete" || e.key === "Backspace") state.remove(s.id);
|
|
19993
|
+
else if (e.key === "Escape") state.select(null);
|
|
19994
|
+
else if ((e.key === "n" || e.key === "N") && onNoteRequest) onNoteRequest(s.id);
|
|
19995
|
+
else return;
|
|
19996
|
+
e.preventDefault();
|
|
19997
|
+
e.stopPropagation();
|
|
19998
|
+
};
|
|
19999
|
+
const live = drag?.kind === "draw" ? {
|
|
20000
|
+
id: "live",
|
|
20001
|
+
brush,
|
|
20002
|
+
points: drag.points
|
|
20003
|
+
} : null;
|
|
20004
|
+
const shown = drawing.strokes.map((s) => (drag?.kind === "move" || drag?.kind === "resize") && drag.stroke.id === s.id ? {
|
|
20005
|
+
...s,
|
|
20006
|
+
points: drag.points
|
|
20007
|
+
} : s);
|
|
20008
|
+
const box = chosen && tool === "select" ? strokeBox(shown.find((s) => s.id === chosen.id) ?? chosen) : null;
|
|
20009
|
+
const handle = HANDLE_PX * unitsPerPx();
|
|
20010
|
+
const noteStroke = noteFor ? drawing.strokes.find((s) => s.id === noteFor) : void 0;
|
|
20011
|
+
const noteBox = noteStroke ? strokeBox(noteStroke) : null;
|
|
20012
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
20013
|
+
className: cn("pointer-events-none absolute inset-0", className),
|
|
20014
|
+
children: [
|
|
20015
|
+
/* @__PURE__ */ jsxs("svg", {
|
|
20016
|
+
ref: svgRef,
|
|
20017
|
+
role: "group",
|
|
20018
|
+
"aria-label": label,
|
|
20019
|
+
viewBox: `0 0 ${drawing.width || 1} ${drawing.height || 1}`,
|
|
20020
|
+
preserveAspectRatio: "none",
|
|
20021
|
+
className: cn("absolute inset-0 size-full overflow-visible", tool === "none" ? "pointer-events-none" : "pointer-events-auto", tool === "draw" && "cursor-crosshair", tool === "erase" && "cursor-cell"),
|
|
20022
|
+
style: { touchAction: tool === "none" ? void 0 : "none" },
|
|
20023
|
+
onPointerDown,
|
|
20024
|
+
onPointerMove,
|
|
20025
|
+
onPointerUp: (e) => finish(e, false),
|
|
20026
|
+
onPointerCancel: (e) => finish(e, true),
|
|
20027
|
+
onDoubleClick: (e) => tool !== "none" && e.stopPropagation(),
|
|
20028
|
+
children: [
|
|
20029
|
+
shown.map((s, i) => /* @__PURE__ */ jsx(StrokeView, {
|
|
20030
|
+
stroke: s,
|
|
20031
|
+
filterId: `${prefix}-${i}`,
|
|
20032
|
+
faded: drag?.kind === "erase" && drag.hit.has(s.id),
|
|
20033
|
+
focusable: tool === "select",
|
|
20034
|
+
label: `${noun} ${i + 1}${s.note ? `: ${s.note}` : ""}`,
|
|
20035
|
+
selected: s.id === selected,
|
|
20036
|
+
onKeyDown: (e) => onKeyDown(e, s),
|
|
20037
|
+
onFocus: () => tool === "select" && state.select(s.id)
|
|
20038
|
+
}, s.id)),
|
|
20039
|
+
live && /* @__PURE__ */ jsx(StrokeView, {
|
|
20040
|
+
stroke: live,
|
|
20041
|
+
filterId: `${prefix}-live`
|
|
20042
|
+
}),
|
|
20043
|
+
box && /* @__PURE__ */ jsxs("g", {
|
|
20044
|
+
"aria-hidden": true,
|
|
20045
|
+
className: "pointer-events-none",
|
|
20046
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
20047
|
+
x: box[0],
|
|
20048
|
+
y: box[1],
|
|
20049
|
+
width: box[2] - box[0],
|
|
20050
|
+
height: box[3] - box[1],
|
|
20051
|
+
fill: "none",
|
|
20052
|
+
className: "stroke-foreground",
|
|
20053
|
+
strokeWidth: 1.5,
|
|
20054
|
+
strokeDasharray: "4 3",
|
|
20055
|
+
vectorEffect: "non-scaling-stroke"
|
|
20056
|
+
}), [
|
|
20057
|
+
[box[0], box[1]],
|
|
20058
|
+
[box[2], box[1]],
|
|
20059
|
+
[box[0], box[3]],
|
|
20060
|
+
[box[2], box[3]]
|
|
20061
|
+
].map(([x, y], i) => /* @__PURE__ */ jsx("rect", {
|
|
20062
|
+
x: x - handle / 2,
|
|
20063
|
+
y: y - handle / 2,
|
|
20064
|
+
width: handle,
|
|
20065
|
+
height: handle,
|
|
20066
|
+
className: "fill-background stroke-foreground",
|
|
20067
|
+
strokeWidth: 1.5,
|
|
20068
|
+
vectorEffect: "non-scaling-stroke"
|
|
20069
|
+
}, i))]
|
|
20070
|
+
})
|
|
20071
|
+
]
|
|
20072
|
+
}),
|
|
20073
|
+
noteBox && /* @__PURE__ */ jsx("span", {
|
|
20074
|
+
ref: anchorRef,
|
|
20075
|
+
"aria-hidden": true,
|
|
20076
|
+
className: "absolute",
|
|
20077
|
+
style: {
|
|
20078
|
+
left: `${noteBox[0] / (drawing.width || 1) * 100}%`,
|
|
20079
|
+
top: `${noteBox[1] / (drawing.height || 1) * 100}%`,
|
|
20080
|
+
width: `${(noteBox[2] - noteBox[0]) / (drawing.width || 1) * 100}%`,
|
|
20081
|
+
height: `${(noteBox[3] - noteBox[1]) / (drawing.height || 1) * 100}%`
|
|
20082
|
+
}
|
|
20083
|
+
}),
|
|
20084
|
+
noteStroke && /* @__PURE__ */ jsx(StrokeNote, {
|
|
20085
|
+
stroke: noteStroke,
|
|
20086
|
+
anchor: anchorRef,
|
|
20087
|
+
words: noteWords,
|
|
20088
|
+
onSave: (note) => state.change(noteStroke.id, { note: note.trim() }, "note"),
|
|
20089
|
+
onRemove: () => state.remove(noteStroke.id),
|
|
20090
|
+
onClose: () => onNoteClose?.()
|
|
20091
|
+
}, noteStroke.id)
|
|
20092
|
+
]
|
|
20093
|
+
});
|
|
20094
|
+
}
|
|
20095
|
+
/** One stroke in the layer: its group (opacity, blend, filter) and its path, focusable as a button for the select tool. */
|
|
20096
|
+
function StrokeView({ stroke, filterId, faded, focusable, label, selected, onKeyDown, onFocus }) {
|
|
20097
|
+
const shape = strokeShape(stroke);
|
|
20098
|
+
const filter = filterMarkup(shape, filterId, strokeBox(stroke));
|
|
20099
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
20100
|
+
"data-stroke": stroke.id,
|
|
20101
|
+
opacity: faded ? shape.opacity * .25 : shape.opacity,
|
|
20102
|
+
style: shape.blend === "multiply" ? { mixBlendMode: "multiply" } : void 0,
|
|
20103
|
+
filter: filter ? `url(#${filterId})` : void 0,
|
|
20104
|
+
role: focusable ? "button" : void 0,
|
|
20105
|
+
tabIndex: focusable ? 0 : void 0,
|
|
20106
|
+
"aria-label": focusable ? label : void 0,
|
|
20107
|
+
"aria-pressed": focusable ? !!selected : void 0,
|
|
20108
|
+
onKeyDown: focusable ? onKeyDown : void 0,
|
|
20109
|
+
onFocus: focusable ? onFocus : void 0,
|
|
20110
|
+
className: "outline-none focus-visible:outline-2 focus-visible:outline-ring",
|
|
20111
|
+
children: [filter && /* @__PURE__ */ jsx("defs", { dangerouslySetInnerHTML: { __html: filter } }), shape.kind === "line" ? /* @__PURE__ */ jsx("path", {
|
|
20112
|
+
d: shape.d,
|
|
20113
|
+
fill: "none",
|
|
20114
|
+
stroke: shape.colour,
|
|
20115
|
+
strokeWidth: shape.width,
|
|
20116
|
+
strokeLinecap: shape.cap,
|
|
20117
|
+
strokeLinejoin: "round"
|
|
20118
|
+
}) : /* @__PURE__ */ jsx("path", {
|
|
20119
|
+
d: shape.d,
|
|
20120
|
+
fill: shape.colour
|
|
20121
|
+
})]
|
|
20122
|
+
});
|
|
20123
|
+
}
|
|
20124
|
+
/** The note box for one stroke, anchored to the stroke's box. The text is saved when it closes, however it closes. */
|
|
20125
|
+
function StrokeNote({ stroke, anchor, words, onSave, onRemove, onClose }) {
|
|
20126
|
+
const [text, setText] = React.useState(stroke.note ?? "");
|
|
20127
|
+
const removed = React.useRef(false);
|
|
20128
|
+
const close = () => {
|
|
20129
|
+
if (!removed.current) onSave(text);
|
|
20130
|
+
onClose();
|
|
20131
|
+
};
|
|
20132
|
+
const [ready, setReady] = React.useState(false);
|
|
20133
|
+
React.useEffect(() => setReady(true), []);
|
|
20134
|
+
if (!ready || !anchor.current) return null;
|
|
20135
|
+
return /* @__PURE__ */ jsx(Popover$1, {
|
|
20136
|
+
triggerRef: anchor,
|
|
20137
|
+
isOpen: true,
|
|
20138
|
+
onOpenChange: (open) => !open && close(),
|
|
20139
|
+
placement: "bottom start",
|
|
20140
|
+
offset: 6,
|
|
20141
|
+
className: cn("layer-overlay w-72 p-3", overlaySurface),
|
|
20142
|
+
children: /* @__PURE__ */ jsxs(Dialog$1, {
|
|
20143
|
+
"aria-label": words.label,
|
|
20144
|
+
className: "grid gap-3 outline-none",
|
|
20145
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
20146
|
+
label: words.label,
|
|
20147
|
+
hint: words.hint,
|
|
20148
|
+
children: /* @__PURE__ */ jsx(Textarea, {
|
|
20149
|
+
autoFocus: true,
|
|
20150
|
+
rows: 3,
|
|
20151
|
+
value: text,
|
|
20152
|
+
onChange: (e) => setText(e.target.value),
|
|
20153
|
+
onKeyDown: (e) => {
|
|
20154
|
+
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
|
20155
|
+
e.preventDefault();
|
|
20156
|
+
close();
|
|
20157
|
+
}
|
|
20158
|
+
}
|
|
20159
|
+
})
|
|
20160
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
20161
|
+
className: "flex justify-between gap-2",
|
|
20162
|
+
children: [/* @__PURE__ */ jsxs(Button, {
|
|
20163
|
+
variant: "ghost",
|
|
20164
|
+
size: "sm",
|
|
20165
|
+
onPress: () => {
|
|
20166
|
+
removed.current = true;
|
|
20167
|
+
onRemove();
|
|
20168
|
+
onClose();
|
|
20169
|
+
},
|
|
20170
|
+
children: [/* @__PURE__ */ jsx(Trash2, {
|
|
20171
|
+
"aria-hidden": true,
|
|
20172
|
+
className: "size-4"
|
|
20173
|
+
}), words.remove ?? "Delete mark"]
|
|
20174
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
20175
|
+
size: "sm",
|
|
20176
|
+
onPress: close,
|
|
20177
|
+
children: words.done ?? "Done"
|
|
20178
|
+
})]
|
|
20179
|
+
})]
|
|
20180
|
+
})
|
|
20181
|
+
});
|
|
20182
|
+
}
|
|
20183
|
+
const TOOL_WORDS = {
|
|
20184
|
+
none: {
|
|
20185
|
+
label: "Look",
|
|
20186
|
+
icon: Hand
|
|
20187
|
+
},
|
|
20188
|
+
select: {
|
|
20189
|
+
label: "Select",
|
|
20190
|
+
icon: MousePointer2
|
|
20191
|
+
},
|
|
20192
|
+
pen: {
|
|
20193
|
+
label: "Pen",
|
|
20194
|
+
icon: PenLine
|
|
20195
|
+
},
|
|
20196
|
+
pencil: {
|
|
20197
|
+
label: "Pencil",
|
|
20198
|
+
icon: Pencil
|
|
20199
|
+
},
|
|
20200
|
+
marker: {
|
|
20201
|
+
label: "Marker",
|
|
20202
|
+
icon: Paintbrush
|
|
20203
|
+
},
|
|
20204
|
+
highlighter: {
|
|
20205
|
+
label: "Highlighter",
|
|
20206
|
+
icon: Highlighter
|
|
20207
|
+
},
|
|
20208
|
+
brush: {
|
|
20209
|
+
label: "Brush",
|
|
20210
|
+
icon: Brush
|
|
20211
|
+
},
|
|
20212
|
+
erase: {
|
|
20213
|
+
label: "Eraser",
|
|
20214
|
+
icon: Eraser
|
|
20215
|
+
}
|
|
20216
|
+
};
|
|
20217
|
+
const NIB_WORDS = {
|
|
20218
|
+
round: "Round",
|
|
20219
|
+
square: "Square",
|
|
20220
|
+
chisel: "Chisel"
|
|
20221
|
+
};
|
|
20222
|
+
const DEFAULT_TOOLS = [
|
|
20223
|
+
"none",
|
|
20224
|
+
"select",
|
|
20225
|
+
"pen",
|
|
20226
|
+
"pencil",
|
|
20227
|
+
"marker",
|
|
20228
|
+
"highlighter",
|
|
20229
|
+
"brush",
|
|
20230
|
+
"erase"
|
|
20231
|
+
];
|
|
20232
|
+
const DEFAULT_CONTROLS = [
|
|
20233
|
+
"colour",
|
|
20234
|
+
"width",
|
|
20235
|
+
"opacity",
|
|
20236
|
+
"hardness",
|
|
20237
|
+
"nib"
|
|
20238
|
+
];
|
|
20239
|
+
const isBrushKind = (t) => t in BRUSHES;
|
|
20240
|
+
/** The whole drawing kit: tools, colour, width, opacity, hardness and nib, with Undo, Redo and Delete for the chosen stroke. */
|
|
20241
|
+
function DrawingToolbar({ state, tool, brush, onChange, tools = DEFAULT_TOOLS, controls = DEFAULT_CONTROLS, palette, maxWidth, scale = 1, onNote, className }) {
|
|
20242
|
+
const choice = tool === "draw" ? brush.kind : tool;
|
|
20243
|
+
const most = maxWidth ?? 60 * scale;
|
|
20244
|
+
const { history, selected } = state;
|
|
20245
|
+
const choose = (t) => {
|
|
20246
|
+
if (isBrushKind(t)) {
|
|
20247
|
+
const base = BRUSHES[t];
|
|
20248
|
+
onChange({
|
|
20249
|
+
tool: "draw",
|
|
20250
|
+
brush: {
|
|
20251
|
+
...base,
|
|
20252
|
+
width: base.width * scale,
|
|
20253
|
+
colour: brush.colour
|
|
20254
|
+
}
|
|
20255
|
+
});
|
|
20256
|
+
} else onChange({
|
|
20257
|
+
tool: t,
|
|
20258
|
+
brush
|
|
20259
|
+
});
|
|
20260
|
+
};
|
|
20261
|
+
const chosen = tool === "select" && selected ? state.drawing.strokes.find((x) => x.id === selected) : void 0;
|
|
20262
|
+
const shown = chosen?.brush ?? brush;
|
|
20263
|
+
const set = (part) => {
|
|
20264
|
+
if (chosen) state.change(chosen.id, { brush: {
|
|
20265
|
+
...chosen.brush,
|
|
20266
|
+
...part
|
|
20267
|
+
} }, "restyle mark", `restyle-${chosen.id}-${Object.keys(part).join()}`);
|
|
20268
|
+
else onChange({
|
|
20269
|
+
tool,
|
|
20270
|
+
brush: {
|
|
20271
|
+
...brush,
|
|
20272
|
+
...part
|
|
20273
|
+
}
|
|
20274
|
+
});
|
|
20275
|
+
};
|
|
20276
|
+
const showBrush = tool === "draw" || chosen !== void 0;
|
|
20277
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
20278
|
+
className: cn("grid gap-2", className),
|
|
20279
|
+
children: [/* @__PURE__ */ jsxs(Toolbar, {
|
|
20280
|
+
label: "Drawing tools",
|
|
20281
|
+
className: "flex-wrap items-center gap-2",
|
|
20282
|
+
children: [
|
|
20283
|
+
tools.length > 1 && /* @__PURE__ */ jsx(ToggleGroup, {
|
|
20284
|
+
label: "Tool",
|
|
20285
|
+
size: "sm",
|
|
20286
|
+
value: choice,
|
|
20287
|
+
onChange: choose,
|
|
20288
|
+
options: tools.map((t) => ({
|
|
20289
|
+
value: t,
|
|
20290
|
+
label: TOOL_WORDS[t].label,
|
|
20291
|
+
icon: TOOL_WORDS[t].icon,
|
|
20292
|
+
iconOnly: true
|
|
20293
|
+
}))
|
|
20294
|
+
}),
|
|
20295
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
20296
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
20297
|
+
size: "sm",
|
|
20298
|
+
variant: "ghost",
|
|
20299
|
+
icon: Undo2,
|
|
20300
|
+
label: history.undoLabel ? `Undo ${history.undoLabel}` : "Nothing to undo",
|
|
20301
|
+
disabled: !history.canUndo,
|
|
20302
|
+
onPress: history.undo
|
|
20303
|
+
}),
|
|
20304
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
20305
|
+
size: "sm",
|
|
20306
|
+
variant: "ghost",
|
|
20307
|
+
icon: Redo2,
|
|
20308
|
+
label: history.redoLabel ? `Redo ${history.redoLabel}` : "Nothing to redo",
|
|
20309
|
+
disabled: !history.canRedo,
|
|
20310
|
+
onPress: history.redo
|
|
20311
|
+
}),
|
|
20312
|
+
selected && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
20313
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
20314
|
+
onNote && /* @__PURE__ */ jsx(Button, {
|
|
20315
|
+
size: "sm",
|
|
20316
|
+
variant: "ghost",
|
|
20317
|
+
onPress: () => onNote(selected),
|
|
20318
|
+
children: "Note"
|
|
20319
|
+
}),
|
|
20320
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
20321
|
+
size: "sm",
|
|
20322
|
+
variant: "ghost",
|
|
20323
|
+
icon: Trash2,
|
|
20324
|
+
label: "Delete mark",
|
|
20325
|
+
onPress: () => state.remove(selected)
|
|
20326
|
+
})
|
|
20327
|
+
] })
|
|
20328
|
+
]
|
|
20329
|
+
}), showBrush && controls.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
20330
|
+
className: "flex flex-wrap items-center gap-x-4 gap-y-2",
|
|
20331
|
+
children: [
|
|
20332
|
+
controls.includes("colour") && /* @__PURE__ */ jsx(ColorField, {
|
|
20333
|
+
"aria-label": "Colour",
|
|
20334
|
+
value: shown.colour,
|
|
20335
|
+
onChange: (c) => c && set({ colour: c }),
|
|
20336
|
+
suggestions: palette,
|
|
20337
|
+
className: "w-56"
|
|
20338
|
+
}),
|
|
20339
|
+
controls.includes("width") && /* @__PURE__ */ jsx(Labelled, {
|
|
20340
|
+
text: "Width",
|
|
20341
|
+
children: /* @__PURE__ */ jsx(Slider, {
|
|
20342
|
+
"aria-label": "Width",
|
|
20343
|
+
value: Math.round(shown.width * 10) / 10,
|
|
20344
|
+
onChange: (w) => set({ width: w }),
|
|
20345
|
+
min: Math.max(.5, scale),
|
|
20346
|
+
max: most,
|
|
20347
|
+
step: .5,
|
|
20348
|
+
className: "w-36"
|
|
20349
|
+
})
|
|
20350
|
+
}),
|
|
20351
|
+
controls.includes("opacity") && /* @__PURE__ */ jsx(Labelled, {
|
|
20352
|
+
text: "Opacity",
|
|
20353
|
+
children: /* @__PURE__ */ jsx(Slider, {
|
|
20354
|
+
"aria-label": "Opacity",
|
|
20355
|
+
value: Math.round(shown.opacity * 100),
|
|
20356
|
+
onChange: (o) => set({ opacity: o / 100 }),
|
|
20357
|
+
min: 5,
|
|
20358
|
+
max: 100,
|
|
20359
|
+
unit: "%",
|
|
20360
|
+
className: "w-36"
|
|
20361
|
+
})
|
|
20362
|
+
}),
|
|
20363
|
+
controls.includes("hardness") && /* @__PURE__ */ jsx(Labelled, {
|
|
20364
|
+
text: "Hardness",
|
|
20365
|
+
children: /* @__PURE__ */ jsx(Slider, {
|
|
20366
|
+
"aria-label": "Hardness",
|
|
20367
|
+
value: Math.round(shown.hardness * 100),
|
|
20368
|
+
onChange: (h) => set({ hardness: h / 100 }),
|
|
20369
|
+
min: 0,
|
|
20370
|
+
max: 100,
|
|
20371
|
+
unit: "%",
|
|
20372
|
+
className: "w-36"
|
|
20373
|
+
})
|
|
20374
|
+
}),
|
|
20375
|
+
controls.includes("nib") && /* @__PURE__ */ jsx(ToggleGroup, {
|
|
20376
|
+
label: "Nib",
|
|
20377
|
+
size: "sm",
|
|
20378
|
+
value: shown.nib,
|
|
20379
|
+
onChange: (n) => set({ nib: n }),
|
|
20380
|
+
options: Object.keys(NIB_WORDS).map((n) => ({
|
|
20381
|
+
value: n,
|
|
20382
|
+
label: NIB_WORDS[n]
|
|
20383
|
+
}))
|
|
20384
|
+
})
|
|
20385
|
+
]
|
|
20386
|
+
})]
|
|
20387
|
+
});
|
|
20388
|
+
}
|
|
20389
|
+
function Labelled({ text, children }) {
|
|
20390
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
20391
|
+
className: "inline-flex items-center gap-2",
|
|
20392
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
20393
|
+
"aria-hidden": true,
|
|
20394
|
+
className: "type-caption text-muted-foreground",
|
|
20395
|
+
children: text
|
|
20396
|
+
}), children]
|
|
20397
|
+
});
|
|
20398
|
+
}
|
|
20399
|
+
|
|
19201
20400
|
// src/components/save.tsx
|
|
19202
20401
|
/** Saves `value` after changes settle, never two at once, and says where it stands. The document's first `value` counts as saved. */
|
|
19203
20402
|
function useAutoSave({ value, save, delayMs = 1500, equals = Object.is, describeError = describeActionError }) {
|
|
@@ -22084,5 +23283,5 @@ function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose
|
|
|
22084
23283
|
});
|
|
22085
23284
|
}
|
|
22086
23285
|
|
|
22087
|
-
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, ByteView, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, Console, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DataTable, DataView$1 as DataView, Density, Dialog, Disclosure, Done, DragSource, EditListPlayer, EmptyState, FIT, Field, FileButton, FileDropOverlay, FileDropZone, FileOutcomes, FilmStrip, FolderPicker, FullscreenFrame, Glimpse, HttpError, INK_COLOURS, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, KeysLegend, LEVEL_FLOOR_DB, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaContents, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, NBSP, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PauseButton, PixelImage, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, SayPicture, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, ShortcutEditor, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelinePlayer, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, WorkflowSummary, Workspace, WorkspaceBar, actualPixelsScale, ancestorsOf, apiPage, appBase, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, checkKey, clampToRoom, clampViewport, clipsQueryKey, cn, colorSchemeScript, commandShortcut, continues, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, currentItem, describeActionError, describeHttpError, describeRegion, describeWorkflowSummary, detectPlatform, diffWords, differences, diskThresholds, drawRect, ease, editTimeOf, editTimes, encodeWav, errorPayload, explainMicrophoneError, fetchJson, fieldErrorsOf, findPage, fitRect, followAim, format, formatChord, frameAt, gainToVolume, geo, gridPoints, gutterOf, inkMatch, inputLevelThresholds, isDoubtful, isRefusal, isReservedChord, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, keyName, labelOf, lerpRect, locateInEdit, logScale, loudnessOf, marksFor, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, mediaStatRows, moveGutter, moveRect, nextBreak, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, pixelZoom, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, resample, resamplePeaks, resizeRect, rgbaToBlob, rmsDb, safeHref, sayPosition, serialiseSort, settleCut, skipAction, snapToGrid, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepOnGrid, stopSpeaking, summariseWorkflow, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useCountdown, useDifference, useEditList, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useInkMatch, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMediaStats, useMicrophone, useObjectUrl, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useRebindableShortcuts, useRecorder, useReserve, useSayOnShow, useSearchParam, useSelection, useSettledStatus, useSharedCursor, useSpeech, useSystemColorScheme, useSystemInfo, useTimeline, useTimelineZoom, useUndoable, useViewOptions, useViewPointers, useViewport, useWheelZoom, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
|
|
23286
|
+
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BRUSHES, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, ByteView, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, Console, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DataTable, DataView$1 as DataView, Density, Dialog, Disclosure, Done, DragSource, DrawingLayer, DrawingToolbar, EditListPlayer, EmptyState, FIT, Field, FileButton, FileDropOverlay, FileDropZone, FileOutcomes, FilmStrip, FolderPicker, FullscreenFrame, Glimpse, HttpError, INK_COLOURS, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, KeysLegend, LEVEL_FLOOR_DB, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaContents, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, NBSP, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PauseButton, PixelImage, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, SayPicture, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, ShortcutEditor, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelinePlayer, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, WorkflowSummary, Workspace, WorkspaceBar, actualPixelsScale, ancestorsOf, apiPage, appBase, applyOp, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, checkKey, clampToRoom, clampViewport, clipsQueryKey, cn, colorSchemeScript, commandShortcut, continues, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, currentItem, currentOf, curvePoints, describeActionError, describeHttpError, describeRegion, describeWorkflowSummary, detectPlatform, diffWords, differences, diskThresholds, drawRect, drawingToSvg, ease, editTimeOf, editTimes, emptyDrawing, encodeWav, errorPayload, explainMicrophoneError, feedbackMarker, fetchJson, fieldErrorsOf, filterMarkup, findPage, fitPoints, fitRect, followAim, format, formatChord, frameAt, gainToVolume, geo, gridPoints, gutterOf, hitsStroke, inkMatch, inputLevelThresholds, invertOp, isDoubtful, isRefusal, isReservedChord, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, keyName, labelOf, lerpRect, locateInEdit, logScale, loudnessOf, marksFor, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, mediaStatRows, moveGutter, movePoints, moveRect, newStrokeId, nextBreak, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, pixelZoom, plainText, pointsBox, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, replay, resample, resamplePeaks, rescaleDrawing, resizeRect, rgbaToBlob, rmsDb, safeHref, sayPosition, serialiseSort, settleCut, simplifyPoints, skipAction, smoothPath, snapToGrid, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepOnGrid, stopSpeaking, strokeAt, strokeBox, strokeShape, summariseWorkflow, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useCountdown, useDifference, useDrawing, useEditList, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useInkMatch, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMediaStats, useMicrophone, useObjectUrl, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useRebindableShortcuts, useRecorder, useReserve, useSayOnShow, useSearchParam, useSelection, useSettledStatus, useSharedCursor, useSpeech, useSystemColorScheme, useSystemInfo, useTimeline, useTimelineZoom, useUndoable, useViewOptions, useViewPointers, useViewport, useWheelZoom, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, widthsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
|
|
22088
23287
|
//# sourceMappingURL=index.js.map
|