@oh-just-another/react-ui 0.57.3 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +167 -0
- package/README.md +117 -14
- package/dist/.tsbuildinfo +1 -1
- package/dist/bottom-sheet.d.ts.map +1 -1
- package/dist/bottom-sheet.js +2 -2
- package/dist/bottom-sheet.js.map +1 -1
- package/dist/color-palette.d.ts +5 -5
- package/dist/color-palette.js +8 -8
- package/dist/color-swatch-picker.d.ts +8 -1
- package/dist/color-swatch-picker.d.ts.map +1 -1
- package/dist/color-swatch-picker.js +7 -3
- package/dist/color-swatch-picker.js.map +1 -1
- package/dist/command-palette.d.ts.map +1 -1
- package/dist/command-palette.js +25 -4
- package/dist/command-palette.js.map +1 -1
- package/dist/comments-panel.d.ts.map +1 -1
- package/dist/comments-panel.js +1 -6
- package/dist/comments-panel.js.map +1 -1
- package/dist/constants.d.ts +43 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +43 -0
- package/dist/constants.js.map +1 -1
- package/dist/context-menu-controller.d.ts +3 -8
- package/dist/context-menu-controller.d.ts.map +1 -1
- package/dist/context-menu-controller.js.map +1 -1
- package/dist/context-menu.d.ts +22 -9
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +54 -11
- package/dist/context-menu.js.map +1 -1
- package/dist/diagram-canvas.d.ts +3 -1
- package/dist/diagram-canvas.d.ts.map +1 -1
- package/dist/diagram-canvas.js +1 -1
- package/dist/diagram-canvas.js.map +1 -1
- package/dist/diagram-root.d.ts +7 -1
- package/dist/diagram-root.d.ts.map +1 -1
- package/dist/diagram-root.js +11 -11
- package/dist/diagram-root.js.map +1 -1
- package/dist/drawing-panel.d.ts +14 -0
- package/dist/drawing-panel.d.ts.map +1 -0
- package/dist/drawing-panel.js +54 -0
- package/dist/drawing-panel.js.map +1 -0
- package/dist/format-time.d.ts +3 -0
- package/dist/format-time.d.ts.map +1 -0
- package/dist/format-time.js +8 -0
- package/dist/format-time.js.map +1 -0
- package/dist/frame-panel.d.ts.map +1 -1
- package/dist/frame-panel.js +2 -2
- package/dist/frame-panel.js.map +1 -1
- package/dist/help-dialog.d.ts.map +1 -1
- package/dist/help-dialog.js +10 -2
- package/dist/help-dialog.js.map +1 -1
- package/dist/hooks.d.ts +14 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +14 -1
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/link-caption-editor.d.ts.map +1 -1
- package/dist/link-caption-editor.js +3 -1
- package/dist/link-caption-editor.js.map +1 -1
- package/dist/link-drop-shape-menu.d.ts.map +1 -1
- package/dist/link-drop-shape-menu.js +3 -1
- package/dist/link-drop-shape-menu.js.map +1 -1
- package/dist/link-hover-popup.d.ts.map +1 -1
- package/dist/link-hover-popup.js +13 -20
- package/dist/link-hover-popup.js.map +1 -1
- package/dist/main-menu.d.ts +2 -1
- package/dist/main-menu.d.ts.map +1 -1
- package/dist/minimap.d.ts +25 -0
- package/dist/minimap.d.ts.map +1 -0
- package/dist/minimap.js +196 -0
- package/dist/minimap.js.map +1 -0
- package/dist/palette.d.ts.map +1 -1
- package/dist/palette.js +4 -9
- package/dist/palette.js.map +1 -1
- package/dist/popover.d.ts.map +1 -1
- package/dist/popover.js +3 -1
- package/dist/popover.js.map +1 -1
- package/dist/portal-container.d.ts +8 -0
- package/dist/portal-container.d.ts.map +1 -0
- package/dist/portal-container.js +17 -0
- package/dist/portal-container.js.map +1 -0
- package/dist/property-panel.d.ts +1 -5
- package/dist/property-panel.d.ts.map +1 -1
- package/dist/property-panel.js +198 -34
- package/dist/property-panel.js.map +1 -1
- package/dist/search-overlay.d.ts +18 -0
- package/dist/search-overlay.d.ts.map +1 -0
- package/dist/search-overlay.js +162 -0
- package/dist/search-overlay.js.map +1 -0
- package/dist/selection-floating-panel.d.ts +0 -2
- package/dist/selection-floating-panel.d.ts.map +1 -1
- package/dist/selection-floating-panel.js +9 -4
- package/dist/selection-floating-panel.js.map +1 -1
- package/dist/stats-panel.d.ts +14 -0
- package/dist/stats-panel.d.ts.map +1 -0
- package/dist/stats-panel.js +104 -0
- package/dist/stats-panel.js.map +1 -0
- package/dist/toolbar.d.ts +0 -9
- package/dist/toolbar.d.ts.map +1 -1
- package/dist/toolbar.js +23 -9
- package/dist/toolbar.js.map +1 -1
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +3 -1
- package/dist/tooltip.js.map +1 -1
- package/dist/use-dismiss-timer.d.ts +6 -0
- package/dist/use-dismiss-timer.d.ts.map +1 -0
- package/dist/use-dismiss-timer.js +23 -0
- package/dist/use-dismiss-timer.js.map +1 -0
- package/dist/versioning.d.ts.map +1 -1
- package/dist/versioning.js +2 -7
- package/dist/versioning.js.map +1 -1
- package/dist/zen-mode.d.ts +30 -0
- package/dist/zen-mode.d.ts.map +1 -0
- package/dist/zen-mode.js +62 -0
- package/dist/zen-mode.js.map +1 -0
- package/package.json +19 -19
- package/src/styles.css +29 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,172 @@
|
|
|
1
1
|
# @oh-just-another/react-ui
|
|
2
2
|
|
|
3
|
+
## 0.59.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1c4941e: New `<DrawingPanel>` — a floating tool-options panel that appears while the brush or eraser is active. It edits `editor.brushSettings` (via the new `useBrushSettings` hook): line colour, enclosed-fill colour, opacity and width for the brush; only the width (which doubles as the eraser radius) for the eraser. `<Diagram>` mounts it automatically top-right, hidden in zen mode; opt out with the new `hideDrawingPanel` prop. This is a functional scaffold intended for restyling.
|
|
8
|
+
- ca48e8a: Add two interaction tools: an eraser (mode `erase`, hotkey `E`) and a laser pointer (mode `laser`, hotkey `K`).
|
|
9
|
+
- Eraser: press-and-drag sweeps shapes under the cursor into a pending set (previewed dimmed) and deletes them all in one undo step on release. Attached links are removed with their shapes, like a Delete-key delete.
|
|
10
|
+
- Laser pointer: press-and-drag paints an ephemeral red trail that fades over a couple of seconds. Nothing is written to the scene or history — it lives purely on the overlay. Available in read-only mode. Collab replication of trails is a follow-up.
|
|
11
|
+
|
|
12
|
+
Both tools appear in the default toolbar (`DEFAULT_TOOLBAR` / `DEFAULT_VERTICAL_TOOLBAR`) and are registered as `mode-erase` / `mode-laser` actions. TTL, colour and width of the laser trail are tunable via `state/constants.ts`.
|
|
13
|
+
|
|
14
|
+
- bdc847e: Add four editor tools:
|
|
15
|
+
- **Eyedropper** — new `eyedropper` mode (toolbar button, `Alt+I`). Click a
|
|
16
|
+
shape to sample its fill/stroke and apply it to the selection.
|
|
17
|
+
`Editor.pickColorAt` / `applyEyedropperAt` + pure `pickColorAt`.
|
|
18
|
+
- **Convert element type** — `Editor.convertSelection(target)` and pure
|
|
19
|
+
`computeConvertType` switch rectangle ↔ ellipse ↔ diamond (polygon) in place,
|
|
20
|
+
preserving position/size/style. New "Shape type" property-panel control.
|
|
21
|
+
- **Image crop** — optional normalised `crop` rect on `ImageElement` (additive,
|
|
22
|
+
serialised). New `crop` mode entered by double-clicking an image or the
|
|
23
|
+
property-panel Crop button: drag a frame, `Enter` to apply, `Esc` to cancel.
|
|
24
|
+
Canvas2D renders the cropped source region (`RenderTarget.drawImage` gains an
|
|
25
|
+
optional `crop` arg). `Editor.beginImageCrop` / `commitImageCrop` /
|
|
26
|
+
`cancelImageCrop` + pure `computeSetImageCrop` / `cropRectFromWorldDrag`.
|
|
27
|
+
- **Flowchart auto-generate** — `Cmd/Ctrl+Alt+Arrow` spawns a connected node
|
|
28
|
+
from the selected node in that direction. `Editor.spawnConnectedNode` + pure
|
|
29
|
+
`computeSpawnConnectedNode`.
|
|
30
|
+
|
|
31
|
+
Also exposes `worldToLocal` from `@oh-just-another/scene`.
|
|
32
|
+
|
|
33
|
+
- 511a22a: The eyedropper is no longer a standalone toolbar tool (its palette button and the `Alt+I` hotkey / `mode-eyedropper` action are removed). Instead, every colour picker (`ColorSwatchPicker`) gains an optional pipette button via a new `onEyedrop` prop: clicking it arms `Editor.beginEyedropperPick(onPick)` and the next canvas click samples the colour of the shape under the cursor straight into that swatch — without changing the current tool mode. New editor API: `beginEyedropperPick` and the `isEyedropperArmed` flag; the cursor shows a crosshair while armed.
|
|
34
|
+
- dda2e56: Add a `<Minimap>` component (react-ui) — a small overview canvas that renders the whole scene with a frame for the current viewport; click / drag to pan the main view. Add `exportMermaid(scene)` (importers) — writes a `flowchart TD` string (inverse of `importMermaid`), round-tripping node + edge structure and emitting `%% skipped: <type>` comments for non-graph elements.
|
|
35
|
+
- 70a08d8: Read-only chrome. `<DiagramRoot>` / `<DiagramCanvas>` accept a `readOnly` prop (applied on mount and synced on change), a new `useReadOnly()` hook exposes the flag reactively, and the `<Toolbar>` disables creation / mutation tools (draw modes, insert-image, tool-lock, undo/redo) in read-only while keeping select / hand live.
|
|
36
|
+
- 7f69f29: Add scene text search, a stats/dimensions overlay, and zen mode.
|
|
37
|
+
- `state`: `searchScene(scene, query)` / `elementSearchText(element)` — a pure, case-insensitive substring index over text shapes, frame names, and edge labels; plus `Editor.selectLink(id)` to programmatically select a single connector.
|
|
38
|
+
- `react-ui`: `<SearchOverlay>` (⌘F) finds and frames matching text with next/prev navigation; `<StatsPanel>` (⌥/) shows the selection's x/y/w/h/angle and scene totals; `<ZenModeProvider>` / `useZenMode` (⌥Z, Esc to exit) hides chrome for focused work. All three are wired into `<Editor>` from `@oh-just-another/editor`.
|
|
39
|
+
|
|
40
|
+
- cf8b735: Add styled text runs (rich text, phase 1): a `TextElement` can now carry an optional `runs` overlay — contiguous substrings each with a partial `TextStyle` (bold / italic / colour / decoration) over the element's base style. The flat `text` stays the source of truth (`runs.map(r => r.text).join("") === text`), so plain-text scenes render, serialise and round-trip byte-for-byte unchanged.
|
|
41
|
+
- `scene`: `TextRun` type + `TextElement.runs?`; pure helpers `runsToText`, `normalizeRuns`, `sliceRuns`, and `applyStyleToRange(el, from, to, partial)` (splits/merges/coalesces runs, sheds the overlay when uniform).
|
|
42
|
+
- `serialization`: additive optional `runs` in the text schema; legacy documents (no `runs`) round-trip unchanged.
|
|
43
|
+
- `renderer-core`: the text renderer draws each visual line's style segments with per-run font + fill through the shared `RenderTarget`, so Canvas2D, WebGL2 and SVG all honour runs. Line breaking still uses the element's base metrics.
|
|
44
|
+
- `state`: `Editor.applyTextStyleToRange(id, from, to, partial)` applies a style to a character range as one undo step.
|
|
45
|
+
- `react-ui`: the text formatting controls (bold / italic / underline / strikethrough / colour) target the current inline-edit selection when one is active — styling just those characters — and fall back to whole-element styling otherwise.
|
|
46
|
+
|
|
47
|
+
Full inline rich-text editing (per-run wrap metrics, caret-aware run editing) is a follow-up.
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- a9558d9: Reworked flowchart keyboard model. Arrow-key bindings are reworked and disambiguated by modifier: `Arrow` nudges (unchanged); `Cmd/Ctrl+Arrow` grows a flowchart CREATE session (each press adds a pending connected sibling, previewed on the overlay, committed as one undo step when Cmd/Ctrl is released, cancelled on Escape); `Alt+Arrow` navigates to the adjacent node (graph neighbour, else spatially nearest); `Cmd/Ctrl+Shift+Arrow` aligns (moved off the old plain `Alt+Arrow`). The old `Cmd/Ctrl+Alt+Arrow` spawn binding is retired.
|
|
52
|
+
|
|
53
|
+
New API: `editor.growFlowchart` / `commitFlowchart` / `cancelFlowchart` / `navigateFlowchart` / `flowchartPreview`, the pure `computeSpawnConnectedNodes`, and `endpointElementId` (scene). `<Diagram>` wires the keyup-commit / Escape-cancel lifecycle for you.
|
|
54
|
+
|
|
55
|
+
- 22b90f9: The keyboard-shortcuts help dialog now lists every real binding. The `arrange` category (align / flip / distribute) was missing from the dialog's category order and is now shown, and keyTest-driven bindings (nudge arrows, Enter edit/create, plus flowchart create/navigate) surface their chips via a new display-only `Action.displayHotkey` field instead of rendering as "—". `displayHotkey` is never dispatched (only `hotkey`/`keyTest`/`sequence` are), which also closes a latent hole where a display matcher could fire a Ctrl-modified combo the `keyTest` deliberately excluded.
|
|
56
|
+
- 34ddb22: The minimap now supports wheel zoom: scrolling over it zooms the main view into the world spot under the cursor (recentering there first, matching its click-to-pan), using the same delta→factor curve as the main canvas. The handler is a non-passive listener so it doesn't scroll the page, and doesn't interfere with click/drag panning. Tunable via `MINIMAP_WHEEL_ZOOM_SPEED` / `MINIMAP_WHEEL_ZOOM_MAX_STEP`.
|
|
57
|
+
- bd2e26c: Make read-only (view) mode a true guard. Every mutating `Editor` method reachable from the UI (`updateStyle`, `updateTextProps`, `deleteSelected`, `duplicateSelected`, group/ungroup, align/flip/distribute, z-order, `moveSelectionBy`, `setLink`, `convertSelection`, `clear`, etc.) is now a no-op while `readOnly` is set, backstopping direct panel/hotkey calls that previously bypassed the pointer-level gate. The overlay keeps the selection outline (halo) but no longer paints resize/rotate/group handles or link endpoint grips in read-only, and the property panel / selection floating panel / mutating context-menu entries are hidden. `copy` / `copy-style` are flagged view-safe so they stay live.
|
|
58
|
+
- 5d8a282: Fix the bold / italic / underline / strikethrough toggles in the text style popover never applying to an in-edit text selection. The toggle button was a component defined inside `TextDecorationControl`, so it got a fresh identity on every panel re-render; during inline text editing the panel re-renders continuously (caret blink), and a remount between `mousedown` and `mouseup` swallowed the synthesized `click`. Hoisted the toggle to a stable module-level component so the button persists across re-renders and the click fires. Colour was unaffected (it goes through a stable control).
|
|
59
|
+
- 71a6c8b: Fix the search bar (⌘F) jumping to a match the moment it opens, before the user types anything. The query was retained across close/open, so reopening re-ran the reveal effect against the stale query and framed the previous match. The query and active index are now reset on close, so the bar always opens empty and only navigates once the user types.
|
|
60
|
+
- 71a6c8b: Search navigation no longer blows a small match up to fill the whole canvas. Jumping to a match now centers it while preserving the current zoom, only zooming out when the match is too large to fit — a small element stays small and just lands in the center. Adds `Editor.revealSelection(padding)` and the pure `computeRevealBounds` helper (never zooms in, unlike `zoomToSelection`'s fit-to-fill).
|
|
61
|
+
- Updated dependencies [783749e]
|
|
62
|
+
- Updated dependencies [c189261]
|
|
63
|
+
- Updated dependencies [c189261]
|
|
64
|
+
- Updated dependencies [c189261]
|
|
65
|
+
- Updated dependencies [641842b]
|
|
66
|
+
- Updated dependencies [c189261]
|
|
67
|
+
- Updated dependencies [c58054b]
|
|
68
|
+
- Updated dependencies [b156869]
|
|
69
|
+
- Updated dependencies [0d3934e]
|
|
70
|
+
- Updated dependencies [0d3934e]
|
|
71
|
+
- Updated dependencies [b0a9f3b]
|
|
72
|
+
- Updated dependencies [571f13b]
|
|
73
|
+
- Updated dependencies [ca48e8a]
|
|
74
|
+
- Updated dependencies [1975a9b]
|
|
75
|
+
- Updated dependencies [1975a9b]
|
|
76
|
+
- Updated dependencies [bdc847e]
|
|
77
|
+
- Updated dependencies [511a22a]
|
|
78
|
+
- Updated dependencies [a9558d9]
|
|
79
|
+
- Updated dependencies [22b90f9]
|
|
80
|
+
- Updated dependencies [99b5bee]
|
|
81
|
+
- Updated dependencies [f381039]
|
|
82
|
+
- Updated dependencies [394d3ce]
|
|
83
|
+
- Updated dependencies [295f38b]
|
|
84
|
+
- Updated dependencies [bd2e26c]
|
|
85
|
+
- Updated dependencies [97de2fd]
|
|
86
|
+
- Updated dependencies [407f203]
|
|
87
|
+
- Updated dependencies [744f4b8]
|
|
88
|
+
- Updated dependencies [71a6c8b]
|
|
89
|
+
- Updated dependencies [7f69f29]
|
|
90
|
+
- Updated dependencies [dde8279]
|
|
91
|
+
- Updated dependencies [cec8f83]
|
|
92
|
+
- Updated dependencies [1975a9b]
|
|
93
|
+
- Updated dependencies [1975a9b]
|
|
94
|
+
- Updated dependencies [1975a9b]
|
|
95
|
+
- Updated dependencies [1975a9b]
|
|
96
|
+
- Updated dependencies [cf8b735]
|
|
97
|
+
- Updated dependencies [571f13b]
|
|
98
|
+
- Updated dependencies [f8302c3]
|
|
99
|
+
- @oh-just-another/scene@0.60.0
|
|
100
|
+
- @oh-just-another/state@0.60.0
|
|
101
|
+
- @oh-just-another/renderer-core@0.59.0
|
|
102
|
+
- @oh-just-another/renderer-canvas@0.60.0
|
|
103
|
+
- @oh-just-another/renderer-svg@0.57.3
|
|
104
|
+
- @oh-just-another/templates@0.57.3
|
|
105
|
+
- @oh-just-another/versioning@0.57.3
|
|
106
|
+
|
|
107
|
+
## 0.58.0
|
|
108
|
+
|
|
109
|
+
### Minor Changes
|
|
110
|
+
|
|
111
|
+
- b4b252b: Arrange operations for the selection. **Flip** mirrors the selection about its bounding-box centre — horizontal (`Shift+H`) and vertical (`Shift+V`); a single shape flips about its own centre. **Align** flushes two or more shapes to the left / right / top / bottom edge or the horizontal / vertical centre of their bounding box (`Alt+←/→/↑/↓` for the four edges; centres via the panel / menu). **Distribute** evenly spaces three or more shapes so the gaps between them are equal, on the horizontal (`Alt+H`) or vertical (`Alt+V`) axis, keeping the outermost shapes fixed. All three are available from the selection property panel and the right-click menu. New engine API: `Editor.flipSelection(axis)`, `Editor.alignSelection(edge)`, and `Editor.distributeSelection(axis)`.
|
|
112
|
+
- 578e728: Clear the whole canvas with `Cmd/Ctrl+Delete` (or `Backspace`), from the command palette, or the right-click menu. Because it wipes every shape and isn't undoable, it always asks for confirmation first.
|
|
113
|
+
- d20d50a: Copy and paste a shape's visual style. `Cmd/Ctrl+Alt+C` captures the fill / stroke / dash / opacity of the selected shape into an in-editor buffer; `Cmd/Ctrl+Alt+V` applies it to the current selection (one undo step). Also available from the right-click menu. New engine API: `Editor.copySelectionStyle()` / `Editor.pasteSelectionStyle()` and the `hasStyleClipboard` flag.
|
|
114
|
+
- 09a096c: Add `PortalContainerProvider` / `usePortalContainer` — floating UI (tooltips, popovers, context menus, hover chips) now portals into a configurable container instead of always `document.body`. Defaults to `document.body`, so existing usage is unchanged; a host mounting the editor in a shadow root points it at a node inside the root so portaled content stays styled.
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- 7217cac: The canvas surface no longer draws a focus ring on a mouse click. The surface
|
|
119
|
+
takes focus on press (so keyboard shortcuts work right after clicking), which
|
|
120
|
+
made it light up with an outline like a focused text input. The ring is now
|
|
121
|
+
gated on `:focus-visible`, so it appears only for keyboard focus (Tab) and never
|
|
122
|
+
for a pointer press.
|
|
123
|
+
- 60e315e: Fix the context menu (and any chrome reading the legacy `--menu-*` / `--panel` /
|
|
124
|
+
`--text` aliases) ignoring an explicit app theme. The aliases forward to the
|
|
125
|
+
`--du-*` theme variables via `var()`, but were declared only on `:root` — and a
|
|
126
|
+
`var()` inside a custom property resolves on the element where it's declared. So
|
|
127
|
+
under an OS dark preference the alias baked in `:root`'s dark value and inherited
|
|
128
|
+
that frozen colour straight past a `[data-theme="light"]` override, leaving a
|
|
129
|
+
dark menu on a light app. The aliases are now declared at every theme scope
|
|
130
|
+
(`:root`, `[data-theme="light"]`, `[data-theme="dark"]`) so each re-resolves
|
|
131
|
+
against the scoped `--du-*`.
|
|
132
|
+
- 60e315e: Fix floating chrome ignoring the app theme. The selection / property panel,
|
|
133
|
+
popovers, tooltips and the right-click context menu portal out of the editor
|
|
134
|
+
root, which also escaped the `data-theme` set there — so under an OS dark
|
|
135
|
+
preference they showed a dark surface even when the app was set to light (and
|
|
136
|
+
vice-versa). They now portal into a wrapper that mirrors the editor's theme, so
|
|
137
|
+
they always match the app. The context menu additionally portals into that
|
|
138
|
+
wrapper and its colours forward to the `--du-*` theme variables (no more
|
|
139
|
+
hard-coded dark fallbacks / hover).
|
|
140
|
+
- Updated dependencies [b4b252b]
|
|
141
|
+
- Updated dependencies [1c7cc6c]
|
|
142
|
+
- Updated dependencies [d20d50a]
|
|
143
|
+
- Updated dependencies [0152ed6]
|
|
144
|
+
- Updated dependencies [938e7c8]
|
|
145
|
+
- Updated dependencies [9673846]
|
|
146
|
+
- Updated dependencies [f370dba]
|
|
147
|
+
- Updated dependencies [1c7cc6c]
|
|
148
|
+
- Updated dependencies [e1fd495]
|
|
149
|
+
- Updated dependencies [8f00738]
|
|
150
|
+
- Updated dependencies [1c7cc6c]
|
|
151
|
+
- Updated dependencies [ff90a95]
|
|
152
|
+
- Updated dependencies [da91d59]
|
|
153
|
+
- Updated dependencies [3152317]
|
|
154
|
+
- Updated dependencies [fc47ecc]
|
|
155
|
+
- Updated dependencies [8fc6b69]
|
|
156
|
+
- Updated dependencies [f98730f]
|
|
157
|
+
- Updated dependencies [904cc09]
|
|
158
|
+
- Updated dependencies [edde5d0]
|
|
159
|
+
- Updated dependencies [1c7cc6c]
|
|
160
|
+
- Updated dependencies [c5be6e5]
|
|
161
|
+
- @oh-just-another/state@0.59.0
|
|
162
|
+
- @oh-just-another/renderer-canvas@0.59.0
|
|
163
|
+
- @oh-just-another/scene@0.59.0
|
|
164
|
+
- @oh-just-another/renderer-core@0.58.0
|
|
165
|
+
- @oh-just-another/math@0.58.0
|
|
166
|
+
- @oh-just-another/renderer-svg@0.57.2
|
|
167
|
+
- @oh-just-another/templates@0.57.2
|
|
168
|
+
- @oh-just-another/versioning@0.57.2
|
|
169
|
+
|
|
3
170
|
## 0.57.3
|
|
4
171
|
|
|
5
172
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# @oh-just-another/react-ui
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@oh-just-another/react-ui)
|
|
4
|
+
|
|
3
5
|
React 18+ wrappers around the editor — `DiagramCanvas`, `Toolbar`, `Palette`, `PropertyPanel`, plus a small set of hooks. Mount it with three lines of JSX, customize with hooks for everything else.
|
|
4
6
|
|
|
7
|
+
The React binding layer (L5) over `@oh-just-another/state`; needs React + DOM. For a single drop-in component, use `@oh-just-another/editor`.
|
|
8
|
+
|
|
5
9
|
## Install
|
|
6
10
|
|
|
7
11
|
```bash
|
|
@@ -30,25 +34,124 @@ export const App = () => (
|
|
|
30
34
|
|
|
31
35
|
`DiagramCanvas` constructs the underlying `Editor` and supplies it to every descendant via context. Toolbar / Palette / PropertyPanel are independent — drop them anywhere in the subtree, layered with normal CSS.
|
|
32
36
|
|
|
33
|
-
##
|
|
37
|
+
## Components
|
|
38
|
+
|
|
39
|
+
Every component reads the editor from context, so most take no required props.
|
|
40
|
+
|
|
41
|
+
### Mounting & layout
|
|
42
|
+
|
|
43
|
+
| Name | Purpose |
|
|
44
|
+
| -------------------------------- | ---------------------------------------------------------------- |
|
|
45
|
+
| `DiagramCanvas` | Mounts a host element, instantiates `Editor`, provides context. |
|
|
46
|
+
| `DiagramRoot` / `DiagramSurface` | Lower-level split of the canvas: provider root + render surface. |
|
|
47
|
+
| `DiagramProvider` | Standalone provider for hosts that build their own editor. |
|
|
48
|
+
| `UILayer` | Positioned overlay layer for placing chrome over the canvas. |
|
|
49
|
+
| `TopBar` / `BottomBar` | Edge-anchored bars for toolbars and status chrome. |
|
|
50
|
+
| `Sidebar` | Collapsible side container for panels. |
|
|
51
|
+
| `BottomSheet` | Sliding bottom container (touch / mobile layouts). |
|
|
52
|
+
| `Minimap` | Overview canvas with a viewport frame; click / drag to pan. |
|
|
53
|
+
|
|
54
|
+
### Toolbar & zoom
|
|
55
|
+
|
|
56
|
+
| Name | Purpose |
|
|
57
|
+
| ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
|
|
58
|
+
| `Toolbar` / `DEFAULT_TOOLBAR` / `DEFAULT_VERTICAL_TOOLBAR` | Declarative tool/action bar. Items: `mode`, `action`, `divider`, `undo`, `redo`. |
|
|
59
|
+
| `openImageFilePicker` | Opens the OS file picker and inserts the chosen image. |
|
|
60
|
+
| `ZoomWidget` / `FloatingZoomControls` | Composite zoom controls. |
|
|
61
|
+
| `ZoomInButton` / `ZoomOutButton` / `ResetZoomButton` / `ZoomToFitButton` / `ZoomDisplay` | Individual zoom controls. |
|
|
62
|
+
| `ResetToContentButton` | Recenters the viewport on scene content. |
|
|
63
|
+
|
|
64
|
+
### Palettes & shape catalog
|
|
65
|
+
|
|
66
|
+
| Name | Purpose |
|
|
67
|
+
| ------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
|
|
68
|
+
| `Palette` | Drag-and-drop catalog of templates. |
|
|
69
|
+
| `LibraryPanel` | Browsable template library panel. |
|
|
70
|
+
| `ColorSwatchPicker` | Color swatch grid picker. |
|
|
71
|
+
| `ELEMENT_PALETTE_LIGHT` / `ELEMENT_PALETTE_DARK` / `CANVAS_PALETTE_LIGHT` / `CANVAS_PALETTE_DARK` | Built-in color palettes. |
|
|
72
|
+
| `resolvePaletteTheme` | Picks the light/dark palette for the active theme. |
|
|
73
|
+
|
|
74
|
+
### Inspectors & property panels
|
|
75
|
+
|
|
76
|
+
| Name | Purpose |
|
|
77
|
+
| ------------------------ | -------------------------------------------- |
|
|
78
|
+
| `PropertyPanel` | Inspector for the current selection. |
|
|
79
|
+
| `LinkStylePanel` | Edge/link styling controls. |
|
|
80
|
+
| `LayerPanel` | Layer list with visibility / ordering. |
|
|
81
|
+
| `FramePanel` | Frame list and controls. |
|
|
82
|
+
| `SelectionFloatingPanel` | Floating controls anchored to the selection. |
|
|
83
|
+
|
|
84
|
+
### Menus, dialogs & overlays
|
|
85
|
+
|
|
86
|
+
| Name | Purpose |
|
|
87
|
+
| -------------------------------------- | -------------------------------------------------- |
|
|
88
|
+
| `MainMenu` | Top-level application menu with submenus. |
|
|
89
|
+
| `ContextMenu` / `DEFAULT_CONTEXT_MENU` | Right-click menu over the canvas. |
|
|
90
|
+
| `CommandPalette` | Searchable command launcher. |
|
|
91
|
+
| `Modal` / `Popover` | Generic modal dialog and anchored popover. |
|
|
92
|
+
| `Tooltip` / `TooltipProvider` | Hover tooltips (wrap the subtree in the provider). |
|
|
93
|
+
| `HelpButton` / `HelpDialog` | Keyboard-shortcut / help dialog and its trigger. |
|
|
94
|
+
| `ToastHost` | Renders transient toasts; pair with `useToast`. |
|
|
95
|
+
|
|
96
|
+
### Collaboration & versioning
|
|
97
|
+
|
|
98
|
+
| Name | Purpose |
|
|
99
|
+
| ----------------------------------- | ----------------------------------------- |
|
|
100
|
+
| `CommentsPanel` / `CommentsPopover` | Thread list and anchored comment popover. |
|
|
101
|
+
| `VersionPanel` | Snapshot history browser. |
|
|
102
|
+
| `MergeDialog` | Resolve conflicts when merging versions. |
|
|
103
|
+
| `DiffPanel` | Visual diff between two scenes. |
|
|
104
|
+
|
|
105
|
+
### Editing overlays
|
|
106
|
+
|
|
107
|
+
| Name | Purpose |
|
|
108
|
+
| ------------------------------------------------------------ | -------------------------------------- |
|
|
109
|
+
| `TextEditorOverlay` / `FrameNameEditorOverlay` | In-place text editors over the canvas. |
|
|
110
|
+
| `LinkHoverPopup` / `LinkDropShapeMenu` / `LinkCaptionEditor` | Link interaction overlays. |
|
|
111
|
+
| `Markdown` | Renders markdown (comments, captions). |
|
|
112
|
+
|
|
113
|
+
### Primitives
|
|
114
|
+
|
|
115
|
+
| Name | Purpose |
|
|
116
|
+
| ----------------------------- | ---------------------------------- |
|
|
117
|
+
| `IconButton` / `ButtonGroup` | Buttons and grouped button rows. |
|
|
118
|
+
| `SegmentedControl` / `Slider` | Segmented toggle and range slider. |
|
|
119
|
+
|
|
120
|
+
## Hooks
|
|
121
|
+
|
|
122
|
+
| Name | Purpose |
|
|
123
|
+
| ------------------------------------------------------------------------ | -------------------------------------------------------------- |
|
|
124
|
+
| `useDiagram()` / `useDiagramOptional()` | Live `Editor` (imperative; no re-render on change). |
|
|
125
|
+
| `useDiagramContext()` / `useDiagramContextOptional()` | Raw context value. |
|
|
126
|
+
| `useEditorSelector(select)` | Custom selector — re-renders when the projected value changes. |
|
|
127
|
+
| `useScene()` / `useSelection()` / `useMode()` | Reactive slices of editor state. |
|
|
128
|
+
| `useHistory()` | `canUndo` / `canRedo` + `undo` / `redo`. |
|
|
129
|
+
| `useLayers()` / `useActiveLayerId()` | Layer list and active layer. |
|
|
130
|
+
| `useAnnotations()` / `useSelectedAnnotation()` / `useSelectedLink()` | Annotation and link selection state. |
|
|
131
|
+
| `useMobileLayout()` | Whether the compact / touch layout is active. |
|
|
132
|
+
| `useToast()` / `useToastOptional()` / `useEphemeralToast()` | Toast API (pair with `ToastHost`). |
|
|
133
|
+
| `useSnapshotStore()` | Snapshot store backing `VersionPanel`. |
|
|
134
|
+
| `useHelpDialogHotkey()` | Wires the help-dialog hotkey. |
|
|
135
|
+
| `useContextMenuController()` / `ContextMenuControllerProvider` | Imperative control of `ContextMenu`. |
|
|
136
|
+
| `usePaletteDropHandler()` / `usePalettePlacement()` / `usePaletteDrag()` | Palette drop / placement / drag wiring. |
|
|
137
|
+
| `getActivePaletteDrag()` / `subscribePaletteDrag()` | Read/observe the active palette drag outside React. |
|
|
138
|
+
|
|
139
|
+
## Layout constants
|
|
140
|
+
|
|
141
|
+
Tunable sizes for the built-in panels and toolbar:
|
|
142
|
+
`PALETTE_WIDTH`, `PALETTE_ITEM_SIZE`, `PROPERTY_PANEL_WIDTH`, `PROPERTY_SWATCH_SIZE`,
|
|
143
|
+
`LAYER_PANEL_WIDTH`, `LAYER_TOGGLE_ICON_SIZE`, `LAYER_SWATCH_SIZE`,
|
|
144
|
+
`COMMENTS_PANEL_WIDTH`, `TOOLBAR_SEPARATOR_HEIGHT`.
|
|
34
145
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
| `DiagramProvider` (+ `useDiagramContext`) | Standalone provider for advanced hosts that build their own editor. |
|
|
39
|
-
| `useDiagram()` | Live `Editor`. Imperative access (no re-render on change). |
|
|
40
|
-
| `useScene()` / `useSelection()` / `useMode()` / `useHistory()` | Reactive slices. `useHistory` exposes `canUndo` / `canRedo` + `undo` / `redo`. |
|
|
41
|
-
| `useEditorSelector(select)` | Build your own selector — re-renders when the projected value changes. |
|
|
42
|
-
| `Toolbar` / `DEFAULT_TOOLBAR` / `ToolbarItem` | Items: `mode`, `action`, `divider`, `undo`, `redo`. Action items receive the live editor. |
|
|
43
|
-
| `Palette` / `PaletteProps` | Drag-and-drop catalog of templates. Defaults to `defaultRegistry`. |
|
|
44
|
-
| `usePaletteDropHandler()` | Convert an HTML5 drop event on any element into `editor.addShape(template.factory(...))`. |
|
|
45
|
-
| `PropertyPanel` / `PropertyPanelProps` | Read-only inspector for the current selection. |
|
|
146
|
+
Each component also exports its `*Props` type (e.g. `ToolbarProps`, `PaletteProps`); menu, toast,
|
|
147
|
+
help, and context-menu modules additionally export their item/section types (`ToolbarItem`,
|
|
148
|
+
`ContextMenuItem`, `ToastKind`, `HelpRow`, etc.).
|
|
46
149
|
|
|
47
150
|
## Design notes
|
|
48
151
|
|
|
49
152
|
- **`<DiagramCanvas>` owns the editor's lifetime.** Created in `useLayoutEffect` so children's effects see the provider value on first paint; disposed on unmount. `initialScene` and `initialMode` are read once — runtime updates go through the editor API (`editor.loadScene`, `editor.setMode`).
|
|
50
|
-
- **Hooks subscribe via the editor's `subscribe`.**
|
|
153
|
+
- **Hooks subscribe via the editor's `subscribe`.** `Editor.setMode` calls `notify()` so `useMode` (and similar bespoke selectors) re-render on mode changes.
|
|
51
154
|
- **No global state.** Every editor instance is independent — composition via context lets multiple canvases live on the same page (useful for diff viewers, presentation modes).
|
|
52
155
|
- **Toolbar item kinds are a discriminated union.** Hosts can mix builtin `mode` / `undo` / `redo` items with arbitrary `action` items in one declarative array.
|
|
53
|
-
- **Palette uses SVG icons through `dangerouslySetInnerHTML`.** Template authors define the icon markup; same SVG goes through the canvas renderer's SVG
|
|
156
|
+
- **Palette uses SVG icons through `dangerouslySetInnerHTML`.** Template authors define the icon markup; the same SVG goes through the canvas renderer's SVG parser, so palette and canvas stay visually identical.
|
|
54
157
|
- **Tests run under `jsdom`.** `tests/setup.ts` stubs `HTMLCanvasElement.prototype.getContext`, pointer-capture, and `ResizeObserver` — enough for the editor to mount without pulling the native `canvas` npm package.
|