Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

slides: connectors for diagrams — curved connectors, seven more tips, a double arrow (#302, #303, #304) (#479)

nyblnet8d8abdde67bb
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index fafb9a2a..d4b9dd0f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1353,6 +1353,17 @@ jobs:
# routes the argument. Bare {{date}} stays viewer-locale (#381).
run: node scripts/test-slides-fields.ts
+ - name: Connectors rig
+ # #302/#303/#304: one tip catalogue (tips.ts) behind the model, the
+ # gate, the panel and the markers; per-tip insets (hollow tips stop the
+ # stroke at the head); the double arrow's polygon is symmetric; a
+ # curve's end tangent and the re-route that moves only its end points;
+ # the straight connector's 1.0.2 functions byte-identical.
+ run: |
+ slides/node_modules/.bin/esbuild scripts/test-slides-connectors.ts --bundle --platform=node --format=esm \
+ --outfile="$RUNNER_TEMP/test-slides-connectors.mjs"
+ node --no-warnings "$RUNNER_TEMP/test-slides-connectors.mjs"
+
- name: Image crop rig
# crop.ts: {x, y, scale} → the one CSS mapping every surface uses;
# the frame can never show empty space; the shape gate admits the
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b7040cf0..99233eeb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,19 @@ pre-1.0.
## [Unreleased]
+- **Connectors for diagrams.** Three asks from xairy, in one go. A
+ *Curved connector* (#302): a curve that sticks to the elements at its ends
+ and re-routes when they move, like the straight Connector, and carries a
+ tip that points the way the curve arrives rather than along the chord; any
+ open curved line can take tips now. Seven more tip styles (#303): open
+ arrow, triangle, hollow triangle, diamond, hollow diamond, square, hollow
+ circle — a hollow head stops the line at its back edge, so nothing shows
+ through. A *Double arrow* shape (#304): the solid arrow with a head at both
+ ends; and a line has always taken an arrowhead at each end through its
+ start and end tips. Sticking (#301) has been in since 1.0.2. Old decks are
+ untouched: the original tips keep their exact geometry. A deck that uses
+ the new tips opens in 1.1.0 and older, but those shells draw a bar where a
+ new tip should be; a double arrow shows there as a single one.
- **A picture can be moved and zoomed inside its frame.** Double-click an
image and the frame becomes a window onto the whole picture: drag to choose
which part shows, scroll or pinch to zoom in, Enter to keep it, Esc to put
diff --git a/scripts/test-slides-connectors.ts b/scripts/test-slides-connectors.ts
new file mode 100644
index 00000000..1681d29a
--- /dev/null
+++ b/scripts/test-slides-connectors.ts
@@ -0,0 +1,207 @@
+#!/usr/bin/env node
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+// Connectors for diagrams (#302 curved connectors, #303 tip styles, #304 the
+// double-headed arrow). Bundled with esbuild in CI (tips.ts reaches the
+// bezier core through an extensionless import):
+//
+// slides/node_modules/.bin/esbuild scripts/test-slides-connectors.ts --bundle --platform=node --format=esm --outfile=/tmp/t.mjs && node /tmp/t.mjs
+//
+// WHAT THIS PROVES. The tip catalogue is ONE list: the model's LineEnding
+// union, the shape gate, the panel's options and the renderer's markers all
+// read tips.ts, so no tip can exist in one place and not another. Each tip's
+// endpoint inset is positive, a hollow tip's inset is at least the depth of
+// its head (the stroke stops at the back edge, nothing shows through), and
+// the three original kinds keep their 2.6 (an old deck renders as before).
+// The double arrow's polygon is mirror-symmetric about the box centre. The
+// end-tangent of a cubic comes from the end handle, falls back to the
+// neighbour's handle, then the chord. Re-routing a curved connector moves
+// only its first/last on-curve point — interior points byte-identical — and
+// a legacy straight connector routes exactly as it did.
+
+import { readFileSync, existsSync } from 'node:fs'
+import { fileURLToPath } from 'node:url'
+import { dirname, join } from 'node:path'
+import { TIPS, TIP_KINDS, tipSpec, tipInsetPx, endTangent, shortenPathEnds, movePathEnds, pathEnds } from '../slides/src/tips.ts'
+import { parseBezier } from '../slides/src/editor/bezier.ts'
+
+let failures = 0
+let checks = 0
+function ok(cond: boolean, msg: string) {
+ checks++
+ if (!cond) { failures++; console.log(` FAIL ${msg}`) }
+ else console.log(` ok ${msg}`)
+}
+// bundled and run from a temp dir in CI: the repo root is the cwd then
+const here = join(dirname(fileURLToPath(import.meta.url)), '..')
+const root = existsSync(join(here, 'slides/src/model.ts')) ? here : process.cwd()
+const read = (f: string) => readFileSync(join(root, f), 'utf8')
+const close = (a: number, b: number, eps = 1e-6) => Math.abs(a - b) < eps
+
+console.log('one tip catalogue\n')
+const model = read('slides/src/model.ts')
+const union = /export type LineEnding = ([^\n]+)/.exec(model)![1]
+const modelKinds = [...union.matchAll(/'([a-z-]+)'/g)].map((m) => m[1])
+ok(modelKinds.join() === TIP_KINDS.join(), `the model's LineEnding union is the catalogue, in order (${TIP_KINDS.length} kinds)`)
+const gate = read('slides/src/untrusted.ts')
+ok(/lineStart: oneOf\(\.\.\.TIP_KINDS\), lineEnd: oneOf\(\.\.\.TIP_KINDS\)/.test(gate), 'the shape gate admits exactly the catalogue')
+const panels = read('slides/src/editor/panels.ts')
+const editor = read('slides/src/editor/editor.ts')
+ok(/TIPS\.map\(\(tip\) => \[tip\.kind, t\(tip\.label\)\]\)/.test(panels), 'the panel lists the catalogue — model words as values, translated labels for display')
+ok(/el\.shape === 'line' \|\| \(el\.shape === 'path' && !\/z\\s\*\$\/i\.test/.test(panels), 'tips are offered on lines and OPEN paths, never on a polygon')
+const render = read('slides/src/render.ts')
+ok(/const spec = tipSpec\(kind\)/.test(render) && !/'M 0 0\.4 L 7\.6 4 L 0 7\.6 Z'/.test(render), 'the renderer builds markers from the catalogue, not from its own geometry')
+ok(new Set(TIP_KINDS).size === TIP_KINDS.length, 'no duplicate kinds')
+ok(TIPS.every((s) => s.label.length > 0), 'every tip has a panel label')
+
+console.log('\ninsets\n')
+for (const s of TIPS) {
+ if (s.kind === 'none') { ok(s.inset === 0 && tipSpec('none') === undefined, 'none: no inset, no marker'); continue }
+ ok(s.inset > 0, `${s.kind}: inset ${s.inset} > 0`)
+ if (s.hollow) {
+ const depth = (s.tipX - s.refX) * s.size / 8
+ ok(s.inset >= depth - 0.01, `${s.kind}: hollow — inset ${s.inset} covers the head depth ${depth.toFixed(2)} so no stroke shows inside`)
+ }
+}
+ok(tipSpec('arrow')!.inset === 2.6 && tipSpec('dot')!.inset === 2.6 && tipSpec('bar')!.inset === 2.6, 'arrow, dot, bar keep 2.6 — an old deck renders as it did')
+ok(tipSpec('arrow')!.refX === 6.4 && tipSpec('arrow')!.size === 5.5, 'the original arrow keeps refX 6.4 / size 5.5')
+ok(close(tipInsetPx('triangle-open', 3), tipSpec('triangle-open')!.inset * 3), 'tipInsetPx scales by the stroke width')
+ok(tipInsetPx(undefined, 3) === 0 && tipInsetPx('none', 3) === 0, 'no tip → no inset')
+
+console.log('\nthe double arrow\n')
+ok(/if \(el\.heads === 2\) \{/.test(render.slice(render.indexOf("case 'arrow': {"), render.indexOf("case 'line': {"))), 'render.ts draws the two-headed polygon inside the ARROW branch')
+ok(/heads: num\(2, 2\)/.test(gate), 'the gate admits heads: 2 on a shape')
+ok(/heads\?: 2/.test(model), 'the model has heads?: 2 on ShapeElement')
+ok(!/arrow2/.test(model) && !/arrow2/.test(gate) && !/'arrow2'/.test(render), 'no new shape kind anywhere — arrow2 is gone')
+const kinds = /export type ShapeKind = ([^\n]+)/.exec(model)![1]
+ok(kinds === "'rect' | 'ellipse' | 'triangle' | 'arrow' | 'line' | 'path'", 'ShapeKind is exactly what 1.1.0 knows (no new kinds — a shipped shell throws on one)')
+ok(/kind: 'arrow', label: 'Double arrow', icon: ICONS\.arrow2, heads: 2/.test(editor) && /defaultShape\(item\.kind, item\.heads \? \{ heads: item\.heads \} : \{\}\)/.test(editor), 'the Shape menu makes a Double arrow as {shape: arrow, heads: 2}')
+ok(/this\.row\('Double-headed', this\.toggle\(el\.heads === 2/.test(panels) && /if \(on\) s\.heads = 2; else delete s\.heads/.test(panels), 'the panel toggle writes heads: 2 and deletes it when off')
+// mirror the polygon exactly as render.ts computes it
+const w = 300, h = 120
+const shaftH = h * 0.44, headW = Math.min(w * 0.3, h), y0 = (h - shaftH) / 2
+const pts = [[0, h / 2], [headW, 0], [headW, y0], [w - headW, y0], [w - headW, 0], [w, h / 2], [w - headW, h], [w - headW, y0 + shaftH], [headW, y0 + shaftH], [headW, h]]
+const mirrored = pts.map(([x, y]) => [w - x, h - y])
+const key = (p: number[][]) => p.map(([x, y]) => `${x.toFixed(3)},${y.toFixed(3)}`).sort().join(' ')
+ok(key(pts) === key(mirrored), 'the two-headed polygon is symmetric under a 180° turn about the box centre (a head at each end, same shape)')
+ok(pts.filter(([x]) => x === 0).length === 1 && pts.filter(([x]) => x === w).length === 1, 'exactly one point on each end — the two tips')
+
+console.log('\nwhat 1.1.0 does with a deck that uses this (frozen fixture)\n')
+// FROZEN from origin/main render.ts at 3a7eb8fb (the 1.1.0 renderer). Two
+// facts about that code decide what an old shell does with a new deck:
+// (1) renderShape: `let node: SVGElement` then `switch (el.shape)` with
+// these case labels and NO default — an unknown kind leaves `node`
+// unassigned and `svg.appendChild(node)` throws a TypeError, which is
+// why the double arrow is a PROPERTY on 'arrow', not a new kind;
+// (2) markerRef: `if (kind === 'arrow') … else if (kind === 'dot') … else
+// { rect x=3.2 width=1.6 … }` — the else branch is the BAR, so any tip
+// kind 1.1.0 does not know is drawn as a bar, not as a plain end.
+const FROZEN_MAIN_SHA = '3a7eb8fb'
+const FROZEN_SWITCH_CASES = ['path', 'rect', 'ellipse', 'triangle', 'arrow', 'line'] // verbatim order of `case '…': {` in renderShape
+const FROZEN_MARKER_ELSE = ` } else {
+ tip = document.createElementNS(SVG_NS, 'rect')
+ tip.setAttribute('x', '3.2')
+ tip.setAttribute('y', '0.4')
+ tip.setAttribute('width', '1.6')
+ tip.setAttribute('height', '7.2')
+ marker.setAttribute('refX', '4')
+ }`
+// the fixture as behaviour: what 1.1.0's renderer does with a kind / a tip
+const frozenRenderShape = (shape: string): 'single-arrow' | 'other' | 'THROWS' => {
+ let node: string | undefined
+ switch (shape) {
+ case 'path': case 'rect': case 'ellipse': case 'triangle': case 'line': node = 'other'; break
+ case 'arrow': node = 'single-arrow'; break
+ // no default — exactly as at 3a7eb8fb
+ }
+ if (node === undefined) return 'THROWS' // svg.appendChild(undefined) → TypeError
+ return node
+}
+const frozenMarker = (kind: string): 'arrow' | 'dot' | 'bar' => (kind === 'arrow' ? 'arrow' : kind === 'dot' ? 'dot' : 'bar')
+ok(FROZEN_SWITCH_CASES.join() === 'path,rect,ellipse,triangle,arrow,line' && kinds.replace(/'| /g, '').split('|').every((k) => FROZEN_SWITCH_CASES.includes(k)), `every ShapeKind on this branch is a case 1.1.0's switch has (frozen at ${FROZEN_MAIN_SHA})`)
+ok(frozenRenderShape('arrow2') === 'THROWS', 'the fixture shows why: an unknown kind would throw in 1.1.0 (the bug the review caught)')
+ok(frozenRenderShape('arrow') === 'single-arrow', 'a deck with {shape: arrow, heads: 2} renders in 1.1.0 as a single arrow — a degrade, not a crash')
+ok(/rect'\)\n\s+tip\.setAttribute\('x', '3\.2'\)/.test(FROZEN_MARKER_ELSE), 'the frozen else-branch is the bar geometry')
+for (const s of TIPS) {
+ if (['none', 'arrow', 'dot', 'bar'].includes(s.kind)) continue
+ ok(frozenMarker(s.kind) === 'bar', `${s.kind}: 1.1.0 draws a BAR at that end (not a plain end) — no throw`)
+}
+ok(/in 1\.1\.0 and older the renderer matches only\n \* 'arrow' and 'dot' and draws a BAR/.test(read('slides/src/tips.ts')), 'tips.ts states the degrade')
+ok(/those shells draw a bar where a\n new tip should be; a double arrow shows there as a single one/.test(read('CHANGELOG.md')), 'the changelog states the same degrade, no softer')
+
+console.log('\nend tangent\n')
+const up = parseBezier('M 0 0 C 30 0 100 -50 100 -100').nodes // last handle points straight up into the endpoint
+let t = endTangent(up, true)!
+ok(close(t.x, 0) && close(t.y, -1), 'end tangent follows the last handle (straight up), not the chord')
+t = endTangent(up, false)!
+ok(close(t.x, -1) && close(t.y, 0), 'start tangent points OUT of the start, along the first handle')
+const degenerate = parseBezier('M 0 0 C 30 0 100 -100 100 -100').nodes // zero-length last handle
+t = endTangent(degenerate, true)!
+const L = Math.hypot(70, 100)
+ok(close(t.x, 70 / L) && close(t.y, -100 / L), 'zero-length end handle → falls back to the neighbour handle (30,0)→(100,-100), not the chord')
+const bothZero = parseBezier('M 0 0 C 0 0 100 -100 100 -100').nodes
+t = endTangent(bothZero, true)!
+ok(close(t.x, Math.SQRT1_2) && close(t.y, -Math.SQRT1_2), 'both handles degenerate → the chord')
+ok(endTangent(parseBezier('M 5 5').nodes, true) === null, 'a single point has no tangent')
+
+console.log('\nshortening ends for a tip\n')
+const d0 = 'M 0 0 C 30 0 100 -50 100 -100'
+const d1 = shortenPathEnds(d0, 0, 10)
+const n1 = parseBezier(d1).nodes
+ok(close(n1[n1.length - 1].p.x, 100) && close(n1[n1.length - 1].p.y, -90), 'end pulled back 10 along its tangent (down the vertical arrival)')
+ok(close(n1[0].p.x, 0) && close(n1[0].p.y, 0), 'start untouched when only the end has a tip')
+ok(shortenPathEnds(d0, 0, 0) === d0, 'no tip → the d comes back unchanged')
+ok(shortenPathEnds('M 0 0 L 10 0 L 10 10 Z', 2, 2) === 'M 0 0 L 10 0 L 10 10 Z', 'a closed path is never shortened')
+
+console.log('\nre-routing a curved connector\n')
+const bow = 'M 0 0 C 33.33 33.33 66.67 66.67 100 100 C 133.33 133.33 166.67 116.67 200 100'
+const before = parseBezier(bow).nodes
+const moved = movePathEnds(bow, { x: -20, y: 10 }, null)
+const after = parseBezier(moved).nodes
+ok(close(after[0].p.x, -20) && close(after[0].p.y, 10), 'the first on-curve point moved to the new anchor')
+ok(after.slice(1).every((n, i) => close(n.p.x, before[i + 1].p.x) && close(n.p.y, before[i + 1].p.y)), 'every other on-curve point is exactly where it was')
+ok(close(after[2].p.x, 200) && close(after[2].p.y, 100) && close(after[1].out!.x, before[1].out!.x), 'the far end and its outgoing handle are byte-identical')
+const moved2 = movePathEnds(bow, null, { x: 250, y: 60 })
+const after2 = parseBezier(moved2).nodes
+ok(close(after2[2].p.x, 250) && close(after2[2].p.y, 60) && close(after2[0].p.x, 0), 'moving only the end leaves the start alone')
+ok(movePathEnds(bow, null, null) === bow, 'nothing to move → unchanged')
+const ends = pathEnds(bow)!
+ok(close(ends[0].x, 0) && close(ends[1].x, 200), 'pathEnds reads the two on-curve ends')
+
+console.log('\nthe legacy straight connector\n')
+// lineedit.ts cannot load in node (it reaches the i18n packs at import), so
+// the straight-line path is held to its 1.0.2 text: these three functions are
+// what routed every connector before this change, byte for byte.
+const lineedit = read('slides/src/editor/lineedit.ts')
+const fn = (name: string) => { const i = lineedit.indexOf(`export function ${name}(`); return lineedit.slice(i, lineedit.indexOf('\n}\n', i) + 3) }
+ok(fn('lineEndpoints') === `export function lineEndpoints(el: ShapeElement): [Pt, Pt] {
+ const cx = el.x + el.w / 2
+ const cy = el.y + el.h / 2
+ const rad = ((el.rotation || 0) * Math.PI) / 180
+ const hw = el.w / 2
+ const dx = Math.cos(rad) * hw
+ const dy = Math.sin(rad) * hw
+ return [{ x: cx - dx, y: cy - dy }, { x: cx + dx, y: cy + dy }]
+}
+`, 'lineEndpoints is the 1.0.2 text')
+ok(fn('setLineEndpoints') === `export function setLineEndpoints(el: ShapeElement, a: Pt, b: Pt): void {
+ const cx = (a.x + b.x) / 2
+ const cy = (a.y + b.y) / 2
+ const w = Math.max(Math.hypot(b.x - a.x, b.y - a.y), 1)
+ const h = el.h || 4
+ el.w = w
+ el.x = cx - w / 2
+ el.y = cy - h / 2
+ el.rotation = (Math.atan2(b.y - a.y, b.x - a.x) * 180) / Math.PI
+}
+`, 'setLineEndpoints is the 1.0.2 text')
+ok(fn('borderPoint').includes('const s = Math.min(sx, sy)\n return { x: cx + dx * s, y: cy + dy * s }'), 'borderPoint is the 1.0.2 text')
+// and the marker numbers an old deck was drawn with
+ok(/inset the endpoints so the tip's point lands on the box edge/.test(render) && /tipInsetPx\(el\.lineStart, lw\)/.test(render), 'a line insets by the catalogue — 2.6 for the original three (asserted above)')
+ok(/el\.shape !== 'line' && el\.shape !== 'path'/.test(editor) && /if \(isPath\) setPathEndpoints\(c, na, nb\)\n\s+else setLineEndpoints\(c, na, nb\)/.test(editor), 'syncConnectors routes lines through setLineEndpoints and paths through setPathEndpoints')
+const canvas = read('slides/src/editor/canvas.ts')
+ok(/kind === 'curve-connector'/.test(canvas) && /el\.lineEnd = 'arrow'\n\s+if \(fromA\) el\.from/.test(canvas), 'the Curved connector tool draws a path with a tip and anchors like Connector')
+ok(/label: 'Curved connector'/.test(editor) && /label: 'Double arrow'/.test(editor), 'both new shapes are in the Shape menu')
+
+console.log(`\n${checks - failures}/${checks} checks passed`)
+process.exit(failures ? 1 : 0)
diff --git a/slides/src/editor/canvas.ts b/slides/src/editor/canvas.ts
index 237996a6..e9b40e56 100644
--- a/slides/src/editor/canvas.ts
+++ b/slides/src/editor/canvas.ts
@@ -19,7 +19,7 @@ import { BezierEditor, isCurve } from './beziereditor'
import { simplifyPoints } from './patheditor'
const SVG_NS = 'http://www.w3.org/2000/svg'
-type DrawKind = 'line' | 'path' | 'connector' | 'free' | 'poly'
+type DrawKind = 'line' | 'path' | 'connector' | 'curve-connector' | 'free' | 'poly'
import { CommentsUI } from './comments'
import { StepBadges } from './stepbadges'
import type { Peer } from '../sync/session'
@@ -1693,7 +1693,7 @@ export class SlideCanvas {
// visible anchor points on the element under the cursor (connector tool)
const showAnchors = (p: Pt | null) => {
dots.innerHTML = ''
- if (kind !== 'connector' || !p) return
+ if ((kind !== 'connector' && kind !== 'curve-connector') || !p) return
const id = this.elementAt(p, 12 * Math.max(k(), 1))
if (!id) return
for (const a of anchorsFor(id)) {
@@ -1708,7 +1708,7 @@ export class SlideCanvas {
}
}
const snap = (p: Pt): { a: Snap; pt: Pt } => {
- if (kind !== 'connector') return { a: null, pt: p }
+ if (kind !== 'connector' && kind !== 'curve-connector') return { a: null, pt: p }
const id = this.elementAt(p, 12 * Math.max(k(), 1))
if (!id) return { a: null, pt: p }
let best: Snap = null
@@ -1788,7 +1788,7 @@ export class SlideCanvas {
const p = toSlide(e)
const sn = snap(p)
showAnchors(p)
- setPreview(kind === 'path' ? this.curveBowD(start, sn.pt) : `M ${start.x} ${start.y} L ${sn.pt.x} ${sn.pt.y}`)
+ setPreview(kind === 'path' || kind === 'curve-connector' ? this.curveBowD(start, sn.pt) : `M ${start.x} ${start.y} L ${sn.pt.x} ${sn.pt.y}`)
}
const up = (e: MouseEvent) => {
window.removeEventListener('mousemove', move)
@@ -1840,15 +1840,22 @@ export class SlideCanvas {
toA?: { el: string; side: 'auto' | 'top' | 'right' | 'bottom' | 'left' },
) {
const ink = readableInk(this.store.slide.background)
- if (kind === 'path') {
+ if (kind === 'path' || kind === 'curve-connector') {
const el = defaultShape('path', { fill: 'transparent', stroke: ink, strokeWidth: 3 }) as ShapeElement
const mx = (a.x + b.x) / 2
const my = (a.y + b.y) / 2
const dx = b.x - a.x
const dy = b.y - a.y
const len = Math.hypot(dx, dy) || 1
- const off = len * 0.2
+ // a gentle default bow: the connector bends ~15%, a plain curve 20%
+ const off = len * (kind === 'curve-connector' ? 0.15 : 0.2)
setPathAnchors(el, [a, { x: mx - (dy / len) * off, y: my + (dx / len) * off }, b])
+ if (kind === 'curve-connector') {
+ // #302: a curve that sticks like a Connector and carries a tip
+ el.lineEnd = 'arrow'
+ if (fromA) el.from = { el: fromA.el, side: fromA.side }
+ if (toA) el.to = { el: toA.el, side: toA.side }
+ }
this.insert(el)
return
}
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.ts
index a6e1c7b7..392c9da8 100644
--- a/slides/src/editor/editor.ts
+++ b/slides/src/editor/editor.ts
@@ -29,7 +29,7 @@ import { noteSavedFromWeb } from './returngate'
import { addVersion, clearRecovery, clearVersions, docContentKey, getRecovery, listVersions, pruneOld, putRecovery, type Snapshot } from '../autosave'
import { insertElements, insertSlides, parseClip, serializeElements, serializeSlides } from './clipboard'
import { openSpeakerWindow, speakerIdleBody } from '../screens'
-import { borderPoint, boxCenter, lineEndpoints, setLineEndpoints, sideMidpoint } from './lineedit'
+import { borderPoint, boxCenter, lineEndpoints, pathEndpoints, setLineEndpoints, setPathEndpoints, sideMidpoint } from './lineedit'
import { ICONS } from '../icons'
import { t, setLocale, locale, localeChoices, LOCALE_CHOICES, applyDirection, isRtl } from '../i18n'
import { stepOf } from '../steps'
@@ -63,14 +63,16 @@ const LONG_PRESS_MS = 500
/** …and how far it may wander first. Past this it was a drag or a pan. */
const LONG_PRESS_SLOP = 10
-const SHAPE_MENU: Array<{ kind: ShapeKind; label: string; icon: string; draw?: 'line' | 'path' | 'connector' | 'free' | 'poly'; tip: string }> = [
+const SHAPE_MENU: Array<{ kind: ShapeKind; label: string; icon: string; heads?: 2; draw?: 'line' | 'path' | 'connector' | 'curve-connector' | 'free' | 'poly'; tip: string }> = [
{ kind: 'rect', label: 'Rectangle', icon: ICONS.rect, tip: 'A rectangle — rounded corners, fills, gradients and shadows in the panel' },
{ kind: 'ellipse', label: 'Ellipse', icon: ICONS.ellipse, tip: 'An ellipse or circle' },
{ kind: 'triangle', label: 'Triangle', icon: ICONS.triangle, tip: 'A triangle' },
{ kind: 'arrow', label: 'Arrow', icon: ICONS.arrow, tip: 'A solid arrow shape' },
+ { kind: 'arrow', label: 'Double arrow', icon: ICONS.arrow2, heads: 2, tip: 'A solid arrow with a head at both ends' },
{ kind: 'line', label: 'Line', icon: ICONS.line, draw: 'line', tip: 'Drag on the slide to draw a straight line — drag its endpoints to adjust' },
{ kind: 'path', label: 'Curved line', icon: ICONS.curve, draw: 'path', tip: 'Drag to draw a curve — then drag its points; double-click to add or remove one' },
{ kind: 'line', label: 'Connector', icon: ICONS.connector, draw: 'connector', tip: 'Drag between two elements — the ends snap on and re-route when they move' },
+ { kind: 'path', label: 'Curved connector', icon: ICONS.curveConnector, draw: 'curve-connector', tip: 'A curved line between two elements — the ends snap on and re-route, the tip follows the curve' },
{ kind: 'path', label: 'Freeform', icon: ICONS.freeform, draw: 'free', tip: 'Draw by hand — the stroke smooths into an editable curve' },
{ kind: 'path', label: 'Polygon', icon: ICONS.polygon, draw: 'poly', tip: 'Click to place corners; click the first point (or double-click) to close the shape' },
]
@@ -1694,7 +1696,7 @@ export class Editor {
// line / curve / connector arm a draw tool — drag on the canvas to draw
// (or click to drop a default); other shapes insert straight away.
if (item.draw) { this.canvas.armDraw(item.draw); return }
- this.canvas.insert(defaultShape(item.kind))
+ this.canvas.insert(defaultShape(item.kind, item.heads ? { heads: item.heads } : {}))
}, t(item.tip))
menu.appendChild(b)
}
@@ -2369,21 +2371,26 @@ export class Editor {
if (changed) this.canvas.render()
}
- /** Re-route connectors (line shapes anchored to elements via from/to) when
- * anything on the slide moves. Derived, not committed — every replica computes
- * the same endpoints from the element boxes (mirrors syncLinkedCharts). */
+ /** Re-route connectors (line and open-path shapes anchored to elements via
+ * from/to) when anything on the slide moves. Derived, not committed — every
+ * replica computes the same endpoints from the element boxes (mirrors
+ * syncLinkedCharts). A line moves its two endpoints; a curve (#302) moves
+ * its first/last anchor and keeps every interior point (tips.movePathEnds). */
private syncConnectors() {
const slide = this.store.slide
const byId = new Map(slide.elements.map((e) => [e.id, e]))
let changed = false
for (const el of slide.elements) {
- if (el.type !== 'shape' || el.shape !== 'line') continue
+ if (el.type !== 'shape' || (el.shape !== 'line' && el.shape !== 'path')) continue
const c = el as import('../model').ShapeElement
if (!c.from && !c.to) continue
if (c.from && !byId.has(c.from.el)) { delete c.from; changed = true }
if (c.to && !byId.has(c.to.el)) { delete c.to; changed = true }
if (!c.from && !c.to) continue
- const [a, b] = lineEndpoints(c)
+ const isPath = c.shape === 'path'
+ const pathEnds = isPath ? pathEndpoints(c) : null
+ if (isPath && !pathEnds) continue
+ const [a, b] = isPath ? pathEnds! : lineEndpoints(c)
const fromBox = c.from ? byId.get(c.from.el) : null
const toBox = c.to ? byId.get(c.to.el) : null
// explicit side → pin to that side's midpoint; 'auto' → nearest border
@@ -2392,7 +2399,8 @@ export class Editor {
const na = fromBox ? end(fromBox, c.from?.side, toBox ? boxCenter(toBox) : b) : a
const nb = toBox ? end(toBox, c.to?.side, fromBox ? boxCenter(fromBox) : a) : b
if (Math.hypot(na.x - a.x, na.y - a.y) > 0.5 || Math.hypot(nb.x - b.x, nb.y - b.y) > 0.5) {
- setLineEndpoints(c, na, nb)
+ if (isPath) setPathEndpoints(c, na, nb)
+ else setLineEndpoints(c, na, nb)
changed = true
}
}
diff --git a/slides/src/editor/lineedit.ts b/slides/src/editor/lineedit.ts
index ac136f51..8d67d7f3 100644
--- a/slides/src/editor/lineedit.ts
+++ b/slides/src/editor/lineedit.ts
@@ -15,6 +15,7 @@
import type { Store } from '../store'
import type { ShapeElement } from '../model'
import { anchorsToPath, parseAnchors, samplePathAnchors } from './patheditor'
+import { movePathEnds, pathEnds } from '../tips'
const rnd = (v: number) => Math.round(v * 100) / 100
/** Closed shapes (polygons) end with Z; straight ones have no curve commands. */
@@ -108,6 +109,67 @@ export function setPathAnchors(el: ShapeElement, pts: Pt[], opts: { closed?: boo
: anchorsToPath(rel)) + (opts.closed ? ' Z' : '')
}
+/** First and last on-curve points of an open path shape, in slide coords —
+ * exact (parsed, not sampled), for connector re-routing. */
+export function pathEndpoints(el: ShapeElement): [Pt, Pt] | null {
+ const ends = pathEnds(el.d ?? '')
+ if (!ends) return null
+ const [px, py, pw, ph] = el.pathBox ?? [0, 0, el.w || 1, el.h || 1]
+ const sx = el.w / (pw || 1)
+ const sy = el.h / (ph || 1)
+ const out = (p: Pt): Pt => ({ x: el.x + (p.x - px) * sx, y: el.y + (p.y - py) * sy })
+ return [out(ends[0]), out(ends[1])]
+}
+
+/** Move an open path's ends to new slide-coord points (connector re-route,
+ * #302): interior anchors keep their positions exactly; the box and pathBox
+ * are renormalised to the on-curve points, the way setPathAnchors does. */
+export function setPathEndpoints(el: ShapeElement, a: Pt, b: Pt): void {
+ const [px, py, pw, ph] = el.pathBox ?? [0, 0, el.w || 1, el.h || 1]
+ const sx = el.w / (pw || 1)
+ const sy = el.h / (ph || 1)
+ // slide → current path units
+ const toPath = (p: Pt): Pt => ({ x: px + (p.x - el.x) / sx, y: py + (p.y - el.y) / sy })
+ const moved = movePathEnds(el.d ?? '', toPath(a), toPath(b))
+ // renormalise: pathBox [0,0,w,h] over the on-curve points, at scale 1
+ const nodes = parseBezierPoints(moved)
+ if (!nodes.length) return
+ const abs = nodes.map((p) => ({ x: el.x + (p.x - px) * sx, y: el.y + (p.y - py) * sy }))
+ const minX = Math.min(...abs.map((p) => p.x))
+ const minY = Math.min(...abs.map((p) => p.y))
+ const w = Math.max(Math.max(...abs.map((p) => p.x)) - minX, 1)
+ const h = Math.max(Math.max(...abs.map((p) => p.y)) - minY, 1)
+ // re-express every coordinate (points AND handles) in the new box
+ const re = moved.replace(/-?\d*\.?\d+(?:e-?\d+)?/g, (() => {
+ let i = 0
+ return (tok: string) => {
+ const v = Number(tok)
+ const isX = i++ % 2 === 0
+ const s = isX ? rnd(el.x + (v - px) * sx - minX) : rnd(el.y + (v - py) * sy - minY)
+ return String(s)
+ }
+ })())
+ el.x = minX
+ el.y = minY
+ el.w = w
+ el.h = h
+ el.pathBox = [0, 0, w, h]
+ el.d = re
+}
+
+/** On-curve points of an M/C path string (path units). */
+function parseBezierPoints(d: string): Pt[] {
+ const out: Pt[] = []
+ const re = /([MC])\s*((?:-?\d*\.?\d+(?:e-?\d+)?[\s,]*)+)/g
+ let m: RegExpExecArray | null
+ while ((m = re.exec(d))) {
+ const nums = m[2].trim().split(/[\s,]+/).map(Number)
+ if (m[1] === 'M') out.push({ x: nums[0], y: nums[1] })
+ else out.push({ x: nums[4], y: nums[5] })
+ }
+ return out
+}
+
export class LineEditor {
private overlay: SVGSVGElement | null = null
private elId = ''
diff --git a/slides/src/editor/panels.ts b/slides/src/editor/panels.ts
index de679b18..fcd45817 100644
--- a/slides/src/editor/panels.ts
+++ b/slides/src/editor/panels.ts
@@ -15,6 +15,7 @@ import { isMacOS } from '../screens'
import { CHART_PRESETS } from '../charts'
import { FONT_CHOICES, firstFamily, injectFonts } from '../fonts'
import { CODE_SCOPES, DEFAULT_CODE_COLORS } from '../code'
+import { TIPS } from '../tips'
import { DATE_PRESETS, TIME_PRESETS, OTHER_FIELDS, formatDate } from '../datefmt'
import { shrinkImageFile, shrinkNote, fmtBytes } from './shrink'
import { revealInOrder, revealTogether, removeReveal, type StepPatch } from './reveal'
@@ -1324,13 +1325,21 @@ export class PropsPanel {
s.strokeStyle = v === 'solid' ? undefined : (v as 'dashed' | 'dotted')
if (v === 'solid') delete s.strokeDash // clear the legacy dash too
}, true)))
- if (el.shape === 'line') {
- const ENDINGS = ['none', 'arrow', 'dot', 'bar']
- this.row('Start tip', this.select(ENDINGS, el.lineStart ?? 'none', (v) =>
+ // Tips: lines, and open paths (a curved line or connector, #302). The
+ // options are tips.ts's catalogue — display labels localized, values the
+ // model's words. A closed path (polygon) has no ends to tip.
+ if (el.shape === 'line' || (el.shape === 'path' && !/z\s*$/i.test(el.d ?? ''))) {
+ const ENDINGS: Array<[string, string]> = TIPS.map((tip) => [tip.kind, t(tip.label)])
+ this.row('Start tip', this.labeledSelect(ENDINGS, el.lineStart ?? 'none', (v) =>
this.mutate(el.id, (e) => { (e as ShapeElement).lineStart = v === 'none' ? undefined : (v as LineEnding) }, true)))
- this.row('End tip', this.select(ENDINGS, el.lineEnd ?? 'none', (v) =>
+ this.row('End tip', this.labeledSelect(ENDINGS, el.lineEnd ?? 'none', (v) =>
this.mutate(el.id, (e) => { (e as ShapeElement).lineEnd = v === 'none' ? undefined : (v as LineEnding) }, true)))
}
+ if (el.shape === 'arrow') {
+ // #304: a head at both ends is a property of the arrow, not a kind
+ this.row('Double-headed', this.toggle(el.heads === 2, (on) =>
+ this.mutate(el.id, (e) => { const s = e as ShapeElement; if (on) s.heads = 2; else delete s.heads }, true)))
+ }
if (el.shape === 'rect') {
this.row('Corner radius', this.number(el.radius, 1, (v, fin) =>
this.mutate(el.id, (e) => { (e as ShapeElement).radius = Math.max(v, 0) }, fin)))
diff --git a/slides/src/i18n/de.ts b/slides/src/i18n/de.ts
index 273ca9c1..c466e62c 100644
--- a/slides/src/i18n/de.ts
+++ b/slides/src/i18n/de.ts
@@ -892,4 +892,16 @@ export const de: Catalog = {
"Replace file (original size)…": "Datei ersetzen (Originalgröße)…",
"Keep aspect ratio": "Seitenverhältnis beibehalten",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "An: Größenänderung behält die Proportionen des Bildes (Umschalt gibt sie für einen Zug frei). Aus: Breite und Höhe ändern sich unabhängig und das Bild wird gestreckt",
+ "Dot": "Punkt",
+ "Open arrow": "Offener Pfeil",
+ "Hollow triangle": "Hohles Dreieck",
+ "Diamond": "Raute",
+ "Hollow diamond": "Hohle Raute",
+ "Square": "Quadrat",
+ "Hollow circle": "Hohler Kreis",
+ "Double arrow": "Doppelpfeil",
+ "A solid arrow with a head at both ends": "Ein massiver Pfeil mit einer Spitze an beiden Enden",
+ "Curved connector": "Gebogener Verbinder",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Eine gebogene Linie zwischen zwei Elementen — die Enden rasten ein und folgen mit, die Spitze folgt der Kurve",
+ "Double-headed": "Zwei Spitzen",
}
diff --git a/slides/src/i18n/es.ts b/slides/src/i18n/es.ts
index 01de485d..98ca7a02 100644
--- a/slides/src/i18n/es.ts
+++ b/slides/src/i18n/es.ts
@@ -892,4 +892,16 @@ export const es: Catalog = {
"Replace file (original size)…": "Reemplazar archivo (tamaño original)…",
"Keep aspect ratio": "Mantener la proporción",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Activado: al redimensionar se conservan las proporciones de la imagen (Mayús las libera durante un arrastre). Desactivado: ancho y alto cambian por separado y la imagen se estira",
+ "Dot": "Punto",
+ "Open arrow": "Flecha abierta",
+ "Hollow triangle": "Triángulo hueco",
+ "Diamond": "Rombo",
+ "Hollow diamond": "Rombo hueco",
+ "Square": "Cuadrado",
+ "Hollow circle": "Círculo hueco",
+ "Double arrow": "Flecha doble",
+ "A solid arrow with a head at both ends": "Una flecha sólida con punta en ambos extremos",
+ "Curved connector": "Conector curvo",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Una línea curva entre dos elementos: los extremos se enganchan y se reajustan, y la punta sigue la curva",
+ "Double-headed": "Dos puntas",
}
diff --git a/slides/src/i18n/fr.ts b/slides/src/i18n/fr.ts
index 046d242b..926eb6d6 100644
--- a/slides/src/i18n/fr.ts
+++ b/slides/src/i18n/fr.ts
@@ -892,4 +892,16 @@ export const fr: Catalog = {
"Replace file (original size)…": "Remplacer le fichier (taille d’origine)…",
"Keep aspect ratio": "Conserver les proportions",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Activé : le redimensionnement conserve les proportions de l’image (Maj les libère le temps d’un glissement). Désactivé : largeur et hauteur changent séparément et l’image s’étire",
+ "Dot": "Point",
+ "Open arrow": "Flèche ouverte",
+ "Hollow triangle": "Triangle creux",
+ "Diamond": "Losange",
+ "Hollow diamond": "Losange creux",
+ "Square": "Carré",
+ "Hollow circle": "Cercle creux",
+ "Double arrow": "Double flèche",
+ "A solid arrow with a head at both ends": "Une flèche pleine avec une pointe à chaque extrémité",
+ "Curved connector": "Connecteur courbe",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Une ligne courbe entre deux éléments — les extrémités s’accrochent et se replacent, la pointe suit la courbe",
+ "Double-headed": "Deux pointes",
}
diff --git a/slides/src/i18n/it.ts b/slides/src/i18n/it.ts
index b8cf92cc..19a10c76 100644
--- a/slides/src/i18n/it.ts
+++ b/slides/src/i18n/it.ts
@@ -892,4 +892,16 @@ export const it: Catalog = {
"Replace file (original size)…": "Sostituisci file (dimensione originale)…",
"Keep aspect ratio": "Mantieni le proporzioni",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Attivo: il ridimensionamento conserva le proporzioni dell’immagine (Maiusc le libera per un trascinamento). Disattivo: larghezza e altezza cambiano separatamente e l’immagine si deforma",
+ "Dot": "Punto",
+ "Open arrow": "Freccia aperta",
+ "Hollow triangle": "Triangolo vuoto",
+ "Diamond": "Rombo",
+ "Hollow diamond": "Rombo vuoto",
+ "Square": "Quadrato",
+ "Hollow circle": "Cerchio vuoto",
+ "Double arrow": "Freccia doppia",
+ "A solid arrow with a head at both ends": "Una freccia piena con la punta a entrambe le estremità",
+ "Curved connector": "Connettore curvo",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Una linea curva tra due elementi — le estremità si agganciano e si riposizionano, la punta segue la curva",
+ "Double-headed": "Due punte",
}
diff --git a/slides/src/i18n/ja.ts b/slides/src/i18n/ja.ts
index 356f1323..39ea7356 100644
--- a/slides/src/i18n/ja.ts
+++ b/slides/src/i18n/ja.ts
@@ -892,4 +892,16 @@ export const ja: Catalog = {
"Replace file (original size)…": "ファイルを置き換え(元のサイズ)…",
"Keep aspect ratio": "縦横比を保つ",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "オン: サイズ変更で画像の比率を保ちます(Shift で一回のドラッグだけ解除)。オフ: 幅と高さを別々に変えられ、画像は引き伸ばされます",
+ "Dot": "点",
+ "Open arrow": "開いた矢印",
+ "Hollow triangle": "中空の三角",
+ "Diamond": "ひし形",
+ "Hollow diamond": "中空のひし形",
+ "Square": "四角",
+ "Hollow circle": "中空の円",
+ "Double arrow": "両端矢印",
+ "A solid arrow with a head at both ends": "両端に矢じりのある塗りつぶし矢印",
+ "Curved connector": "曲線コネクタ",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "2つの要素をつなぐ曲線 — 両端は要素に吸着して追従し、先端は曲線に沿います",
+ "Double-headed": "両端に矢じり",
}
diff --git a/slides/src/i18n/packed.ts b/slides/src/i18n/packed.ts
index cf27e0d5..a7d02251 100644
--- a/slides/src/i18n/packed.ts
+++ b/slides/src/i18n/packed.ts
@@ -898,4 +898,16 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"Replace file (original size)…": ["ファイルを置き換え(元のサイズ)…","替换文件(原始尺寸)…","取代檔案(原始尺寸)…","Reemplazar archivo (tamaño original)…","Remplacer le fichier (taille d’origine)…","Datei ersetzen (Originalgröße)…","Sostituisci file (dimensione originale)…","Substituir ficheiro (tamanho original)…"],
"Keep aspect ratio": ["縦横比を保つ","保持宽高比","保持長寬比","Mantener la proporción","Conserver les proportions","Seitenverhältnis beibehalten","Mantieni le proporzioni","Manter proporções"],
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": ["オン: サイズ変更で画像の比率を保ちます(Shift で一回のドラッグだけ解除)。オフ: 幅と高さを別々に変えられ、画像は引き伸ばされます","开:调整大小时保持图片比例(按住 Shift 可临时解除一次拖动)。关:宽和高各自变化,图片会被拉伸","開:調整大小時保持圖片比例(按住 Shift 可暫時解除一次拖曳)。關:寬和高各自變化,圖片會被拉伸","Activado: al redimensionar se conservan las proporciones de la imagen (Mayús las libera durante un arrastre). Desactivado: ancho y alto cambian por separado y la imagen se estira","Activé : le redimensionnement conserve les proportions de l’image (Maj les libère le temps d’un glissement). Désactivé : largeur et hauteur changent séparément et l’image s’étire","An: Größenänderung behält die Proportionen des Bildes (Umschalt gibt sie für einen Zug frei). Aus: Breite und Höhe ändern sich unabhängig und das Bild wird gestreckt","Attivo: il ridimensionamento conserva le proporzioni dell’immagine (Maiusc le libera per un trascinamento). Disattivo: larghezza e altezza cambiano separatamente e l’immagine si deforma","Ligado: redimensionar mantém as proporções da imagem (Shift liberta-as durante um arrasto). Desligado: largura e altura mudam separadamente e a imagem estica"],
+ "Dot": ["点","圆点","圓點","Punto","Point","Punkt","Punto","Ponto"],
+ "Open arrow": ["開いた矢印","开放箭头","開放箭頭","Flecha abierta","Flèche ouverte","Offener Pfeil","Freccia aperta","Seta aberta"],
+ "Hollow triangle": ["中空の三角","空心三角","空心三角","Triángulo hueco","Triangle creux","Hohles Dreieck","Triangolo vuoto","Triângulo oco"],
+ "Diamond": ["ひし形","菱形","菱形","Rombo","Losange","Raute","Rombo","Losango"],
+ "Hollow diamond": ["中空のひし形","空心菱形","空心菱形","Rombo hueco","Losange creux","Hohle Raute","Rombo vuoto","Losango oco"],
+ "Square": ["四角","方块","方塊","Cuadrado","Carré","Quadrat","Quadrato","Quadrado"],
+ "Hollow circle": ["中空の円","空心圆","空心圓","Círculo hueco","Cercle creux","Hohler Kreis","Cerchio vuoto","Círculo oco"],
+ "Double arrow": ["両端矢印","双向箭头","雙向箭頭","Flecha doble","Double flèche","Doppelpfeil","Freccia doppia","Seta dupla"],
+ "A solid arrow with a head at both ends": ["両端に矢じりのある塗りつぶし矢印","两端都有箭头的实心箭头","兩端都有箭頭的實心箭頭","Una flecha sólida con punta en ambos extremos","Une flèche pleine avec une pointe à chaque extrémité","Ein massiver Pfeil mit einer Spitze an beiden Enden","Una freccia piena con la punta a entrambe le estremità","Uma seta sólida com ponta em ambas as extremidades"],
+ "Curved connector": ["曲線コネクタ","曲线连接线","曲線連接線","Conector curvo","Connecteur courbe","Gebogener Verbinder","Connettore curvo","Conector curvo"],
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": ["2つの要素をつなぐ曲線 — 両端は要素に吸着して追従し、先端は曲線に沿います","两个元素之间的曲线 — 两端吸附并跟随移动,箭头沿曲线方向","兩個元素之間的曲線 — 兩端吸附並跟隨移動,箭頭沿曲線方向","Una línea curva entre dos elementos: los extremos se enganchan y se reajustan, y la punta sigue la curva","Une ligne courbe entre deux éléments — les extrémités s’accrochent et se replacent, la pointe suit la courbe","Eine gebogene Linie zwischen zwei Elementen — die Enden rasten ein und folgen mit, die Spitze folgt der Kurve","Una linea curva tra due elementi — le estremità si agganciano e si riposizionano, la punta segue la curva","Uma linha curva entre dois elementos — as extremidades encaixam e reposicionam-se, a ponta segue a curva"],
+ "Double-headed": ["両端に矢じり","双头","雙頭","Dos puntas","Deux pointes","Zwei Spitzen","Due punte","Duas pontas"],
}
diff --git a/slides/src/i18n/packs/ar.ts b/slides/src/i18n/packs/ar.ts
index 78987751..82fe39de 100644
--- a/slides/src/i18n/packs/ar.ts
+++ b/slides/src/i18n/packs/ar.ts
@@ -912,4 +912,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "استبدال الملف (الحجم الأصلي)…",
"Keep aspect ratio": "الحفاظ على نسبة الأبعاد",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "مفعّل: يحافظ تغيير الحجم على نسب الصورة (Shift يحرّرها لسحبة واحدة). معطّل: يتغير العرض والارتفاع باستقلال وتتمدد الصورة",
+ "Dot": "نقطة",
+ "Open arrow": "سهم مفتوح",
+ "Hollow triangle": "مثلث مجوّف",
+ "Diamond": "معيّن",
+ "Hollow diamond": "معيّن مجوّف",
+ "Square": "مربع",
+ "Hollow circle": "دائرة مجوّفة",
+ "Double arrow": "سهم مزدوج",
+ "A solid arrow with a head at both ends": "سهم مصمت برأس في كلا الطرفين",
+ "Curved connector": "موصّل منحنٍ",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "خط منحنٍ بين عنصرين — يلتصق الطرفان ويعاد توجيههما، ويتبع الرأس المنحنى",
+ "Double-headed": "برأسين",
}
diff --git a/slides/src/i18n/packs/bn.ts b/slides/src/i18n/packs/bn.ts
index 826c1bcf..47443f15 100644
--- a/slides/src/i18n/packs/bn.ts
+++ b/slides/src/i18n/packs/bn.ts
@@ -915,4 +915,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "ফাইল বদলান (মূল আকার)…",
"Keep aspect ratio": "অনুপাত বজায় রাখুন",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "চালু: আকার বদলালে ছবির অনুপাত বজায় থাকে (Shift এক টানের জন্য মুক্ত করে)। বন্ধ: প্রস্থ ও উচ্চতা আলাদাভাবে বদলায় এবং ছবি টেনে বড় হয়",
+ "Dot": "বিন্দু",
+ "Open arrow": "খোলা তীর",
+ "Hollow triangle": "ফাঁপা ত্রিভুজ",
+ "Diamond": "হীরক",
+ "Hollow diamond": "ফাঁপা হীরক",
+ "Square": "বর্গ",
+ "Hollow circle": "ফাঁপা বৃত্ত",
+ "Double arrow": "দ্বিমুখী তীর",
+ "A solid arrow with a head at both ends": "দুই প্রান্তেই মাথাসহ একটি ভরাট তীর",
+ "Curved connector": "বাঁকা সংযোজক",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "দুটি উপাদানের মধ্যে একটি বাঁকা রেখা — প্রান্তগুলো আটকে যায় ও পুনর্বিন্যস্ত হয়, মাথাটি বাঁক অনুসরণ করে",
+ "Double-headed": "দুই মাথা",
}
diff --git a/slides/src/i18n/packs/da.ts b/slides/src/i18n/packs/da.ts
index 3e04f8fc..112aa1a2 100644
--- a/slides/src/i18n/packs/da.ts
+++ b/slides/src/i18n/packs/da.ts
@@ -904,4 +904,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "Erstat fil (original størrelse)…",
"Keep aspect ratio": "Bevar størrelsesforhold",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Til: ændring af størrelse bevarer billedets proportioner (Skift frigiver dem for ét træk). Fra: bredde og højde ændres uafhængigt, og billedet strækkes",
+ "Dot": "Prik",
+ "Open arrow": "Åben pil",
+ "Hollow triangle": "Hul trekant",
+ "Diamond": "Rombe",
+ "Hollow diamond": "Hul rombe",
+ "Square": "Firkant",
+ "Hollow circle": "Hul cirkel",
+ "Double arrow": "Dobbeltpil",
+ "A solid arrow with a head at both ends": "En massiv pil med spids i begge ender",
+ "Curved connector": "Buet forbinder",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "En buet linje mellem to elementer — enderne snapper på og flytter med, spidsen følger kurven",
+ "Double-headed": "To spidser",
}
diff --git a/slides/src/i18n/packs/fa.ts b/slides/src/i18n/packs/fa.ts
index 634c93f5..8a5ff293 100644
--- a/slides/src/i18n/packs/fa.ts
+++ b/slides/src/i18n/packs/fa.ts
@@ -908,4 +908,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "جایگزینی پرونده (اندازهٔ اصلی)…",
"Keep aspect ratio": "حفظ نسبت ابعاد",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "روشن: تغییر اندازه نسبت تصویر را حفظ می‌کند (Shift آن را برای یک کشیدن آزاد می‌کند). خاموش: عرض و ارتفاع مستقل تغییر می‌کنند و تصویر کشیده می‌شود",
+ "Dot": "نقطه",
+ "Open arrow": "پیکان باز",
+ "Hollow triangle": "مثلث توخالی",
+ "Diamond": "لوزی",
+ "Hollow diamond": "لوزی توخالی",
+ "Square": "مربع",
+ "Hollow circle": "دایرهٔ توخالی",
+ "Double arrow": "پیکان دوسر",
+ "A solid arrow with a head at both ends": "پیکانی توپر با سر در هر دو انتها",
+ "Curved connector": "اتصال‌دهندهٔ منحنی",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "خطی منحنی بین دو عنصر — دو سر می‌چسبند و دوباره مسیر می‌گیرند، نوک در امتداد منحنی است",
+ "Double-headed": "دو سر",
}
diff --git a/slides/src/i18n/packs/fi.ts b/slides/src/i18n/packs/fi.ts
index 00f0e2f9..3648983d 100644
--- a/slides/src/i18n/packs/fi.ts
+++ b/slides/src/i18n/packs/fi.ts
@@ -909,4 +909,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "Korvaa tiedosto (alkuperäinen koko)…",
"Keep aspect ratio": "Säilytä kuvasuhde",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Päällä: koon muutos säilyttää kuvan mittasuhteet (Vaihto vapauttaa ne yhden vedon ajaksi). Pois: leveys ja korkeus muuttuvat erikseen ja kuva venyy",
+ "Dot": "Piste",
+ "Open arrow": "Avoin nuoli",
+ "Hollow triangle": "Ontto kolmio",
+ "Diamond": "Vinoneliö",
+ "Hollow diamond": "Ontto vinoneliö",
+ "Square": "Neliö",
+ "Hollow circle": "Ontto ympyrä",
+ "Double arrow": "Kaksipäinen nuoli",
+ "A solid arrow with a head at both ends": "Umpinainen nuoli, jossa kärki molemmissa päissä",
+ "Curved connector": "Kaareva yhdysviiva",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Kaareva viiva kahden elementin välillä — päät tarttuvat ja reitittyvät uudelleen, kärki seuraa kaarta",
+ "Double-headed": "Kaksipäinen",
}
diff --git a/slides/src/i18n/packs/fil.ts b/slides/src/i18n/packs/fil.ts
index ec3e9b36..ee5234e4 100644
--- a/slides/src/i18n/packs/fil.ts
+++ b/slides/src/i18n/packs/fil.ts
@@ -921,4 +921,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "Palitan ang file (orihinal na laki)…",
"Keep aspect ratio": "Panatilihin ang aspect ratio",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Naka-on: pinapanatili ng pag-resize ang proporsyon ng larawan (pinapalaya ito ng Shift sa isang drag). Naka-off: hiwalay na nagbabago ang lapad at taas at nababanat ang larawan",
+ "Dot": "Tuldok",
+ "Open arrow": "Bukas na arrow",
+ "Hollow triangle": "Guwang na tatsulok",
+ "Diamond": "Diyamante",
+ "Hollow diamond": "Guwang na diyamante",
+ "Square": "Parisukat",
+ "Hollow circle": "Guwang na bilog",
+ "Double arrow": "Dobleng arrow",
+ "A solid arrow with a head at both ends": "Solidong arrow na may ulo sa magkabilang dulo",
+ "Curved connector": "Kurbadong connector",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Kurbadong linya sa pagitan ng dalawang elemento — kumakapit at umaayos ang mga dulo, sumusunod sa kurba ang dulo",
+ "Double-headed": "Dalawang ulo",
}
diff --git a/slides/src/i18n/packs/he.ts b/slides/src/i18n/packs/he.ts
index f51bc632..f7de5eb9 100644
--- a/slides/src/i18n/packs/he.ts
+++ b/slides/src/i18n/packs/he.ts
@@ -905,4 +905,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "החלפת קובץ (גודל מקורי)…",
"Keep aspect ratio": "שמירה על יחס גובה-רוחב",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "פעיל: שינוי גודל שומר על הפרופורציות של התמונה (Shift משחרר אותן לגרירה אחת). כבוי: רוחב וגובה משתנים בנפרד והתמונה נמתחת",
+ "Dot": "נקודה",
+ "Open arrow": "חץ פתוח",
+ "Hollow triangle": "משולש חלול",
+ "Diamond": "מעוין",
+ "Hollow diamond": "מעוין חלול",
+ "Square": "ריבוע",
+ "Hollow circle": "עיגול חלול",
+ "Double arrow": "חץ כפול",
+ "A solid arrow with a head at both ends": "חץ מלא עם ראש בשני הקצוות",
+ "Curved connector": "מחבר מעוגל",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "קו מעוגל בין שני רכיבים — הקצוות נצמדים ומתעדכנים, והראש עוקב אחרי העקומה",
+ "Double-headed": "שני ראשים",
}
diff --git a/slides/src/i18n/packs/hi.ts b/slides/src/i18n/packs/hi.ts
index bceaee43..d146bca3 100644
--- a/slides/src/i18n/packs/hi.ts
+++ b/slides/src/i18n/packs/hi.ts
@@ -912,4 +912,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "फ़ाइल बदलें (मूल आकार)…",
"Keep aspect ratio": "अनुपात बनाए रखें",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "चालू: आकार बदलने पर छवि का अनुपात बना रहता है (Shift एक खिंचाव के लिए मुक्त करता है)। बंद: चौड़ाई और ऊँचाई अलग-अलग बदलती हैं और छवि खिंचती है",
+ "Dot": "बिंदु",
+ "Open arrow": "खुला तीर",
+ "Hollow triangle": "खोखला त्रिभुज",
+ "Diamond": "हीरा",
+ "Hollow diamond": "खोखला हीरा",
+ "Square": "वर्ग",
+ "Hollow circle": "खोखला वृत्त",
+ "Double arrow": "दोहरा तीर",
+ "A solid arrow with a head at both ends": "दोनों सिरों पर नोक वाला ठोस तीर",
+ "Curved connector": "घुमावदार कनेक्टर",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "दो तत्वों के बीच घुमावदार रेखा — सिरे चिपकते और फिर से जुड़ते हैं, नोक वक्र के साथ चलती है",
+ "Double-headed": "दो नोक",
}
diff --git a/slides/src/i18n/packs/id.ts b/slides/src/i18n/packs/id.ts
index aaa9be78..5dcf8cb3 100644
--- a/slides/src/i18n/packs/id.ts
+++ b/slides/src/i18n/packs/id.ts
@@ -902,4 +902,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "Ganti file (ukuran asli)…",
"Keep aspect ratio": "Pertahankan rasio aspek",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Aktif: mengubah ukuran mempertahankan proporsi gambar (Shift membebaskannya untuk satu seretan). Nonaktif: lebar dan tinggi berubah terpisah dan gambar meregang",
+ "Dot": "Titik",
+ "Open arrow": "Panah terbuka",
+ "Hollow triangle": "Segitiga berongga",
+ "Diamond": "Wajik",
+ "Hollow diamond": "Wajik berongga",
+ "Square": "Persegi",
+ "Hollow circle": "Lingkaran berongga",
+ "Double arrow": "Panah ganda",
+ "A solid arrow with a head at both ends": "Panah pejal dengan kepala di kedua ujung",
+ "Curved connector": "Penghubung melengkung",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Garis lengkung di antara dua elemen — ujungnya menempel dan menyesuaikan, kepalanya mengikuti lengkungan",
+ "Double-headed": "Dua kepala",
}
diff --git a/slides/src/i18n/packs/ko.ts b/slides/src/i18n/packs/ko.ts
index 0c3b2cc2..cc544766 100644
--- a/slides/src/i18n/packs/ko.ts
+++ b/slides/src/i18n/packs/ko.ts
@@ -896,4 +896,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "파일 바꾸기 (원본 크기)…",
"Keep aspect ratio": "가로세로 비율 유지",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "켜짐: 크기를 조절해도 이미지 비율이 유지됩니다 (Shift로 한 번의 드래그만 해제). 꺼짐: 너비와 높이가 따로 바뀌고 이미지가 늘어납니다",
+ "Dot": "점",
+ "Open arrow": "열린 화살표",
+ "Hollow triangle": "속 빈 삼각형",
+ "Diamond": "마름모",
+ "Hollow diamond": "속 빈 마름모",
+ "Square": "사각형",
+ "Hollow circle": "속 빈 원",
+ "Double arrow": "양방향 화살표",
+ "A solid arrow with a head at both ends": "양 끝에 머리가 있는 실선 화살표",
+ "Curved connector": "곡선 연결선",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "두 요소 사이의 곡선 — 양 끝이 붙어 따라 움직이고 화살촉은 곡선을 따릅니다",
+ "Double-headed": "양쪽 머리",
}
diff --git a/slides/src/i18n/packs/ms.ts b/slides/src/i18n/packs/ms.ts
index 798f0736..84083fe6 100644
--- a/slides/src/i18n/packs/ms.ts
+++ b/slides/src/i18n/packs/ms.ts
@@ -905,4 +905,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "Gantikan fail (saiz asal)…",
"Keep aspect ratio": "Kekalkan nisbah aspek",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Hidup: mengubah saiz mengekalkan kadaran imej (Shift membebaskannya untuk satu seretan). Mati: lebar dan tinggi berubah secara berasingan dan imej meregang",
+ "Dot": "Titik",
+ "Open arrow": "Anak panah terbuka",
+ "Hollow triangle": "Segi tiga berongga",
+ "Diamond": "Berlian",
+ "Hollow diamond": "Berlian berongga",
+ "Square": "Segi empat",
+ "Hollow circle": "Bulatan berongga",
+ "Double arrow": "Anak panah dua hala",
+ "A solid arrow with a head at both ends": "Anak panah pejal dengan kepala di kedua-dua hujung",
+ "Curved connector": "Penyambung melengkung",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Garis melengkung antara dua elemen — hujungnya melekat dan dilaraskan semula, hujung anak panah mengikut lengkung",
+ "Double-headed": "Dua kepala",
}
diff --git a/slides/src/i18n/packs/nb.ts b/slides/src/i18n/packs/nb.ts
index c7a100bd..2945e601 100644
--- a/slides/src/i18n/packs/nb.ts
+++ b/slides/src/i18n/packs/nb.ts
@@ -906,4 +906,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "Erstatt fil (original størrelse)…",
"Keep aspect ratio": "Behold størrelsesforhold",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "På: endring av størrelse beholder bildets proporsjoner (Skift frigjør dem for ett drag). Av: bredde og høyde endres uavhengig, og bildet strekkes",
+ "Dot": "Prikk",
+ "Open arrow": "Åpen pil",
+ "Hollow triangle": "Hul trekant",
+ "Diamond": "Rombe",
+ "Hollow diamond": "Hul rombe",
+ "Square": "Firkant",
+ "Hollow circle": "Hul sirkel",
+ "Double arrow": "Dobbeltpil",
+ "A solid arrow with a head at both ends": "En massiv pil med spiss i begge ender",
+ "Curved connector": "Buet kobling",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "En buet linje mellom to elementer — endene fester seg og flytter med, spissen følger kurven",
+ "Double-headed": "To spisser",
}
diff --git a/slides/src/i18n/packs/nl.ts b/slides/src/i18n/packs/nl.ts
index b5fa3140..4fb6a525 100644
--- a/slides/src/i18n/packs/nl.ts
+++ b/slides/src/i18n/packs/nl.ts
@@ -900,4 +900,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "Bestand vervangen (originele grootte)…",
"Keep aspect ratio": "Verhouding behouden",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Aan: bij het schalen blijven de verhoudingen van de afbeelding behouden (Shift geeft ze vrij voor één sleep). Uit: breedte en hoogte veranderen los van elkaar en de afbeelding rekt uit",
+ "Dot": "Punt",
+ "Open arrow": "Open pijl",
+ "Hollow triangle": "Holle driehoek",
+ "Diamond": "Ruit",
+ "Hollow diamond": "Holle ruit",
+ "Square": "Vierkant",
+ "Hollow circle": "Holle cirkel",
+ "Double arrow": "Dubbele pijl",
+ "A solid arrow with a head at both ends": "Een massieve pijl met een punt aan beide uiteinden",
+ "Curved connector": "Gebogen verbinder",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Een gebogen lijn tussen twee elementen — de uiteinden klikken vast en schuiven mee, de punt volgt de kromme",
+ "Double-headed": "Twee punten",
}
diff --git a/slides/src/i18n/packs/pl.ts b/slides/src/i18n/packs/pl.ts
index a0b98b65..ce73b9fb 100644
--- a/slides/src/i18n/packs/pl.ts
+++ b/slides/src/i18n/packs/pl.ts
@@ -903,4 +903,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "Zastąp plik (oryginalny rozmiar)…",
"Keep aspect ratio": "Zachowaj proporcje",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Włączone: zmiana rozmiaru zachowuje proporcje obrazu (Shift zwalnia je na jedno przeciągnięcie). Wyłączone: szerokość i wysokość zmieniają się niezależnie, a obraz się rozciąga",
+ "Dot": "Kropka",
+ "Open arrow": "Otwarta strzałka",
+ "Hollow triangle": "Pusty trójkąt",
+ "Diamond": "Romb",
+ "Hollow diamond": "Pusty romb",
+ "Square": "Kwadrat",
+ "Hollow circle": "Puste kółko",
+ "Double arrow": "Podwójna strzałka",
+ "A solid arrow with a head at both ends": "Pełna strzałka z grotem na obu końcach",
+ "Curved connector": "Łącznik krzywy",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Zakrzywiona linia między dwoma elementami — końce przyczepiają się i dopasowują, grot podąża za krzywą",
+ "Double-headed": "Dwa groty",
}
diff --git a/slides/src/i18n/packs/ru.ts b/slides/src/i18n/packs/ru.ts
index cde41bcf..dd96bd4c 100644
--- a/slides/src/i18n/packs/ru.ts
+++ b/slides/src/i18n/packs/ru.ts
@@ -904,4 +904,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "Заменить файл (исходный размер)…",
"Keep aspect ratio": "Сохранять пропорции",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Вкл.: изменение размера сохраняет пропорции изображения (Shift освобождает их на одно перетаскивание). Выкл.: ширина и высота меняются независимо, изображение растягивается",
+ "Dot": "Точка",
+ "Open arrow": "Открытая стрелка",
+ "Hollow triangle": "Пустой треугольник",
+ "Diamond": "Ромб",
+ "Hollow diamond": "Пустой ромб",
+ "Square": "Квадрат",
+ "Hollow circle": "Пустой круг",
+ "Double arrow": "Двойная стрелка",
+ "A solid arrow with a head at both ends": "Сплошная стрелка с наконечником на обоих концах",
+ "Curved connector": "Изогнутый соединитель",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Изогнутая линия между двумя элементами — концы прилипают и перестраиваются, наконечник идёт вдоль кривой",
+ "Double-headed": "Два наконечника",
}
diff --git a/slides/src/i18n/packs/sv.ts b/slides/src/i18n/packs/sv.ts
index a4dbb644..95e9efca 100644
--- a/slides/src/i18n/packs/sv.ts
+++ b/slides/src/i18n/packs/sv.ts
@@ -901,4 +901,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "Ersätt fil (originalstorlek)…",
"Keep aspect ratio": "Behåll proportioner",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "På: storleksändring behåller bildens proportioner (Skift frigör dem för ett drag). Av: bredd och höjd ändras oberoende och bilden töjs",
+ "Dot": "Punkt",
+ "Open arrow": "Öppen pil",
+ "Hollow triangle": "Ihålig triangel",
+ "Diamond": "Romb",
+ "Hollow diamond": "Ihålig romb",
+ "Square": "Kvadrat",
+ "Hollow circle": "Ihålig cirkel",
+ "Double arrow": "Dubbelpil",
+ "A solid arrow with a head at both ends": "En fylld pil med spets i båda ändar",
+ "Curved connector": "Böjd koppling",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "En böjd linje mellan två element — ändarna fäster och flyttar med, spetsen följer kurvan",
+ "Double-headed": "Två spetsar",
}
diff --git a/slides/src/i18n/packs/th.ts b/slides/src/i18n/packs/th.ts
index 1418c9bd..c64911e2 100644
--- a/slides/src/i18n/packs/th.ts
+++ b/slides/src/i18n/packs/th.ts
@@ -906,4 +906,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "แทนที่ไฟล์ (ขนาดเดิม)…",
"Keep aspect ratio": "คงอัตราส่วนภาพ",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "เปิด: การปรับขนาดคงสัดส่วนของภาพ (กด Shift เพื่อปลดชั่วคราวหนึ่งครั้ง) ปิด: ความกว้างและความสูงเปลี่ยนแยกกัน ภาพจะถูกยืด",
+ "Dot": "จุด",
+ "Open arrow": "ลูกศรเปิด",
+ "Hollow triangle": "สามเหลี่ยมกลวง",
+ "Diamond": "ข้าวหลามตัด",
+ "Hollow diamond": "ข้าวหลามตัดกลวง",
+ "Square": "สี่เหลี่ยม",
+ "Hollow circle": "วงกลมกลวง",
+ "Double arrow": "ลูกศรสองหัว",
+ "A solid arrow with a head at both ends": "ลูกศรทึบที่มีหัวทั้งสองด้าน",
+ "Curved connector": "เส้นเชื่อมโค้ง",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "เส้นโค้งระหว่างสององค์ประกอบ — ปลายเกาะติดและปรับตามเมื่อย้าย หัวลูกศรวิ่งตามเส้นโค้ง",
+ "Double-headed": "สองหัว",
}
diff --git a/slides/src/i18n/packs/tk.ts b/slides/src/i18n/packs/tk.ts
index 0b7c4f8f..94f9269d 100644
--- a/slides/src/i18n/packs/tk.ts
+++ b/slides/src/i18n/packs/tk.ts
@@ -929,4 +929,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "Faýly çalyş (asyl ölçegi)…",
"Keep aspect ratio": "Taraplaryň gatnaşygyny sakla",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Açyk: ölçeg üýtgedilende suratyň gatnaşygy saklanýar (Shift bir süýremek üçin boşadýar). Ýapyk: ini we beýikligi aýratyn üýtgeýär we surat çekilýär",
+ "Dot": "Nokat",
+ "Open arrow": "Açyk ok",
+ "Hollow triangle": "Boş üçburçluk",
+ "Diamond": "Romb",
+ "Hollow diamond": "Boş romb",
+ "Square": "Kwadrat",
+ "Hollow circle": "Boş tegelek",
+ "Double arrow": "Goşa ok",
+ "A solid arrow with a head at both ends": "Iki ujunda-da ujy bolan doly ok",
+ "Curved connector": "Egri birleşdiriji",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Iki elementiň arasyndaky egri çyzyk — uçlary ýapyşýar we täzeden ugrukdyrylýar, ujy egriniň yzyndan gidýär",
+ "Double-headed": "Iki uçly",
}
diff --git a/slides/src/i18n/packs/tr.ts b/slides/src/i18n/packs/tr.ts
index 937d7d71..bf89a11d 100644
--- a/slides/src/i18n/packs/tr.ts
+++ b/slides/src/i18n/packs/tr.ts
@@ -903,4 +903,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "Dosyayı değiştir (özgün boyut)…",
"Keep aspect ratio": "En-boy oranını koru",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Açık: yeniden boyutlandırma görselin oranını korur (Shift bir sürükleme için serbest bırakır). Kapalı: genişlik ve yükseklik bağımsız değişir ve görsel esner",
+ "Dot": "Nokta",
+ "Open arrow": "Açık ok",
+ "Hollow triangle": "İçi boş üçgen",
+ "Diamond": "Eşkenar dörtgen",
+ "Hollow diamond": "İçi boş eşkenar dörtgen",
+ "Square": "Kare",
+ "Hollow circle": "İçi boş daire",
+ "Double arrow": "Çift ok",
+ "A solid arrow with a head at both ends": "İki ucunda da başı olan dolu ok",
+ "Curved connector": "Eğri bağlayıcı",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "İki öğe arasında eğri bir çizgi — uçlar yapışır ve yeniden yönlenir, uç eğriyi izler",
+ "Double-headed": "Çift başlı",
}
diff --git a/slides/src/i18n/packs/uk.ts b/slides/src/i18n/packs/uk.ts
index d999f1fb..718834dd 100644
--- a/slides/src/i18n/packs/uk.ts
+++ b/slides/src/i18n/packs/uk.ts
@@ -912,4 +912,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "Замінити файл (початковий розмір)…",
"Keep aspect ratio": "Зберігати пропорції",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Увімк.: зміна розміру зберігає пропорції зображення (Shift звільняє їх на одне перетягування). Вимк.: ширина й висота змінюються незалежно, зображення розтягується",
+ "Dot": "Крапка",
+ "Open arrow": "Відкрита стрілка",
+ "Hollow triangle": "Порожній трикутник",
+ "Diamond": "Ромб",
+ "Hollow diamond": "Порожній ромб",
+ "Square": "Квадрат",
+ "Hollow circle": "Порожнє коло",
+ "Double arrow": "Подвійна стрілка",
+ "A solid arrow with a head at both ends": "Суцільна стрілка з вістрям на обох кінцях",
+ "Curved connector": "Вигнутий з’єднувач",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Вигнута лінія між двома елементами — кінці прилипають і перебудовуються, вістря йде вздовж кривої",
+ "Double-headed": "Два вістря",
}
diff --git a/slides/src/i18n/packs/ur.ts b/slides/src/i18n/packs/ur.ts
index c459bb70..b2165c4d 100644
--- a/slides/src/i18n/packs/ur.ts
+++ b/slides/src/i18n/packs/ur.ts
@@ -922,4 +922,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "فائل بدلیں (اصل سائز)…",
"Keep aspect ratio": "پہلو تناسب برقرار رکھیں",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "آن: سائز بدلنے پر تصویر کا تناسب برقرار رہتا ہے (Shift ایک ڈریگ کے لیے آزاد کرتا ہے)۔ آف: چوڑائی اور اونچائی الگ الگ بدلتی ہیں اور تصویر کھنچ جاتی ہے",
+ "Dot": "نقطہ",
+ "Open arrow": "کھلا تیر",
+ "Hollow triangle": "کھوکھلا مثلث",
+ "Diamond": "ہیرا",
+ "Hollow diamond": "کھوکھلا ہیرا",
+ "Square": "مربع",
+ "Hollow circle": "کھوکھلا دائرہ",
+ "Double arrow": "دوہرا تیر",
+ "A solid arrow with a head at both ends": "دونوں سروں پر نوک والا ٹھوس تیر",
+ "Curved connector": "خمدار کنیکٹر",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "دو عناصر کے درمیان خمدار لکیر — سرے چپکتے اور دوبارہ جڑتے ہیں، نوک خم کے ساتھ چلتی ہے",
+ "Double-headed": "دو نوک",
}
diff --git a/slides/src/i18n/packs/vi.ts b/slides/src/i18n/packs/vi.ts
index 328ea691..da19bfe9 100644
--- a/slides/src/i18n/packs/vi.ts
+++ b/slides/src/i18n/packs/vi.ts
@@ -902,4 +902,16 @@ export const strings: Catalog = {
"Replace file (original size)…": "Thay tệp (kích thước gốc)…",
"Keep aspect ratio": "Giữ tỷ lệ khung hình",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Bật: đổi kích thước giữ nguyên tỷ lệ ảnh (Shift bỏ giữ trong một lần kéo). Tắt: chiều rộng và chiều cao đổi độc lập và ảnh bị kéo giãn",
+ "Dot": "Chấm",
+ "Open arrow": "Mũi tên hở",
+ "Hollow triangle": "Tam giác rỗng",
+ "Diamond": "Hình thoi",
+ "Hollow diamond": "Hình thoi rỗng",
+ "Square": "Hình vuông",
+ "Hollow circle": "Hình tròn rỗng",
+ "Double arrow": "Mũi tên hai đầu",
+ "A solid arrow with a head at both ends": "Mũi tên đặc có đầu ở cả hai phía",
+ "Curved connector": "Đường nối cong",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Đường cong giữa hai phần tử — hai đầu bám vào và tự chỉnh lại, đầu mũi tên đi theo đường cong",
+ "Double-headed": "Hai đầu",
}
diff --git a/slides/src/i18n/pt.ts b/slides/src/i18n/pt.ts
index 62b1493d..345716d6 100644
--- a/slides/src/i18n/pt.ts
+++ b/slides/src/i18n/pt.ts
@@ -890,4 +890,16 @@ export const pt: Catalog = {
"Replace file (original size)…": "Substituir ficheiro (tamanho original)…",
"Keep aspect ratio": "Manter proporções",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "Ligado: redimensionar mantém as proporções da imagem (Shift liberta-as durante um arrasto). Desligado: largura e altura mudam separadamente e a imagem estica",
+ "Dot": "Ponto",
+ "Open arrow": "Seta aberta",
+ "Hollow triangle": "Triângulo oco",
+ "Diamond": "Losango",
+ "Hollow diamond": "Losango oco",
+ "Square": "Quadrado",
+ "Hollow circle": "Círculo oco",
+ "Double arrow": "Seta dupla",
+ "A solid arrow with a head at both ends": "Uma seta sólida com ponta em ambas as extremidades",
+ "Curved connector": "Conector curvo",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "Uma linha curva entre dois elementos — as extremidades encaixam e reposicionam-se, a ponta segue a curva",
+ "Double-headed": "Duas pontas",
}
diff --git a/slides/src/i18n/zh-Hans.ts b/slides/src/i18n/zh-Hans.ts
index 0ed5a382..cd4eb221 100644
--- a/slides/src/i18n/zh-Hans.ts
+++ b/slides/src/i18n/zh-Hans.ts
@@ -892,4 +892,16 @@ export const zhHans: Catalog = {
"Replace file (original size)…": "替换文件(原始尺寸)…",
"Keep aspect ratio": "保持宽高比",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "开:调整大小时保持图片比例(按住 Shift 可临时解除一次拖动)。关:宽和高各自变化,图片会被拉伸",
+ "Dot": "圆点",
+ "Open arrow": "开放箭头",
+ "Hollow triangle": "空心三角",
+ "Diamond": "菱形",
+ "Hollow diamond": "空心菱形",
+ "Square": "方块",
+ "Hollow circle": "空心圆",
+ "Double arrow": "双向箭头",
+ "A solid arrow with a head at both ends": "两端都有箭头的实心箭头",
+ "Curved connector": "曲线连接线",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "两个元素之间的曲线 — 两端吸附并跟随移动,箭头沿曲线方向",
+ "Double-headed": "双头",
}
diff --git a/slides/src/i18n/zh-Hant.ts b/slides/src/i18n/zh-Hant.ts
index 18b1c346..6241c0b5 100644
--- a/slides/src/i18n/zh-Hant.ts
+++ b/slides/src/i18n/zh-Hant.ts
@@ -892,4 +892,16 @@ export const zhHant: Catalog = {
"Replace file (original size)…": "取代檔案(原始尺寸)…",
"Keep aspect ratio": "保持長寬比",
"On: a resize keeps the image’s proportions (Shift frees it for one drag). Off: width and height move independently and the image stretches": "開:調整大小時保持圖片比例(按住 Shift 可暫時解除一次拖曳)。關:寬和高各自變化,圖片會被拉伸",
+ "Dot": "圓點",
+ "Open arrow": "開放箭頭",
+ "Hollow triangle": "空心三角",
+ "Diamond": "菱形",
+ "Hollow diamond": "空心菱形",
+ "Square": "方塊",
+ "Hollow circle": "空心圓",
+ "Double arrow": "雙向箭頭",
+ "A solid arrow with a head at both ends": "兩端都有箭頭的實心箭頭",
+ "Curved connector": "曲線連接線",
+ "A curved line between two elements — the ends snap on and re-route, the tip follows the curve": "兩個元素之間的曲線 — 兩端吸附並跟隨移動,箭頭沿曲線方向",
+ "Double-headed": "雙頭",
}
diff --git a/slides/src/icons.ts b/slides/src/icons.ts
index 4524694c..1cfdddef 100644
--- a/slides/src/icons.ts
+++ b/slides/src/icons.ts
@@ -30,6 +30,7 @@ export const ICONS = {
presenter: svg('<rect x="3" y="4" width="18" height="14" rx="2"/><line x1="14" y1="4" x2="14" y2="18"/><line x1="16.5" y1="8" x2="18.5" y2="8"/><line x1="16.5" y1="11" x2="18.5" y2="11"/><line x1="16.5" y1="14" x2="18" y2="14"/><line x1="9" y1="21" x2="15" y2="21"/>'),
curve: svg('<path d="M3 18 C 7 6, 17 6, 21 18"/>'),
connector: svg('<circle cx="5" cy="19" r="2.4"/><circle cx="19" cy="5" r="2.4"/><path d="M7 17 L 17 7"/>'),
+ curveConnector: svg('<circle cx="5" cy="19" r="2.4"/><circle cx="19" cy="5" r="2.4"/><path d="M7 17 C 9 9, 11 7, 17 7"/>'),
freeform: svg('<path d="M3 17 C 6 7, 9 21, 12 12 S 18 4, 21 9"/>'),
polygon: svg('<polygon points="12 3 21 10 17 20 7 20 3 10"/>'),
slideshow: svg('<rect x="3" y="4" width="18" height="12" rx="2"/><polygon points="10 7.5 15 10 10 12.5" fill="currentColor" stroke="none"/><line x1="12" y1="16" x2="12" y2="20"/><line x1="8" y1="20" x2="16" y2="20"/>'),
@@ -51,6 +52,7 @@ export const ICONS = {
ellipse: svg('<ellipse cx="12" cy="12" rx="9" ry="7"/>'),
triangle: svg('<path d="M12 4 21 20H3z"/>'),
arrow: svg('<line x1="3" y1="12" x2="19" y2="12"/><polyline points="13 6 19 12 13 18"/>'),
+ arrow2: svg('<line x1="5" y1="12" x2="19" y2="12"/><polyline points="13 6 19 12 13 18"/><polyline points="11 6 5 12 11 18"/>'),
line: svg('<line x1="4" y1="19" x2="20" y2="5"/>'),
} as const
diff --git a/slides/src/model.ts b/slides/src/model.ts
index 36b52381..e9c1789e 100644
--- a/slides/src/model.ts
+++ b/slides/src/model.ts
@@ -200,8 +200,11 @@ export interface GradientFill {
stops: Array<{ at: number; color: string }>
}
-/** Decoration at a line's tip. Sized relative to the stroke width. */
-export type LineEnding = 'none' | 'arrow' | 'dot' | 'bar'
+/** Decoration at a line's tip. Sized relative to the stroke width. The
+ * catalogue — geometry, insets, panel labels — is slides/src/tips.ts; the
+ * seven kinds after `bar` arrived in 1.1.1 (#303) and are additive: an older
+ * shell that does not know one draws that end plain. */
+export type LineEnding = 'none' | 'arrow' | 'dot' | 'bar' | 'arrow-open' | 'triangle' | 'triangle-open' | 'diamond' | 'diamond-open' | 'square' | 'circle-open'
export interface ShapeElement extends ElementBase {
type: 'shape'
@@ -213,11 +216,18 @@ export interface ShapeElement extends ElementBase {
strokeWidth: number
/** corner radius, rect only */
radius: number
+ /** arrow only (v1.1.1, #304): 2 = a head at both ends. Absent = one head.
+ * A property, not a shape kind, on purpose: a shipped shell's renderer
+ * switches on `shape` with no default and would throw on a kind it does
+ * not know — an unknown property it simply ignores, so 1.1.0 draws the
+ * single arrow instead of failing the slide. */
+ heads?: 2
/** dash length in px; 0/undefined = solid stroke (legacy — see strokeStyle) */
strokeDash?: number
/** stroke pattern; wins over strokeDash when set */
strokeStyle?: 'solid' | 'dashed' | 'dotted'
- /** line shape only: tip decorations */
+ /** line and (v1.1.1, #302) open path shapes: tip decorations. On a path
+ * the tip points along the curve's end tangent. */
lineStart?: LineEnding
lineEnd?: LineEnding
/** path only: SVG path data in the coordinate space given by pathBox */
diff --git a/slides/src/modelkeys.generated.ts b/slides/src/modelkeys.generated.ts
index a3a4ec1b..81194ceb 100644
--- a/slides/src/modelkeys.generated.ts
+++ b/slides/src/modelkeys.generated.ts
@@ -15,7 +15,7 @@ export const MODEL_KEYS = {
"comment": ["at", "author", "elementId", "id", "replies", "resolved", "text", "x", "y"],
"element": {
"text": ["align", "backdropFilter", "blend", "blur", "color", "colorGradient", "fontFamily", "fontSize", "fontWeight", "fx", "group", "groupId", "h", "html", "id", "letterSpacing", "lineHeight", "link", "morphId", "opacity", "placeholder", "role", "rotation", "shadow", "showOnHover", "textStroke", "themeRefs", "type", "valign", "w", "x", "y"],
- "shape": ["backdropFilter", "blend", "blur", "d", "fill", "fillGradient", "from", "fx", "group", "groupId", "h", "id", "lineEnd", "lineStart", "link", "morphId", "opacity", "pathBox", "radius", "role", "rotation", "shadow", "shape", "showOnHover", "stroke", "strokeDash", "strokeStyle", "strokeWidth", "themeRefs", "to", "type", "w", "x", "y"],
+ "shape": ["backdropFilter", "blend", "blur", "d", "fill", "fillGradient", "from", "fx", "group", "groupId", "h", "heads", "id", "lineEnd", "lineStart", "link", "morphId", "opacity", "pathBox", "radius", "role", "rotation", "shadow", "shape", "showOnHover", "stroke", "strokeDash", "strokeStyle", "strokeWidth", "themeRefs", "to", "type", "w", "x", "y"],
"image": ["backdropFilter", "blend", "blur", "crop", "fit", "fx", "group", "groupId", "h", "id", "keepAspectRatio", "link", "morphId", "opacity", "radius", "role", "rotation", "shadow", "showOnHover", "src", "themeRefs", "type", "w", "x", "y"],
"svg": ["asset", "backdropFilter", "blend", "blur", "css", "fx", "group", "groupId", "h", "id", "link", "markup", "morphId", "opacity", "role", "rotation", "shadow", "showOnHover", "themeRefs", "type", "w", "x", "y"],
"chart": ["backdropFilter", "blend", "blur", "fx", "group", "groupId", "h", "id", "link", "morphId", "opacity", "option", "preset", "role", "rotation", "shadow", "showOnHover", "source", "themeRefs", "type", "w", "x", "y"],
diff --git a/slides/src/render.ts b/slides/src/render.ts
index 31e73cdd..182e368f 100644
--- a/slides/src/render.ts
+++ b/slides/src/render.ts
@@ -9,6 +9,7 @@ import { morphKey, paginates, isWebUrl } from './model'
import { chartSnapshotSvg } from './charts'
import temml from 'temml'
import { renderCodeInto } from './code'
+import { tipSpec, tipInsetPx, shortenPathEnds } from './tips'
import { formatDate } from './datefmt'
import { cropImgStyle, isIdentityCrop } from './crop'
@@ -300,37 +301,46 @@ function dashArray(el: ShapeElement, w: number): string | undefined {
let markSeq = 0
-/** A line-tip marker in <defs>; sized in strokeWidth units, colored like the line. */
+/** A line-tip marker in <defs>; sized in strokeWidth units, colored like the
+ * line. Geometry comes from tips.ts — one catalogue for every tip. A hollow
+ * tip is an outline in the line colour with an open interior. */
function markerRef(svg: SVGSVGElement, kind: NonNullable<ShapeElement['lineStart']>, color: string, start: boolean): string | null {
- if (kind === 'none') return null
+ const spec = tipSpec(kind)
+ if (!spec) return null
const id = `bento-mark-${markSeq++}`
const marker = document.createElementNS(SVG_NS, 'marker')
marker.setAttribute('id', id)
marker.setAttribute('viewBox', '0 0 8 8')
+ marker.setAttribute('refX', String(spec.refX))
marker.setAttribute('refY', '4')
marker.setAttribute('orient', start ? 'auto-start-reverse' : 'auto')
- marker.setAttribute('markerWidth', '5.5')
- marker.setAttribute('markerHeight', '5.5')
+ marker.setAttribute('markerWidth', String(spec.size))
+ marker.setAttribute('markerHeight', String(spec.size))
+ const g = spec.geom
let tip: SVGElement
- if (kind === 'arrow') {
+ if (g.tag === 'path') {
tip = document.createElementNS(SVG_NS, 'path')
- tip.setAttribute('d', 'M 0 0.4 L 7.6 4 L 0 7.6 Z')
- marker.setAttribute('refX', '6.4')
- } else if (kind === 'dot') {
+ tip.setAttribute('d', g.d)
+ } else if (g.tag === 'circle') {
tip = document.createElementNS(SVG_NS, 'circle')
- tip.setAttribute('cx', '4')
- tip.setAttribute('cy', '4')
- tip.setAttribute('r', '2.6')
- marker.setAttribute('refX', '4')
+ tip.setAttribute('cx', String(g.cx))
+ tip.setAttribute('cy', String(g.cy))
+ tip.setAttribute('r', String(g.r))
} else {
tip = document.createElementNS(SVG_NS, 'rect')
- tip.setAttribute('x', '3.2')
- tip.setAttribute('y', '0.4')
- tip.setAttribute('width', '1.6')
- tip.setAttribute('height', '7.2')
- marker.setAttribute('refX', '4')
+ tip.setAttribute('x', String(g.x))
+ tip.setAttribute('y', String(g.y))
+ tip.setAttribute('width', String(g.w))
+ tip.setAttribute('height', String(g.h))
+ }
+ if (spec.hollow) {
+ tip.setAttribute('fill', 'none')
+ tip.setAttribute('stroke', color)
+ tip.setAttribute('stroke-width', '1.1')
+ tip.setAttribute('stroke-linejoin', 'round')
+ } else {
+ tip.setAttribute('fill', color)
}
- tip.setAttribute('fill', color)
marker.appendChild(tip)
let defs = svg.querySelector('defs')
if (!defs) {
@@ -356,7 +366,26 @@ export function shapeSvg(el: ShapeElement): SVGSVGElement {
// arbitrary vector data, stretched from its authored viewBox into the box
if (el.pathBox) svg.setAttribute('viewBox', el.pathBox.join(' '))
node = document.createElementNS(SVG_NS, 'path')
- node.setAttribute('d', el.d ?? '')
+ let d = el.d ?? ''
+ // Tips on a curve (#302): SVG orients a marker along the path's own end
+ // tangent, so the head points the way the curve arrives. The endpoint is
+ // pulled back along that tangent by the tip's inset (tips.ts) so the
+ // point lands on the model's endpoint and a hollow head has no stroke
+ // inside it. Insets are in slide px; the path is in pathBox units, so
+ // divide by the box→slide scale (uniform for anything the editor draws —
+ // a connector is renormalised on every re-route).
+ if ((el.lineStart || el.lineEnd) && sw > 0 && !/z\s*$/i.test(d)) {
+ const [, , pw, ph] = el.pathBox ?? [0, 0, w, h]
+ const k = ((w / (pw || 1)) + (h / (ph || 1))) / 2 || 1
+ d = shortenPathEnds(d, tipInsetPx(el.lineStart, sw) / k, tipInsetPx(el.lineEnd, sw) / k)
+ const color = el.stroke && el.stroke !== 'transparent' ? el.stroke : el.fill
+ const mStart = el.lineStart ? markerRef(svg, el.lineStart, color, true) : null
+ const mEnd = el.lineEnd ? markerRef(svg, el.lineEnd, color, false) : null
+ if (mStart) node.setAttribute('marker-start', mStart)
+ if (mEnd) node.setAttribute('marker-end', mEnd)
+ if (tipSpec(el.lineStart)?.hollow || tipSpec(el.lineEnd)?.hollow) node.setAttribute('stroke-linecap', 'butt')
+ }
+ node.setAttribute('d', d)
if (sw > 0) node.setAttribute('vector-effect', 'non-scaling-stroke')
break
}
@@ -386,8 +415,21 @@ export function shapeSvg(el: ShapeElement): SVGSVGElement {
// right-pointing arrow: shaft + head, proportional to the box
node = document.createElementNS(SVG_NS, 'polygon')
const shaftH = h * 0.44
- const headW = Math.min(w * 0.38, h)
const y0 = (h - shaftH) / 2
+ if (el.heads === 2) {
+ // a head at BOTH ends (#304): the same head, mirrored, symmetric about
+ // the box centre. Still `shape: 'arrow'` — a shell that predates
+ // `heads` draws the single arrow. Morph: the polygon's points are not
+ // tweened (no shape geometry is); a one-head ↔ two-head morph tweens
+ // the box and fill and the point list snaps at the swap.
+ const headW = Math.min(w * 0.3, h)
+ node.setAttribute(
+ 'points',
+ `0,${h / 2} ${headW},0 ${headW},${y0} ${w - headW},${y0} ${w - headW},0 ${w},${h / 2} ${w - headW},${h} ${w - headW},${y0 + shaftH} ${headW},${y0 + shaftH} ${headW},${h}`,
+ )
+ break
+ }
+ const headW = Math.min(w * 0.38, h)
node.setAttribute(
'points',
`0,${y0} ${w - headW},${y0} ${w - headW},0 ${w},${h / 2} ${w - headW},${h} ${w - headW},${y0 + shaftH} 0,${y0 + shaftH}`,
@@ -397,15 +439,16 @@ export function shapeSvg(el: ShapeElement): SVGSVGElement {
case 'line': {
node = document.createElementNS(SVG_NS, 'line')
const lw = Math.max(sw, 2)
- // inset the endpoints so tip decorations sit inside the element box
- const tipPad = (k?: string) => (k && k !== 'none' ? lw * 2.6 : 0)
- node.setAttribute('x1', String(tipPad(el.lineStart)))
+ // inset the endpoints so the tip's point lands on the box edge (tips.ts:
+ // the three original kinds keep their 2.6 — every old deck unchanged)
+ node.setAttribute('x1', String(tipInsetPx(el.lineStart, lw)))
node.setAttribute('y1', String(h / 2))
- node.setAttribute('x2', String(w - tipPad(el.lineEnd)))
+ node.setAttribute('x2', String(w - tipInsetPx(el.lineEnd, lw)))
node.setAttribute('y2', String(h / 2))
node.setAttribute('stroke', el.fill)
node.setAttribute('stroke-width', String(lw))
- node.setAttribute('stroke-linecap', el.strokeStyle === 'dashed' ? 'butt' : 'round')
+ const hollow = tipSpec(el.lineStart)?.hollow || tipSpec(el.lineEnd)?.hollow
+ node.setAttribute('stroke-linecap', el.strokeStyle === 'dashed' || hollow ? 'butt' : 'round')
const lineDash = dashArray(el, lw)
if (lineDash) node.setAttribute('stroke-dasharray', lineDash)
const mStart = el.lineStart ? markerRef(svg, el.lineStart, el.fill, true) : null
diff --git a/slides/src/tips.ts b/slides/src/tips.ts
new file mode 100644
index 00000000..4d6e4c09
--- /dev/null
+++ b/slides/src/tips.ts
@@ -0,0 +1,162 @@
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+/**
+ * Line tips — the ONE catalogue behind `lineStart`/`lineEnd` (discussion
+ * #303): the model's allowed values, the shape gate, the panel's options and
+ * the renderer's marker geometry all read this list, so a tip cannot exist in
+ * one place and not another.
+ *
+ * Geometry lives in an 8×8 marker frame, the line arriving from the left and
+ * the tip pointing +x. `size` is the marker's width in STROKE units (SVG
+ * `markerUnits="strokeWidth"`), `refX` the frame x that sits on the line's
+ * end, `tipX` where the point is. A hollow tip needs the line to STOP at the
+ * head's back edge — otherwise the stroke shows through the hollow — so the
+ * renderer insets the endpoint by `inset` stroke units, which for the new
+ * kinds is exactly the distance from the line end to the point. The three
+ * original kinds keep their historic numbers (2.6 inset, refX inside the
+ * head) so every existing deck renders byte-identically.
+ *
+ * DEGRADE, stated plainly: in 1.1.0 and older the renderer matches only
+ * 'arrow' and 'dot' and draws a BAR for anything else — so a deck carrying
+ * one of the seven newer tips shows a bar at that end in those shells, not a
+ * plain end. Nothing throws; the deck opens.
+ *
+ * Also here, because a curved connector needs it (#302): the END TANGENT of
+ * a cubic path, so a tip on a curve points along the curve and the endpoint
+ * is inset along it, not along the chord.
+ */
+
+import { parseBezier, serializeBezier, type BezNode, type Pt } from './editor/bezier'
+
+export type TipKind = 'none' | 'arrow' | 'dot' | 'bar' | 'arrow-open' | 'triangle' | 'triangle-open' | 'diamond' | 'diamond-open' | 'square' | 'circle-open'
+
+export interface TipSpec {
+ kind: TipKind
+ /** panel label, English key for t() */
+ label: string
+ /** marker width in stroke units */
+ size: number
+ refX: number
+ tipX: number
+ /** 'path' | 'circle' | 'rect' + geometry in the 8×8 frame */
+ geom: { tag: 'path'; d: string } | { tag: 'circle'; cx: number; cy: number; r: number } | { tag: 'rect'; x: number; y: number; w: number; h: number }
+ /** drawn as an outline in the line's colour, interior left open */
+ hollow?: boolean
+ /** endpoint inset in stroke units; legacy kinds pin 2.6 */
+ inset: number
+}
+
+const geometric = (tipX: number, refX: number, size: number) => Math.round(((tipX - refX) * size / 8) * 100) / 100
+
+export const TIPS: ReadonlyArray<TipSpec> = [
+ { kind: 'none', label: 'none', size: 0, refX: 0, tipX: 0, geom: { tag: 'path', d: '' }, inset: 0 },
+ // the original three — numbers unchanged since 1.0.2
+ { kind: 'arrow', label: 'Arrow', size: 5.5, refX: 6.4, tipX: 7.6, geom: { tag: 'path', d: 'M 0 0.4 L 7.6 4 L 0 7.6 Z' }, inset: 2.6 },
+ { kind: 'dot', label: 'Dot', size: 5.5, refX: 4, tipX: 6.6, geom: { tag: 'circle', cx: 4, cy: 4, r: 2.6 }, inset: 2.6 },
+ { kind: 'bar', label: 'Bar', size: 5.5, refX: 4, tipX: 4.8, geom: { tag: 'rect', x: 3.2, y: 0.4, w: 1.6, h: 7.2 }, inset: 2.6 },
+ // #303
+ { kind: 'arrow-open', label: 'Open arrow', size: 5.5, refX: 7.2, tipX: 7.6, geom: { tag: 'path', d: 'M 0.4 0.4 L 7.6 4 L 0.4 7.6' }, hollow: true, inset: geometric(7.6, 7.2, 5.5) },
+ { kind: 'triangle', label: 'Triangle', size: 7.5, refX: 0.4, tipX: 7.6, geom: { tag: 'path', d: 'M 0.4 0.4 L 7.6 4 L 0.4 7.6 Z' }, inset: geometric(7.6, 0.4, 7.5) },
+ { kind: 'triangle-open', label: 'Hollow triangle', size: 7.5, refX: 0.4, tipX: 7.6, geom: { tag: 'path', d: 'M 0.4 0.4 L 7.6 4 L 0.4 7.6 Z' }, hollow: true, inset: geometric(7.6, 0.4, 7.5) },
+ { kind: 'diamond', label: 'Diamond', size: 6.5, refX: 0.4, tipX: 7.6, geom: { tag: 'path', d: 'M 0.4 4 L 4 0.8 L 7.6 4 L 4 7.2 Z' }, inset: geometric(7.6, 0.4, 6.5) },
+ { kind: 'diamond-open', label: 'Hollow diamond', size: 6.5, refX: 0.4, tipX: 7.6, geom: { tag: 'path', d: 'M 0.4 4 L 4 0.8 L 7.6 4 L 4 7.2 Z' }, hollow: true, inset: geometric(7.6, 0.4, 6.5) },
+ { kind: 'square', label: 'Square', size: 5.5, refX: 1.2, tipX: 7.6, geom: { tag: 'rect', x: 1.2, y: 0.8, w: 6.4, h: 6.4 }, inset: geometric(7.6, 1.2, 5.5) },
+ { kind: 'circle-open', label: 'Hollow circle', size: 5.5, refX: 0.8, tipX: 7.2, geom: { tag: 'circle', cx: 4, cy: 4, r: 3.2 }, hollow: true, inset: geometric(7.2, 0.8, 5.5) },
+]
+
+export const TIP_KINDS: ReadonlyArray<TipKind> = TIPS.map((t) => t.kind)
+
+export const tipSpec = (kind: string | undefined): TipSpec | undefined =>
+ kind && kind !== 'none' ? TIPS.find((t) => t.kind === kind) : undefined
+
+/** Endpoint inset for a tip, in px, given the drawn stroke width. */
+export const tipInsetPx = (kind: string | undefined, strokePx: number): number => (tipSpec(kind)?.inset ?? 0) * strokePx
+
+/** Unit tangent at a path's start or end: from the end node's own handle,
+ * else the neighbour's handle, else the chord — so a degenerate (zero
+ * length) handle never yields a zero vector. `null` for fewer than 2 nodes. */
+export function endTangent(nodes: ReadonlyArray<BezNode>, atEnd: boolean): Pt | null {
+ if (nodes.length < 2) return null
+ const a = atEnd ? nodes[nodes.length - 2] : nodes[1]
+ const b = atEnd ? nodes[nodes.length - 1] : nodes[0]
+ // direction pointing OUT of the path at that end
+ const candidates: Array<[Pt, Pt]> = atEnd
+ ? [[b.in ?? b.p, b.p], [a.out ?? a.p, b.p], [a.p, b.p]]
+ : [[b.out ?? b.p, b.p], [a.in ?? a.p, b.p], [a.p, b.p]]
+ for (const [from, to] of candidates) {
+ const dx = to.x - from.x
+ const dy = to.y - from.y
+ const len = Math.hypot(dx, dy)
+ if (len > 1e-6) return { x: dx / len, y: dy / len }
+ }
+ return null
+}
+
+/** The path `d` with each tipped end pulled back along its tangent by the
+ * given amounts (path units), so a marker's point lands where the model's
+ * endpoint is and a hollow head has no stroke inside it. Interior nodes are
+ * untouched; the end node's handle moves with it so the curve keeps its
+ * arrival direction. */
+export function shortenPathEnds(d: string, startBy: number, endBy: number): string {
+ if (!(startBy > 0) && !(endBy > 0)) return d
+ const { nodes, closed } = parseBezier(d)
+ if (closed || nodes.length < 2) return d
+ const pull = (i: number, by: number, atEnd: boolean) => {
+ const t = endTangent(nodes, atEnd)
+ if (!t || !(by > 0)) return
+ const n = nodes[i]
+ const dx = -t.x * by
+ const dy = -t.y * by
+ const h = atEnd ? n.in : n.out
+ nodes[i] = { ...n, p: { x: n.p.x + dx, y: n.p.y + dy }, ...(h ? (atEnd ? { in: { x: h.x + dx, y: h.y + dy } } : { out: { x: h.x + dx, y: h.y + dy } }) : {}) }
+ }
+ pull(0, startBy, false)
+ pull(nodes.length - 1, endBy, true)
+ return serializeBezier(nodes, false)
+}
+
+/**
+ * Move a path's first and/or last on-curve point (path units) for connector
+ * re-routing (#302). The moved node's handle is recomputed the auto way —
+ * one sixth of the way toward its neighbour, the Catmull-Rom end rule the
+ * curve editor uses for untouched nodes — so the curve leaves the new anchor
+ * smoothly; the neighbour's facing handle is recomputed only if it was auto
+ * itself (matched the rule before the move), so a hand-shaped interior point
+ * keeps its tangents. Every other node is returned byte-identical.
+ */
+export function movePathEnds(d: string, start: Pt | null, end: Pt | null): string {
+ const { nodes, closed } = parseBezier(d)
+ if (closed || nodes.length < 2 || (!start && !end)) return d
+ const sixth = (from: Pt, to: Pt): Pt => ({ x: from.x + (to.x - from.x) / 6, y: from.y + (to.y - from.y) / 6 })
+ const near = (a: Pt | undefined, b: Pt) => !!a && Math.abs(a.x - b.x) < 0.02 && Math.abs(a.y - b.y) < 0.02
+ const catmullIn = (i: number): Pt => {
+ // Catmull-Rom incoming handle at node i (P(i) - (P(i+1) - P(i-1)) / 6)
+ const P = (k: number) => nodes[Math.max(0, Math.min(nodes.length - 1, k))].p
+ return { x: P(i).x - (P(i + 1).x - P(i - 1).x) / 6, y: P(i).y - (P(i + 1).y - P(i - 1).y) / 6 }
+ }
+ const catmullOut = (i: number): Pt => {
+ const P = (k: number) => nodes[Math.max(0, Math.min(nodes.length - 1, k))].p
+ return { x: P(i).x + (P(i + 1).x - P(i - 1).x) / 6, y: P(i).y + (P(i + 1).y - P(i - 1).y) / 6 }
+ }
+ if (start) {
+ const nb = nodes[1]
+ const nbWasAuto = near(nb.in, catmullIn(1))
+ nodes[0] = { p: start, out: sixth(start, nb.p) }
+ if (nbWasAuto) nodes[1] = { ...nb, in: catmullIn(1) }
+ }
+ if (end) {
+ const last = nodes.length - 1
+ const nb = nodes[last - 1]
+ const nbWasAuto = near(nb.out, catmullOut(last - 1))
+ nodes[last] = { p: end, in: sixth(end, nb.p) }
+ if (nbWasAuto) nodes[last - 1] = { ...nb, out: catmullOut(last - 1) }
+ }
+ return serializeBezier(nodes, false)
+}
+
+/** First and last on-curve points of a path (path units). */
+export function pathEnds(d: string): [Pt, Pt] | null {
+ const { nodes } = parseBezier(d)
+ if (nodes.length < 2) return null
+ return [nodes[0].p, nodes[nodes.length - 1].p]
+}
diff --git a/slides/src/untrusted.ts b/slides/src/untrusted.ts
index 8734bc21..91b6ce0a 100644
--- a/slides/src/untrusted.ts
+++ b/slides/src/untrusted.ts
@@ -44,6 +44,7 @@ import type { Slide, SlideElement } from './model'
import { isWebUrl } from './model'
import { parseThemeRef } from './palette.ts'
import { MODEL_KEYS } from './modelkeys.generated'
+import { TIP_KINDS } from './tips'
/** Reject. JSON has no `undefined`, so it can never collide with a real value. */
const DROP = undefined
@@ -405,10 +406,12 @@ const ELEMENT_CHECKS: Record<string, Check> = {
}, ['width', 'color']),
// shape
shape: oneOf('rect', 'ellipse', 'triangle', 'arrow', 'line', 'path'),
+ heads: num(2, 2),
fill: paint, fillGradient: gradient, stroke: paint,
strokeWidth: num(0, 1e4), strokeDash: num(0, 1e4),
strokeStyle: oneOf('solid', 'dashed', 'dotted'),
- lineStart: oneOf('none', 'arrow', 'dot', 'bar'), lineEnd: oneOf('none', 'arrow', 'dot', 'bar'),
+ // the tip list is tips.ts's — one catalogue for the gate, the panel and the renderer
+ lineStart: oneOf(...TIP_KINDS), lineEnd: oneOf(...TIP_KINDS),
radius: num(0, 1e5), d: pathData,
pathBox: (v) => (Array.isArray(v) && v.length === 4 ? list(4, num(-1e6, 1e6))(v) : DROP),
from: connectorEnd, to: connectorEnd,