@widgetic/canvas 0.5.35 → 0.5.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -36
- package/dist/canvas/DomCanvas.svelte +454 -0
- package/dist/canvas/DomCanvas.svelte.d.ts +222 -0
- package/dist/canvas/boardFrame.d.ts +13 -0
- package/dist/canvas/boardFrame.js +13 -0
- package/dist/canvas/boardSurface.d.ts +9 -0
- package/dist/canvas/boardSurface.js +9 -0
- package/dist/canvas/chromeLayout.d.ts +76 -0
- package/dist/canvas/chromeLayout.js +121 -0
- package/dist/canvas/emptyBoardHint.d.ts +17 -0
- package/dist/canvas/emptyBoardHint.js +12 -0
- package/dist/canvas/eventScope.d.ts +1 -1
- package/dist/canvas/eventScope.js +1 -1
- package/dist/canvas/host/CanvasHost.d.ts +351 -0
- package/dist/canvas/host/CanvasHost.js +1740 -0
- package/dist/canvas/host/CanvasHostApi.d.ts +30 -0
- package/dist/canvas/host/CanvasHostApi.js +95 -0
- package/dist/canvas/host/browserServices.d.ts +46 -0
- package/dist/canvas/host/browserServices.js +167 -0
- package/dist/canvas/host/conversion.d.ts +51 -0
- package/dist/canvas/host/conversion.js +123 -0
- package/dist/canvas/host/hostObject.d.ts +40 -0
- package/dist/canvas/host/hostObject.js +93 -0
- package/dist/canvas/host/pageEvents.d.ts +24 -0
- package/dist/canvas/host/pageEvents.js +35 -0
- package/dist/canvas/host/screenRects.d.ts +66 -0
- package/dist/canvas/host/screenRects.js +102 -0
- package/dist/canvas/host/strokeSnap.d.ts +67 -0
- package/dist/canvas/host/strokeSnap.js +165 -0
- package/dist/canvas/index.d.ts +7 -7
- package/dist/canvas/index.js +8 -8
- package/dist/canvas/openMarks.d.ts +17 -0
- package/dist/canvas/openMarks.js +26 -0
- package/dist/canvas/panZoomPosition.d.ts +15 -0
- package/dist/canvas/panZoomPosition.js +16 -0
- package/dist/canvas/preferredTextFont.d.ts +12 -0
- package/dist/canvas/preferredTextFont.js +38 -0
- package/dist/canvas/shapes/ShapeLibrary.d.ts +1 -1
- package/dist/canvas/shapes/ShapeLibrary.js +13 -1
- package/dist/canvas/shapes/strokeShapeSnap.d.ts +14 -12
- package/dist/canvas/shapes/strokeShapeSnap.js +10 -8
- package/dist/canvas/toolbarPosition.d.ts +11 -11
- package/dist/canvas/toolbarPosition.js +11 -24
- package/dist/canvas/types.d.ts +14 -0
- package/dist/canvas/ui/CanvasContextMenu.svelte +173 -0
- package/dist/canvas/ui/CanvasContextMenu.svelte.d.ts +12 -0
- package/dist/canvas/ui/CanvasHint.svelte +20 -0
- package/dist/canvas/ui/CanvasHint.svelte.d.ts +18 -0
- package/dist/canvas/ui/CanvasToolbar.svelte +95 -0
- package/dist/canvas/ui/CanvasToolbar.svelte.d.ts +14 -0
- package/dist/canvas/ui/ColorField.svelte +155 -0
- package/dist/canvas/ui/ColorField.svelte.d.ts +14 -0
- package/dist/canvas/ui/LoadNotice.svelte +39 -0
- package/dist/canvas/ui/LoadNotice.svelte.d.ts +8 -0
- package/dist/canvas/ui/SelectionPanel.svelte +300 -0
- package/dist/canvas/ui/SelectionPanel.svelte.d.ts +20 -0
- package/dist/canvas/ui/SelectorBar.svelte +82 -0
- package/dist/canvas/ui/SelectorBar.svelte.d.ts +12 -0
- package/dist/canvas/ui/ShapesMenu.svelte +185 -0
- package/dist/canvas/ui/ShapesMenu.svelte.d.ts +15 -0
- package/dist/canvas/ui/ShortcutsPanel.svelte +124 -0
- package/dist/canvas/ui/ShortcutsPanel.svelte.d.ts +7 -0
- package/dist/canvas/ui/ToolButton.svelte +78 -0
- package/dist/canvas/ui/ToolButton.svelte.d.ts +20 -0
- package/dist/canvas/ui/WidgetActions.svelte +152 -0
- package/dist/canvas/ui/WidgetActions.svelte.d.ts +19 -0
- package/dist/canvas/ui/ZoomControl.svelte +89 -0
- package/dist/canvas/ui/ZoomControl.svelte.d.ts +18 -0
- package/dist/canvas/ui/colorModel.d.ts +18 -0
- package/dist/canvas/ui/colorModel.js +85 -0
- package/dist/canvas/ui/colorPickerMessages.d.ts +5 -0
- package/dist/canvas/ui/colorPickerMessages.js +15 -0
- package/dist/canvas/ui/floatingCard.d.ts +107 -0
- package/dist/canvas/ui/floatingCard.js +107 -0
- package/dist/canvas/ui/floatingLayer.d.ts +21 -0
- package/dist/canvas/ui/floatingLayer.js +52 -0
- package/dist/canvas/ui/icons.d.ts +12 -0
- package/dist/canvas/ui/icons.js +7 -0
- package/dist/canvas/ui/keyHints.d.ts +27 -0
- package/dist/canvas/ui/keyHints.js +43 -0
- package/dist/canvas/ui/popoverSide.d.ts +5 -0
- package/dist/canvas/ui/popoverSide.js +20 -0
- package/dist/canvas/ui/selectionTraits.d.ts +61 -0
- package/dist/canvas/ui/selectionTraits.js +99 -0
- package/dist/canvas/view/CanvasStage.svelte +132 -0
- package/dist/canvas/view/CanvasStage.svelte.d.ts +21 -0
- package/dist/canvas/view/EraserTrail.svelte +50 -0
- package/dist/canvas/view/EraserTrail.svelte.d.ts +9 -0
- package/dist/canvas/view/ObjectView.svelte +245 -0
- package/dist/canvas/view/ObjectView.svelte.d.ts +21 -0
- package/dist/canvas/view/SelectionOverlay.svelte +487 -0
- package/dist/canvas/view/SelectionOverlay.svelte.d.ts +17 -0
- package/dist/canvas/view/TextEditor.svelte +76 -0
- package/dist/canvas/view/TextEditor.svelte.d.ts +9 -0
- package/dist/canvas/view/WidgetChromeLayer.svelte +83 -0
- package/dist/canvas/view/WidgetChromeLayer.svelte.d.ts +13 -0
- package/dist/canvas/view/erasingMarks.d.ts +13 -0
- package/dist/canvas/view/erasingMarks.js +34 -0
- package/dist/canvas/view/geometry.d.ts +169 -0
- package/dist/canvas/view/geometry.js +272 -0
- package/dist/components/CanvasBoardPlaceholder.svelte +5 -3
- package/dist/components/CanvasBoardPlaceholder.svelte.d.ts +3 -3
- package/dist/components/index.js +1 -1
- package/dist/components/input-controls/ColorIC.svelte +2 -2
- package/dist/engine/EngineCore.d.ts +273 -0
- package/dist/engine/EngineCore.js +1051 -0
- package/dist/engine/codec/canvasDocument.d.ts +57 -0
- package/dist/engine/codec/canvasDocument.js +471 -0
- package/dist/engine/codec/hostReadableKeys.d.ts +25 -0
- package/dist/engine/codec/hostReadableKeys.js +25 -0
- package/dist/engine/core/arrange.d.ts +20 -0
- package/dist/engine/core/arrange.js +81 -0
- package/dist/engine/core/arrow.d.ts +91 -0
- package/dist/engine/core/arrow.js +182 -0
- package/dist/engine/core/brush.d.ts +68 -0
- package/dist/engine/core/brush.js +173 -0
- package/dist/engine/core/defaults.d.ts +70 -0
- package/dist/engine/core/defaults.js +158 -0
- package/dist/engine/core/freehand.d.ts +130 -0
- package/dist/engine/core/freehand.js +430 -0
- package/dist/engine/core/geometry.d.ts +44 -0
- package/dist/engine/core/geometry.js +216 -0
- package/dist/engine/core/history.d.ts +39 -0
- package/dist/engine/core/history.js +69 -0
- package/dist/engine/core/hitTest.d.ts +54 -0
- package/dist/engine/core/hitTest.js +298 -0
- package/dist/engine/core/matrix.d.ts +47 -0
- package/dist/engine/core/matrix.js +101 -0
- package/dist/engine/core/pathData.d.ts +50 -0
- package/dist/engine/core/pathData.js +550 -0
- package/dist/engine/core/rotationReset.d.ts +10 -0
- package/dist/engine/core/rotationReset.js +17 -0
- package/dist/engine/core/scene.d.ts +99 -0
- package/dist/engine/core/scene.js +450 -0
- package/dist/engine/core/scribble.d.ts +64 -0
- package/dist/engine/core/scribble.js +121 -0
- package/dist/engine/core/shapePaths.d.ts +34 -0
- package/dist/engine/core/shapePaths.js +69 -0
- package/dist/engine/core/shapeTools.d.ts +80 -0
- package/dist/engine/core/shapeTools.js +161 -0
- package/dist/engine/core/snapping.d.ts +64 -0
- package/dist/engine/core/snapping.js +164 -0
- package/dist/engine/core/style.d.ts +40 -0
- package/dist/engine/core/style.js +151 -0
- package/dist/engine/core/transform.d.ts +79 -0
- package/dist/engine/core/transform.js +258 -0
- package/dist/engine/core/types.d.ts +238 -0
- package/dist/engine/core/types.js +31 -0
- package/dist/engine/core/viewport.d.ts +32 -0
- package/dist/engine/core/viewport.js +84 -0
- package/dist/engine/input/PointerController.d.ts +38 -0
- package/dist/engine/input/PointerController.js +545 -0
- package/dist/engine/input/arrowHandles.d.ts +38 -0
- package/dist/engine/input/arrowHandles.js +60 -0
- package/dist/engine/input/gestures.d.ts +79 -0
- package/dist/engine/input/gestures.js +769 -0
- package/dist/engine/input/hoverCursor.d.ts +29 -0
- package/dist/engine/input/hoverCursor.js +23 -0
- package/dist/engine/input/keyboard.d.ts +75 -0
- package/dist/engine/input/keyboard.js +264 -0
- package/dist/engine/input/selectionHandles.d.ts +89 -0
- package/dist/engine/input/selectionHandles.js +169 -0
- package/dist/engine/input/types.d.ts +82 -0
- package/dist/engine/input/types.js +5 -0
- package/dist/engine/render/rasterize.d.ts +74 -0
- package/dist/engine/render/rasterize.js +273 -0
- package/dist/engine/state.d.ts +124 -0
- package/dist/engine/state.js +47 -0
- package/dist/engine/text/layoutText.d.ts +53 -0
- package/dist/engine/text/layoutText.js +170 -0
- package/dist/engine/widgets.d.ts +124 -0
- package/dist/engine/widgets.js +345 -0
- package/dist/i18n/labels.d.ts +4 -15
- package/dist/i18n/labels.js +33 -53
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +51 -122
- package/dist/i18n/messages.js +58 -131
- package/dist/i18n/shortcuts.d.ts +0 -1
- package/dist/i18n/shortcuts.js +2 -11
- package/dist/index.d.ts +4 -2
- package/dist/index.js +5 -3
- package/package.json +30 -5
- package/dist/canvas/Canvas.svelte +0 -13363
- package/dist/canvas/Canvas.svelte.d.ts +0 -286
- package/dist/canvas/CanvasToolbar.svelte +0 -1498
- package/dist/canvas/CanvasToolbar.svelte.d.ts +0 -69
- package/dist/canvas/ContextMenu.svelte +0 -305
- package/dist/canvas/ContextMenu.svelte.d.ts +0 -42
- package/dist/canvas/PanZoomPanel.svelte +0 -478
- package/dist/canvas/PanZoomPanel.svelte.d.ts +0 -38
- package/dist/canvas/WidgetSelectionLayer.svelte +0 -156
- package/dist/canvas/WidgetSelectionLayer.svelte.d.ts +0 -11
- package/dist/canvas/props-panel/PropsPanel.svelte +0 -2075
- package/dist/canvas/props-panel/PropsPanel.svelte.d.ts +0 -84
- package/dist/canvas/props-panel/TextPropsICSection.svelte +0 -242
- package/dist/canvas/props-panel/TextPropsICSection.svelte.d.ts +0 -40
- package/dist/canvas/shadowRootText.d.ts +0 -5
- package/dist/canvas/shadowRootText.js +0 -43
- package/dist/canvas/shapes/FrameShape.d.ts +0 -97
- package/dist/canvas/shapes/FrameShape.js +0 -953
- package/dist/canvas/shapes/ImageShape.d.ts +0 -47
- package/dist/canvas/shapes/ImageShape.js +0 -339
- package/dist/canvas/shapes/WidgetShape.d.ts +0 -30
- package/dist/canvas/shapes/WidgetShape.js +0 -200
- package/dist/canvas/widgetPreviewGeometry.d.ts +0 -19
- package/dist/canvas/widgetPreviewGeometry.js +0 -66
- package/dist/i18n/shapeWords.d.ts +0 -30
- package/dist/i18n/shapeWords.js +0 -36
- package/dist/i18n/slots.d.ts +0 -20
- package/dist/i18n/slots.js +0 -40
package/README.md
CHANGED
|
@@ -49,8 +49,8 @@ canvas is open:
|
|
|
49
49
|
locale="de"
|
|
50
50
|
messages={{
|
|
51
51
|
'canvas.tool.draw': 'Zeichnen',
|
|
52
|
-
'canvas.tool.
|
|
53
|
-
'canvas.zoom.
|
|
52
|
+
'canvas.tool.undo': 'Rückgängig',
|
|
53
|
+
'canvas.zoom.resetLabel': 'Zoom auf 100 % zurücksetzen',
|
|
54
54
|
}}
|
|
55
55
|
/>
|
|
56
56
|
```
|
|
@@ -68,22 +68,23 @@ canvas is open:
|
|
|
68
68
|
import { CANVAS_MESSAGES } from '@widgetic/canvas';
|
|
69
69
|
|
|
70
70
|
console.log(Object.keys(CANVAS_MESSAGES).length); // every word of the canvas
|
|
71
|
-
console.log(CANVAS_MESSAGES['canvas.zoom.
|
|
71
|
+
console.log(CANVAS_MESSAGES['canvas.zoom.fitLabel']); // 'Fit content to view'
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
A page that loads the canvas on demand can read the words without loading it: `@widgetic/canvas/i18n` has
|
|
75
75
|
`CANVAS_MESSAGES` and `checkCanvasMessages` and nothing else, so it brings the translator and the list of words, not
|
|
76
|
-
|
|
76
|
+
the canvas itself.
|
|
77
77
|
|
|
78
78
|
| Keys start with | The words of |
|
|
79
79
|
| --- | --- |
|
|
80
|
-
| `canvas.state
|
|
81
|
-
| `canvas.
|
|
82
|
-
| `canvas.
|
|
83
|
-
| `canvas.
|
|
80
|
+
| `canvas.state.` | "Loading canvas…", the line when the canvas could not start, the name of the board for a screen reader, and the notice when a saved canvas cannot be opened |
|
|
81
|
+
| `canvas.hint.` | the hint on an empty board |
|
|
82
|
+
| `canvas.defaults.`, `canvas.draw.` | what new things start with ("Type here", "Untitled Shape"), and the words a widget card draws (its name when it has none, "Widget preview") |
|
|
83
|
+
| `canvas.toolbar.`, `canvas.tool.`, `canvas.menu.`, `canvas.category.`, `canvas.shape.` | the toolbar: the tools and their hints, the menu of shapes, its groups, and the name of every shape in it |
|
|
84
|
+
| `canvas.action.`, `canvas.layer.` | cut, copy, paste, group, and the order of the layers (the context menu) |
|
|
84
85
|
| `canvas.shortcuts.`, `canvas.key.` | the list of keyboard shortcuts and the names of keys that are words ("Ctrl/Cmd", "Del", "Space") |
|
|
85
|
-
| `canvas.zoom.` | the
|
|
86
|
-
| `canvas.
|
|
86
|
+
| `canvas.zoom.` | the zoom control |
|
|
87
|
+
| `canvas.panel.`, `canvas.type.`, `canvas.widget.`, `canvas.control.` | the selection panel: its sections, what the selected thing is called, the widget actions, and the colour and text controls |
|
|
87
88
|
|
|
88
89
|
### Writing a message
|
|
89
90
|
|
|
@@ -91,7 +92,7 @@ A message is text. Two kinds of `{...}` have a meaning:
|
|
|
91
92
|
|
|
92
93
|
| Write | It shows |
|
|
93
94
|
| --- | --- |
|
|
94
|
-
| `{name}` | a value the canvas puts in (`'canvas.
|
|
95
|
+
| `{name}` | a value the canvas puts in (`'canvas.type.drawingOf': '{name} (Drawing)'`). A number is written the way the locale writes numbers. |
|
|
95
96
|
| `{count, plural, one {# child} other {# children}}` | the branch that fits the number in the page's language. `other` is required; `=0 {none}` matches exactly 0; `#` is the number. A language with more forms says so: Polish uses `one`, `few`, `many` and `other`. |
|
|
96
97
|
|
|
97
98
|
`\{`, `\}`, `\#` and `\\` write that character itself. Each English message names the values it is given: a translation
|
|
@@ -119,42 +120,110 @@ console says `[Canvas] ...` once.
|
|
|
119
120
|
|
|
120
121
|
### What stays as it is
|
|
121
122
|
|
|
122
|
-
- **Words that belong to someone else.** The names of widgets
|
|
123
|
-
|
|
124
|
-
- **What a new thing starts with
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
- **Words
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
than its box. A shape that is not on a canvas yet speaks English.
|
|
131
|
-
- **The one dialog.** When a picture cannot be loaded from an address, the canvas asks the browser to say so with its
|
|
132
|
-
own `alert`: the words are yours, the dialog is the browser's.
|
|
123
|
+
- **Words that belong to someone else.** The names of widgets and files, and what people typed into a text, are shown
|
|
124
|
+
as they were written.
|
|
125
|
+
- **What a new thing starts with.** A new text starts empty and shows "Type here" until something is typed; a selection
|
|
126
|
+
that becomes a widget is sent to your `onConvertToWidget` under the name "Untitled Shape" when it has none. Both are
|
|
127
|
+
messages, said in the language of the canvas they are on.
|
|
128
|
+
- **Words a widget card draws** (its name, "Widget preview" when it has no picture yet) are read from the canvas the card
|
|
129
|
+
is on and shown again whenever the language changes. They are never written into the saved canvas, and the picture
|
|
130
|
+
sent to the AI says them in the same language.
|
|
133
131
|
- **Names the canvas saves.** The groups of the shape library (`Geometric Shapes`, `Symbol Shapes` …) and a shape's key
|
|
134
132
|
are data a saved canvas knows its shapes by, and the descriptions of shapes the canvas hands to your
|
|
135
133
|
`onRecognizeStroke` (`rectangle or square`, `oval (ellipse)` …) are written for the recognizer, not for a screen: they
|
|
136
134
|
stay English. Each screen says the groups and the shapes through a message (`canvas.category.*`, `canvas.shape.*`).
|
|
137
135
|
- **Keys.** Names of keys that are words (`Ctrl/Cmd`, `Del`, `Click`) are messages, so a language can write "Strg" or
|
|
138
|
-
"Entf". Letters and symbols (`V`, `↑`, `]`) are the same on every keyboard, and the `⌘` glyphs in the
|
|
139
|
-
|
|
140
|
-
- **Right to left.** The canvas has no prop for it: its toolbar, the
|
|
141
|
-
out with logical sides (`start` and `end`, never `left` and `right`), so they start at the start of the line wherever
|
|
142
|
-
screen around the canvas is read right to left (the widget creator sets that on its root). The drawing board
|
|
143
|
-
(
|
|
144
|
-
the page, stay left to right.
|
|
145
|
-
|
|
146
|
-
|
|
136
|
+
"Entf". Letters and symbols (`V`, `↑`, `]`) are the same on every keyboard, and the `⌘` glyphs in the menus are the
|
|
137
|
+
Mac key caps.
|
|
138
|
+
- **Right to left.** The canvas has no prop for it: its toolbar, the selection panel, the menus and the lists are laid
|
|
139
|
+
out with logical sides (`start` and `end`, never `left` and `right`), so they start at the start of the line wherever
|
|
140
|
+
the screen around the canvas is read right to left (the widget creator sets that on its root). The drawing board
|
|
141
|
+
itself (`dir="ltr"`), the widgets drawn on it and the three text alignment buttons, whose left, centre and right are
|
|
142
|
+
sides of the page, stay left to right. A text on the board is written the way its first letter is (Hebrew and Arabic
|
|
143
|
+
from right to left), on the board, in the field it is typed in and in the picture sent to the AI.
|
|
144
|
+
`tests/canvas-direction.test.mjs` keeps it so. For a language written right to left a name that is put inside a
|
|
145
|
+
sentence sits between two invisible marks (Unicode isolates U+2068 and U+2069, made by the shared translator), so the
|
|
146
|
+
words around it cannot turn it around; a test that compares text has to leave them out.
|
|
147
|
+
- **The design system.** The canvas needs `@widgetic/design-system` **0.5.23 or newer**: the translator comes from
|
|
148
|
+
`@widgetic/design-system/i18n`, the same one the File Browser, the editor and the chat use, and the toolbar parts
|
|
149
|
+
(`IconButton`, `StepperButton`, the soft `Input`) first shipped in 0.5.23.
|
|
147
150
|
|
|
148
151
|
A part used on its own (a `ColorIC` or a `TextAlignIC` outside a `Canvas`) speaks English; call
|
|
149
152
|
`provideCanvasLanguage({ locale, messages })` in the component that holds it to give it a language. Inside a `Canvas` it
|
|
150
153
|
reads the language of that canvas, so two canvases on one page can speak two languages.
|
|
151
154
|
|
|
152
|
-
##
|
|
155
|
+
## How the canvas works
|
|
153
156
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
The canvas is a Svelte DOM canvas: every shape on the board is an element (an `<svg>`, a text block, an image, a widget
|
|
158
|
+
card) inside one layer that is moved and scaled as a whole, so the browser does the drawing, the text and the zoom. There
|
|
159
|
+
is no drawing library underneath. What a page sees is unchanged: `Canvas` takes the same props and exports the same
|
|
160
|
+
functions as before, and sends the same two events on `window`.
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
Canvas (DomCanvas.svelte, the one public component: props in, exported functions out)
|
|
164
|
+
└─ CanvasHost (plain TypeScript: props, autosave, widget cards, conversions, the page's callbacks)
|
|
165
|
+
└─ EngineCore (the scene, the selection, the history, the viewport; no DOM, runs in Node)
|
|
166
|
+
├─ PointerController (what a press, a move and a release do, by tool)
|
|
167
|
+
└─ keyboard routing (the shortcuts)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
The saved canvas is a versioned document (`CANVAS_DOCUMENT_VERSION = 2`): a flat, z-ordered list of shapes (`rect`,
|
|
171
|
+
`ellipse`, `path`, `text`, `image`, `widget`, `group`). The keys a page reads out of it (`canvas.objects`, `type`,
|
|
172
|
+
`_widgetId`, `_isWidgetImage`) are unchanged. A canvas saved by the old drawing-library engine is not read: it opens
|
|
173
|
+
empty with a notice and is left as it is until something new is added.
|
|
174
|
+
|
|
175
|
+
**The pencil is a brush.** A stroke is thicker where the hand slows down (a pen's own pressure draws it when the device reports
|
|
176
|
+
one), a click is a round dot, **Shift** draws a straight line, and a resize makes a stroke longer, never fatter. A board saves
|
|
177
|
+
each stroke as its line and its pressures (`ink`) and draws the outline again when it is read.
|
|
178
|
+
|
|
179
|
+
**An arrow is two points and a bend.** Its open head keeps its size when the arrow is stretched, a selected arrow has a handle
|
|
180
|
+
on each end and one in the middle that bends it (**Shift** holds the direction to steps of 15°), and a board saves it as
|
|
181
|
+
`arrow` and draws the outline again when it is read. An arrow does not attach to a shape. **The eraser marks** the shapes the
|
|
182
|
+
pointer passes over, dimmed, and removes them all in one step on release (**Esc** leaves them).
|
|
183
|
+
|
|
184
|
+
**The toolbar and the zoom control stand at one of eight places:** `toolbarPosition` and `panZoomPosition` take `TL` `TC` `TR`
|
|
185
|
+
`CL` `CR` `BL` `BC` `BR` (the defaults, `BC` and `BL`, are the Widgetic layout; the Shopify package passes
|
|
186
|
+
`toolbarPosition="BL"` and `panZoomPosition="BR"`).
|
|
187
|
+
|
|
188
|
+
**Freehand shape snap (off by default).** A stroke that is a clean rectangle, circle, oval, triangle, diamond or hexagon
|
|
189
|
+
stays as it was drawn unless the page asks: pass `shapeSnap={true}` on `<Canvas>` and a finished Draw stroke is replaced by
|
|
190
|
+
that shape when the geometry is confident (a stroke it cannot decide is handed to the page's optional `onRecognizeStroke`).
|
|
191
|
+
The package constant `CANVAS_SHAPE_SNAP_ENABLED` stays `false`: it is the one line that turns the snap on for every page, or
|
|
192
|
+
back off.
|
|
193
|
+
|
|
194
|
+
[`__docs/dom-canvas.md`](./__docs/dom-canvas.md) explains the parts, the host contract, the document, the tools and the
|
|
195
|
+
tests. The engine this one replaced is gone from the package, with no fallback to it: no dependency, no reader for its saved
|
|
196
|
+
files, and no document about it. Its specs and progress log are only in the git history (`git show d824044:__specs/<file>`).
|
|
197
|
+
|
|
198
|
+
## Tests
|
|
199
|
+
|
|
200
|
+
`npm test` runs everything in Node (no browser): the engine and the host against a fake page, the document codec, the
|
|
201
|
+
message catalog and the audits that hold every visible word to a message and every side to `start` and `end`.
|
|
202
|
+
`npm run check` type-checks the Svelte files.
|
|
203
|
+
|
|
204
|
+
The browser checks live in `scripts/browser/` (Playwright and Chrome are borrowed from `../ui-sdk/modules`, nothing is
|
|
205
|
+
installed here). They are not npm scripts: start the dev server (`npm run dev`, port 5181) and run one against it.
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/conformance.mjs # the host contract, as a page uses it
|
|
209
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/interaction.mjs # a real mouse and keyboard: tools, gestures, keys
|
|
210
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/shadow.mjs # inside a shadow root, as the UI SDK mounts it
|
|
211
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/widgetCard.mjs # a live widget laid over a card
|
|
212
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/touch.mjs # touch and pen
|
|
213
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/responsive.mjs # the Figma layouts at desktop, tablet and phone widths
|
|
214
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/a11y.mjs # the accessibility tree, focus, reduced motion
|
|
215
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/chrome.mjs # where the toolbar and the zoom control stand, at each of eight places
|
|
216
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/eraser.mjs # the eraser marks, then removes on release
|
|
217
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/brush.mjs # the pencil's brush
|
|
218
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/handles.mjs # handles and rotation (a text is not turned)
|
|
219
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/marquee.mjs # what a marquee would take is outlined while it is dragged
|
|
220
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/outlinePixels.mjs # ... and that outline is the pointer's, pixel for pixel
|
|
221
|
+
ORIGIN=http://127.0.0.1:5181 node scripts/browser/arrows.mjs # arrows and their handles
|
|
222
|
+
npm run build && npx vite preview --port 5182 # a production build, in one terminal ...
|
|
223
|
+
node scripts/browser/stress.mjs # ... and the frame cost, in another
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Each prints one line per check and exits 1 when one fails. `__docs/dom-canvas.md` says what each holds.
|
|
158
227
|
|
|
159
228
|
## Publishing
|
|
160
229
|
|