@weasel-js/text-tools 1.19.1 → 2.0.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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/actions/editEffectText.ts","../src/actions/editTextAt.ts","../src/actions/enterTextEdit.ts","../src/editor/editingDrawOne.ts","../src/node/textItems.ts","../src/node/textOutline.ts","../src/node/textFrame.ts","../src/node/textPainter.ts","../src/editor/textHitAt.ts","../src/editor/hostTextEditors.ts","../src/editor/sceneTextDrafts.ts","../src/editor/textEditScreenPose.ts","../src/editor/useSceneTextEdit.ts","../src/editor/textEditStub.ts","../src/editor/canvasEditor.tsx","../src/ingest/textHandler.ts","../src/node/insert.ts","../src/node/properties.ts","../src/tools/sticky/stickyNode.ts","../src/tools/sticky/useStickyTool.ts","../src/tools/text/useTextTool.ts","../src/presets.ts","../src/toolSets.ts","../src/editor/textLayer.ts"],"names":["defineAction","isBody","ActionDisabledReason","loadTextOutlines","TextOutlinesError","resolveFill","effectSourceFor","poseFrameOf","isTextData","canvas","asNodeId","scene","shownLookup","scenePaintedPoseOf","withInheritedPaint","useLatest","useMemo","useDepSource","useRef","useEffect","registerPaintStandIn","DEFAULT_TEXT_FILL","shareToolOptions","defineTool","INSERT_DRAG_MODS","insertBindingBehaviors","INSERT_REPOSITION_BINDING","meanScale","textCommandFromPose"],"mappings":";;;;;;;;;;;;;;;;;;AAaA,SAAS,SAAA,CAAU,MAA8B,KAAA,EAAoF;AACnI,EAAA,MAAM,QAAQ,IAAA,EAAM,KAAA;AACpB,EAAA,IAAI,CAAC,KAAA,IAAS,CAAC,KAAA,IAAS,CAAC,IAAA,EAAM,QAAA,IAAY,CAAC,KAAA,CAAM,IAAI,CAAA,EAAG,OAAO,IAAA;AAChE,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,WAAA,GAAc,KAAK,CAAA;AACtC,EAAA,IAAI,CAAC,OAAO,OAAO,IAA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ACzB,QAAA,IAAI,IAAA,CAAK,IAAA,IAAQ,IAAA,CAAK,IAAA,CAAK,MAAA,GAAS,CAAA,IAAK,eAAA,CAAgB,IAAA,CAAK,IAAI,CAAA,KAAM,IAAA,CAAK,IAAA,EAAM;AACjF,UAAA,MAAM,IAAI,KAAA;AAAA,YACR,CAAA,sJAAA;AAAA,WAGF;AAAA,QACF;AACA,QAAA,MAAM,OAAA,GAAUC,mBAAAA,CAAoB,IAAA,EAAM,KAAK,CAAA;AAC/C,QAAA,QAAA,CAAS,KAAK,YAAA,GAAe,YAAA,CAAa,OAAA,EAAS,IAAI,IAAI,OAAO,CAAA;AAAA,MACpE;AAEA,MAAA,OAAO,QAAA;AAAA,IACT;AAAA,GACF;AACF","file":"index.js","sourcesContent":["/**\n * In path edit on a path an effect hides, the effect is lit and a click on it\n * opens its text, since the effect is what draws that text.\n */\nimport type { ActionDeps } from '@weasel-js/routing';\nimport { ActionDisabledReason, defineAction, isBody } from '@weasel-js/routing';\nimport { isTextData } from '@weasel-js/text';\nimport { effectSourceFor, type NodeId } from '@weasel-js/core';\nimport { anchorUnder, depOf } from '@weasel-js/path-tools';\nimport type {} from '../actionParamSchema';\nimport type {} from '../editor/textEditDep';\n\n/** The text source a click at `world` opens, with its length, or null. */\nfunction textUnder(deps: ActionDeps | undefined, world: { x: number; y: number } | undefined): { id: string; length: number } | null {\n const scene = deps?.scene;\n if (!world || !scene || !deps?.textEdit || !depOf(deps)) return null;\n const under = deps.nodeAtPoint?.(world);\n if (!under) return null;\n const text = effectSourceFor(scene, under as NodeId, 'items');\n if (text === null || scene.isLocked(text) || anchorUnder(deps, world) !== -1) return null;\n const data = scene.get(text)?.data;\n return { id: String(text), length: isTextData(data) ? data.text.length : 0 };\n}\n\n/** A click on a text-on-path effect's body opens its source text for editing, unless an anchor is under the pointer. */\nexport const editEffectTextAction = defineAction({\n id: 'editEffectText',\n label: 'Edit text along the path',\n // On the effect's body, so it outranks the untargeted anchor click; an anchor under the pointer gives the click back.\n defaultBinding: [{ spec: { kind: 'click', target: { kindOf: isBody }, mods: {} }, opts: { id: 'editEffectText.click' } }],\n eligible: { capability: 'edits-anchors' },\n requires: ['textEdit', 'nodeAtPoint', 'scene', 'editAnchors', 'view', 'kitSettings'],\n invoker: {\n timing: 'immediate',\n run(deps, params) {\n const hit = textUnder(deps, params?.world);\n if (hit) deps.textEdit?.startEdit(hit.id, { caret: hit.length });\n },\n },\n enabled: (deps, at) => (textUnder(deps, at) ? true : ActionDisabledReason.NotApplicable),\n});\n","import type {} from '../actionParamSchema';\nimport { ActionDisabledReason, defineAction, isBody } from '@weasel-js/routing';\n\n/**\n * Opens the top-most text node at the pointer in place, the caret at the glyph\n * there, through the `textEdit` dep. It declines where no text is under the\n * pointer, and where the double-click names a group above the text, whose own\n * double-click enters it, as `enterPathEdit` declines there. `enterTextEdit`\n * opens the selection instead.\n */\nexport const editTextAtAction = defineAction({\n id: 'editTextAt',\n label: 'Edit text here',\n defaultBinding: [{\n spec: { kind: 'doubleClick', target: { kindOf: isBody } },\n opts: { id: 'editTextAt.doubleClick' },\n }],\n eligible: { mode: 'normal' },\n requires: ['textEdit', 'hitAt'],\n invoker: {\n timing: 'immediate',\n run: (deps, params) => {\n const world = params?.world;\n const hit = world ? deps.textEdit?.textAt(world) : null;\n if (hit) deps.textEdit!.startEdit(hit.id, { caret: hit.caret });\n },\n },\n enabled: (deps, at) => {\n if (!at || deps?.hitAt?.(at)?.doubleClick) return ActionDisabledReason.NotApplicable;\n return deps?.textEdit?.textAt(at) ? true : ActionDisabledReason.NotApplicable;\n },\n});\n","import type { Action } from '@weasel-js/routing';\n\n/**\n * Starts in-place text editing on the single selected node. It has no\n * `defaultBinding`: it fires only via `Tool.bindings`.\n *\n * A `'selected-body'` target matches any selected node kind, so the action\n * skips a node `TextEditDep.isTextNode` rejects. With no `isTextNode` it fires\n * unconditionally, and the binding spec is the only gate; a binding can\n * pre-filter with `target: 'kind:text:selected'` instead.\n */\nexport const enterTextEditAction: Action & { requires: string[] } = {\n id: 'enterTextEdit',\n label: 'Enter text edit',\n eligible: { mode: 'normal' },\n requires: ['textEdit', 'operands'],\n invoker: {\n timing: 'immediate',\n run: (deps) => {\n const sel = deps.operands?.get() ?? [];\n if (sel.length !== 1) return;\n\n const id = sel[0];\n const textEdit = deps.textEdit;\n if (!textEdit) return;\n\n // Self-guard: skip non-text nodes when the predicate is supplied.\n if (textEdit.isTextNode && !textEdit.isTextNode(id)) return;\n\n textEdit.startEdit(id);\n },\n },\n};\n","import type { DrawCommand } from '@weasel-js/renderer';\nimport { defaultDrawOne, type SceneNode as Node, type NodePaintCtx, type View } from '@weasel-js/core';\n\n/** A scene `drawOne` that leaves out one node's glyphs. */\nexport type EditingDrawOne = <TNode extends Node<unknown, string, unknown>>(\n node: TNode, pose: unknown, view?: View, ctx?: NodePaintCtx,\n) => DrawCommand[];\n\n/** `base`, `defaultDrawOne` by default, less the text commands of the node `editingId` names. */\nexport function drawOneEditing(editingId: string | null, base: EditingDrawOne = defaultDrawOne): EditingDrawOne {\n return (node, pose, view, ctx) => {\n const out = base(node, pose, view, ctx);\n return node.id === editingId ? withoutText(out) : out;\n };\n}\n\n/** `cmds` with every text command gone, at any depth, and any group left\n * empty by it — a clipped node's glyphs ride in one. What the canvas keeps of\n * a node an editor's overlay stands in for. */\nexport function withoutText(cmds: readonly DrawCommand[]): DrawCommand[] {\n const out: DrawCommand[] = [];\n for (const c of cmds) {\n if (c.kind === 'text') continue;\n if (c.kind !== 'group') {\n out.push(c);\n continue;\n }\n const children = withoutText(c.children);\n if (children.length > 0) out.push({ ...c, children });\n }\n return out;\n}\n","/**\n * A text node as a path effect's items: its first line's grapheme clusters,\n * each one's outlines and decoration rules in its own frame, sized as the node\n * draws them.\n */\nimport { poseFrameOf, transformPath, type Affine, type PathInWorldPose } from '@weasel-js/geom';\nimport {\n loadTextOutlines, textClusters, TextOutlinesError, type TextCluster, type TextOutlineSource,\n} from '@weasel-js/text';\nimport { noteFontRead, type EffectItem } from '@weasel-js/core';\n\n/**\n * The clusters of `data`'s first line as items, laid in `pose`'s box width.\n * The pose's scale grows them; its rotation and skew are dropped, since the\n * path an effect lays them along decides their turn. `[]` while a face's\n * outlines are loading — the load is started, and the font read is noted so\n * the derivation re-runs once it lands.\n */\nexport function textEffectItems(data: TextOutlineSource, pose: PathInWorldPose): readonly EffectItem[] {\n noteFontRead();\n let clusters: TextCluster[];\n try {\n clusters = textClusters(data, { width: pose.width });\n } catch (err) {\n if (!(err instanceof TextOutlinesError)) throw err;\n loadTextOutlines(data).catch(() => {});\n return [];\n }\n const k = scaleOf(pose);\n const grow: Affine | null = k === 1 ? null : [k, 0, 0, k, 0, 0];\n return clusters.map((c) => ({\n length: c.advance * k,\n middle: c.middle * k,\n parts: c.paths.map((p) => ({\n path: grow === null ? p.path : transformPath(p.path, grow),\n fill: p.fill,\n stroke: p.stroke ?? null,\n })),\n bands: c.rules.map((r) => ({\n x0: r.x0 * k, x1: r.x1 * k, y0: r.y0 * k, y1: r.y1 * k, fill: r.fill, stroke: r.stroke ?? null,\n })),\n }));\n}\n\nfunction scaleOf(pose: PathInWorldPose): number {\n const m = poseFrameOf(pose);\n return m === null ? 1 : Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2]));\n}\n","/** A text node's glyphs as its outline: what `kit:text` answers for `NodeShapeEntry.outline`. */\nimport type { PathInWorldPose } from '@weasel-js/geom';\nimport {\n loadTextOutlines, textToPath, textToPathsByPaint, TextOutlinesError, type TextOutlineSource,\n} from '@weasel-js/text';\nimport type { TextNodeData } from './textPainter';\nimport { NodeOutlineError, strokeCovers, withInheritedPaint, type InheritedPaint, type NodeOutline } from '@weasel-js/core';\n\n/** `d`'s glyphs laid in `box`, the box its padding insets, wearing its paint with `inherited`'s resolved. */\nexport function textOutlineOf(d: TextNodeData, box: PathInWorldPose, inherited?: InheritedPaint): NodeOutline {\n const { text, runs, style, verticalAlign, fit, fill, stroke } = withInheritedPaint(d, inherited);\n const data: TextOutlineSource = { text, runs, style, verticalAlign, fit, fill, stroke };\n return {\n stroked: strokeCovers(stroke) || !!runs?.some((r) => strokeCovers(r.stroke)),\n path: () => outlined(() => textToPath(data, box)),\n parts: () => outlined(() => textToPathsByPaint(data, box)),\n load: () => loadTextOutlines(data),\n };\n}\n\nfunction outlined<T>(build: () => T): T {\n try {\n return build();\n } catch (err) {\n if (!(err instanceof TextOutlinesError)) throw err;\n throw new NodeOutlineError(err.message, {\n summary: `Text in \"${err.family}\" can't be converted to outlines`,\n pending: err.reason === 'outlines-loading',\n cause: err,\n });\n }\n}\n","/**\n * What a text node with a `background` draws around its box: an edge in a\n * shade of the background, and a shadow under it. Described once here, and\n * drawn by the canvas painter and written by the SVG export from it.\n */\nimport { isSolidPaint, mixOklab, parseColor, resolveFill, rgbaToHex, type Fill } from '@weasel-js/paint';\nimport { dropShadowLayers } from '@weasel-js/renderer';\nimport type { Path, Rect } from '@weasel-js/geom';\n\n/** A rule just inside a text node's box, in its background's color mixed toward black. */\nexport interface TextEdge {\n /** World units. */\n width: number;\n /** How far toward black, 0..1, mixed in OKLab, so the edge keeps the background's hue. */\n shade: number;\n}\n\n/** The shadow a text node's background casts: black at `alpha`, offset and blurred in world units. */\nexport interface TextShadow {\n x: number;\n y: number;\n blur: number;\n alpha: number;\n}\n\n/** A text node's frame, ready to draw: each part `null` when there is none. */\nexport interface TextFrame {\n /** Filled in `color`, each at `opacity`, under the background. */\n shadow: { paths: Path[]; color: string; opacity: number } | null;\n /** Stroked in `color` at `width`, over the background. */\n edge: { path: Path; color: string; width: number } | null;\n}\n\n\nconst BLACK = [0, 0, 0, 1] as const;\n\n/** `background`'s color mixed `shade` of the way to black, or `null` for a background with no single color. */\nexport function edgeColor(background: Fill, shade: number): string | null {\n const paint = background.paint;\n if (paint === undefined || !isSolidPaint(paint)) return null;\n return rgbaToHex(mixOklab(BLACK, parseColor(paint.color), Math.min(1, Math.max(0, shade))));\n}\n\n/** The frame of a text node with `d`'s background, edge and shadow, round `box`. */\nexport function textFrameOf(\n d: { background?: Fill | null; edge?: TextEdge; shadow?: TextShadow },\n box: Rect,\n): TextFrame {\n const bg = resolveFill(d.background);\n if (!bg) return { shadow: null, edge: null };\n return { shadow: shadowOf(d.shadow, box), edge: edgeOf(d.edge, bg, box) };\n}\n\nfunction shadowOf(s: TextShadow | undefined, box: Rect): TextFrame['shadow'] {\n if (!s || !(s.alpha > 0)) return null;\n const { paths, alpha } = dropShadowLayers(box, 0, s);\n return { paths, color: rgbaToHex([0, 0, 0, Math.min(1, s.alpha)]), opacity: alpha };\n}\n\nfunction edgeOf(edge: TextEdge | undefined, bg: Fill, box: Rect): TextFrame['edge'] {\n if (!edge || !(edge.width > 0)) return null;\n const color = edgeColor(bg, edge.shade);\n if (color === null) return null;\n const w = Math.min(edge.width, box.width / 2, box.height / 2);\n return {\n path: { kind: 'rect', x: box.x + w / 2, y: box.y + w / 2, width: box.width - w, height: box.height - w },\n color,\n width: w,\n };\n}\n\n/** How far a text node's shadow reaches, as a box, or `null` for none. */\nexport function textShadowBox(d: { background?: Fill | null; shadow?: TextShadow }, box: Rect): Rect | null {\n const s = d.shadow;\n if (!s || !(s.alpha > 0) || !resolveFill(d.background)) return null;\n const e = Math.max(0, s.blur) / 2;\n return { x: box.x + s.x - e, y: box.y + s.y - e, width: box.width + 2 * e, height: box.height + 2 * e };\n}\n","import {\n PATH_L,\n PATH_M,\n PATH_Z,\n type PolygonPath,\n type Rect,\n unionRects,\n} from '@weasel-js/geom';\nimport type { Stroke, Fill, Inherit } from '@weasel-js/paint';\nimport type { StyledRun, TextFit, TextPose, TextStyle, TextVerticalAlign } from '@weasel-js/text';\nimport { textEngineGeneration, textLineBoxes, type TextOutlineSource } from '@weasel-js/text';\nimport { faceGeneration } from '@weasel-js/font';\nimport type { PathInWorldPose } from '@weasel-js/geom';\nimport { textEffectItems } from './textItems';\nimport { textOutlineOf } from './textOutline';\nimport { commandFill, textCommandFromPose, type DrawCommand } from '@weasel-js/renderer';\nimport { INHERIT, resolveFill, resolveStroke } from '@weasel-js/paint';\nimport { textFrameOf, textShadowBox, type TextEdge, type TextShadow } from './textFrame';\nimport { inkReach, nodeMemo, PAINT_SLOT, paintsPose, strokeOutsetPerAxis, type InheritedPaint, type NodeShapeEntry, type RectPose } from '@weasel-js/core';\n\n/** The `data` a `kit:text` node carries. */\nexport interface TextNodeData {\n text: string;\n style?: TextStyle;\n runs?: readonly StyledRun[];\n fill?: Fill | Inherit | null;\n stroke?: Stroke | Inherit | null;\n verticalAlign?: TextVerticalAlign;\n /** Paint for the whole pose box, drawn under the glyphs. `fill` is the\n * glyphs' own paint, so a box behind them needs a key of its own. */\n background?: Fill | null;\n /** World units between the pose box and the box the text lays out in, on\n * every side. */\n padding?: number;\n /** What happens to text that runs past the pose box: `'visible'` (the\n * default) draws it there, `'clip'` cuts it at the box's edge. */\n overflow?: TextOverflow;\n /** `'shrink'` sets the text at the largest size, at most its own, whose\n * lines fit the box inside `padding`. Default `'none'`. */\n fit?: TextFit;\n /** A rule just inside the box in a shade of `background`. Needs a solid background. */\n edge?: TextEdge;\n /** The shadow `background` casts. Needs a background. */\n shadow?: TextShadow;\n}\n\n/** How a text node treats lines that run past its box. */\nexport type TextOverflow = 'visible' | 'clip';\n\n\n/** `cmd` cut to `box`: a group whose clip is the box as a rect, which the\n * renderer cuts on the CPU when the frame keeps it axis-aligned. */\nexport function clippedToBox(cmd: DrawCommand, box: Rect): DrawCommand {\n return {\n kind: 'group',\n clip: { kind: 'rect', x: box.x, y: box.y, width: box.width, height: box.height },\n children: [cmd],\n };\n}\n\n/** The box a text node's lines lay out in: its pose box, inset by\n * `data.padding` and never past its center. */\nexport function textBoxOf(\n d: Pick<TextNodeData, 'padding'>,\n p: RectPose,\n): { x: number; y: number; width: number; height: number } {\n const pad = Math.max(0, d.padding ?? 0);\n const px = Math.min(pad, p.width / 2);\n const py = Math.min(pad, p.height / 2);\n return { x: p.x + px, y: p.y + py, width: p.width - 2 * px, height: p.height - 2 * py };\n}\n\n/** A `kit:text` node as the `TextPose` every text consumer reads, in the box\n * {@link textBoxOf} insets. The stroke goes through the same resolver every\n * other node kind's does, so one carrying no paint is dropped here rather\n * than throwing in the renderer. */\nexport function textPoseOf(d: TextNodeData, p: RectPose, inherited?: InheritedPaint): TextPose {\n return {\n ...textBoxOf(d, p),\n text: d.text,\n runs: d.runs as StyledRun[] | undefined,\n style: d.style,\n fill: d.fill === INHERIT ? resolveFill(d.fill, inherited?.fill) : d.fill,\n stroke: resolveStroke(d.stroke, inherited?.stroke) ?? undefined,\n verticalAlign: d.verticalAlign,\n fit: d.fit,\n };\n}\n\n/** The node shape that paints a text node: one whose data carries a `text` string, drawn at its box pose. */\nexport const TEXT_PAINTER: NodeShapeEntry<unknown, RectPose> = {\n id: 'kit:text',\n snapsToBox: true,\n matches: (node) => {\n if (!paintsPose(node.pose)) return false;\n const d = node.data as { text?: string } | null;\n return d?.text != null;\n },\n // Memoized because the renderer's layout cache keys on the `ResolvedRun[]` array\n // identity: a fresh runs array per frame would leave that cache missing on every\n // draw. Both resolvers are pure style merging — no font reads — so `(data, pose)` is\n // the whole key, with the view scale beside it for `{ px }` text. See PAINT_SLOT.\n paint: (node, pose, ctx) => {\n const d = node.data as TextNodeData;\n const inherited = ctx?.inherited;\n const scale = textLayoutScale(d, ctx?.scale);\n if (scale === 1) return nodeMemo(node, PAINT_SLOT, pose, () => paintText(d, pose, inherited, 1), inherited);\n const held = nodeMemo(node, SCREEN_PAINT_SLOT, pose,\n (): ScreenPaint => ({ scale, inherited, cmds: paintText(d, pose, inherited, scale) }));\n if (held.scale !== scale || held.inherited !== inherited) {\n held.scale = scale;\n held.inherited = inherited;\n held.cmds = paintText(d, pose, inherited, scale);\n }\n return held.cmds;\n },\n // The pose is a layout box, not a bounding box: the union of the line boxes is what\n // the node actually covers, so picking, lasso, and clipping stop grabbing blank space.\n //\n // `null` rather than an empty path when there are no non-blank lines: a caller\n // reading \"no silhouette\" falls back to the pose rect, which keeps an empty text\n // node pickable.\n //\n // A background is ink across the whole box, so a node with one is its box.\n // A clipped node's lines are cut to the box, as they are drawn.\n silhouette: (node, pose, ctx) => {\n const d = node.data as TextNodeData;\n if (resolveFill(d.background)) {\n return { kind: 'rect', x: pose.x, y: pose.y, width: pose.width, height: pose.height };\n }\n const lines = textLineBoxes(textPoseOf(d, pose), { scale: textLayoutScale(d, ctx?.scale) });\n const boxes = d.overflow === 'clip' ? cutRects(lines, pose) : lines;\n if (boxes.length === 0) return null;\n return rectsToPath(boxes);\n },\n // `filled` is unconditional, `data.fill: null` included: the silhouette above is line\n // boxes, not glyph ink, so reporting outline-only text as unfilled would leave it\n // grabbable within a stroke width of a box edge and nowhere near the letters.\n ink: (node, _pose, ctx) => {\n const d = node.data as TextNodeData;\n return { filled: true, ...inkReach(resolveStroke(d.stroke, ctx?.inherited?.stroke), ctx?.scale) };\n },\n drawnBounds: (node, pose, ctx) => {\n const d = node.data as TextNodeData;\n const stroke = resolveStroke(d.stroke, ctx?.inherited?.stroke);\n const lines = stroke\n ? strokedLinesBox(pose, textLineBoxes(textPoseOf(d, pose, ctx?.inherited), { scale: textLayoutScale(d, ctx?.scale) }), strokeOutsetPerAxis(stroke, ctx))\n : null;\n const shadow = textShadowBox(d, pose);\n return shadow ? unionRects([lines ?? pose, shadow]) : lines;\n },\n outline: (node, pose, ctx) => {\n const d = node.data as TextNodeData;\n return textOutlineOf(d, { ...pose, ...textBoxOf(d, pose) }, ctx?.inherited);\n },\n // Line boxes and glyphs follow the faces and the registered layout engines.\n geometryGeneration: () => faceGeneration() + textEngineGeneration(),\n silhouetteKey: (node, ctx) => textLayoutScale(node.data as TextNodeData, ctx?.scale),\n effectItems: (node, pose) => textEffectItems(node.data as TextOutlineSource, pose as PathInWorldPose),\n};\n\n/** The view scale `d` lays out at: `scale` when its style or a run sizes\n * something in `{ px }`, else 1, so world-sized text keeps its memo through a zoom. */\nexport function textLayoutScale(d: Pick<TextNodeData, 'style' | 'runs'>, scale: number | undefined): number {\n if (scale === undefined || scale === 1) return 1;\n const sized = (s: Pick<TextStyle, 'fontSize' | 'letterSpacing'> | undefined): boolean =>\n typeof s?.fontSize === 'object' || typeof s?.letterSpacing === 'object';\n return sized(d.style) || (d.runs?.some(sized) ?? false) ? scale : 1;\n}\n\n/** A `{ px }` text node's commands and the scale and inherited paint they were laid out under. */\ninterface ScreenPaint { scale: number; inherited: InheritedPaint | undefined; cmds: DrawCommand[] }\n\nconst SCREEN_PAINT_SLOT = 'shape:paint:text-screen';\n\n/** `y` is the top of the first line box, not a baseline — see `TextDrawCommand.y`. */\nfunction paintText(d: TextNodeData, pose: RectPose, inherited: InheritedPaint | undefined, scale: number): DrawCommand[] {\n const laid = textCommandFromPose(textPoseOf(d, pose, inherited), scale);\n const text = d.overflow === 'clip' ? clippedToBox(laid, pose) : laid;\n const bg = resolveFill(d.background);\n if (!bg) return [text];\n const fill = commandFill(bg, pose);\n const { shadow, edge } = textFrameOf(d, pose);\n const out: DrawCommand[] = [];\n if (shadow) {\n const paint = { paint: { kind: 'solid' as const, color: shadow.color } };\n out.push({ kind: 'group', alpha: shadow.opacity, children: shadow.paths.map((path) => ({ kind: 'path' as const, path, fill: paint })) });\n }\n out.push({ kind: 'path', path: { kind: 'rect', x: pose.x, y: pose.y, width: pose.width, height: pose.height }, ...(fill ? { fill } : {}) });\n if (edge) out.push({ kind: 'path', path: edge.path, stroke: { paint: { kind: 'solid', color: edge.color }, width: edge.width } });\n out.push(text);\n return out;\n}\n\n/** Each of `rects` cut to `box`, leaving out any it does not overlap. */\nfunction cutRects(rects: readonly Rect[], box: Rect): Rect[] {\n const out: Rect[] = [];\n for (const r of rects) {\n const x0 = Math.max(r.x, box.x);\n const y0 = Math.max(r.y, box.y);\n const x1 = Math.min(r.x + r.width, box.x + box.width);\n const y1 = Math.min(r.y + r.height, box.y + box.height);\n if (x1 > x0 && y1 > y0) out.push({ x: x0, y: y0, width: x1 - x0, height: y1 - y0 });\n }\n return out;\n}\n\n/**\n * The layout box grown where a stroked line reaches it: each line box, cut to\n * the layout box, then outset by the stroke's reach. A line that overflows the\n * layout box is left to it — the layout box is what a text node claims.\n */\nfunction strokedLinesBox(pose: RectPose, lines: readonly Rect[], reach: { x: number; y: number }): Rect | null {\n if (!(reach.x > 0 || reach.y > 0)) return null;\n let x0 = pose.x, y0 = pose.y, x1 = pose.x + pose.width, y1 = pose.y + pose.height;\n for (const l of lines) {\n const lx0 = Math.max(l.x, pose.x), ly0 = Math.max(l.y, pose.y);\n const lx1 = Math.min(l.x + l.width, pose.x + pose.width), ly1 = Math.min(l.y + l.height, pose.y + pose.height);\n if (lx1 <= lx0 || ly1 <= ly0) continue;\n x0 = Math.min(x0, lx0 - reach.x); y0 = Math.min(y0, ly0 - reach.y);\n x1 = Math.max(x1, lx1 + reach.x); y1 = Math.max(y1, ly1 + reach.y);\n }\n return { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };\n}\n\n/**\n * Union of axis-aligned rects as one multi-contour `PolygonPath`.\n *\n * Every contour winds the same way, so `'nonzero'` reads overlapping rects as\n * covered rather than punching a hole where two lines happen to overlap —\n * which they do the moment `lineHeight` drops below 1.\n */\nexport function rectsToPath(rects: readonly { x: number; y: number; width: number; height: number }[]): PolygonPath {\n const commands = new Uint8Array(rects.length * 6);\n const coords = new Float32Array(rects.length * 10);\n let ci = 0;\n let cmd = 0;\n for (const r of rects) {\n const { x, y, width: w, height: h } = r;\n commands[cmd++] = PATH_M; coords[ci++] = x; coords[ci++] = y;\n commands[cmd++] = PATH_L; coords[ci++] = x + w; coords[ci++] = y;\n commands[cmd++] = PATH_L; coords[ci++] = x + w; coords[ci++] = y + h;\n commands[cmd++] = PATH_L; coords[ci++] = x; coords[ci++] = y + h;\n commands[cmd++] = PATH_L; coords[ci++] = x; coords[ci++] = y;\n commands[cmd++] = PATH_Z;\n }\n return { kind: 'polygon', commands, coords, fillRule: 'nonzero' };\n}\n","import { boundsOfPath, pathContainsPoint, type Path } from '@weasel-js/geom';\nimport { caretIndexAt, pointInTextPose, type StyledRun, type TextFit, type TextStyle, type TextVerticalAlign } from '@weasel-js/text';\nimport { textBoxOf } from '../node/textPainter';\nimport { AUTO_POSE_DESCRIPTOR, derivedPartsOf, effectSourceFor, indexedCandidates, nodesAsShown, sceneDerivedPathOf, scenePaintedPoseOf, shownLookup, targetTransformOf, worldToLocal, type RectPose, type Scene } from '@weasel-js/core';\n\n/** How a node's text fields are read from its `data`. */\nexport interface TextReads<TData> {\n isText(data: TData): boolean;\n text(data: TData): string;\n style(data: TData): TextStyle | undefined;\n runs(data: TData): readonly StyledRun[] | undefined;\n verticalAlign(data: TData): TextVerticalAlign | undefined;\n padding(data: TData): number | undefined;\n /** How the text's size answers to its box. Absent reads none. */\n fit?(data: TData): TextFit | undefined;\n}\n\n/**\n * The top-most unlocked text node at world `(cx, cy)`, and the caret there.\n *\n * `pointInTextPose` and `caretIndexAt` work in the node's own box, so the\n * point is taken back through the frame the node is drawn in. The whole box\n * takes the point, padding included; the caret is placed in the inset one.\n *\n * A path effect hiding a text source answers for it within the bounds of any\n * glyph it lays, counters included, with the caret at the end of the text.\n * A curved glyph takes a double-click anywhere in its axis-aligned box, wider\n * than the ink selection picks.\n *\n * The scene's pick index, read through `AUTO_POSE_DESCRIPTOR` because the\n * text box is read as a rect, narrows the walk to the nodes boxed over the\n * point when it is current; the answer is the full walk's either way.\n */\nexport function textHitAt<TData, TPose extends RectPose>(\n scene: Scene<TData, string, TPose>,\n read: TextReads<TData>,\n cx: number,\n cy: number,\n): { id: string; caret: number } | null {\n // renderOrder() is back-to-front, so iterate in reverse and stop on the first hit.\n // Hit as painted: an open edit's draft is what the glyphs and the caret are laid out from.\n const order = indexedOrderAt(scene, cx, cy) ?? nodesAsShown(scene.overrides, scene.renderOrderNodes());\n const shown = shownLookup(scene);\n const paintedPoseOf = scenePaintedPoseOf(scene);\n const derivedPathOf = sceneDerivedPathOf(scene);\n for (let i = order.length - 1; i >= 0; i--) {\n const node = order[i];\n if (scene.isLocked(node.id) || scene.isHidden(node.id)) continue;\n if (!read.isText(node.data)) {\n const source = effectSourceFor(scene, node.id, 'items');\n const text = source === null || scene.isLocked(source) ? undefined : shown.get(source);\n if (text === undefined || !read.isText(text.data)) continue;\n const path = derivedPathOf(node);\n if (path !== null && onAGlyph(path, cx, cy)) return { id: String(source), caret: read.text(text.data).length };\n continue;\n }\n const at = paintedPoseOf(node);\n const p = worldToLocal(targetTransformOf(at), cx, cy);\n if (!p) continue;\n const pose = {\n ...textBoxOf({ padding: read.padding(node.data) }, at),\n text: read.text(node.data),\n runs: read.runs(node.data) as StyledRun[] | undefined,\n style: read.style(node.data),\n verticalAlign: read.verticalAlign(node.data),\n fit: read.fit?.(node.data),\n };\n const box = { x: at.x, y: at.y, width: at.width, height: at.height };\n if (!pointInTextPose(p.x, p.y, { ...pose, ...box })) continue;\n return { id: String(node.id), caret: caretIndexAt(p.x, p.y, pose) };\n }\n return null;\n}\n\ntype ShownNode<TData, TPose> = ReturnType<Scene<TData, string, TPose>['renderOrderNodes']>[number];\n\n/** The nodes the pick index boxes over `(cx, cy)`, as shown and in render order, or null when it has no answer. */\nfunction indexedOrderAt<TData, TPose>(\n scene: Scene<TData, string, TPose>,\n cx: number,\n cy: number,\n): readonly ShownNode<TData, TPose>[] | null {\n const broad = { box: { x: cx, y: cy, width: 0, height: 0 } };\n const found = indexedCandidates(scene as never, AUTO_POSE_DESCRIPTOR, () => broad);\n return found as unknown as readonly ShownNode<TData, TPose>[] | null;\n}\n\n/** Whether `(x, y)` is within the bounds of one of `path`'s parts: a glyph's box, so a stem too thin to land on and the\n * hole in an o still take the click. */\nfunction onAGlyph(path: Path, x: number, y: number): boolean {\n const parts = derivedPartsOf(path);\n if (parts === undefined) return pathContainsPoint(path, x, y);\n return parts.some(({ path: part }) => {\n const b = boundsOfPath(part);\n return x >= b.x && x <= b.x + b.width && y >= b.y && y <= b.y + b.height;\n });\n}\n","/**\n * The containers of every text editor a host mounted with `useSceneTextEdit`,\n * and the `textEdit` dep each answers. The canvas's own editor (`textPreset`)\n * stands down for a canvas inside one and answers with the host's dep instead,\n * so a double-click there opens the host's overlay and no second one. Each\n * host's editor stands in for the glyphs of the node it has open\n * (`registerPaintStandIn`), so the canvas leaves them out.\n */\nimport { registerPaintStandIn } from '@weasel-js/core';\nimport type { TextEditDep } from './textEditDep';\nimport { withoutText } from './editingDrawOne';\n\ninterface HostEditor {\n container: HTMLElement;\n scene: object;\n dep: TextEditDep;\n}\n\nconst editors = new Map<symbol, HostEditor>();\n\n/** A host's editor, registered with {@link registerHostTextEditor}. */\nexport interface HostTextEditorHandle {\n /** Report the node the editor now has open, `null` for none. */\n setEditing(id: string | null): void;\n dispose(): void;\n}\n\n/** Record `container` as holding a host's editor of `scene`, answering `dep`, until the handle is disposed. */\nexport function registerHostTextEditor(container: HTMLElement, scene: object, dep: TextEditDep): HostTextEditorHandle {\n const key = Symbol('textEditor');\n editors.set(key, { container, scene, dep });\n const standIn = registerPaintStandIn(scene, container, withoutText);\n return {\n setEditing(id) {\n if (editors.has(key)) standIn.show(id);\n },\n dispose() {\n editors.delete(key);\n standIn.dispose();\n },\n };\n}\n\n/** Whether a host's editor holds `el`. */\nexport function hostTextEditorHolds(el: Element): boolean {\n for (const e of editors.values()) if (e.container.contains(el)) return true;\n return false;\n}\n\n/** The dep of a host's editor of `scene` holding `el`, or `null` for none. */\nexport function hostTextEditDep(el: Element, scene: object): TextEditDep | null {\n for (const e of editors.values()) if (e.scene === scene && e.container.contains(el)) return e.dep;\n return null;\n}\n","/**\n * A text edit shown to the scene keystroke by keystroke, for the readers that\n * see a node somewhere besides the overlay: text something derives from, such\n * as the hidden text a path effect lays along a path, or a second view.\n */\nimport type { StyledRun, TextStyle } from '@weasel-js/text';\nimport type { TextEditDraft } from '@weasel-js/text-dom';\nimport type { DefaultTextData, UseSceneTextEditOptions } from './useSceneTextEdit';\nimport { asNodeId, type PoseHold, type Scene, type SceneBatchOptions } from '@weasel-js/core';\n\n/**\n * Options for a batch that makes node `id` for a text edit to fill in: `scene.batch('Add label', add,\n * textEditJoin(id))`. The edit's commit then joins that batch's undo entry, so one undo takes the node and its\n * first text away together. A host's `onEnd` that removes a node left empty passes the same options, and the\n * removal joins too. The run ends with the edit: a later edit of the node is an entry of its own.\n */\nexport function textEditJoin(id: string): SceneBatchOptions {\n return { coalesceKey: `textEdit:${id}` };\n}\n\n/** `data` with an edit's text, runs and style folded in through the options' setters, for one `scene.update`. */\nexport function editedData<TData extends DefaultTextData>(\n data: TData,\n edit: { text: string; runs?: readonly StyledRun[]; style?: TextStyle },\n { setText, setRuns, setStyle }: UseSceneTextEditOptions<TData>,\n): TData {\n let next = setText ? setText(data, edit.text) : { ...data, text: edit.text };\n if (edit.runs) next = setRuns ? setRuns(next, [...edit.runs]) : { ...next, runs: edit.runs };\n if (edit.style) next = setStyle ? setStyle(next, edit.style) : { ...next, style: edit.style };\n return next;\n}\n\n/** Where an edit's writes go. Each `draft` is shown as a data override folding the draft into whatever the node stores,\n * so a recorded write made meanwhile shows through it and the document holds no draft; the `commit` records the\n * result as one undo entry and then lets the override go; `end` lets it go, so a canceled edit leaves no entry and\n * the redo stack as it was. */\nexport function sceneTextDrafts<TData extends DefaultTextData, TLayer extends string, TPose>(\n sceneRef: { readonly current: Scene<TData, TLayer, TPose> },\n optsRef: { readonly current: UseSceneTextEditOptions<TData> },\n): {\n draft: (id: string, draft: TextEditDraft) => void;\n commit: (id: string, data: TData) => void;\n end: (id: string) => void;\n /** Let any open edit's draft go, as an unmount must: the overlay goes without an `end`. */\n close: () => void;\n} {\n /** The open edit's claim on the scene's overrides, with the scene it was made on. */\n let held: { id: string; scene: Scene<TData, TLayer, TPose>; hold: PoseHold<TPose, TData> } | null = null;\n const release = (id: string): void => {\n if (held?.id !== id) return;\n held.hold.drop();\n held = null;\n };\n return {\n draft: (id, draft) => {\n const scene = sceneRef.current;\n if (scene.get(asNodeId(id)) === undefined) return;\n if (held !== null && (held.id !== id || held.scene !== scene)) release(held.id);\n held ??= { id, scene, hold: scene.overrides.hold() };\n const opts = optsRef.current;\n held.hold.show([[asNodeId(id), { data: (stored) => editedData(stored, draft, opts) }]]);\n },\n commit: (id, data) => {\n const scene = sceneRef.current;\n scene.batch('Edit text', () => scene.update(asNodeId(id), { data }), textEditJoin(id));\n // After the write, so no frame shows the text from before the edit in between.\n release(id);\n },\n end: release,\n close: () => {\n if (held !== null) release(held.id);\n },\n };\n}\n","import { meanScale, poseFrameOf } from '@weasel-js/geom';\nimport { resolveScreenLength } from '@weasel-js/paint';\nimport { DEFAULT_TEXT_STYLE, textFitScale, type StyledRun } from '@weasel-js/text';\nimport type { TextEditClipRect, TextEditScreenPose } from '@weasel-js/text-dom';\nimport { textBoxOf, textLayoutScale, type TextOverflow } from '../node/textPainter';\nimport type { TextReads } from './textHitAt';\nimport { type RectPose, type View } from '@weasel-js/core';\n\n/** What the overlay's pose reads of a node's `data`. */\nexport type ScreenPoseReads<TData> = TextReads<TData> & { overflow(data: TData): TextOverflow | undefined };\n\n/** The overlay's pose for a node painted at `painted`: its text box, inset\n * about the box center, which is all the overlay's frame needs, projected\n * through `view`. Text the node's `fit` shrinks is edited at its own size\n * under a zoom smaller by the fit, in a box larger by it, so it shows at the\n * size the canvas draws it and writes its own sizes back. */\nexport function screenPoseOf<TData>(\n d: TData,\n painted: RectPose,\n read: ScreenPoseReads<TData>,\n view: View | undefined,\n origin: TextEditClipRect | undefined,\n): TextEditScreenPose {\n const inset = textBoxOf({ padding: read.padding(d) }, painted);\n const box = screenBoxOf({ ...painted, ...inset }, view, origin);\n const style = read.style(d);\n const runs = read.runs(d) as StyledRun[] | undefined;\n const scale = textLayoutScale({ style, runs }, view ? meanScale(view.scale) : undefined);\n const k = textFitScale({\n ...inset, text: read.text(d), runs, style,\n verticalAlign: read.verticalAlign(d), fit: read.fit?.(d),\n }, scale);\n const clip = read.overflow(d) === 'clip' ? clipToBox(inset, painted) : null;\n return {\n ...box,\n width: box.width / k,\n height: box.height / k,\n zoom: box.zoom * k,\n fontSize: resolveScreenLength(style?.fontSize ?? DEFAULT_TEXT_STYLE.fontSize, scale),\n pxScale: scale,\n verticalAlign: read.verticalAlign(d),\n ...(clip ? { clip: { top: clip.top / k, left: clip.left / k, bottom: clip.bottom / k, right: clip.right / k } } : {}),\n };\n}\n\n/** How far `box` reaches past `inner` on each side: the overlay's cut at\n * `box` when its own pose is `inner`. */\nfunction clipToBox(inner: RectPose, box: RectPose): NonNullable<TextEditScreenPose['clip']> {\n return {\n top: inner.y - box.y,\n left: inner.x - box.x,\n bottom: box.y + box.height - (inner.y + inner.height),\n right: box.x + box.width - (inner.x + inner.width),\n };\n}\n\n/**\n * `pose`'s box as the overlay takes it, `origin` being the canvas's corner in\n * container pixels. Only the box center is projected, since the overlay's\n * frame is about it. Width and height stay in world units and reach the\n * screen through the overlay's own `scale(zoom)` — see\n * `TextEditScreenPose.zoom`.\n */\nfunction screenBoxOf(\n pose: RectPose,\n view: View | undefined,\n origin: { x: number; y: number } | undefined,\n): Pick<TextEditScreenPose, 'x' | 'y' | 'width' | 'height' | 'frame'> & { zoom: number } {\n const zoom = view ? view.scale.x : 1;\n const zoomY = view ? view.scale.y : 1;\n const cx = (origin?.x ?? 0) + (pose.x + pose.width / 2 - (view?.x ?? 0)) * zoom;\n const cy = (origin?.y ?? 0) + (pose.y + pose.height / 2 - (view?.y ?? 0)) * zoomY;\n return {\n x: cx - (pose.width * zoom) / 2,\n y: cy - (pose.height * zoom) / 2,\n width: pose.width,\n height: pose.height,\n zoom,\n frame: frameLinearOf(pose, zoomY / zoom),\n };\n}\n\n/** The linear part of the frame `pose` is drawn in, as the overlay takes it.\n * `stretch` is the view's y scale over its x scale: the overlay scales both\n * axes by the x scale, so the frame carries what is left of y. */\nfunction frameLinearOf(pose: unknown, stretch: number): TextEditScreenPose['frame'] {\n const m = poseFrameOf(pose);\n if (!m && stretch === 1) return undefined;\n const [a, b, c, d] = m ?? [1, 0, 0, 1];\n return [a, b * stretch, c, d * stretch];\n}\n","/**\n * `useSceneTextEdit` — scene-aware wrapper around `useTextEdit`: scene\n * lookups for text / style / runs / screen-pose, and\n * `scene.update(id, { data })` for commits. The overlay and a double-click\n * both read the pose a node is painted at, so text inside a container whose\n * pose is a frame is edited where it is drawn.\n *\n * Defaults assume the node's `data` carries `text` / `style` / `runs`\n * directly. For custom data shapes, override any of the optional projections.\n * Consumers with non-rect poses should drop down to raw `useTextEdit` and\n * supply their own `getScreenPose`.\n */\nimport { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport { drawOneEditing, type EditingDrawOne } from './editingDrawOne';\nimport { textHitAt } from './textHitAt';\nimport { registerHostTextEditor, type HostTextEditorHandle } from './hostTextEditors';\nimport { editedData, sceneTextDrafts } from './sceneTextDrafts';\nimport type { Stroke, Fill, Inherit } from '@weasel-js/paint';\nimport { layoutBoxOf, type Point2 } from '@weasel-js/routing';\nimport { isTextData, type StyledRun, type TextFit, type TextPaint, type TextStyle, type TextVerticalAlign } from '@weasel-js/text';\nimport type { TextOverflow } from '../node/textPainter';\nimport { screenPoseOf } from './textEditScreenPose';\nimport { useTextEdit, type TextEditClipRect, type UseTextEditReturn } from '@weasel-js/text-dom';\nimport { asNodeId, findMountedCanvas, inheritedPaintIn, scenePaintedPoseOf, shownLookup, withInheritedPaint, type MountedCanvas, type RectPose, type Scene, type View } from '@weasel-js/core';\n\n/** Shape the default projections expect `data` to satisfy. All fields\n * optional so any object satisfies the constraint — projections fill in\n * the gaps for non-default shapes. */\nexport interface DefaultTextData {\n text?: string;\n style?: TextStyle;\n runs?: readonly StyledRun[];\n fill?: Fill | Inherit | null;\n stroke?: Stroke | Inherit | null;\n verticalAlign?: TextVerticalAlign;\n padding?: number;\n overflow?: TextOverflow;\n fit?: TextFit;\n}\n\n/** All-optional projections + fontSize fallback. */\nexport interface UseSceneTextEditOptions<TData> {\n /**\n * Is this node text? A double-click opens an edit only on a node that\n * answers yes, and passes through any other to the text under it. Default:\n * `isTextData`, the test `inferredNodeRouting` classifies a text node by. Pass one when `getText` reads some other shape.\n */\n isText?: (data: TData) => boolean;\n /** Read plain text from `data`. Default: `data.text ?? ''`. */\n getText?: (data: TData) => string;\n /** Read style from `data`. Default: `data.style`. */\n getStyle?: (data: TData) => TextStyle | undefined;\n /** Read the node's paint from `data`. Default: `data.fill` / `data.stroke`. */\n getPaint?: (data: TData) => TextPaint | undefined;\n /** Read rich-text runs from `data`. Default: `data.runs`. */\n getRuns?: (data: TData) => readonly StyledRun[] | undefined;\n /** Read the box vertical alignment from `data`. Default: `data.verticalAlign`. */\n getVerticalAlign?: (data: TData) => TextVerticalAlign | undefined;\n /** Read the inset from the node's box to its text from `data`. Default: `data.padding`. */\n getPadding?: (data: TData) => number | undefined;\n /** Read whether the node cuts its text at its box from `data`. The overlay\n * then does too, and scrolls the text in the box while it is edited.\n * Default: `data.overflow`. */\n getOverflow?: (data: TData) => TextOverflow | undefined;\n /** Read how the node's text size answers to its box from `data`. The overlay\n * sets the text at the size the canvas fits it to. Default: `data.fit`. */\n getFit?: (data: TData) => TextFit | undefined;\n /** Produce updated data with new text. Default: `{ ...data, text }`. */\n setText?: (data: TData, text: string) => TData;\n /** Produce updated data with new runs. Default: `{ ...data, runs }`. */\n setRuns?: (data: TData, runs: StyledRun[]) => TData;\n /**\n * Produce updated data with a new node-wide style. Default:\n * `{ ...data, style }`. Written only when a range toggle has to *clear* a\n * flag the node itself sets — the run algebra is additive, so that edit\n * lowers the node flag and raises it on the runs outside the range. See\n * `useTextEdit`'s `setStyle`.\n *\n * An edit's text, runs, and style are folded through these three and\n * written as one `scene.update`, so a commit is one undo step.\n */\n setStyle?: (data: TData, style: TextStyle) => TData;\n /**\n * The view to project the overlay through. Omit it and the view is read\n * live from the weasel canvas mounted inside `container` (the first, when\n * there are several). With no canvas there, the node's world box is passed\n * through as screen pixels.\n *\n * A thunk is re-read on every projection; a plain `View` is the value from\n * the render that supplied it.\n */\n view?: View | (() => View);\n /**\n * Forwarded to `useTextEdit`: is `el` part of the editor's own chrome?\n * Focus moving into it does not end the edit. Wire it to whatever renders\n * the character controls.\n */\n isEditorChrome?: (el: Element) => boolean;\n /** Forwarded to `useTextEdit`: what Escape does to the edit. */\n escape?: 'cancel' | 'commit';\n /** Forwarded to `useTextEdit`: how long an edit waits for its face. */\n fontHold?: number;\n /** Forwarded to `useTextEdit`: called as an edit of the node `id` opens,\n * whichever way it was started. */\n onStart?: (id: string) => void;\n /** Forwarded to `useTextEdit`: called as the edit of `id` closes, after\n * any commit has been written to the scene. */\n onEnd?: (id: string) => void;\n}\n\nfunction resolveView(view: View | (() => View) | undefined): View | undefined {\n return typeof view === 'function' ? view() : view;\n}\n\n/** Return shape extends `UseTextEditReturn` with what the `textEdit` dep\n * answers: a double-click on a canvas inside `container` reaches the editor\n * through it, with no handler of the host's. */\nexport interface UseSceneTextEditReturn extends UseTextEditReturn {\n /** The top-most unlocked text node at world point `at`, and the caret at\n * the glyph there: what `TextEditDep.textAt` wants. */\n textAt: (at: Point2) => { id: string; caret: number } | null;\n /** The `isText` option asked of the node with this id: what\n * `TextEditDep.isTextNode` wants, so both ways into an edit agree. */\n isTextNode: (id: string) => boolean;\n /**\n * `defaultDrawOne`, less the glyphs of the node being edited: the overlay\n * stands in for its text, and the rest of the node, a `background` among\n * it, goes on painting. A `<SceneCanvas>` inside `container` drawing this\n * scene already leaves those glyphs out; this is for anything else that\n * draws the node.\n */\n drawOne: EditingDrawOne;\n}\n\n/** How each field is read from a node's `data`: the option's projection, else the default shape. */\nfunction projectionsOf<TData extends DefaultTextData>(opts: { readonly current: UseSceneTextEditOptions<TData> }) {\n return {\n isText: (data: TData): boolean =>\n opts.current.isText ? opts.current.isText(data) : isTextData(data),\n text: (data: TData): string =>\n opts.current.getText ? opts.current.getText(data) : (data.text ?? ''),\n style: (data: TData): TextStyle | undefined =>\n opts.current.getStyle ? opts.current.getStyle(data) : data.style,\n runs: (data: TData): readonly StyledRun[] | undefined =>\n opts.current.getRuns ? opts.current.getRuns(data) : data.runs,\n verticalAlign: (data: TData): TextVerticalAlign | undefined =>\n opts.current.getVerticalAlign ? opts.current.getVerticalAlign(data) : data.verticalAlign,\n padding: (data: TData): number | undefined =>\n opts.current.getPadding ? opts.current.getPadding(data) : data.padding,\n overflow: (data: TData): TextOverflow | undefined =>\n opts.current.getOverflow ? opts.current.getOverflow(data) : data.overflow,\n fit: (data: TData): TextFit | undefined =>\n opts.current.getFit ? opts.current.getFit(data) : data.fit,\n };\n}\n\n/** Wire in-place text editing on a scene: mounts a DOM editing overlay over\n * the node being edited and writes the result back as an undoable op.\n * `<SceneCanvas>`'s own editor stands down for any canvas inside `container`\n * and answers its `textEdit` dep with this one, so the canvas's double-click\n * (`enterTextEdit.doubleClick`) and a text tool open this editor, and such a\n * canvas leaves out the glyphs of the node being edited. */\nexport function useSceneTextEdit<\n TData extends DefaultTextData,\n TLayer extends string,\n TPose extends RectPose = RectPose,\n>(\n scene: Scene<TData, TLayer, TPose>,\n container: HTMLElement | null,\n options: UseSceneTextEditOptions<TData> = {},\n): UseSceneTextEditReturn {\n const host = useRef<HostTextEditorHandle | null>(null);\n const edit = useSceneTextEditor(scene, container, options);\n const editRef = useLatest(edit);\n useEffect(() => {\n if (!container) return undefined;\n const handle = registerHostTextEditor(container, scene, {\n startEdit: (id, opts) => editRef.current.startEdit(id, opts),\n textAt: (at) => editRef.current.textAt(at),\n isTextNode: (id) => editRef.current.isTextNode(id),\n });\n host.current = handle;\n return () => {\n handle.dispose();\n if (host.current === handle) host.current = null;\n };\n }, [container, scene, editRef]);\n useEffect(() => { host.current?.setEditing(edit.editingId); }, [edit.editingId, container, scene]);\n return edit;\n}\n\n/** `useSceneTextEdit` without announcing itself as a host's editor: what\n * `<SceneCanvas>` mounts as its own, projecting through `canvas`, the\n * element of the canvas it edits for. A host's editor projects through the\n * first canvas inside `container`. */\nexport function useSceneTextEditor<\n TData extends DefaultTextData,\n TLayer extends string,\n TPose extends RectPose = RectPose,\n>(\n scene: Scene<TData, TLayer, TPose>,\n container: HTMLElement | null,\n options: UseSceneTextEditOptions<TData> = {},\n canvas: () => Element | null = () => null,\n): UseSceneTextEditReturn {\n // Refs, so the useTextEdit callbacks always see the current values\n // without re-binding.\n const sceneRef = useLatest(scene);\n const optsRef = useLatest(options);\n const containerRef = useLatest(container);\n const canvasRef = useLatest(canvas);\n const drafts = useMemo(() => sceneTextDrafts(sceneRef, optsRef), [sceneRef, optsRef]);\n useEffect(() => () => drafts.close(), [drafts]);\n\n // The canvas's box in container pixels is both the origin its view projects\n // from and the region its glyphs are clipped to.\n const surface = (): { canvas: MountedCanvas; box: TextEditClipRect } | null => {\n const root = containerRef.current;\n const canvas = root ? findMountedCanvas(root, canvasRef.current()) : null;\n if (!root || !canvas) return null;\n // Layout boxes: under an ancestor transform a client offset is the container's px times its scale.\n const a = layoutBoxOf(canvas.element);\n const b = layoutBoxOf(root);\n return {\n canvas,\n box: {\n x: (a.left - b.left) / b.scale.x - root.clientLeft + root.scrollLeft,\n y: (a.top - b.top) / b.scale.y - root.clientTop + root.scrollTop,\n width: a.width,\n height: a.height,\n },\n };\n };\n\n const read = useMemo(() => projectionsOf(optsRef), [optsRef]);\n\n const edit = useTextEdit({\n container,\n isEditorChrome: (el) => optsRef.current.isEditorChrome?.(el) ?? false,\n escape: options.escape,\n fontHold: options.fontHold,\n onStart: (id) => optsRef.current.onStart?.(id),\n onEnd: (id) => {\n drafts.end(id);\n optsRef.current.onEnd?.(id);\n sceneRef.current.history.seal();\n },\n onDraft: drafts.draft,\n getText: (id) => {\n const node = sceneRef.current.get(asNodeId(id));\n return node ? read.text(node.data) : '';\n },\n getStyle: (id) => {\n const node = sceneRef.current.get(asNodeId(id));\n return node ? read.style(node.data) : undefined;\n },\n getPaint: (id) => {\n const node = sceneRef.current.get(asNodeId(id));\n if (!node) return undefined;\n const get = optsRef.current.getPaint;\n return get ? get(node.data) : shownTextPaint(sceneRef.current, node);\n },\n getScreenPose: (id) => {\n const scene = sceneRef.current;\n const node = shownLookup(scene).get(asNodeId(id)); // As shown, so a fit follows the draft being typed.\n if (!node) return null;\n const at = surface();\n const view = resolveView(optsRef.current.view) ?? at?.canvas.getView();\n return screenPoseOf(node.data, scenePaintedPoseOf(scene)(node), read, view, at?.box);\n },\n getClipRect: () => surface()?.box ?? null,\n getRuns: (id) => {\n const node = sceneRef.current.get(asNodeId(id));\n return node ? read.runs(node.data) : undefined;\n },\n commit: (id, { text, runs, style }) => {\n const nid = asNodeId(id);\n const node = sceneRef.current.get(nid);\n // A node removed or locked during the edit takes no write; the edit still ends.\n if (!node || sceneRef.current.isLocked(nid)) return;\n drafts.commit(id, editedData(node.data, { text, runs, style }, optsRef.current));\n },\n });\n\n const textAt = useCallback(\n (at: Point2) => textHitAt(sceneRef.current, read, at.x, at.y),\n [read, sceneRef],\n );\n\n const isTextNode = useCallback((id: string): boolean => {\n const node = sceneRef.current.get(asNodeId(id));\n return node !== undefined && read.isText(node.data);\n }, [read, sceneRef]);\n\n const drawOne = useMemo(() => drawOneEditing(edit.editingId), [edit.editingId]);\n return { ...edit, textAt, isTextNode, drawOne };\n}\n\n/** A text node's paint as the canvas paints it: an inherited one is its container's. */\nfunction shownTextPaint<TData extends DefaultTextData>(\n scene: Scene<TData, string, unknown>,\n node: NonNullable<ReturnType<Scene<TData, string, unknown>['get']>>,\n): TextPaint {\n const { fill, stroke } = withInheritedPaint(node.data, inheritedPaintIn(scene, node));\n return { fill, stroke };\n}\n","/**\n * `useTextEditDepSource` — the `textEdit` dep `enterTextEditAction` reads when\n * no editor answers it: a `startEdit` that does nothing, a `textAt` that finds\n * nothing, and an `isTextNode` that asks `isTextData`. The canvas's own editor registers over it\n * (`canvasEditor.tsx`), and so does a host's.\n */\nimport { useDepSource } from '@weasel-js/routing/react';\nimport { useLatest, isDev } from '@weasel-js/react';\nimport type { TextEditDep } from './textEditDep';\nimport { isTextData } from '@weasel-js/text';\nimport { type NodeId, type Scene } from '@weasel-js/core';\n\nexport function useTextEditDepSource(\n scene: Scene<unknown, string, unknown>,\n): void {\n const sceneRef = useLatest(scene);\n\n useDepSource('textEdit', (): TextEditDep => {\n const sc = sceneRef.current;\n return {\n startEdit(_id: string, _opts?: { caret?: number | 'all' }) {\n if (isDev()) {\n console.warn(\n 'weasel textEditDep: startEdit called but this canvas has no text editor: it was given ' +\n 'createTextPreset({ editor: false }), or a host useSceneTextEdit holds it without publishing the \"textEdit\" dep. ' +\n 'Publish it with useDepSource(\"textEdit\", ...) from inside <SceneCanvas>.',\n );\n }\n },\n textAt: () => null,\n isTextNode(id: string) {\n return isTextData(sc.get(id as NodeId)?.data);\n },\n };\n });\n}\n","/**\n * The canvas's own text editor: the one `enterTextEdit` reaches, from a text\n * or sticky tool or a double-click on a text node, when the host has wired\n * none of its own. `textPreset` mounts it inside the canvas. It stands down for\n * a host editor: a `useSceneTextEdit` whose container holds the canvas, which\n * the `textEdit` dep then answers with, or a `textEdit` dep registered over it.\n */\nimport { useEffect, useLayoutEffect, useMemo, useRef, useState, type ComponentType, type MutableRefObject } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport { useDepSource } from '@weasel-js/routing/react';\nimport { registerPaintStandIn, type PaintStandIn, type PresetComponentProps, type Scene } from '@weasel-js/core';\nimport type { TextEditDep } from './textEditDep';\nimport {\n useSceneTextEditor, type DefaultTextData, type UseSceneTextEditOptions, type UseSceneTextEditReturn,\n} from './useSceneTextEdit';\nimport { hostTextEditDep, hostTextEditorHolds } from './hostTextEditors';\nimport { withoutText } from './editingDrawOne';\nimport { useTextEditDepSource } from './textEditStub';\n\n/** The canvas's own editor: `useSceneTextEdit`'s options, or `false` for none. */\nexport type CanvasTextEditorOptions<TData = DefaultTextData> = false | UseSceneTextEditOptions<TData>;\n\ninterface DefaultTextEditor {\n edit: UseSceneTextEditReturn;\n /** Where the overlay mounts: the canvas's containing block, or `null` while it has none. */\n container: HTMLElement | null;\n /** The `textEdit` dep this editor answers with while it is the one standing. */\n dep: TextEditDep;\n element: HTMLElement | null;\n /** Whether the host has an editor of its own over this canvas. */\n yields: () => boolean;\n /** The dep of the host's editor over this canvas, or `null` for none. */\n host: () => TextEditDep | null;\n}\n\n/**\n * The editor, mounted into the canvas's containing block — its offset parent,\n * else its parent — so the overlay is positioned against the box it is\n * measured from. `on` false mounts it nowhere.\n */\nfunction useDefaultTextEditor<TData>(\n scene: Scene<TData, string, unknown>,\n elementRef: MutableRefObject<HTMLElement | null>,\n config: CanvasTextEditorOptions<TData> | undefined,\n on: boolean,\n): DefaultTextEditor {\n const [element, setElement] = useState<HTMLElement | null>(null);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- the canvas fills elementRef on commit, so every commit rereads it; the guard stops a loop\n useLayoutEffect(() => {\n if (elementRef.current !== element) setElement(elementRef.current);\n });\n const live = on && config !== false;\n const container = live && element ? ((element.offsetParent ?? element.parentElement) as HTMLElement | null) : null;\n const elRef = useLatest(element);\n const edit = useSceneTextEditor(\n scene as unknown as Scene<DefaultTextData, string>, container, (config || {}) as unknown as UseSceneTextEditOptions<DefaultTextData>,\n () => elRef.current,\n );\n const editRef = useLatest(edit);\n const dep = useMemo<TextEditDep>(() => ({\n startEdit: (id, opts) => editRef.current.startEdit(id, opts),\n textAt: (at) => editRef.current.textAt(at),\n isTextNode: (id) => editRef.current.isTextNode(id),\n }), [editRef]);\n const yields = useMemo(() => () => {\n const el = elRef.current;\n return el === null || hostTextEditorHolds(el);\n }, [elRef]);\n const sceneRef = useLatest(scene);\n const host = useMemo(() => () => {\n const el = elRef.current;\n return el === null ? null : hostTextEditDep(el, sceneRef.current);\n }, [elRef, sceneRef]);\n return { edit, container, dep, element: container ? element : null, yields, host };\n}\n\n/**\n * Publishes the editor as the `textEdit` dep, or the editor of a host's\n * `useSceneTextEdit` holding the canvas while there is one. Rendered after\n * the stub, among the canvas's preset components, so it sits over the stub and\n * under any `textEdit` a child of the canvas registers.\n */\nfunction DefaultTextEditDep({ editor }: { editor: DefaultTextEditor }): null {\n const { dep, element, yields, host } = editor;\n useDepSource('textEdit', (below) => {\n if (element && !yields()) return dep;\n return host() ?? (below() as TextEditDep);\n });\n return null;\n}\n\n/** While the canvas's own editor has a node open, its overlay stands in for that node's glyphs. */\nfunction useEditingStandIn(scene: object, editor: DefaultTextEditor): void {\n const within = editor.container;\n const editing = editor.edit.editingId;\n const editingRef = useLatest(editing);\n const standIn = useRef<PaintStandIn | null>(null);\n useEffect(() => {\n if (!within) return undefined;\n const held = registerPaintStandIn(scene, within, withoutText);\n held.show(editingRef.current);\n standIn.current = held;\n return () => { held.dispose(); standIn.current = null; };\n }, [scene, within, editingRef]);\n useEffect(() => { standIn.current?.show(editing); }, [editing]);\n}\n\nfunction TextEditStub({ scene }: { scene: Scene<unknown, string, unknown> }): null {\n useTextEditDepSource(scene);\n return null;\n}\n\n/**\n * The canvas's own editor as a preset component, configured by `config`: the\n * `textEdit` dep's stub, the editor over it, and its stand-in for the glyphs of\n * the node it has open. Not mounted under `paintInto`, where the canvas element\n * is the host's.\n */\nexport function canvasTextEditor(config?: CanvasTextEditorOptions): ComponentType<PresetComponentProps> {\n function CanvasTextEditor({ scene, canvasRef, paintsInto }: PresetComponentProps) {\n const editor = useDefaultTextEditor(scene as Scene<DefaultTextData, string, unknown>, canvasRef, config, !paintsInto);\n useEditingStandIn(scene, editor);\n return (\n <>\n <TextEditStub scene={scene} />\n <DefaultTextEditDep editor={editor} />\n </>\n );\n }\n return CanvasTextEditor;\n}\n","/**\n * The `text/plain` content handler: a pasted or dropped string becomes a text\n * node. `textPreset` brings it to the canvas's ingestion, after the kit's own.\n *\n * Strings that arrive beside a file are passed over: there they describe the\n * file (its name, a URL to it), as when a browser drags an image or the OS\n * copies a file, and the file is what was meant.\n *\n * The node's box is the string's own laid-out size at the default text style,\n * so it holds the text exactly and wraps nowhere the string does not break.\n * Placement is the image handler's: on the point, or centered in the viewport.\n *\n * Priority -110, below every kit handler, so SVG markup and a copied node\n * payload arriving as plain text go to the handlers that read them.\n */\nimport { measureTextBounds } from '@weasel-js/text';\nimport type { IngestItem } from '@weasel-js/routing';\nimport { arrivalBounds, type ContentHandlerEntry, type IngestCtx } from '@weasel-js/core';\n\n/** Options for {@link createTextHandler}. */\nexport interface TextHandlerOptions {\n /** Size of a string's layout box in world units. Default\n * `measureTextBounds`, which reads the registered font. */\n measure?: (text: string) => { width: number; height: number };\n}\n\n/** Build the plain-text content handler; {@link textContentHandler} is the one\n * with the default measurer. */\nexport function createTextHandler(opts: TextHandlerOptions = {}): ContentHandlerEntry {\n const measure = opts.measure ?? ((text: string) => measureTextBounds(text));\n return {\n id: 'text-tools:text',\n match: (item: IngestItem) => item.kind === 'string' && item.mime === 'text/plain',\n types: ['text/plain'],\n priority: -110,\n handle(items, ctx: IngestCtx) {\n if ((ctx.items ?? items).some((it) => it.kind === 'file')) return;\n let index = 0;\n for (const item of items) {\n if (item.kind !== 'string') continue;\n const text = item.text.replace(/\\r\\n?/g, '\\n').replace(/\\n+$/, '');\n if (text.trim() === '') continue;\n ctx.insert.commit(arrivalBounds(ctx, measure(text), index), { kind: 'text', text });\n index++;\n }\n },\n };\n}\n\n/** Turns pasted or dropped plain text into a text node sized to the string. A kit handler, so a\n * canvas with the `ingest` feature takes text unless its `ingestion.kitHandlers` omits it. */\nexport const textContentHandler: ContentHandlerEntry = createTextHandler();\n","/** How a text node is inserted: what `textPreset` gives the canvas's `insert` dep for `text`, and the hooks a node\n * made to be typed into commits with. */\nimport { DEFAULT_TEXT_FILL } from '@weasel-js/text';\nimport type { InsertedNode, InsertNodeFactory, InsertStyle } from '@weasel-js/core';\nimport { textEditJoin } from '../editor/sceneTextDrafts';\nimport type {} from '../editor/textEditDep';\n\n/**\n * `data` inserted: an empty node is made to be typed into, so its commit opens the run its first edit joins (one\n * undo takes the node and its text together) and drops into its caret. One arriving with text, as a paste does,\n * is its own entry and opens nothing.\n */\nexport function typeIn(data: { text: string }): InsertedNode {\n if (data.text !== '') return { data };\n return {\n data,\n batch: textEditJoin,\n inserted: (id, deps) => deps.get('textEdit')?.startEdit(id, { caret: 0 }),\n };\n}\n\n/** The `text` insert: an empty box you then type into, or a pasted string, set in the tool's fill. The `kit:text`\n * painter applies the style's defaults when it draws. */\nexport const textNodeFactory: InsertNodeFactory = (_bounds, extras) => {\n const e = extras as Partial<{ text: string; style: InsertStyle }>;\n const fill = e.style?.fill;\n return typeIn({ text: e.text ?? '', fill: fill === undefined ? DEFAULT_TEXT_FILL : fill && { paint: fill } } as { text: string });\n};\n","/** The properties a `text` node edits: its content, background, and typography beside the standard shape sections. */\nimport type { PrefBooleanEncoding, PrefLeaf, PrefSection } from '@weasel-js/prefs';\nimport { decimal } from '@weasel-js/quantity';\nimport { shapePropertiesSchema, type NodePropertiesEntry } from '@weasel-js/core';\nimport { icon } from '../icons.gen';\n\nconst TWO_PLACES = decimal({ maxPlaces: 2, grouping: false });\n\n/** `TextStyle.fontStyle` as an Italic flag. Off removes the field rather than\n * storing `'normal'`, which is what an absent one already means. */\nconst italicEncoding: PrefBooleanEncoding = {\n read: (stored) => stored === 'italic',\n write: (on) => (on ? 'italic' : undefined),\n};\n\n/** `data.overflow` as a flag: on is `'clip'`, and off removes the key, since\n * absent draws past the box. */\nconst overflowEncoding: PrefBooleanEncoding = {\n read: (stored) => stored === 'clip',\n write: (on) => (on ? 'clip' : undefined),\n};\n\n/** `data.fit` as a flag: on is `'shrink'`, and off removes the key, since\n * absent sets the text at its own size. */\nconst fitEncoding: PrefBooleanEncoding = {\n read: (stored) => stored === 'shrink',\n write: (on) => (on ? 'shrink' : undefined),\n};\n\n/** A text node's `data.background`: a `Fill`, as `data.fill` is, painted over\n * the whole box rather than the glyphs. */\nconst BACKGROUND_LEAF: PrefLeaf = {\n kind: 'object',\n block: true,\n name: 'Background',\n description: 'Paint behind the text, over the whole box.',\n default: { paint: { kind: 'solid', color: '#ffffffff' } },\n children: {\n paint: { kind: 'paint', name: 'Background', description: 'Paint behind the text.', default: { kind: 'solid', color: '#ffffffff' }, alpha: true, block: true },\n },\n};\n\nconst CONTENT: PrefSection = {\n name: 'Content',\n members: {\n // `block`: the content is the section, so a 64px label column\n // reading \"Text\" inside a section reading \"Text\" is one word\n // twice and a narrower field for the sake of it.\n 'data.text': { kind: 'string', name: 'Text', description: 'Text content.', absentIsDefault: true, default: '', block: true },\n },\n};\n\nconst TYPOGRAPHY: PrefSection = {\n // Headless: `Character` and `Paragraph` carry the labels, and a\n // `Typography` heading over them names nothing a reader can't\n // already see.\n name: '',\n members: {\n // One object leaf, not a row of siblings addressing into it:\n // `data.style` is a `TextStyle`, and its character and\n // paragraph fields are one value that reads as two lists.\n // The groups head those lists and contribute nothing to the\n // path — a field inside one is still a field of the style.\n 'data.style': {\n kind: 'object',\n name: 'Style',\n description: 'Typography for the whole node. Its color is the node\\'s own `data.fill`, in Appearance.',\n default: {},\n absentIsDefault: true,\n block: true,\n children: {\n character: {\n name: 'Character',\n members: {\n fontFamily: { kind: 'font-family', name: 'Font', description: 'Registered font family.', absentIsDefault: true, default: 'sans-serif' },\n fontSize: { kind: 'number', display: TWO_PLACES, name: 'Size', description: 'Font size, world units.', absentIsDefault: true, default: 16, min: 1, step: 1, pair: { with: 'data.style.fontWeight', label: 'Size / weight' } },\n fontWeight: { kind: 'font-weight', name: 'Weight', description: 'Font weight, from the faces the family has.', absentIsDefault: true, default: 400 },\n // One row of segments, the strip every text editor\n // draws: the slant, the three rules, then the two\n // scripts. Italic is a flag here although the field\n // is `fontStyle`, whose only other value is upright.\n fontStyle: { kind: 'boolean', name: 'Italic', description: 'Set the text in its italic face.', default: false, control: 'toggle', icon: /* @icon */ 'core:italic', short: ['I'], pair: { with: ['data.style.underline', 'data.style.strikethrough', 'data.style.overline', 'data.style.script'], label: 'Style' }, encoding: italicEncoding },\n underline: { kind: 'boolean', name: 'Underline', description: 'Underline the text.', absentIsDefault: true, default: false, control: 'toggle', icon: /* @icon */ 'core:underline', short: ['U'] },\n strikethrough: { kind: 'boolean', name: 'Strikethrough', description: 'Strike through the text.', absentIsDefault: true, default: false, control: 'toggle', icon: /* @icon */ 'core:strikethrough', short: ['S'] },\n overline: { kind: 'boolean', name: 'Overline', description: 'Rule the text above its ascent.', absentIsDefault: true, default: false, control: 'toggle', icon: /* @icon */ 'core:overline', short: ['O'] },\n script: { kind: 'enum', name: 'Script', description: 'Set the text smaller and raised or lowered, on the line it would otherwise hold.', default: undefined, control: 'toggle', clearable: true, options: [{ value: 'super', label: 'Superscript', icon: /* @icon */ 'core:superscript' }, { value: 'sub', label: 'Subscript', icon: /* @icon */ 'core:subscript' }] },\n letterSpacing: { kind: 'number', display: TWO_PLACES, name: 'Tracking', description: 'Extra advance per glyph, world units.', absentIsDefault: true, default: 0, step: 0.1 },\n textTransform: { kind: 'enum', name: 'Case', description: 'Draw the text in capitals, lowercase or title case. The text itself is unchanged.', absentIsDefault: true, default: 'none', control: 'toggle', options: [{ value: 'none', label: 'None', short: ['–'] }, { value: 'uppercase', label: 'Uppercase', short: ['AA'] }, { value: 'lowercase', label: 'Lowercase', short: ['aa'] }, { value: 'capitalize', label: 'Capitalize', short: ['Aa'] }] },\n fontVariantCaps: { kind: 'enum', name: 'Small caps', description: 'Draw lowercase letters as smaller capitals. The text itself is unchanged.', absentIsDefault: true, default: 'normal', control: 'toggle', options: [{ value: 'normal', label: 'Normal', short: ['–'] }, { value: 'small-caps', label: 'Small caps', short: ['Sc'] }] },\n lang: { kind: 'string', name: 'Language', description: 'A BCP 47 tag, such as sr or ur, that picks the forms a font draws for that language. Empty means none.', default: '' },\n },\n },\n paragraph: {\n name: 'Paragraph',\n members: {\n lineHeight: { kind: 'number', display: TWO_PLACES, name: 'Leading', description: 'Line height as a multiple of font size.', absentIsDefault: true, default: 1.2, min: 0.5, step: 0.1 },\n wrap: { kind: 'boolean', name: 'Wrap', description: 'Break lines between words at the box width.', absentIsDefault: true, default: false, control: 'switch' },\n tabSize: { kind: 'number', display: TWO_PLACES, name: 'Tab size', description: 'Distance between tab stops, in spaces.', absentIsDefault: true, default: 8, min: 1, step: 1 },\n direction: { kind: 'enum', name: 'Direction', description: 'Reading direction. Auto takes each paragraph\\'s from its first strong character.', absentIsDefault: true, default: 'auto', control: 'toggle', options: [{ value: 'auto', label: 'Auto', short: ['Auto'] }, { value: 'ltr', label: 'Left to right', short: ['LTR'] }, { value: 'rtl', label: 'Right to left', short: ['RTL'] }] },\n // Last, so the box's vertical alignment — a field of\n // the node rather than of its style — follows it.\n align: { kind: 'enum', name: 'Align', description: 'Horizontal alignment.', absentIsDefault: true, default: 'left', control: 'toggle', options: [{ value: 'left', label: 'Left', icon: /* @icon */ 'core:textAlignLeft' }, { value: 'center', label: 'Center', icon: /* @icon */ 'core:textAlignCenter' }, { value: 'right', label: 'Right', icon: /* @icon */ 'core:textAlignRight' }, { value: 'justify', label: 'Justify', icon: /* @icon */ 'core:textAlignJustify' }, { value: 'start', label: 'Start', icon: /* @icon */ 'core:textAlignStart' }, { value: 'end', label: 'End', icon: /* @icon */ 'core:textAlignEnd' }] },\n },\n },\n },\n },\n 'data.padding': { kind: 'number', display: TWO_PLACES, measure: 'length', name: 'Padding', description: 'Inset from the box to the text on every side, world units.', absentIsDefault: true, default: 0, min: 0, step: 1 },\n 'data.verticalAlign': { kind: 'enum', name: 'Vertical', description: 'Where the lines sit in the box\\'s height.', absentIsDefault: true, default: 'top', control: 'toggle', options: [{ value: 'top', label: 'Top', icon: /* @icon */ 'core:textAlignTop' }, { value: 'center', label: 'Middle', icon: /* @icon */ 'core:textAlignMiddle' }, { value: 'bottom', label: 'Bottom', icon: /* @icon */ 'core:textAlignBottom' }] },\n 'data.overflow': { kind: 'boolean', name: 'Clip', description: 'Cut the text at the box\\'s edge instead of drawing it past.', default: false, control: 'switch', encoding: overflowEncoding },\n 'data.fit': { kind: 'boolean', name: 'Shrink to fit', description: 'Set the text smaller, never larger, until its lines fit the box.', default: false, control: 'switch', encoding: fitEncoding },\n },\n};\n\n/** The `text` kind's properties, for a `SelectionPanel` given `textPreset`. */\nexport const TEXT_PROPERTIES: NodePropertiesEntry = {\n name: 'text',\n schema: shapePropertiesSchema({\n // What the node *is* outranks how it is painted: a text node's copy is the first thing an editor reaches for.\n lead: { content: CONTENT },\n appearance: { 'data.background': BACKGROUND_LEAF },\n trail: { text: TYPOGRAPHY },\n }),\n};\n","import type { Fill, Paint } from '@weasel-js/paint';\nimport { DEFAULT_TEXT_FILL, type TextStyle, type TextVerticalAlign } from '@weasel-js/text';\nimport type { TextNodeData, TextOverflow } from '../../node/textPainter';\nimport type { TextEdge, TextShadow } from '../../node/textFrame';\nimport { type InsertNodeFactory, type MinSize } from '@weasel-js/core';\nimport { typeIn } from '../../node/insert';\n\n/** How a sticky note looks as it is made, named as the text node it becomes\n * names them. Every field has a default, in {@link STICKY_DEFAULTS}. */\nexport interface StickyStyle {\n /** The note itself, painted over its whole box. */\n background?: Fill;\n /** The text's paint. */\n fill?: Fill;\n /** World units from the note's edge to its text, on every side. */\n padding?: number;\n /** Typography for the note's text. */\n style?: TextStyle;\n verticalAlign?: TextVerticalAlign;\n /** What happens to text that outgrows the note. */\n overflow?: TextOverflow;\n /** The rule round the note, in a darker shade of its paper. */\n edge?: TextEdge;\n /** The shadow the note casts. */\n shadow?: TextShadow;\n /** The smallest note a drag makes or a resize leaves, in world units. */\n minSize?: MinSize;\n /** The note a click makes, centered on the click, in world units. A drag\n * makes the note it draws. */\n size?: { width: number; height: number };\n}\n\n/** A sticky insert's extras: the tool's {@link StickyStyle}, and its `paper` and `ink` options, the paints that\n * stand over `background` and `fill`. */\nexport type StickyLook = StickyStyle & { paper?: Paint | null; ink?: Paint | null };\n\n/** `option`'s paint as a fill, `null` for none, else `fallback`. */\nconst optionFill = (option: Paint | null | undefined, fallback: Fill): Fill | null =>\n option === undefined ? fallback : option && { paint: option };\n\n/** The look a sticky note takes for any field its tool leaves out. */\nexport const STICKY_DEFAULTS = {\n background: { paint: { kind: 'solid', color: '#fff1a6ff' } },\n fill: DEFAULT_TEXT_FILL,\n padding: 12,\n style: { fontSize: 18, align: 'center', wrap: true },\n verticalAlign: 'center',\n overflow: 'clip',\n edge: { width: 1, shade: 0.18 },\n shadow: { x: 0, y: 2, blur: 6, alpha: 0.18 },\n // One line of the default type inside the default padding.\n minSize: { width: 48, height: 48 },\n size: { width: 160, height: 160 },\n} as const satisfies Required<StickyStyle>;\n\n/**\n * A sticky note's `data`: a text node with a `background`, so the `kit:text`\n * painter draws it and the text editor edits it with no sticky case of its\n * own. `look` is the `sticky` insert's extras, which carry the tool's\n * {@link StickyStyle}.\n */\nexport function stickyData(look: StickyLook & { text?: string }): TextNodeData & { minSize: MinSize } {\n return {\n text: look.text ?? '',\n background: optionFill(look.paper, look.background ?? STICKY_DEFAULTS.background),\n padding: look.padding ?? STICKY_DEFAULTS.padding,\n style: look.style ?? STICKY_DEFAULTS.style,\n verticalAlign: look.verticalAlign ?? STICKY_DEFAULTS.verticalAlign,\n overflow: look.overflow ?? STICKY_DEFAULTS.overflow,\n edge: look.edge ?? STICKY_DEFAULTS.edge,\n shadow: look.shadow ?? STICKY_DEFAULTS.shadow,\n minSize: look.minSize ?? STICKY_DEFAULTS.minSize,\n fill: optionFill(look.ink, look.fill ?? STICKY_DEFAULTS.fill),\n };\n}\n\n/** The `sticky` insert as an `InsertNodeFactory`: what `textPreset` installs, for a canvas that wraps it — to tag\n * the data with a `kind`, say — under `insertNodeFactories`. An empty note opens for typing, as text does. */\nexport const stickyNodeFactory: InsertNodeFactory = (_bounds, extras) =>\n typeIn(stickyData(extras as StickyLook & { text?: string }));\n","import { useMemo } from 'react';\nimport { cursorFor } from '@weasel-js/cursor';\nimport { icon } from '../../icons.gen';\nimport { STICKY_DEFAULTS, type StickyStyle } from './stickyNode';\nimport { shareToolOptions, withToolOptionDefault, type ToolOptions } from '@weasel-js/routing';\nimport type { Paint } from '@weasel-js/paint';\nimport { defineTool, INSERT_DRAG_MODS, INSERT_REPOSITION_BINDING, insertBindingBehaviors, styleOptionLeaves, toolOptionPaint, type InsertToolOptions, type Tool } from '@weasel-js/core';\n\n/** Options for `useStickyTool`: the look of the notes it makes, and the\n * insert behaviors every drag-to-insert tool takes. Keep object options\n * stable across renders: a new one rebuilds the tool. */\nexport interface UseStickyToolOptions extends InsertToolOptions, StickyStyle {}\n\n/** The sticky tool's options: the note's paper and its ink, its own rather than shared with the shape tools.\n * Both inserts read them, the drag's and the click's. */\nexport const STICKY_TOOL_OPTIONS: ToolOptions = {\n actionId: ['insert', 'place'],\n prefs: {\n name: 'Sticky note',\n as: 'bar',\n children: {\n paper: { ...styleOptionLeaves({ fill: STICKY_DEFAULTS.background.paint }, ['fill']).fill!, name: 'Paper', description: 'What a new note is painted on.' },\n ink: { ...styleOptionLeaves({ fill: STICKY_DEFAULTS.fill.paint }, ['fill']).fill!, name: 'Ink', description: 'What a new note’s text is set in.' },\n },\n },\n};\n\n/**\n * Sticky-note tool. A drag draws a note through `insertAction`, a click\n * places one of `size` through `placeAction`, and either drops into the new\n * note's caret. Neither makes a note smaller than `minSize`, and the note\n * keeps it as the floor a resize stops at. A click on a selected note edits it.\n *\n * The note is minted by the `insert` dep's `sticky` kind (`textPreset`'s\n * `stickyNodeFactory`), as a text node with a `background` (see `stickyData`); the look rides on the bindings' params\n * as that insert's extras, and its paper and ink are the tool's options\n * (`background` and `fill` set their defaults). A consumer wanting its own node overrides the dep\n * (`insertNodeFactories.sticky`), not the tool.\n */\nexport function createStickyTool(options: UseStickyToolOptions = {}): Tool {\n const {\n behaviors, size = STICKY_DEFAULTS.size, minSize = STICKY_DEFAULTS.minSize,\n background, fill, padding, style, verticalAlign, overflow, edge, shadow, share,\n } = options;\n {\n const color = (paint: Paint | null | undefined) => (paint === undefined ? undefined : toolOptionPaint(paint));\n const toolOptions = withToolOptionDefault(\n withToolOptionDefault(shareToolOptions(STICKY_TOOL_OPTIONS, share), 'paper', color(background?.paint)),\n 'ink', color(fill?.paint),\n );\n // `minSize` rides on both inserts: the drag grows to it, and the note\n // keeps it as its own minimum.\n const look = {\n kind: 'sticky',\n minSize,\n ...(padding !== undefined ? { padding } : {}),\n ...(style !== undefined ? { style } : {}),\n ...(verticalAlign !== undefined ? { verticalAlign } : {}),\n ...(overflow !== undefined ? { overflow } : {}),\n ...(edge !== undefined ? { edge } : {}),\n ...(shadow !== undefined ? { shadow } : {}),\n };\n return defineTool({\n id: 'sticky',\n keybinding: { key: 'S' },\n capabilities: ['creates-text'],\n hookName: 'useStickyTool',\n options: toolOptions,\n cursor: cursorFor('crosshair', { mark: 'rect', fallback: 'crosshair' }),\n presentation: {\n label: 'Sticky note',\n icon: /* @icon */ 'core:sticky',\n group: 'type',\n },\n bindings: [\n { spec: { kind: 'drag', mods: INSERT_DRAG_MODS }, actionId: 'insert', opts: { id: 'sticky.drag', params: look, ...insertBindingBehaviors(behaviors) } },\n { spec: { kind: 'click' }, actionId: 'place', opts: { id: 'sticky.click', params: { ...look, size } } },\n { spec: { kind: 'click', target: 'selected-body' }, actionId: 'enterTextEdit', opts: { id: 'sticky.editText' } },\n INSERT_REPOSITION_BINDING,\n ],\n });\n }\n}\n\n/** {@link createStickyTool}, rebuilt only when an option changes. */\nexport function useStickyTool(options: UseStickyToolOptions = {}): Tool {\n const {\n behaviors, size, minSize, background, fill, padding, style, verticalAlign, overflow, edge, shadow, share,\n } = options;\n return useMemo(\n () => createStickyTool({ behaviors, size, minSize, background, fill, padding, style, verticalAlign, overflow, edge, shadow, share }),\n [behaviors, size, minSize, background, fill, padding, style, verticalAlign, overflow, edge, shadow, share],\n );\n}\n","import { useMemo } from 'react';\nimport { shareToolOptions } from '@weasel-js/routing';\nimport { DEFAULT_TEXT_FILL } from '@weasel-js/text';\nimport { icon } from '../../icons.gen';\nimport { defineTool, INSERT_DRAG_MODS, INSERT_REPOSITION_BINDING, insertBindingBehaviors, shapeToolOptions, type InsertToolOptions, type Tool } from '@weasel-js/core';\n\nconst PRESENTATION = {\n label: 'Text',\n icon: /* @icon */ 'core:text',\n group: 'type',\n};\n\n/** The text tool's options: the fill new text is set in, shared under `textFill`. Not the shapes' `fill`: a white\n * shape fill would set white text on a white page. */\nexport const TEXT_TOOL_OPTIONS = shareToolOptions(shapeToolOptions({\n actionId: 'insert', name: 'Text', keys: ['fill'], style: { fill: DEFAULT_TEXT_FILL.paint },\n}), { fill: 'textFill' });\n\n/** Text tool. Drag-rect insertion is owned end-to-end by the dispatcher's\n * `insertAction` (kind: `'text'`); click-on-selected-text-node enters edit\n * mode via the `enterTextEdit` action.\n *\n * Its actions, the `text` insert and the `textEdit` dep come with\n * `textPreset`. Custom node factories and hit gating belong on those deps,\n * not on the tool. */\nexport function createTextTool(options: InsertToolOptions = {}): Tool {\n const { behaviors, share } = options;\n return defineTool({\n id: 'text',\n keybinding: { key: 'T' },\n capabilities: ['creates-text'],\n hookName: 'useTextTool',\n options: shareToolOptions(TEXT_TOOL_OPTIONS, share),\n cursor: 'text',\n presentation: PRESENTATION,\n bindings: [\n { spec: { kind: 'drag', mods: INSERT_DRAG_MODS }, actionId: 'insert', opts: { id: 'text.drag', params: { kind: 'text' }, ...insertBindingBehaviors(behaviors) } },\n { spec: { kind: 'click', target: 'selected-body' }, actionId: 'enterTextEdit', opts: { id: 'text.editText' } },\n INSERT_REPOSITION_BINDING,\n ],\n });\n}\n\n/** {@link createTextTool}, rebuilt only when an option changes. */\nexport function useTextTool(options: InsertToolOptions = {}): Tool {\n const { behaviors, share } = options;\n return useMemo(() => createTextTool({ behaviors, share }), [behaviors, share]);\n}\n","/**\n * Text as `<SceneCanvas features>` presets. `textPreset` teaches a canvas the\n * text node kind and opens it for editing; `textToolsPreset` adds the text and\n * sticky-note tools, and `whiteboardPreset` a whiteboard made with them.\n */\nimport { isTextData } from '@weasel-js/text';\nimport { viewPreset, type FeaturePreset, type NodeRoutingEntry } from '@weasel-js/core';\nimport { editEffectTextAction } from './actions/editEffectText';\nimport { editTextAtAction } from './actions/editTextAt';\nimport { enterTextEditAction } from './actions/enterTextEdit';\nimport { canvasTextEditor, type CanvasTextEditorOptions } from './editor/canvasEditor';\nimport type { DefaultTextData } from './editor/useSceneTextEdit';\nimport { textContentHandler } from './ingest/textHandler';\nimport { textNodeFactory } from './node/insert';\nimport { TEXT_PROPERTIES } from './node/properties';\nimport { TEXT_PAINTER } from './node/textPainter';\nimport { stickyNodeFactory } from './tools/sticky/stickyNode';\nimport { createStickyTool, type UseStickyToolOptions } from './tools/sticky/useStickyTool';\nimport { createTextTool } from './tools/text/useTextTool';\nimport { editPreset, movePreset, pickPreset, resizePreset } from '@weasel-js/editing';\n\n/** Routes a leaf whose `data.text` is a string as `'text'`, ahead of the canvas's own routing, so an\n * SVG-imported text node carrying a fallback `path` routes to text edit. */\nexport const textNodeRouting: NodeRoutingEntry = {\n name: 'text', matches: (data, node) => node?.kind !== 'group' && isTextData(data),\n};\n\n/** Options for {@link createTextPreset}. */\nexport interface TextPresetOptions<TData = DefaultTextData> {\n /** The canvas's own editor: `useSceneTextEdit`'s options, or `false` for none. Default `{}`. It mounts its\n * overlay in the canvas's offset parent, so the canvas wants a positioned ancestor, and stands down for a\n * host's own editor: a `useSceneTextEdit` whose container holds the canvas, or a `textEdit` dep a child of\n * the canvas registers. Wire one of those for character controls, which read the edit's state. */\n editor?: CanvasTextEditorOptions<TData>;\n}\n\n/**\n * The text node kind and its editing, configured by `options`: the `kit:text` painter, whose glyphs are its\n * outline; `'text'` routing and properties; the `text` and `sticky` inserts; the canvas's own editor and the\n * `textEdit` dep; `enterTextEdit`, a double-click opening text in place (`editTextAt`), and a click on a path\n * effect's hidden text opening it (`editEffectText`); and plain-text paste.\n */\nexport function createTextPreset<TData = DefaultTextData>(options: TextPresetOptions<TData> = {}): FeaturePreset {\n return {\n id: 'text',\n label: 'Text',\n shapes: [TEXT_PAINTER],\n routing: [textNodeRouting],\n properties: [TEXT_PROPERTIES],\n insertNodeFactories: { text: textNodeFactory, sticky: stickyNodeFactory },\n actions: [enterTextEditAction, editTextAtAction, editEffectTextAction],\n components: [canvasTextEditor(options.editor as CanvasTextEditorOptions | undefined)],\n contentHandlers: [textContentHandler],\n };\n}\n\n/** {@link createTextPreset} with its defaults. */\nexport const textPreset: FeaturePreset = createTextPreset();\n\n/** Options for {@link createTextToolsPreset}: the insert behaviors both tools take, and the sticky notes' look. */\nexport interface TextToolsPresetOptions extends Pick<UseStickyToolOptions, 'behaviors' | 'share'> {\n sticky?: Omit<UseStickyToolOptions, 'behaviors' | 'share'>;\n /** The text preset the tools need, for a canvas configuring its editor. Default {@link textPreset}. */\n text?: FeaturePreset;\n}\n\n/** The text and sticky-note tools, with the text preset whose actions and inserts they bind. */\nexport function createTextToolsPreset(options: TextToolsPresetOptions = {}): FeaturePreset {\n const { behaviors, share, sticky, text = textPreset } = options;\n return {\n id: 'tools:text',\n label: 'Text tools',\n tools: [createTextTool({ behaviors, share }), createStickyTool({ ...sticky, behaviors, share })],\n includes: [text],\n };\n}\n\n/** {@link createTextToolsPreset} with its defaults. */\nexport const textToolsPreset: FeaturePreset = createTextToolsPreset();\n\n/**\n * A whiteboard: text and the sticky note on an open canvas you pan and zoom, with the select tool, moving,\n * resizing and editing what is on it. A note is the sticky tool's, a text node with a `background`. A pencil is\n * `@weasel-js/path-tools`' `usePencilTool`, passed in `tools`.\n */\nexport const whiteboardPreset: FeaturePreset = {\n id: 'whiteboard',\n label: 'Whiteboard',\n includes: [viewPreset, pickPreset, movePreset, resizePreset, editPreset, textToolsPreset],\n};\n","import { useMemo } from 'react';\nimport { toolSet, type Tool, type ToolSet } from '@weasel-js/core';\nimport { useStickyTool, type UseStickyToolOptions } from './tools/sticky/useStickyTool';\nimport { useTextTool } from './tools/text/useTextTool';\n\n/** The ids {@link useTextToolsTools} keys its tools by. */\nexport type TextToolId = 'text' | 'sticky';\n\n/** The text tools: text and the sticky note. A palette groups them as `type`. */\nexport const TEXT_TOOLS: ToolSet<TextToolId> = toolSet('type', ['text', 'sticky'], { label: 'Type' });\n\n/** The tools a whiteboard makes things with: text and the sticky note. A pencil is `@weasel-js/path-tools`'. */\nexport const WHITEBOARD_TOOLS: ToolSet<TextToolId> = toolSet('whiteboard', ['text', 'sticky'], { label: 'Whiteboard' });\n\n/**\n * Every tool in {@link TEXT_TOOLS}, keyed by id, for `<SceneCanvas tools>` beside `textPreset`, whose actions\n * they bind. `textToolsPreset` mounts the same tools without a hook.\n */\nexport function useTextToolsTools(options: UseStickyToolOptions = {}): Record<TextToolId, Tool> {\n const text = useTextTool({ behaviors: options.behaviors, share: options.share });\n const sticky = useStickyTool(options);\n return useMemo(() => ({ text, sticky }), [text, sticky]);\n}\n","/**\n * Text RenderLayer for text that is not in a scene: one `textCommandFromPose`\n * command per item, the same command the `kit:text` node painter emits, so an\n * item lays out — and wraps, or doesn't, per its style — as a node would.\n *\n * The GL renderer uses MSDF text. The resolved style's `fontFamily` must\n * be registered via `registerFont(family, variant, metricsUrl, atlasUrl)`\n * from the renderer module *before* the GL backend dispatches this layer.\n * Unregistered families render with a warning and no glyphs (see\n * `TextDrawCommand`'s contract).\n */\n\nimport { type DrawCommand } from '@weasel-js/renderer';\nimport type { TextPose } from '@weasel-js/text';\n\nimport { textCommandFromPose } from '@weasel-js/renderer';\nimport { runsToPlainText } from '@weasel-js/text';\nimport { meanScale } from '@weasel-js/geom';\nimport { clippedToBox } from '../node/textPainter';\nimport { type RenderLayer } from '@weasel-js/core';\n\n\n/** Options for `createTextLayer`. */\nexport interface CreateTextLayerOptions<T> {\n id?: string;\n label?: string;\n getTexts: () => readonly T[];\n getPose: (node: T) => TextPose;\n /** Optional per-node hide hook (e.g., suppress while editing). */\n isHidden?: (node: T) => boolean;\n /** When `true`, each text command is wrapped in a clipped group so any\n * overflow beyond the pose's `(width × height)` is hidden. Default\n * `false` (legacy: text can spill outside the declared bounds). Opt-in\n * so existing consumers who rely on overflow keep working. */\n clipToBounds?: boolean;\n}\n\n/** Build a `RenderLayer` that emits one `TextDrawCommand` per text node. */\nexport function createTextLayer<T>(opts: CreateTextLayerOptions<T>): RenderLayer<unknown> {\n const { id = 'text', label = 'Text', getTexts, getPose, isHidden, clipToBounds = false } = opts;\n return {\n id,\n label,\n draw: (_data, view) => {\n // A world-space layer, so a `{ px }` size in a pose's style resolves\n // against the live camera. Radial in effect — one factor for both axes.\n const scale = meanScale(view.scale);\n const children: DrawCommand[] = [];\n for (const node of getTexts()) {\n if (isHidden?.(node)) continue;\n const pose = getPose(node);\n if (pose.runs && pose.runs.length > 0 && runsToPlainText(pose.runs) !== pose.text) {\n throw new Error(\n `weasel createTextLayer: TextPose invariant violated — ` +\n `runsToPlainText(runs) !== text. Either omit \\`runs\\` or keep it ` +\n `synchronized with \\`text\\`.`,\n );\n }\n const textCmd = textCommandFromPose(pose, scale);\n children.push(clipToBounds ? clippedToBox(textCmd, pose) : textCmd);\n }\n // World-space commands; drawLayers wraps in viewToMat3 automatically.\n return children;\n },\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/toolSets.ts","../src/editor/textLayer.ts"],"names":[],"mappings":";;;;;;;;AASO,IAAM,UAAA,GAAkC,OAAA,CAAQ,MAAA,EAAQ,CAAC,MAAA,EAAQ,QAAQ,CAAA,EAAG,EAAE,KAAA,EAAO,MAAA,EAAQ;AAM7F,SAAS,iBAAA,CAAkB,OAAA,GAAgC,EAAC,EAA6B;AAC9F,EAAA,MAAM,IAAA,GAAO,YAAY,EAAE,SAAA,EAAW,QAAQ,SAAA,EAAW,KAAA,EAAO,OAAA,CAAQ,KAAA,EAAO,CAAA;AAC/E,EAAA,MAAM,MAAA,GAAS,cAAc,OAAO,CAAA;AACpC,EAAA,OAAO,OAAA,CAAQ,OAAO,EAAE,IAAA,EAAM,QAAO,CAAA,EAAI,CAAC,IAAA,EAAM,MAAM,CAAC,CAAA;AACzD;ACmBO,SAAS,gBAAmB,IAAA,EAAuD;AACxF,EAAA,MAAM,EAAE,EAAA,GAAK,MAAA,EAAQ,KAAA,GAAQ,MAAA,EAAQ,UAAU,OAAA,EAAS,QAAA,EAAU,YAAA,GAAe,KAAA,EAAM,GAAI,IAAA;AAC3F,EAAA,OAAO;AAAA,IACL,EAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA,EAAM,CAAC,KAAA,EAAO,IAAA,KAAS;AAGrB,MAAA,MAAM,KAAA,GAAQ,SAAA,CAAU,IAAA,CAAK,KAAK,CAAA;AAClC,MAAA,MAAM,WAA0B,EAAC;AACjC,MAAA,KAAA,MAAW,IAAA,IAAQ,UAAS,EAAG;AAC7B,QAAA,IAAI,QAAA,GAAW,IAAI,CAAA,EAAG;AACtB,QAAA,MAAM,IAAA,GAAO,QAAQ,IAAI,CAAA;AACzB,QAAA,IAAI,IAAA,CAAK,IAAA,IAAQ,IAAA,CAAK,IAAA,CAAK,MAAA,GAAS,CAAA,IAAK,eAAA,CAAgB,IAAA,CAAK,IAAI,CAAA,KAAM,IAAA,CAAK,IAAA,EAAM;AACjF,UAAA,MAAM,IAAI,KAAA;AAAA,YACR,CAAA,sJAAA;AAAA,WAGF;AAAA,QACF;AACA,QAAA,MAAM,OAAA,GAAU,mBAAA,CAAoB,IAAA,EAAM,KAAK,CAAA;AAC/C,QAAA,QAAA,CAAS,KAAK,YAAA,GAAe,YAAA,CAAa,OAAA,EAAS,IAAI,IAAI,OAAO,CAAA;AAAA,MACpE;AAEA,MAAA,OAAO,QAAA;AAAA,IACT;AAAA,GACF;AACF","file":"index.js","sourcesContent":["import { useMemo } from 'react';\nimport { toolSet, type Tool, type ToolSet } from '@weasel-js/core';\nimport { useStickyTool, type UseStickyToolOptions } from './tools/sticky/useStickyTool';\nimport { useTextTool } from './tools/text/useTextTool';\n\n/** The ids {@link useTextToolsTools} keys its tools by. */\nexport type TextToolId = 'text' | 'sticky';\n\n/** The text tools: text and the sticky note. A palette groups them as `text`. */\nexport const TEXT_TOOLS: ToolSet<TextToolId> = toolSet('text', ['text', 'sticky'], { label: 'Text' });\n\n/**\n * Every tool in {@link TEXT_TOOLS}, keyed by id, for `<SceneCanvas tools>` beside `textTools.text`, whose actions\n * they bind. `textTools.textTools` mounts the same tools without a hook.\n */\nexport function useTextToolsTools(options: UseStickyToolOptions = {}): Record<TextToolId, Tool> {\n const text = useTextTool({ behaviors: options.behaviors, share: options.share });\n const sticky = useStickyTool(options);\n return useMemo(() => ({ text, sticky }), [text, sticky]);\n}\n","/**\n * Text RenderLayer for text that is not in a scene: one `textCommandFromPose`\n * command per item, the same command the `kit:text` node painter emits, so an\n * item lays out — and wraps, or doesn't, per its style — as a node would.\n *\n * The GL renderer uses MSDF text. The resolved style's `fontFamily` must\n * be registered via `registerFont(family, variant, metricsUrl, atlasUrl)`\n * from the renderer module *before* the GL backend dispatches this layer.\n * Unregistered families render with a warning and no glyphs (see\n * `TextDrawCommand`'s contract).\n */\n\nimport { type DrawCommand } from '@weasel-js/renderer';\nimport type { TextPose } from '@weasel-js/text';\n\nimport { textCommandFromPose } from '@weasel-js/renderer';\nimport { runsToPlainText } from '@weasel-js/text';\nimport { meanScale } from '@weasel-js/geom';\nimport { clippedToBox } from '../node/textPainter';\nimport { type RenderLayer } from '@weasel-js/core';\n\n\n/** Options for `createTextLayer`. */\nexport interface CreateTextLayerOptions<T> {\n id?: string;\n label?: string;\n getTexts: () => readonly T[];\n getPose: (node: T) => TextPose;\n /** Optional per-node hide hook (e.g., suppress while editing). */\n isHidden?: (node: T) => boolean;\n /** When `true`, each text command is wrapped in a clipped group so any\n * overflow beyond the pose's `(width × height)` is hidden. Default\n * `false` (legacy: text can spill outside the declared bounds). Opt-in\n * so existing consumers who rely on overflow keep working. */\n clipToBounds?: boolean;\n}\n\n/** Build a `RenderLayer` that emits one `TextDrawCommand` per text node. */\nexport function createTextLayer<T>(opts: CreateTextLayerOptions<T>): RenderLayer<unknown> {\n const { id = 'text', label = 'Text', getTexts, getPose, isHidden, clipToBounds = false } = opts;\n return {\n id,\n label,\n draw: (_data, view) => {\n // A world-space layer, so a `{ px }` size in a pose's style resolves\n // against the live camera. Radial in effect — one factor for both axes.\n const scale = meanScale(view.scale);\n const children: DrawCommand[] = [];\n for (const node of getTexts()) {\n if (isHidden?.(node)) continue;\n const pose = getPose(node);\n if (pose.runs && pose.runs.length > 0 && runsToPlainText(pose.runs) !== pose.text) {\n throw new Error(\n `weasel createTextLayer: TextPose invariant violated — ` +\n `runsToPlainText(runs) !== text. Either omit \\`runs\\` or keep it ` +\n `synchronized with \\`text\\`.`,\n );\n }\n const textCmd = textCommandFromPose(pose, scale);\n children.push(clipToBounds ? clippedToBox(textCmd, pose) : textCmd);\n }\n // World-space commands; drawLayers wraps in viewToMat3 automatically.\n return children;\n },\n };\n}\n"]}