@widgetic/canvas 0.5.44 → 0.5.45

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.
Files changed (160) hide show
  1. package/dist/canvas/DomCanvas.svelte +52 -3
  2. package/dist/canvas/DomCanvas.svelte.d.ts +59 -34
  3. package/dist/canvas/autosaveScheduler.js +89 -37
  4. package/dist/canvas/boardFrame.js +1 -1
  5. package/dist/canvas/boardSurface.js +1 -1
  6. package/dist/canvas/canvasLogger.js +19 -7
  7. package/dist/canvas/chromeLayout.js +21 -19
  8. package/dist/canvas/eventScope.js +14 -10
  9. package/dist/canvas/host/CanvasHost.d.ts +68 -1
  10. package/dist/canvas/host/CanvasHost.js +1901 -1407
  11. package/dist/canvas/host/CanvasHostApi.d.ts +2 -2
  12. package/dist/canvas/host/CanvasHostApi.js +28 -5
  13. package/dist/canvas/host/boardFiles.d.ts +90 -0
  14. package/dist/canvas/host/boardFiles.js +155 -0
  15. package/dist/canvas/host/browserServices.d.ts +17 -0
  16. package/dist/canvas/host/browserServices.js +211 -65
  17. package/dist/canvas/host/conversion.js +170 -82
  18. package/dist/canvas/host/hostObject.js +7 -7
  19. package/dist/canvas/host/nearCards.js +21 -18
  20. package/dist/canvas/host/pageEvents.js +5 -5
  21. package/dist/canvas/host/pictureSaves.js +11 -9
  22. package/dist/canvas/host/screenRects.js +31 -28
  23. package/dist/canvas/host/storedPictures.js +243 -149
  24. package/dist/canvas/host/strokeSnap.js +143 -88
  25. package/dist/canvas/index.d.ts +1 -0
  26. package/dist/canvas/openMarks.js +2 -2
  27. package/dist/canvas/outsideClickDeselect.js +7 -6
  28. package/dist/canvas/panZoomPosition.js +2 -2
  29. package/dist/canvas/preferredTextFont.js +25 -13
  30. package/dist/canvas/shapes/ShapeLibrary.js +148 -138
  31. package/dist/canvas/shapes/shapeImageStore.js +4 -4
  32. package/dist/canvas/shapes/strokeShapeSnap.js +233 -188
  33. package/dist/canvas/toolbarPosition.js +2 -2
  34. package/dist/canvas/ui/CanvasContextMenu.svelte +7 -0
  35. package/dist/canvas/ui/CanvasToolbar.svelte +4 -1
  36. package/dist/canvas/ui/CanvasToolbar.svelte.d.ts +2 -0
  37. package/dist/canvas/ui/SelectionPanel.svelte +78 -17
  38. package/dist/canvas/ui/ShapesMenu.svelte +65 -31
  39. package/dist/canvas/ui/ShapesMenu.svelte.d.ts +2 -0
  40. package/dist/canvas/ui/ShortcutTooltip.svelte +64 -0
  41. package/dist/canvas/ui/ShortcutTooltip.svelte.d.ts +24 -0
  42. package/dist/canvas/ui/ToolButton.svelte +34 -55
  43. package/dist/canvas/ui/ToolButton.svelte.d.ts +4 -1
  44. package/dist/canvas/ui/colorModel.js +32 -21
  45. package/dist/canvas/ui/colorPickerMessages.js +5 -5
  46. package/dist/canvas/ui/floatingCard.d.ts +26 -4
  47. package/dist/canvas/ui/floatingCard.js +43 -21
  48. package/dist/canvas/ui/floatingLayer.js +6 -5
  49. package/dist/canvas/ui/icons.d.ts +1 -1
  50. package/dist/canvas/ui/icons.js +1 -1
  51. package/dist/canvas/ui/keyHints.js +11 -9
  52. package/dist/canvas/ui/popoverSide.js +3 -2
  53. package/dist/canvas/ui/selectionTraits.d.ts +12 -0
  54. package/dist/canvas/ui/selectionTraits.js +66 -35
  55. package/dist/canvas/ui/sizeLabelVisibility.d.ts +4 -2
  56. package/dist/canvas/ui/sizeLabelVisibility.js +5 -5
  57. package/dist/canvas/view/CanvasStage.svelte +7 -2
  58. package/dist/canvas/view/CanvasStage.svelte.d.ts +2 -0
  59. package/dist/canvas/view/SelectionOverlay.svelte +17 -10
  60. package/dist/canvas/view/WidgetChromeLayer.svelte +15 -3
  61. package/dist/canvas/view/erasingMarks.js +7 -7
  62. package/dist/canvas/view/geometry.d.ts +1 -1
  63. package/dist/canvas/view/geometry.js +90 -71
  64. package/dist/canvas/view/liftedScene.js +36 -24
  65. package/dist/canvas/view/mountedScene.js +79 -76
  66. package/dist/components/CanvasBoardPoster.svelte +206 -0
  67. package/dist/components/CanvasBoardPoster.svelte.d.ts +17 -0
  68. package/dist/components/CanvasToolbarPlaceholder.svelte +115 -0
  69. package/dist/components/CanvasToolbarPlaceholder.svelte.d.ts +9 -0
  70. package/dist/components/index.d.ts +7 -0
  71. package/dist/components/index.js +8 -0
  72. package/dist/components/preferenceStorage.js +2 -2
  73. package/dist/engine/EngineCore.d.ts +37 -2
  74. package/dist/engine/EngineCore.js +946 -768
  75. package/dist/engine/codec/canvasDocument.d.ts +7 -0
  76. package/dist/engine/codec/canvasDocument.js +172 -186
  77. package/dist/engine/codec/hostReadableKeys.js +1 -1
  78. package/dist/engine/core/arrange.js +38 -26
  79. package/dist/engine/core/arrow.d.ts +18 -8
  80. package/dist/engine/core/arrow.js +109 -84
  81. package/dist/engine/core/arrowBinding.d.ts +1 -1
  82. package/dist/engine/core/arrowBinding.js +126 -101
  83. package/dist/engine/core/arrowBindingRecords.d.ts +9 -3
  84. package/dist/engine/core/arrowBindingRecords.js +48 -29
  85. package/dist/engine/core/brush.d.ts +8 -0
  86. package/dist/engine/core/brush.js +98 -78
  87. package/dist/engine/core/cameraMove.d.ts +6 -0
  88. package/dist/engine/core/cameraMove.js +56 -38
  89. package/dist/engine/core/defaults.js +51 -90
  90. package/dist/engine/core/freehand.js +163 -147
  91. package/dist/engine/core/geometry.js +54 -47
  92. package/dist/engine/core/history.js +55 -38
  93. package/dist/engine/core/hitTest.js +81 -68
  94. package/dist/engine/core/matrix.js +20 -18
  95. package/dist/engine/core/pathData.js +210 -183
  96. package/dist/engine/core/rotationReset.js +6 -5
  97. package/dist/engine/core/scene.d.ts +22 -0
  98. package/dist/engine/core/scene.js +288 -139
  99. package/dist/engine/core/scribble.js +84 -59
  100. package/dist/engine/core/shapePaths.js +15 -12
  101. package/dist/engine/core/shapeTools.js +63 -72
  102. package/dist/engine/core/snapping.js +117 -65
  103. package/dist/engine/core/style.d.ts +10 -0
  104. package/dist/engine/core/style.js +82 -33
  105. package/dist/engine/core/transform.d.ts +6 -0
  106. package/dist/engine/core/transform.js +103 -83
  107. package/dist/engine/core/types.d.ts +7 -0
  108. package/dist/engine/core/types.js +4 -4
  109. package/dist/engine/core/viewport.js +36 -23
  110. package/dist/engine/input/PointerController.d.ts +15 -1
  111. package/dist/engine/input/PointerController.js +547 -476
  112. package/dist/engine/input/arrowHandles.js +12 -12
  113. package/dist/engine/input/gestures.d.ts +3 -1
  114. package/dist/engine/input/gestures.js +340 -266
  115. package/dist/engine/input/hoverCursor.js +1 -1
  116. package/dist/engine/input/keyboard.d.ts +22 -3
  117. package/dist/engine/input/keyboard.js +131 -32
  118. package/dist/engine/input/selectionHandles.js +50 -45
  119. package/dist/engine/input/types.d.ts +7 -0
  120. package/dist/engine/input/types.js +1 -1
  121. package/dist/engine/render/rasterize.js +158 -86
  122. package/dist/engine/state.d.ts +18 -0
  123. package/dist/engine/state.js +25 -4
  124. package/dist/engine/text/layoutText.js +62 -43
  125. package/dist/engine/text/textMetrics.js +10 -8
  126. package/dist/engine/widgets.js +137 -101
  127. package/dist/fonts/interFont.js +83 -30
  128. package/dist/fonts/workspaceFonts.d.ts +6 -0
  129. package/dist/fonts/workspaceFonts.js +108 -34
  130. package/dist/i18n/labels.js +4 -4
  131. package/dist/i18n/language.d.ts +3 -3
  132. package/dist/i18n/language.js +4 -4
  133. package/dist/i18n/messages.d.ts +6 -0
  134. package/dist/i18n/messages.js +7 -1
  135. package/dist/i18n/shortcuts.d.ts +6 -4
  136. package/dist/i18n/shortcuts.js +30 -26
  137. package/dist/index.d.ts +1 -0
  138. package/dist/poster/boardPlacement.d.ts +80 -0
  139. package/dist/poster/boardPlacement.js +140 -0
  140. package/dist/poster/boardPoster.d.ts +80 -0
  141. package/dist/poster/boardPoster.js +251 -0
  142. package/dist/poster/paintBoardPoster.d.ts +49 -0
  143. package/dist/poster/paintBoardPoster.js +112 -0
  144. package/dist/poster/posterPictures.d.ts +32 -0
  145. package/dist/poster/posterPictures.js +138 -0
  146. package/dist/settings/workspaceToolSettings.d.ts +6 -0
  147. package/dist/settings/workspaceToolSettings.js +58 -34
  148. package/dist/tools/components/catalog.js +74 -64
  149. package/dist/tools/components/grouping.js +28 -6
  150. package/dist/tools/definitions.js +31 -9
  151. package/dist/tools/executors.js +214 -106
  152. package/dist/tools/hostAdapter.d.ts +5 -1
  153. package/dist/tools/hostAdapter.js +15 -11
  154. package/dist/tools/sceneSummary.js +57 -43
  155. package/dist/tools/sketchIntent.js +21 -13
  156. package/dist/tools/styleArguments.d.ts +35 -0
  157. package/dist/tools/styleArguments.js +93 -0
  158. package/dist/tools/types.d.ts +26 -1
  159. package/dist/tools/types.js +2 -1
  160. package/package.json +1 -1
