@widgetic/canvas 0.5.45 → 0.5.47
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 +3 -2
- package/dist/canvas/DomCanvas.svelte +1 -2
- package/dist/canvas/autosaveScheduler.js +37 -89
- package/dist/canvas/boardFrame.js +1 -1
- package/dist/canvas/boardSurface.js +1 -1
- package/dist/canvas/canvasLogger.js +7 -19
- package/dist/canvas/chromeLayout.js +19 -21
- package/dist/canvas/eventScope.js +10 -14
- package/dist/canvas/host/CanvasHost.d.ts +6 -5
- package/dist/canvas/host/CanvasHost.js +1664 -1861
- package/dist/canvas/host/CanvasHostApi.js +4 -19
- package/dist/canvas/host/boardFiles.js +35 -51
- package/dist/canvas/host/browserServices.js +108 -196
- package/dist/canvas/host/conversion.js +82 -170
- package/dist/canvas/host/hostObject.js +7 -7
- package/dist/canvas/host/nearCards.js +18 -21
- package/dist/canvas/host/pageEvents.js +5 -5
- package/dist/canvas/host/pauseCollector.d.ts +18 -0
- package/dist/canvas/host/pauseCollector.js +45 -0
- package/dist/canvas/host/pictureSaves.js +9 -11
- package/dist/canvas/host/screenRects.js +28 -31
- package/dist/canvas/host/storedPictures.js +149 -243
- package/dist/canvas/host/strokeSnap.js +88 -143
- package/dist/canvas/index.d.ts +1 -1
- package/dist/canvas/openMarks.js +2 -2
- package/dist/canvas/outsideClickDeselect.js +6 -7
- package/dist/canvas/panZoomPosition.js +2 -2
- package/dist/canvas/preferredTextFont.js +13 -25
- package/dist/canvas/shapes/ShapeLibrary.js +138 -148
- package/dist/canvas/shapes/shapeImageStore.js +4 -4
- package/dist/canvas/shapes/strokeShapeSnap.js +188 -233
- package/dist/canvas/toolbarPosition.js +2 -2
- package/dist/canvas/types.d.ts +7 -1
- package/dist/canvas/ui/CanvasContextMenu.svelte +40 -3
- package/dist/canvas/ui/CanvasHint.svelte +10 -9
- package/dist/canvas/ui/SelectionPanel.svelte +14 -12
- package/dist/canvas/ui/SelectionPanel.svelte.d.ts +0 -2
- package/dist/canvas/ui/ShapesMenu.svelte +6 -4
- package/dist/canvas/ui/ToolButton.svelte +7 -6
- package/dist/canvas/ui/colorModel.js +21 -32
- package/dist/canvas/ui/colorPickerMessages.js +5 -5
- package/dist/canvas/ui/floatingCard.d.ts +28 -8
- package/dist/canvas/ui/floatingCard.js +48 -28
- package/dist/canvas/ui/floatingLayer.js +5 -6
- package/dist/canvas/ui/keyHints.js +9 -11
- package/dist/canvas/ui/popoverSide.js +2 -3
- package/dist/canvas/ui/selectionTraits.d.ts +8 -4
- package/dist/canvas/ui/selectionTraits.js +44 -58
- package/dist/canvas/view/CanvasStage.svelte +1 -1
- package/dist/canvas/view/SelectionOverlay.svelte +2 -2
- package/dist/canvas/view/erasingMarks.js +7 -7
- package/dist/canvas/view/geometry.d.ts +1 -1
- package/dist/canvas/view/geometry.js +72 -91
- package/dist/canvas/view/liftedScene.js +24 -36
- package/dist/canvas/view/mountedScene.js +76 -79
- package/dist/components/CanvasBoardPlaceholder.svelte +68 -10
- package/dist/components/CanvasBoardPlaceholder.svelte.d.ts +10 -2
- package/dist/components/CanvasToolbarPlaceholder.svelte +25 -11
- package/dist/components/CanvasToolbarPlaceholder.svelte.d.ts +6 -0
- package/dist/components/boardLoaderDelay.d.ts +39 -0
- package/dist/components/boardLoaderDelay.js +71 -0
- package/dist/components/input-controls/ColorIC.svelte +1 -1
- package/dist/components/input-controls/FontSelectorIC.svelte +1 -1
- package/dist/components/preferenceStorage.js +2 -2
- package/dist/engine/EngineCore.d.ts +42 -10
- package/dist/engine/EngineCore.js +843 -916
- package/dist/engine/codec/canvasDocument.js +192 -155
- package/dist/engine/codec/hostReadableKeys.js +1 -1
- package/dist/engine/core/arrange.js +26 -38
- package/dist/engine/core/arrow.js +79 -92
- package/dist/engine/core/arrowBinding.js +98 -116
- package/dist/engine/core/arrowBindingRecords.js +23 -38
- package/dist/engine/core/brush.d.ts +24 -0
- package/dist/engine/core/brush.js +223 -103
- package/dist/engine/core/cameraMove.js +39 -51
- package/dist/engine/core/defaults.js +92 -51
- package/dist/engine/core/freehand.js +147 -163
- package/dist/engine/core/geometry.js +47 -54
- package/dist/engine/core/history.js +38 -55
- package/dist/engine/core/hitTest.js +68 -81
- package/dist/engine/core/matrix.js +18 -20
- package/dist/engine/core/pathData.js +183 -210
- package/dist/engine/core/rotationReset.js +5 -6
- package/dist/engine/core/scene.js +160 -224
- package/dist/engine/core/scribble.js +59 -84
- package/dist/engine/core/shapePaths.js +12 -15
- package/dist/engine/core/shapeTools.d.ts +23 -18
- package/dist/engine/core/shapeTools.js +104 -67
- package/dist/engine/core/snapping.js +65 -117
- package/dist/engine/core/style.d.ts +18 -2
- package/dist/engine/core/style.js +79 -80
- package/dist/engine/core/styleMemory.d.ts +88 -0
- package/dist/engine/core/styleMemory.js +189 -0
- package/dist/engine/core/transform.js +84 -95
- package/dist/engine/core/types.js +4 -4
- package/dist/engine/core/viewport.js +23 -36
- package/dist/engine/input/PointerController.js +513 -526
- package/dist/engine/input/arrowHandles.js +12 -12
- package/dist/engine/input/gestures.d.ts +8 -3
- package/dist/engine/input/gestures.js +378 -346
- package/dist/engine/input/hoverCursor.js +1 -1
- package/dist/engine/input/keyboard.js +42 -41
- package/dist/engine/input/selectionHandles.js +45 -50
- package/dist/engine/input/types.js +1 -1
- package/dist/engine/render/rasterize.js +86 -158
- package/dist/engine/state.js +6 -17
- package/dist/engine/text/layoutText.js +43 -62
- package/dist/engine/text/textMetrics.js +8 -10
- package/dist/engine/widgets.js +101 -137
- package/dist/fonts/interFont.js +30 -83
- package/dist/fonts/workspaceFonts.js +33 -92
- package/dist/i18n/labels.js +4 -4
- package/dist/i18n/language.js +4 -4
- package/dist/i18n/messages.js +1 -1
- package/dist/i18n/shortcuts.js +14 -14
- package/dist/index.d.ts +1 -1
- package/dist/poster/boardPlacement.d.ts +4 -1
- package/dist/poster/boardPlacement.js +34 -33
- package/dist/poster/boardPoster.js +58 -83
- package/dist/poster/paintBoardPoster.js +16 -39
- package/dist/poster/posterPictures.js +27 -43
- package/dist/settings/rememberedStyles.d.ts +22 -0
- package/dist/settings/rememberedStyles.js +47 -0
- package/dist/settings/rememberedTool.d.ts +50 -0
- package/dist/settings/rememberedTool.js +68 -0
- package/dist/settings/workspaceToolSettings.d.ts +25 -0
- package/dist/settings/workspaceToolSettings.js +38 -48
- package/dist/tools/components/catalog.js +64 -74
- package/dist/tools/components/grouping.js +6 -28
- package/dist/tools/definitions.js +5 -5
- package/dist/tools/executors.js +137 -169
- package/dist/tools/hostAdapter.js +10 -13
- package/dist/tools/sceneSummary.js +43 -57
- package/dist/tools/sketchIntent.js +13 -21
- package/dist/tools/styleArguments.js +19 -21
- package/dist/tools/types.js +1 -1
- package/package.json +5 -5
|
@@ -4,19 +4,8 @@
|
|
|
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
|
-
};
|
|
18
7
|
/** The look of a shape in the wireframe mode (the default of the canvas) and outside it. */
|
|
19
|
-
export
|
|
8
|
+
export const SHAPE_STYLE_DEFAULTS = {
|
|
20
9
|
wireframeFill: '#ffffff',
|
|
21
10
|
wireframeStroke: '#374151',
|
|
22
11
|
wireframeStrokeWidth: 2,
|
|
@@ -26,7 +15,7 @@ export var SHAPE_STYLE_DEFAULTS = {
|
|
|
26
15
|
inkStroke: '#1f2937',
|
|
27
16
|
inkStrokeWidth: 3
|
|
28
17
|
};
|
|
29
|
-
export
|
|
18
|
+
export const TEXT_DEFAULTS = {
|
|
30
19
|
fontSize: 20,
|
|
31
20
|
fontFamily: 'Inter',
|
|
32
21
|
color: '#111827',
|
|
@@ -41,23 +30,21 @@ export var TEXT_DEFAULTS = {
|
|
|
41
30
|
emptyTextMeasureStandIn: 'Type here'
|
|
42
31
|
};
|
|
43
32
|
/** The size of a shape that is placed by a click or a button, not dragged out. */
|
|
44
|
-
export
|
|
33
|
+
export const DEFAULT_OBJECT_SIZE = 100;
|
|
45
34
|
/** A random vivid colour, for a new shape on a board that is not in the wireframe mode. */
|
|
46
|
-
export function randomShapeFill(random) {
|
|
47
|
-
|
|
48
|
-
return "hsl(".concat(Math.floor(random() * 360), ", 70%, 50%)");
|
|
35
|
+
export function randomShapeFill(random = Math.random) {
|
|
36
|
+
return `hsl(${Math.floor(random() * 360)}, 70%, 50%)`;
|
|
49
37
|
}
|
|
50
|
-
|
|
38
|
+
let idCounter = 0;
|
|
51
39
|
/** A unique id: time, a counter and a random tail, so two tabs and two calls in one millisecond never collide. */
|
|
52
|
-
export function createObjectId(prefix) {
|
|
53
|
-
if (prefix === void 0) { prefix = 'obj'; }
|
|
40
|
+
export function createObjectId(prefix = 'obj') {
|
|
54
41
|
idCounter += 1;
|
|
55
|
-
|
|
56
|
-
return
|
|
42
|
+
const randomTail = Math.random().toString(36).slice(2, 8);
|
|
43
|
+
return `${prefix}_${Date.now().toString(36)}_${idCounter.toString(36)}${randomTail}`;
|
|
57
44
|
}
|
|
58
45
|
/** The dash pattern of a stroke style. Dotted uses zero-length dashes, which a round cap turns into dots. */
|
|
59
46
|
export function strokeDashArray(strokeStyle, strokeWidth) {
|
|
60
|
-
|
|
47
|
+
const unit = Math.max(2, strokeWidth);
|
|
61
48
|
switch (strokeStyle) {
|
|
62
49
|
case 'dashed':
|
|
63
50
|
return [unit * 4, unit * 2];
|
|
@@ -67,7 +54,7 @@ export function strokeDashArray(strokeStyle, strokeWidth) {
|
|
|
67
54
|
return null;
|
|
68
55
|
}
|
|
69
56
|
}
|
|
70
|
-
|
|
57
|
+
const BOX_DEFAULTS = {
|
|
71
58
|
parentId: null,
|
|
72
59
|
x: 0,
|
|
73
60
|
y: 0,
|
|
@@ -76,44 +63,98 @@ var BOX_DEFAULTS = {
|
|
|
76
63
|
rotation: 0,
|
|
77
64
|
opacity: 1
|
|
78
65
|
};
|
|
79
|
-
|
|
66
|
+
const PAINT_DEFAULTS = {
|
|
80
67
|
fill: SHAPE_STYLE_DEFAULTS.wireframeFill,
|
|
81
68
|
fillOpacity: 1,
|
|
82
69
|
stroke: SHAPE_STYLE_DEFAULTS.wireframeStroke,
|
|
83
70
|
strokeWidth: SHAPE_STYLE_DEFAULTS.wireframeStrokeWidth,
|
|
84
71
|
strokeStyle: 'solid'
|
|
85
72
|
};
|
|
86
|
-
export function createRectObject(fields) {
|
|
87
|
-
|
|
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' });
|
|
73
|
+
export function createRectObject(fields = {}) {
|
|
74
|
+
return { ...BOX_DEFAULTS, ...PAINT_DEFAULTS, roundness: 0, ...fields, id: fields.id ?? createObjectId(), type: 'rect' };
|
|
90
75
|
}
|
|
91
|
-
export function createEllipseObject(fields) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
76
|
+
export function createEllipseObject(fields = {}) {
|
|
77
|
+
return {
|
|
78
|
+
...BOX_DEFAULTS,
|
|
79
|
+
...PAINT_DEFAULTS,
|
|
80
|
+
aspectLocked: false,
|
|
81
|
+
...fields,
|
|
82
|
+
id: fields.id ?? createObjectId(),
|
|
83
|
+
type: 'ellipse'
|
|
84
|
+
};
|
|
95
85
|
}
|
|
96
|
-
export function createPathObject(fields) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
86
|
+
export function createPathObject(fields = {}) {
|
|
87
|
+
return {
|
|
88
|
+
...BOX_DEFAULTS,
|
|
89
|
+
...PAINT_DEFAULTS,
|
|
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
|
+
};
|
|
100
104
|
}
|
|
101
|
-
export function createTextObject(fields) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
export function createTextObject(fields = {}) {
|
|
106
|
+
return {
|
|
107
|
+
...BOX_DEFAULTS,
|
|
108
|
+
width: TEXT_DEFAULTS.minimumWidth,
|
|
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
|
+
};
|
|
105
126
|
}
|
|
106
|
-
export function createImageObject(fields) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
127
|
+
export function createImageObject(fields = {}) {
|
|
128
|
+
return {
|
|
129
|
+
...BOX_DEFAULTS,
|
|
130
|
+
width: 300,
|
|
131
|
+
height: 200,
|
|
132
|
+
src: null,
|
|
133
|
+
imageRef: null,
|
|
134
|
+
fileName: null,
|
|
135
|
+
libraryFileId: null,
|
|
136
|
+
libraryFileUrl: null,
|
|
137
|
+
naturalWidth: 0,
|
|
138
|
+
naturalHeight: 0,
|
|
139
|
+
...fields,
|
|
140
|
+
id: fields.id ?? createObjectId(),
|
|
141
|
+
type: 'image'
|
|
142
|
+
};
|
|
110
143
|
}
|
|
111
144
|
export function createWidgetObject(fields) {
|
|
112
|
-
|
|
113
|
-
|
|
145
|
+
return {
|
|
146
|
+
...BOX_DEFAULTS,
|
|
147
|
+
width: 360,
|
|
148
|
+
height: 268,
|
|
149
|
+
widgetName: null,
|
|
150
|
+
isPrimary: false,
|
|
151
|
+
thumbnail: null,
|
|
152
|
+
thumbnailRef: null,
|
|
153
|
+
...fields,
|
|
154
|
+
id: fields.id ?? createObjectId(),
|
|
155
|
+
type: 'widget'
|
|
156
|
+
};
|
|
114
157
|
}
|
|
115
|
-
export function createGroupObject(fields) {
|
|
116
|
-
|
|
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
|
+
export function createGroupObject(fields = {}) {
|
|
159
|
+
return { parentId: null, ...fields, id: fields.id ?? createObjectId('group'), type: 'group' };
|
|
119
160
|
}
|