@widgetic/canvas 0.5.43 → 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.
- package/dist/canvas/DomCanvas.svelte +56 -3
- package/dist/canvas/DomCanvas.svelte.d.ts +59 -28
- package/dist/canvas/autosaveScheduler.js +89 -37
- package/dist/canvas/boardFrame.js +1 -1
- package/dist/canvas/boardSurface.js +1 -1
- package/dist/canvas/canvasLogger.js +19 -7
- package/dist/canvas/chromeLayout.js +21 -19
- package/dist/canvas/eventScope.js +14 -10
- package/dist/canvas/host/CanvasHost.d.ts +87 -2
- package/dist/canvas/host/CanvasHost.js +1948 -1394
- package/dist/canvas/host/CanvasHostApi.d.ts +2 -2
- package/dist/canvas/host/CanvasHostApi.js +32 -5
- package/dist/canvas/host/boardFiles.d.ts +90 -0
- package/dist/canvas/host/boardFiles.js +155 -0
- package/dist/canvas/host/browserServices.d.ts +17 -0
- package/dist/canvas/host/browserServices.js +211 -65
- package/dist/canvas/host/conversion.js +170 -82
- package/dist/canvas/host/hostObject.js +7 -7
- package/dist/canvas/host/nearCards.js +21 -18
- package/dist/canvas/host/pageEvents.js +5 -5
- package/dist/canvas/host/pictureSaves.js +11 -9
- package/dist/canvas/host/screenRects.js +31 -28
- package/dist/canvas/host/storedPictures.js +243 -149
- package/dist/canvas/host/strokeSnap.js +143 -88
- package/dist/canvas/index.d.ts +2 -0
- package/dist/canvas/openMarks.js +2 -2
- package/dist/canvas/outsideClickDeselect.js +7 -6
- package/dist/canvas/panZoomPosition.js +2 -2
- package/dist/canvas/preferredTextFont.js +25 -13
- package/dist/canvas/shapes/ShapeLibrary.js +148 -138
- package/dist/canvas/shapes/shapeImageStore.js +4 -4
- package/dist/canvas/shapes/strokeShapeSnap.js +233 -188
- package/dist/canvas/toolbarPosition.js +2 -2
- package/dist/canvas/types.d.ts +17 -0
- package/dist/canvas/ui/CanvasContextMenu.svelte +7 -0
- package/dist/canvas/ui/CanvasToolbar.svelte +4 -1
- package/dist/canvas/ui/CanvasToolbar.svelte.d.ts +2 -0
- package/dist/canvas/ui/ColorField.svelte +7 -2
- package/dist/canvas/ui/SelectionPanel.svelte +105 -42
- package/dist/canvas/ui/ShapesMenu.svelte +65 -31
- package/dist/canvas/ui/ShapesMenu.svelte.d.ts +2 -0
- package/dist/canvas/ui/ShortcutTooltip.svelte +64 -0
- package/dist/canvas/ui/ShortcutTooltip.svelte.d.ts +24 -0
- package/dist/canvas/ui/ToolButton.svelte +35 -54
- package/dist/canvas/ui/ToolButton.svelte.d.ts +4 -1
- package/dist/canvas/ui/colorModel.js +32 -21
- package/dist/canvas/ui/colorPickerMessages.js +5 -5
- package/dist/canvas/ui/floatingCard.d.ts +26 -4
- package/dist/canvas/ui/floatingCard.js +43 -21
- package/dist/canvas/ui/floatingLayer.js +6 -5
- package/dist/canvas/ui/icons.d.ts +1 -1
- package/dist/canvas/ui/icons.js +1 -1
- package/dist/canvas/ui/keyHints.js +11 -9
- package/dist/canvas/ui/popoverSide.js +3 -2
- package/dist/canvas/ui/selectionTraits.d.ts +12 -0
- package/dist/canvas/ui/selectionTraits.js +66 -35
- package/dist/canvas/ui/sizeLabelVisibility.d.ts +4 -2
- package/dist/canvas/ui/sizeLabelVisibility.js +5 -5
- package/dist/canvas/view/CanvasStage.svelte +7 -2
- package/dist/canvas/view/CanvasStage.svelte.d.ts +2 -0
- package/dist/canvas/view/SelectionOverlay.svelte +17 -10
- package/dist/canvas/view/WidgetChromeLayer.svelte +15 -3
- package/dist/canvas/view/erasingMarks.js +7 -7
- package/dist/canvas/view/geometry.d.ts +1 -1
- package/dist/canvas/view/geometry.js +90 -71
- package/dist/canvas/view/liftedScene.js +36 -24
- package/dist/canvas/view/mountedScene.js +79 -76
- package/dist/components/CanvasBoardPoster.svelte +206 -0
- package/dist/components/CanvasBoardPoster.svelte.d.ts +17 -0
- package/dist/components/CanvasToolbarPlaceholder.svelte +115 -0
- package/dist/components/CanvasToolbarPlaceholder.svelte.d.ts +9 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.js +8 -0
- package/dist/components/preferenceStorage.js +2 -2
- package/dist/engine/EngineCore.d.ts +111 -2
- package/dist/engine/EngineCore.js +1013 -707
- package/dist/engine/codec/canvasDocument.d.ts +7 -0
- package/dist/engine/codec/canvasDocument.js +172 -186
- package/dist/engine/codec/hostReadableKeys.js +1 -1
- package/dist/engine/core/arrange.js +38 -26
- package/dist/engine/core/arrow.d.ts +18 -8
- package/dist/engine/core/arrow.js +109 -84
- package/dist/engine/core/arrowBinding.d.ts +1 -1
- package/dist/engine/core/arrowBinding.js +126 -101
- package/dist/engine/core/arrowBindingRecords.d.ts +9 -3
- package/dist/engine/core/arrowBindingRecords.js +48 -29
- package/dist/engine/core/brush.d.ts +8 -0
- package/dist/engine/core/brush.js +98 -78
- package/dist/engine/core/cameraMove.d.ts +73 -0
- package/dist/engine/core/cameraMove.js +172 -0
- package/dist/engine/core/defaults.js +51 -90
- package/dist/engine/core/freehand.js +163 -147
- package/dist/engine/core/geometry.js +54 -47
- package/dist/engine/core/history.js +55 -38
- package/dist/engine/core/hitTest.js +81 -68
- package/dist/engine/core/matrix.js +20 -18
- package/dist/engine/core/pathData.js +210 -183
- package/dist/engine/core/rotationReset.js +6 -5
- package/dist/engine/core/scene.d.ts +22 -0
- package/dist/engine/core/scene.js +288 -139
- package/dist/engine/core/scribble.js +84 -59
- package/dist/engine/core/shapePaths.js +15 -12
- package/dist/engine/core/shapeTools.js +63 -72
- package/dist/engine/core/snapping.js +117 -65
- package/dist/engine/core/style.d.ts +10 -0
- package/dist/engine/core/style.js +82 -33
- package/dist/engine/core/transform.d.ts +6 -0
- package/dist/engine/core/transform.js +103 -83
- package/dist/engine/core/types.d.ts +7 -0
- package/dist/engine/core/types.js +4 -4
- package/dist/engine/core/viewport.js +36 -23
- package/dist/engine/input/PointerController.d.ts +15 -1
- package/dist/engine/input/PointerController.js +549 -466
- package/dist/engine/input/arrowHandles.js +12 -12
- package/dist/engine/input/gestures.d.ts +3 -1
- package/dist/engine/input/gestures.js +340 -266
- package/dist/engine/input/hoverCursor.js +1 -1
- package/dist/engine/input/keyboard.d.ts +22 -3
- package/dist/engine/input/keyboard.js +131 -32
- package/dist/engine/input/selectionHandles.js +50 -45
- package/dist/engine/input/types.d.ts +7 -0
- package/dist/engine/input/types.js +1 -1
- package/dist/engine/render/rasterize.js +158 -86
- package/dist/engine/state.d.ts +18 -0
- package/dist/engine/state.js +25 -4
- package/dist/engine/text/layoutText.js +62 -43
- package/dist/engine/text/textMetrics.js +10 -8
- package/dist/engine/widgets.js +137 -101
- package/dist/fonts/interFont.js +83 -30
- package/dist/fonts/workspaceFonts.d.ts +6 -0
- package/dist/fonts/workspaceFonts.js +108 -34
- package/dist/i18n/labels.js +4 -4
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/language.js +4 -4
- package/dist/i18n/messages.d.ts +6 -0
- package/dist/i18n/messages.js +7 -1
- package/dist/i18n/shortcuts.d.ts +6 -4
- package/dist/i18n/shortcuts.js +30 -26
- package/dist/index.d.ts +2 -1
- package/dist/poster/boardPlacement.d.ts +80 -0
- package/dist/poster/boardPlacement.js +140 -0
- package/dist/poster/boardPoster.d.ts +80 -0
- package/dist/poster/boardPoster.js +251 -0
- package/dist/poster/paintBoardPoster.d.ts +49 -0
- package/dist/poster/paintBoardPoster.js +112 -0
- package/dist/poster/posterPictures.d.ts +32 -0
- package/dist/poster/posterPictures.js +138 -0
- package/dist/settings/workspaceToolSettings.d.ts +6 -0
- package/dist/settings/workspaceToolSettings.js +58 -34
- package/dist/tools/components/catalog.js +74 -64
- package/dist/tools/components/grouping.js +28 -6
- package/dist/tools/definitions.js +31 -9
- package/dist/tools/executors.js +214 -106
- package/dist/tools/hostAdapter.d.ts +5 -1
- package/dist/tools/hostAdapter.js +15 -11
- package/dist/tools/sceneSummary.js +57 -43
- package/dist/tools/sketchIntent.js +21 -13
- package/dist/tools/styleArguments.d.ts +35 -0
- package/dist/tools/styleArguments.js +93 -0
- package/dist/tools/types.d.ts +26 -1
- package/dist/tools/types.js +2 -1
- package/package.json +1 -1
|
@@ -4,8 +4,19 @@
|
|
|
4
4
|
* Every factory takes only what differs from the defaults, so a tool says "a rectangle here, this big" and
|
|
5
5
|
* nothing else. Ids come from `createObjectId`; a test passes its own `id` and gets the same record every time.
|
|
6
6
|
*/
|
|
7
|
+
var __assign = (this && this.__assign) || function () {
|
|
8
|
+
__assign = Object.assign || function(t) {
|
|
9
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
10
|
+
s = arguments[i];
|
|
11
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
12
|
+
t[p] = s[p];
|
|
13
|
+
}
|
|
14
|
+
return t;
|
|
15
|
+
};
|
|
16
|
+
return __assign.apply(this, arguments);
|
|
17
|
+
};
|
|
7
18
|
/** The look of a shape in the wireframe mode (the default of the canvas) and outside it. */
|
|
8
|
-
export
|
|
19
|
+
export var SHAPE_STYLE_DEFAULTS = {
|
|
9
20
|
wireframeFill: '#ffffff',
|
|
10
21
|
wireframeStroke: '#374151',
|
|
11
22
|
wireframeStrokeWidth: 2,
|
|
@@ -15,7 +26,7 @@ export const SHAPE_STYLE_DEFAULTS = {
|
|
|
15
26
|
inkStroke: '#1f2937',
|
|
16
27
|
inkStrokeWidth: 3
|
|
17
28
|
};
|
|
18
|
-
export
|
|
29
|
+
export var TEXT_DEFAULTS = {
|
|
19
30
|
fontSize: 20,
|
|
20
31
|
fontFamily: 'Inter',
|
|
21
32
|
color: '#111827',
|
|
@@ -30,21 +41,23 @@ export const TEXT_DEFAULTS = {
|
|
|
30
41
|
emptyTextMeasureStandIn: 'Type here'
|
|
31
42
|
};
|
|
32
43
|
/** The size of a shape that is placed by a click or a button, not dragged out. */
|
|
33
|
-
export
|
|
44
|
+
export var DEFAULT_OBJECT_SIZE = 100;
|
|
34
45
|
/** A random vivid colour, for a new shape on a board that is not in the wireframe mode. */
|
|
35
|
-
export function randomShapeFill(random
|
|
36
|
-
|
|
46
|
+
export function randomShapeFill(random) {
|
|
47
|
+
if (random === void 0) { random = Math.random; }
|
|
48
|
+
return "hsl(".concat(Math.floor(random() * 360), ", 70%, 50%)");
|
|
37
49
|
}
|
|
38
|
-
|
|
50
|
+
var idCounter = 0;
|
|
39
51
|
/** A unique id: time, a counter and a random tail, so two tabs and two calls in one millisecond never collide. */
|
|
40
|
-
export function createObjectId(prefix
|
|
52
|
+
export function createObjectId(prefix) {
|
|
53
|
+
if (prefix === void 0) { prefix = 'obj'; }
|
|
41
54
|
idCounter += 1;
|
|
42
|
-
|
|
43
|
-
return
|
|
55
|
+
var randomTail = Math.random().toString(36).slice(2, 8);
|
|
56
|
+
return "".concat(prefix, "_").concat(Date.now().toString(36), "_").concat(idCounter.toString(36)).concat(randomTail);
|
|
44
57
|
}
|
|
45
58
|
/** The dash pattern of a stroke style. Dotted uses zero-length dashes, which a round cap turns into dots. */
|
|
46
59
|
export function strokeDashArray(strokeStyle, strokeWidth) {
|
|
47
|
-
|
|
60
|
+
var unit = Math.max(2, strokeWidth);
|
|
48
61
|
switch (strokeStyle) {
|
|
49
62
|
case 'dashed':
|
|
50
63
|
return [unit * 4, unit * 2];
|
|
@@ -54,7 +67,7 @@ export function strokeDashArray(strokeStyle, strokeWidth) {
|
|
|
54
67
|
return null;
|
|
55
68
|
}
|
|
56
69
|
}
|
|
57
|
-
|
|
70
|
+
var BOX_DEFAULTS = {
|
|
58
71
|
parentId: null,
|
|
59
72
|
x: 0,
|
|
60
73
|
y: 0,
|
|
@@ -63,96 +76,44 @@ const BOX_DEFAULTS = {
|
|
|
63
76
|
rotation: 0,
|
|
64
77
|
opacity: 1
|
|
65
78
|
};
|
|
66
|
-
|
|
79
|
+
var PAINT_DEFAULTS = {
|
|
67
80
|
fill: SHAPE_STYLE_DEFAULTS.wireframeFill,
|
|
68
81
|
fillOpacity: 1,
|
|
69
82
|
stroke: SHAPE_STYLE_DEFAULTS.wireframeStroke,
|
|
70
83
|
strokeWidth: SHAPE_STYLE_DEFAULTS.wireframeStrokeWidth,
|
|
71
84
|
strokeStyle: 'solid'
|
|
72
85
|
};
|
|
73
|
-
export function createRectObject(fields
|
|
74
|
-
|
|
86
|
+
export function createRectObject(fields) {
|
|
87
|
+
var _a;
|
|
88
|
+
if (fields === void 0) { fields = {}; }
|
|
89
|
+
return __assign(__assign(__assign(__assign(__assign({}, BOX_DEFAULTS), PAINT_DEFAULTS), { roundness: 0 }), fields), { id: (_a = fields.id) !== null && _a !== void 0 ? _a : createObjectId(), type: 'rect' });
|
|
75
90
|
}
|
|
76
|
-
export function createEllipseObject(fields
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
aspectLocked: false,
|
|
81
|
-
...fields,
|
|
82
|
-
id: fields.id ?? createObjectId(),
|
|
83
|
-
type: 'ellipse'
|
|
84
|
-
};
|
|
91
|
+
export function createEllipseObject(fields) {
|
|
92
|
+
var _a;
|
|
93
|
+
if (fields === void 0) { fields = {}; }
|
|
94
|
+
return __assign(__assign(__assign(__assign(__assign({}, BOX_DEFAULTS), PAINT_DEFAULTS), { aspectLocked: false }), fields), { id: (_a = fields.id) !== null && _a !== void 0 ? _a : createObjectId(), type: 'ellipse' });
|
|
85
95
|
}
|
|
86
|
-
export function createPathObject(fields
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
d: '',
|
|
91
|
-
shape: null,
|
|
92
|
-
roundness: 0,
|
|
93
|
-
aspectLocked: false,
|
|
94
|
-
flipX: false,
|
|
95
|
-
flipY: false,
|
|
96
|
-
lineCap: 'round',
|
|
97
|
-
lineJoin: 'round',
|
|
98
|
-
ink: null,
|
|
99
|
-
arrow: null,
|
|
100
|
-
...fields,
|
|
101
|
-
id: fields.id ?? createObjectId(),
|
|
102
|
-
type: 'path'
|
|
103
|
-
};
|
|
96
|
+
export function createPathObject(fields) {
|
|
97
|
+
var _a;
|
|
98
|
+
if (fields === void 0) { fields = {}; }
|
|
99
|
+
return __assign(__assign(__assign(__assign(__assign({}, BOX_DEFAULTS), PAINT_DEFAULTS), { d: '', shape: null, roundness: 0, aspectLocked: false, flipX: false, flipY: false, lineCap: 'round', lineJoin: 'round', ink: null, arrow: null }), fields), { id: (_a = fields.id) !== null && _a !== void 0 ? _a : createObjectId(), type: 'path' });
|
|
104
100
|
}
|
|
105
|
-
export function createTextObject(fields
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
height: Math.ceil(TEXT_DEFAULTS.fontSize * 1.2),
|
|
110
|
-
text: '',
|
|
111
|
-
color: TEXT_DEFAULTS.color,
|
|
112
|
-
fontSize: TEXT_DEFAULTS.fontSize,
|
|
113
|
-
fontFamily: TEXT_DEFAULTS.fontFamily,
|
|
114
|
-
fontWeight: 'normal',
|
|
115
|
-
fontStyle: 'normal',
|
|
116
|
-
underline: false,
|
|
117
|
-
align: 'left',
|
|
118
|
-
lineHeight: 1.2,
|
|
119
|
-
padding: 0,
|
|
120
|
-
backgroundColor: 'transparent',
|
|
121
|
-
autoWidth: true,
|
|
122
|
-
...fields,
|
|
123
|
-
id: fields.id ?? createObjectId(),
|
|
124
|
-
type: 'text'
|
|
125
|
-
};
|
|
101
|
+
export function createTextObject(fields) {
|
|
102
|
+
var _a;
|
|
103
|
+
if (fields === void 0) { fields = {}; }
|
|
104
|
+
return __assign(__assign(__assign(__assign({}, BOX_DEFAULTS), { width: TEXT_DEFAULTS.minimumWidth, height: Math.ceil(TEXT_DEFAULTS.fontSize * 1.2), text: '', color: TEXT_DEFAULTS.color, fontSize: TEXT_DEFAULTS.fontSize, fontFamily: TEXT_DEFAULTS.fontFamily, fontWeight: 'normal', fontStyle: 'normal', underline: false, align: 'left', lineHeight: 1.2, padding: 0, backgroundColor: 'transparent', autoWidth: true }), fields), { id: (_a = fields.id) !== null && _a !== void 0 ? _a : createObjectId(), type: 'text' });
|
|
126
105
|
}
|
|
127
|
-
export function createImageObject(fields
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
height: 200,
|
|
132
|
-
src: null,
|
|
133
|
-
imageRef: null,
|
|
134
|
-
fileName: null,
|
|
135
|
-
naturalWidth: 0,
|
|
136
|
-
naturalHeight: 0,
|
|
137
|
-
...fields,
|
|
138
|
-
id: fields.id ?? createObjectId(),
|
|
139
|
-
type: 'image'
|
|
140
|
-
};
|
|
106
|
+
export function createImageObject(fields) {
|
|
107
|
+
var _a;
|
|
108
|
+
if (fields === void 0) { fields = {}; }
|
|
109
|
+
return __assign(__assign(__assign(__assign({}, BOX_DEFAULTS), { width: 300, height: 200, src: null, imageRef: null, fileName: null, libraryFileId: null, libraryFileUrl: null, naturalWidth: 0, naturalHeight: 0 }), fields), { id: (_a = fields.id) !== null && _a !== void 0 ? _a : createObjectId(), type: 'image' });
|
|
141
110
|
}
|
|
142
111
|
export function createWidgetObject(fields) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
width: 360,
|
|
146
|
-
height: 268,
|
|
147
|
-
widgetName: null,
|
|
148
|
-
isPrimary: false,
|
|
149
|
-
thumbnail: null,
|
|
150
|
-
thumbnailRef: null,
|
|
151
|
-
...fields,
|
|
152
|
-
id: fields.id ?? createObjectId(),
|
|
153
|
-
type: 'widget'
|
|
154
|
-
};
|
|
112
|
+
var _a;
|
|
113
|
+
return __assign(__assign(__assign(__assign({}, BOX_DEFAULTS), { width: 360, height: 268, widgetName: null, isPrimary: false, thumbnail: null, thumbnailRef: null }), fields), { id: (_a = fields.id) !== null && _a !== void 0 ? _a : createObjectId(), type: 'widget' });
|
|
155
114
|
}
|
|
156
|
-
export function createGroupObject(fields
|
|
157
|
-
|
|
115
|
+
export function createGroupObject(fields) {
|
|
116
|
+
var _a;
|
|
117
|
+
if (fields === void 0) { fields = {}; }
|
|
118
|
+
return __assign(__assign({ parentId: null }, fields), { id: (_a = fields.id) !== null && _a !== void 0 ? _a : createObjectId('group'), type: 'group' });
|
|
158
119
|
}
|