@@ -19,12 +19,12 @@
19
19
  */
20
20
  import { ZOOM_CONTROL_MIN_WIDTHS, ZOOM_CONTROL_VISIBLE_FROM } from './ui/floatingCard.js';
21
21
  /** The eight places a card can stand. */
22
- export const CHROME_ANCHORS = ['TL', 'TC', 'TR', 'CL', 'CR', 'BL', 'BC', 'BR'];
22
+ export var CHROME_ANCHORS = ['TL', 'TC', 'TR', 'CL', 'CR', 'BL', 'BC', 'BR'];
23
23
  /**
24
24
  * The classes that put an anchor in place, 16 px from the edges as the Figma design has it. Written out in full, so that
25
25
  * the stylesheet of a page that installs the canvas picks every one of them up when it reads this file.
26
26
  */
27
- const ANCHOR_CLASSES = {
27
+ var ANCHOR_CLASSES = {
28
28
  // rtl-ok: the page names a corner of the screen, as it is drawn
29
29
  TL: 'absolute top-4 left-4',
30
30
  TC: 'absolute top-4 left-1/2 -translate-x-1/2',
@@ -45,9 +45,9 @@ const ANCHOR_CLASSES = {
45
45
  * are against), a column on a side edge (centred on each other, so the layout does not depend on the direction of the
46
46
  * page). A slot never grows larger than the board minus its 16 px edges.
47
47
  */
48
- const SLOT_TOP_ROW_CLASSES = 'flex flex-row items-start gap-2 max-w-[calc(100%-2rem)]';
49
- const SLOT_BOTTOM_ROW_CLASSES = 'flex flex-row items-end gap-2 max-w-[calc(100%-2rem)]';
50
- const SLOT_COLUMN_CLASSES = 'flex flex-col items-center gap-2 max-h-[calc(100%-2rem)]';
48
+ var SLOT_TOP_ROW_CLASSES = 'flex flex-row items-start gap-2 max-w-[calc(100%-2rem)]';
49
+ var SLOT_BOTTOM_ROW_CLASSES = 'flex flex-row items-end gap-2 max-w-[calc(100%-2rem)]';
50
+ var SLOT_COLUMN_CLASSES = 'flex flex-col items-center gap-2 max-h-[calc(100%-2rem)]';
51
51
  /** The anchor to use for what a page passed: anything that is not one of the eight is the fallback, so a mistyped option never takes a card off the board. */
52
52
  export function normalizeAnchor(value, fallback) {
53
53
  return CHROME_ANCHORS.includes(value) ? value : fallback;
@@ -77,18 +77,19 @@ export function anchorClasses(anchor) {
77
77
  * from one anchor to another does not make the other one start again.
78
78
  */
79
79
  export function chromeSlots(toolbarAnchor, zoomAnchor, shown) {
80
- const slots = [];
81
- for (const anchor of CHROME_ANCHORS) {
82
- const cards = [];
80
+ var slots = [];
81
+ for (var _i = 0, CHROME_ANCHORS_1 = CHROME_ANCHORS; _i < CHROME_ANCHORS_1.length; _i++) {
82
+ var anchor = CHROME_ANCHORS_1[_i];
83
+ var cards = [];
83
84
  if (shown.toolbar && toolbarAnchor === anchor)
84
85
  cards.push('toolbar');
85
86
  if (shown.zoom && zoomAnchor === anchor)
86
87
  cards.push('zoom');
87
88
  if (cards.length === 0)
88
89
  continue;
89
- const vertical = isSideAnchor(anchor);
90
- const layout = vertical ? SLOT_COLUMN_CLASSES : isTopAnchor(anchor) ? SLOT_TOP_ROW_CLASSES : SLOT_BOTTOM_ROW_CLASSES;
91
- slots.push({ anchor, cards, vertical, classes: `${ANCHOR_CLASSES[anchor]} ${layout}` });
90
+ var vertical = isSideAnchor(anchor);
91
+ var layout = vertical ? SLOT_COLUMN_CLASSES : isTopAnchor(anchor) ? SLOT_TOP_ROW_CLASSES : SLOT_BOTTOM_ROW_CLASSES;
92
+ slots.push({ anchor: anchor, cards: cards, vertical: vertical, classes: "".concat(ANCHOR_CLASSES[anchor], " ").concat(layout) });
92
93
  }
93
94
  return slots;
94
95
  }
@@ -101,8 +102,8 @@ export function zoomVisibilityClasses(toolbarAnchor, zoomAnchor) {
101
102
  // A card on a side edge shares no line with a card on the top or the bottom edge, and neither do two cards on different edges.
102
103
  if (isSideAnchor(toolbarAnchor) || isSideAnchor(zoomAnchor) || toolbarAnchor[0] !== zoomAnchor[0])
103
104
  return ZOOM_CONTROL_VISIBLE_FROM.alone;
104
- const toolbarColumn = toolbarAnchor[1];
105
- const zoomColumn = zoomAnchor[1];
105
+ var toolbarColumn = toolbarAnchor[1];
106
+ var zoomColumn = zoomAnchor[1];
106
107
  if (toolbarColumn === zoomColumn)
107
108
  return ZOOM_CONTROL_VISIBLE_FROM.sameSlot;
108
109
  if (toolbarColumn === 'C')
@@ -113,7 +114,7 @@ export function zoomVisibilityClasses(toolbarAnchor, zoomAnchor) {
113
114
  }
114
115
  /** Minimum board width (px) before the zoom card is drawn; pairs with scoped `@container` CSS in `ZoomControl.svelte`. */
115
116
  export function zoomVisibilityMinWidth(toolbarAnchor, zoomAnchor) {
116
- const className = zoomVisibilityClasses(toolbarAnchor, zoomAnchor);
117
+ var className = zoomVisibilityClasses(toolbarAnchor, zoomAnchor);
117
118
  if (className === ZOOM_CONTROL_VISIBLE_FROM.alone)
118
119
  return ZOOM_CONTROL_MIN_WIDTHS.alone;
119
120
  if (className === ZOOM_CONTROL_VISIBLE_FROM.sameSlot)
@@ -130,18 +131,19 @@ export function zoomVisibilityMinWidth(toolbarAnchor, zoomAnchor) {
130
131
  * out in full, so that the stylesheet of a page that installs the canvas picks both up.
131
132
  */
132
133
  export function selectorIndicatorTopClassFor(slots) {
133
- return slots.some((slot) => slot.anchor === 'TC') ? 'top-16' : 'top-4';
134
+ return slots.some(function (slot) { return slot.anchor === 'TC'; }) ? 'top-16' : 'top-4';
134
135
  }
135
- const TOP_PANEL_CONFLICT_ANCHORS = new Set(['TC', 'TR']);
136
+ var TOP_PANEL_CONFLICT_ANCHORS = new Set(['TC', 'TR']);
136
137
  /**
137
138
  * What the panel keeps clear of, for the slots that are drawn. The selector's indicator, when it is shown, stands across the
138
139
  * top centre (it can be as wide as the board), so the panel starts below it as it does below a card of the top edge.
139
140
  */
140
- export function panelClearanceFor(slots, options = {}) {
141
- const rightEdgeSlot = slots.find((slot) => slot.anchor === 'CR');
141
+ export function panelClearanceFor(slots, options) {
142
+ if (options === void 0) { options = {}; }
143
+ var rightEdgeSlot = slots.find(function (slot) { return slot.anchor === 'CR'; });
142
144
  return {
143
145
  // Top-left chrome (e.g. zoom on the creator big page) does not overlap the top-right selection panel.
144
- belowTopCards: options.selectorIndicator === true || slots.some((slot) => TOP_PANEL_CONFLICT_ANCHORS.has(slot.anchor)),
146
+ belowTopCards: options.selectorIndicator === true || slots.some(function (slot) { return TOP_PANEL_CONFLICT_ANCHORS.has(slot.anchor); }),
145
147
  besideSideCard: rightEdgeSlot ? (rightEdgeSlot.cards.includes('toolbar') ? 'toolbar' : 'zoom') : null
146
148
  };
147
149
  }
@@ -16,9 +16,10 @@
16
16
  */
17
17
  /** The shadow root a node lives in, or null when it lives in the page itself (or is not in a tree at all). */
18
18
  export function getShadowRootOf(node) {
19
- const root = node?.getRootNode?.();
19
+ var _a;
20
+ var root = (_a = node === null || node === void 0 ? void 0 : node.getRootNode) === null || _a === void 0 ? void 0 : _a.call(node);
20
21
  // (`instanceof ShadowRoot` would not hold for a root made by another window, an iframe's, say.)
21
- const isShadowRoot = !!root && root.nodeType === 11 && 'host' in root;
22
+ var isShadowRoot = !!root && root.nodeType === 11 && 'host' in root;
22
23
  return isShadowRoot ? root : null;
23
24
  }
24
25
  /**
@@ -31,14 +32,14 @@ export function getShadowRootOf(node) {
31
32
  * Has to be called while the event is being dispatched (`composedPath()` is empty afterwards).
32
33
  */
33
34
  export function eventIsForScope(event, scopeNode) {
34
- const shadowRoot = getShadowRootOf(scopeNode);
35
+ var shadowRoot = getShadowRootOf(scopeNode);
35
36
  if (!shadowRoot)
36
37
  return true;
37
38
  return event.composedPath().includes(shadowRoot);
38
39
  }
39
40
  /** The element that has the focus in the tree `scopeNode` lives in: the page's, or the shadow root's own. */
40
41
  export function getFocusedElementIn(scopeNode) {
41
- const shadowRoot = getShadowRootOf(scopeNode);
42
+ var shadowRoot = getShadowRootOf(scopeNode);
42
43
  return shadowRoot ? shadowRoot.activeElement : document.activeElement;
43
44
  }
44
45
  /**
@@ -46,7 +47,8 @@ export function getFocusedElementIn(scopeNode) {
46
47
  * event from inside a shadow root; the first element of the path is the one that was pressed.
47
48
  */
48
49
  export function getEventOrigin(event) {
49
- const first = event.composedPath()[0] ?? event.target;
50
+ var _a;
51
+ var first = (_a = event.composedPath()[0]) !== null && _a !== void 0 ? _a : event.target;
50
52
  return first && first.nodeType === 1 ? first : null;
51
53
  }
52
54
  /**
@@ -64,7 +66,8 @@ export function eventWentThrough(event, element) {
64
66
  * page never sees it, and otherwise `document.body`.
65
67
  */
66
68
  export function getTransientHostFor(scopeNode) {
67
- return getShadowRootOf(scopeNode) ?? document.body;
69
+ var _a;
70
+ return (_a = getShadowRootOf(scopeNode)) !== null && _a !== void 0 ? _a : document.body;
68
71
  }
69
72
  /**
70
73
  * Whether the canvas whose element is `scopeNode` should take the keyboard back after the element that held it went away
@@ -76,14 +79,15 @@ export function getTransientHostFor(scopeNode) {
76
79
  * the shortcuts do not mind where the focus is, so there is nothing to do.
77
80
  */
78
81
  export function shouldTakeFocusBack(scopeNode) {
79
- const shadowRoot = getShadowRootOf(scopeNode);
82
+ var _a;
83
+ var shadowRoot = getShadowRootOf(scopeNode);
80
84
  if (!shadowRoot)
81
85
  return false;
82
86
  if (shadowRoot.activeElement)
83
87
  return false;
84
88
  // The focus in the tree the shadow root's host is in (the page's, or another shadow root's).
85
- const outerTree = shadowRoot.host.getRootNode();
86
- const focusOutside = outerTree.activeElement;
87
- const outerBody = outerTree.body ?? null;
89
+ var outerTree = shadowRoot.host.getRootNode();
90
+ var focusOutside = outerTree.activeElement;
91
+ var outerBody = (_a = outerTree.body) !== null && _a !== void 0 ? _a : null;
88
92
  return !focusOutside || focusOutside === shadowRoot.host || focusOutside === outerBody;
89
93
  }
@@ -16,7 +16,7 @@ import { EngineCore } from '../../engine/EngineCore.js';
16
16
  import type { ToolShortcut } from '../../engine/input/keyboard.js';
17
17
  import { PointerController } from '../../engine/input/PointerController.js';
18
18
  import type { TextLayout } from '../../engine/text/layoutText.js';
19
- import type { EngineState, ToolId } from '../../engine/state.js';
19
+ import type { EngineState, PenStyle, ToolId } from '../../engine/state.js';
20
20
  import { ConversionRegistry } from '../../engine/widgets.js';
21
21
  import type { WidgetMetadata } from '../../engine/widgets.js';
22
22
  import { type WorkspaceCanvasFont } from '../../fonts/workspaceFonts.js';
@@ -26,9 +26,11 @@ import type { ToolbarPosition } from '../toolbarPosition.js';
26
26
  import type { Translate as CatalogTranslate } from '@widgetic/design-system/i18n';
27
27
  import type { CanvasMessageKey } from '../../i18n/messages.js';
28
28
  import type { CanvasFlyOptions, CanvasMoveOptions, ObjectClickPayload, StrokeRecognizer } from '../types.js';
29
+ import type { BoardFilePicker, BoardLibraryFile, BoardPicture, BoardPictureLibraryFile } from './boardFiles.js';
29
30
  import type { LoadedImageFile } from './browserServices.js';
30
31
  import type { HostObject } from './hostObject.js';
31
32
  import type { ListWidgetScreenRectsOptions, ScreenRect, WidgetScreenRect } from './screenRects.js';
33
+ import type { CanvasToolAsset } from '../../tools/types.js';
32
34
  /** The words of the selector's indicator at the top of the board (the line that says how to use the selector). */
33
35
  export interface SelectorGuide {
34
36
  click: string;
@@ -104,6 +106,8 @@ export interface CanvasHostProps {
104
106
  onRecognizeStroke: StrokeRecognizer | null;
105
107
  onNonWidgetSelected: (() => void) | null;
106
108
  onWidgetShapeDuplicated: ((sourceWidgetId: string, clonedObject: any) => void) | null;
109
+ /** Whether widget cards can be duplicated/pasted on the board. Off in single-widget sketch canvases. */
110
+ allowWidgetDuplication: boolean;
107
111
  onWidgetShapeDeleting: ((widgetId: string) => Promise<boolean>) | null;
108
112
  onWidgetRename: ((widgetId: string, newName: string) => void) | null;
109
113
  onRefreshScreenshot: ((widgetId: string) => void) | null;
@@ -131,6 +135,21 @@ export interface CanvasHostProps {
131
135
  * page declares (the design system's `fonts.css` does), so it never requests a path of a page that is not ours.
132
136
  */
133
137
  interFontSources: readonly string[];
138
+ /**
139
+ * Whether the Shapes menu offers the person's file library (the File Browser of their workspace) before the Image entry. Off unless
140
+ * the page passes true. It needs `pickFiles`: with no picker there is nothing to open, and the entry is not shown.
141
+ */
142
+ showFileBrowser: boolean;
143
+ /**
144
+ * The page's File Browser (see `BoardFilePicker`). It opens in select state for pictures and vector files and answers with the
145
+ * files the person chose, which the board puts down. The page owns the browser, the workspace and a partner's media library.
146
+ */
147
+ pickFiles: BoardFilePicker | null;
148
+ /**
149
+ * Pictures the sketch assistant may put on the board by their id with the `add_asset` tool: the icons of the brand kit, the files
150
+ * of the person's library. The page decides the list (it knows the brand kit and the library); the board only draws what is named.
151
+ */
152
+ sketchAssets: readonly CanvasToolAsset[];
134
153
  }
135
154
  /** What each prop is until the page sets it (the values the canvas this one replaces had, but for `panZoomPosition`). */
136
155
  export declare const DEFAULT_HOST_PROPS: Readonly<CanvasHostProps>;
@@ -213,6 +232,18 @@ export declare class CanvasHost {
213
232
  setProps(patch: Partial<CanvasHostProps>): void;
214
233
  /** Persists tool style changes for this workspace (called from the selection panel). */
215
234
  persistWorkspaceStyle(patch: StylePatch): void;
235
+ /**
236
+ * Sets the pen, the line the Draw tool draws next (its colour, its width, how much of the board shows through it), and keeps it
237
+ * for this workspace, so the pen is the same when the page is opened again. The settings panel calls it while the Draw tool is
238
+ * chosen and nothing is selected, which is how the pen is set before a line is drawn. The pen is not on the board: nothing that
239
+ * is drawn already changes, and no step of the history is taken.
240
+ *
241
+ * `final` is false while a slider or a colour picker is still being dragged: the pen changes (the next line is drawn with it)
242
+ * and is kept, but the console has one line for the whole drag, written when it ends (`final`, with no patch for the pen).
243
+ */
244
+ changePenStyle(patch: Partial<PenStyle>, options?: {
245
+ final?: boolean;
246
+ }): void;
216
247
  /** The shell gives the host the words of the page's language. */
217
248
  setTranslator(translate: Translate): void;
218
249
  get ui(): HostUiState;
@@ -287,6 +318,12 @@ export declare class CanvasHost {
287
318
  onSelectSelectTool(): void;
288
319
  onSelectDrawTool(): void;
289
320
  onSelectEraseTool(): void;
321
+ /**
322
+ * The Text tool. The text is on the board the moment the tool is chosen: an empty text, shown as the placeholder prompt, in the
323
+ * middle of the view and ready to be typed in (its field has the focus, so the letters go straight into it). Escape takes it away
324
+ * and the tool with it; a press elsewhere on the board, while nothing is typed, places the text there instead (a drag gives it a
325
+ * width); a press on a text that is already there edits that one.
326
+ */
290
327
  onSelectTextTool(): void;
291
328
  onSelectArrowTool(): void;
292
329
  onSelectPanTool(): void;
@@ -357,6 +394,36 @@ export declare class CanvasHost {
357
394
  addImage(): Promise<void>;
358
395
  /** The SVG entry of the shapes menu: the same as `addImage`, but the chooser only offers vector files. */
359
396
  addSvg(): Promise<void>;
397
+ /**
398
+ * The Files entry of the Shapes menu: asks the page's File Browser (`pickFiles`) for pictures and vector files of the person's
399
+ * library, in the workspace they are in, and puts the chosen ones on the board as one step. Nothing happens when the page did not
400
+ * turn the entry on (`showFileBrowser`) or gave no picker, when the browser is open already, or when the person closes it without
401
+ * choosing. The picker's answer comes from the page, so it is checked before anything is read (see `normalizeLibraryFiles`).
402
+ */
403
+ openFileBrowser(): Promise<void>;
404
+ /**
405
+ * Puts files of the person's library on the board, side by side from `at` (the middle of the view by default), as one step. Each
406
+ * picture remembers the library file it is (`libraryFileId`, `libraryFileUrl`), so the page knows it is in the library already. A
407
+ * file that cannot be shown is left out (and said in the console).
408
+ */
409
+ insertPickedFiles(files: readonly BoardLibraryFile[], at?: Point): Promise<ObjectId[]>;
410
+ /**
411
+ * The pictures that are on the board and where each one comes from: what the page needs to put the ones its library does not have
412
+ * into it (see `setPictureLibraryFile`). Waits for the pictures that are still on their way from the page's store.
413
+ */
414
+ getBoardPictures(): Promise<BoardPicture[]>;
415
+ /**
416
+ * The same list as `getBoardPictures`, at once and without waiting: the pictures that are on the board now. A picture whose bytes
417
+ * are still on their way from the page's store has `src: null` for the moment. It is for the moment the board is about to change
418
+ * (the sketch becoming the widget's card) and the page has no time to wait, only to take note of what is there: it keeps each
419
+ * picture's `src` and puts the ones its library lacks into it afterwards, when the pictures are no longer on the board.
420
+ */
421
+ getLoadedBoardPictures(): BoardPicture[];
422
+ /**
423
+ * Remembers that the page's library has the picture of an object now (the page put it there). The picture itself, the history and
424
+ * the selection are left as they are; the board is saved with the new ids. True when something was written.
425
+ */
426
+ setPictureLibraryFile(objectId: ObjectId, file: BoardPictureLibraryFile): boolean;
360
427
  /** Reads picture files and puts them on the board, side by side from `at` (the middle of the view by default), as one step. */
361
428
  insertImageFiles(files: readonly (File | Blob)[], at?: Point): Promise<ObjectId[]>;
362
429
  insertLoadedImages(pictures: readonly LoadedImageFile[], at?: Point): ObjectId[];