@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,6 +4,26 @@
|
|
|
4
4
|
* A gesture changes the scene *transiently* on every move and the engine records one undo step when it ends,
|
|
5
5
|
* so a drag of a hundred frames is one step. `cancel` puts the board back as it was before the press.
|
|
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
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
+
if (ar || !(i in from)) {
|
|
21
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
+
ar[i] = from[i];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
+
};
|
|
7
27
|
import { arrowPointsInWorld, bendTowards, isArrow, reshapeArrow } from '../core/arrow.js';
|
|
8
28
|
import { pickArrowBinding, positionBoundArrow } from '../core/arrowBinding.js';
|
|
9
29
|
import { bindingOfEnd, releaseUnmovedEnds } from '../core/arrowBindingRecords.js';
|
|
@@ -20,117 +40,125 @@ import { CORNER_HANDLES, ROTATE_CURSOR, cursorForHandle, isCornerHandle } from '
|
|
|
20
40
|
import { fitTextObject } from '../text/layoutText.js';
|
|
21
41
|
import { cursorForTool } from '../EngineCore.js';
|
|
22
42
|
/** A press that moves less than this (screen pixels) is still a click. */
|
|
23
|
-
export
|
|
43
|
+
export var DRAG_THRESHOLD = 3;
|
|
24
44
|
/** How far the eraser reaches, in screen pixels. */
|
|
25
|
-
export
|
|
45
|
+
export var ERASER_RADIUS = 8;
|
|
26
46
|
/** The step a rotation snaps to while Shift (or Ctrl, or Meta) is held, in degrees. */
|
|
27
|
-
export
|
|
47
|
+
export var ROTATION_SNAP_DEGREES = 5;
|
|
28
48
|
/** When true, a text corner resize hides the pointer and draws an arrow on the corner. */
|
|
29
|
-
export
|
|
49
|
+
export var ENABLE_TEXT_VIRTUAL_CURSOR = false;
|
|
30
50
|
/** Objects farther than this from the screen (in screen pixels) are not snapped to. */
|
|
31
|
-
|
|
51
|
+
var SNAP_TARGET_MARGIN = 400;
|
|
32
52
|
function worldOf(context, input) {
|
|
33
53
|
return context.engine.toWorld({ x: input.x, y: input.y });
|
|
34
54
|
}
|
|
35
55
|
/** Puts changed shapes into the scene the gesture started from. */
|
|
36
56
|
function withShapes(scene, shapes) {
|
|
37
|
-
|
|
38
|
-
for (
|
|
57
|
+
var byId = new Map();
|
|
58
|
+
for (var _i = 0, shapes_1 = shapes; _i < shapes_1.length; _i++) {
|
|
59
|
+
var shape = shapes_1[_i];
|
|
39
60
|
byId.set(shape.id, shape);
|
|
40
|
-
|
|
61
|
+
}
|
|
62
|
+
return scene.map(function (object) { var _a; return (_a = byId.get(object.id)) !== null && _a !== void 0 ? _a : object; });
|
|
41
63
|
}
|
|
42
64
|
function fitAll(context, shapes) {
|
|
43
|
-
|
|
44
|
-
return shapes.map((shape)
|
|
65
|
+
var measure = context.engine.services.measureText;
|
|
66
|
+
return shapes.map(function (shape) { return (shape.type === 'text' ? fitTextObject(shape, measure) : shape); });
|
|
45
67
|
}
|
|
46
68
|
/** The unit (top-level object, or member of the entered group) that holds an object. */
|
|
47
69
|
function unitIdOf(index, id, enteredGroupId) {
|
|
48
|
-
|
|
49
|
-
|
|
70
|
+
var _a;
|
|
71
|
+
var current = index.get(id);
|
|
72
|
+
var seen = new Set();
|
|
50
73
|
while (current && current.parentId !== null && current.parentId !== enteredGroupId && !seen.has(current.id)) {
|
|
51
74
|
seen.add(current.id);
|
|
52
75
|
current = index.get(current.parentId);
|
|
53
76
|
}
|
|
54
|
-
return current
|
|
77
|
+
return (_a = current === null || current === void 0 ? void 0 : current.id) !== null && _a !== void 0 ? _a : id;
|
|
55
78
|
}
|
|
56
79
|
/** The boxes of the other units near the screen: what a moving selection snaps to. */
|
|
57
80
|
function collectSnapTargets(context, movingIds) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
for (
|
|
81
|
+
var engine = context.engine;
|
|
82
|
+
var state = engine.state;
|
|
83
|
+
var index = engine.sceneIndex();
|
|
84
|
+
var reach = inflateRect(engine.visibleRect(), SNAP_TARGET_MARGIN / state.viewport.zoom);
|
|
85
|
+
var rectsByUnit = new Map();
|
|
86
|
+
for (var _i = 0, _a = state.scene; _i < _a.length; _i++) {
|
|
87
|
+
var object = _a[_i];
|
|
64
88
|
if (object.type === 'group' || state.pending[object.id])
|
|
65
89
|
continue;
|
|
66
|
-
|
|
90
|
+
var unitId = unitIdOf(index, object.id, state.enteredGroupId);
|
|
67
91
|
if (movingIds.has(unitId))
|
|
68
92
|
continue;
|
|
69
|
-
|
|
70
|
-
|
|
93
|
+
var bounds = shapeBounds(object);
|
|
94
|
+
var list = rectsByUnit.get(unitId);
|
|
71
95
|
if (list)
|
|
72
96
|
list.push(bounds);
|
|
73
97
|
else
|
|
74
98
|
rectsByUnit.set(unitId, [bounds]);
|
|
75
99
|
}
|
|
76
|
-
|
|
77
|
-
for (
|
|
78
|
-
|
|
100
|
+
var targets = [];
|
|
101
|
+
for (var _b = 0, _c = rectsByUnit.values(); _b < _c.length; _b++) {
|
|
102
|
+
var rects = _c[_b];
|
|
103
|
+
var union = unionRects(rects);
|
|
79
104
|
if (union && rectsIntersect(union, reach))
|
|
80
105
|
targets.push(union);
|
|
81
106
|
}
|
|
82
107
|
return targets;
|
|
83
108
|
}
|
|
84
109
|
/** Drags the selected units. Nothing moves until the pointer has gone `DRAG_THRESHOLD` pixels. */
|
|
85
|
-
export function createMoveGesture(context, start, unitIds, options
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
110
|
+
export function createMoveGesture(context, start, unitIds, options) {
|
|
111
|
+
if (options === void 0) { options = {}; }
|
|
112
|
+
var engine = context.engine;
|
|
113
|
+
var startScene = engine.state.scene;
|
|
114
|
+
var startWorld = worldOf(context, start);
|
|
115
|
+
var moving = new Set(unitIds);
|
|
116
|
+
var startBounds = boundsOfObjects(startScene, unitIds);
|
|
117
|
+
var speed = new PointerSpeedTracker();
|
|
118
|
+
var started = false;
|
|
119
|
+
var duplicated = false;
|
|
120
|
+
var targets = null;
|
|
95
121
|
// The shapes the drag carries, asked once at the first step: the same shapes move at every step, and a step must not
|
|
96
122
|
// walk the board's groups again to find them (a press that never becomes a drag never asks).
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
123
|
+
var carried = null;
|
|
124
|
+
var last = start;
|
|
125
|
+
var apply = function (input) {
|
|
126
|
+
var _a, _b, _c, _d, _e;
|
|
127
|
+
var world = worldOf(context, input);
|
|
128
|
+
var deltaX = world.x - startWorld.x;
|
|
129
|
+
var deltaY = world.y - startWorld.y;
|
|
130
|
+
var lockX = input.shiftKey && Math.abs(deltaX) < Math.abs(deltaY);
|
|
131
|
+
var lockY = input.shiftKey && !lockX;
|
|
105
132
|
if (lockX)
|
|
106
133
|
deltaX = 0;
|
|
107
134
|
if (lockY)
|
|
108
135
|
deltaY = 0;
|
|
109
|
-
|
|
110
|
-
|
|
136
|
+
var guides = [];
|
|
137
|
+
// Ctrl or Cmd, and G, turn the guides off for as long as they are held: nothing catches the selection, and no guide is drawn.
|
|
138
|
+
var snapping = ((_c = (_b = (_a = context.options).snapEnabled) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : true) && !input.metaKey && !input.ctrlKey && !((_e = (_d = context.guidesSuppressed) === null || _d === void 0 ? void 0 : _d.call(context)) !== null && _e !== void 0 ? _e : false);
|
|
111
139
|
speed.update(input.x, input.y, input.time);
|
|
112
140
|
if (snapping && startBounds) {
|
|
113
141
|
if (!targets)
|
|
114
142
|
targets = collectSnapTargets(context, moving);
|
|
115
|
-
|
|
116
|
-
|
|
143
|
+
var reach = snapReachInWorld(engine.state.viewport.zoom, speed.speed);
|
|
144
|
+
var snap = computeMoveSnap(__assign(__assign({}, startBounds), { x: startBounds.x + deltaX, y: startBounds.y + deltaY }), targets, reach);
|
|
117
145
|
if (!lockX)
|
|
118
146
|
deltaX += snap.deltaX;
|
|
119
147
|
if (!lockY)
|
|
120
148
|
deltaY += snap.deltaY;
|
|
121
|
-
guides = snap.guides.filter((guide)
|
|
149
|
+
guides = snap.guides.filter(function (guide) { return (guide.orientation === 'vertical' ? !lockX : !lockY); });
|
|
122
150
|
}
|
|
123
|
-
carried
|
|
151
|
+
carried !== null && carried !== void 0 ? carried : (carried = movingShapeIds(startScene, __spreadArray([], moving, true)));
|
|
124
152
|
engine.applyScene(translateShapes(startScene, carried, deltaX, deltaY), 'transient');
|
|
125
153
|
// The handles step aside while the selection is carried: what is carried is all that is to be seen. The board is also told
|
|
126
154
|
// what is carried, from which records and how far (`CarriedShapes`), so that it can draw a big selection as one layer and
|
|
127
155
|
// not as a new record for every shape at every step; the records written above are the same, and the engine reads only them.
|
|
128
|
-
engine.setOverlay({ guides, dragging: 'move', carry: { startRecords: engine.sceneIndex(startScene), shapeIds: carried, deltaX, deltaY } });
|
|
156
|
+
engine.setOverlay({ guides: guides, dragging: 'move', carry: { startRecords: engine.sceneIndex(startScene), shapeIds: carried, deltaX: deltaX, deltaY: deltaY } });
|
|
129
157
|
};
|
|
130
158
|
return {
|
|
131
159
|
kind: 'move',
|
|
132
160
|
pointerId: start.pointerId,
|
|
133
|
-
move(input) {
|
|
161
|
+
move: function (input) {
|
|
134
162
|
last = input;
|
|
135
163
|
if (options.immovable)
|
|
136
164
|
return;
|
|
@@ -143,7 +171,7 @@ export function createMoveGesture(context, start, unitIds, options = {}) {
|
|
|
143
171
|
duplicated = true;
|
|
144
172
|
if (engine.state.selectedIds.length === 0 && unitIds.length > 0)
|
|
145
173
|
engine.select(unitIds);
|
|
146
|
-
|
|
174
|
+
var copyIds = engine.duplicateSelectionForDrag();
|
|
147
175
|
if (copyIds.length > 0) {
|
|
148
176
|
moving = new Set(copyIds);
|
|
149
177
|
startScene = engine.state.scene;
|
|
@@ -153,9 +181,10 @@ export function createMoveGesture(context, start, unitIds, options = {}) {
|
|
|
153
181
|
}
|
|
154
182
|
apply(input);
|
|
155
183
|
},
|
|
156
|
-
end(input) {
|
|
184
|
+
end: function (input) {
|
|
185
|
+
var _a;
|
|
157
186
|
if (!started) {
|
|
158
|
-
options.onClick
|
|
187
|
+
(_a = options.onClick) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
159
188
|
return;
|
|
160
189
|
}
|
|
161
190
|
last = input;
|
|
@@ -164,21 +193,28 @@ export function createMoveGesture(context, start, unitIds, options = {}) {
|
|
|
164
193
|
engine.commit();
|
|
165
194
|
engine.setCursor(cursorForTool(engine.state.tool));
|
|
166
195
|
},
|
|
167
|
-
cancel() {
|
|
196
|
+
cancel: function () {
|
|
168
197
|
if (started)
|
|
169
198
|
engine.revertToCommitted();
|
|
170
199
|
engine.setCursor(cursorForTool(engine.state.tool));
|
|
171
200
|
},
|
|
172
|
-
modifiersChanged(modifiers) {
|
|
201
|
+
modifiersChanged: function (modifiers) {
|
|
202
|
+
// What the keys say is what the next layout of the drag reads too (the one G asks for below), so it is kept with the pointer.
|
|
203
|
+
last = __assign(__assign({}, last), modifiers);
|
|
173
204
|
if (started)
|
|
174
|
-
apply(
|
|
205
|
+
apply(last);
|
|
206
|
+
},
|
|
207
|
+
// G went down or up under a pointer that stays still: the selection is laid out again at once, with the guides or without them.
|
|
208
|
+
guidesSuppressedChanged: function () {
|
|
209
|
+
if (started)
|
|
210
|
+
apply(last);
|
|
175
211
|
}
|
|
176
212
|
};
|
|
177
213
|
}
|
|
178
214
|
// ──────────────────────────────────────────────────────────── resize
|
|
179
215
|
/** Where a handle of a frame is in the world. */
|
|
180
216
|
function handlePointOf(frame, handle) {
|
|
181
|
-
|
|
217
|
+
var direction = handleDirection(handle);
|
|
182
218
|
return applyMatrixToPoint(boxToWorldMatrix(frame), {
|
|
183
219
|
x: direction.x === 0 ? frame.width / 2 : direction.x > 0 ? frame.width : 0,
|
|
184
220
|
y: direction.y === 0 ? frame.height / 2 : direction.y > 0 ? frame.height : 0
|
|
@@ -186,11 +222,12 @@ function handlePointOf(frame, handle) {
|
|
|
186
222
|
}
|
|
187
223
|
/** The corner of a frame that is nearest to a point of the world: the one a corner handle dragged to that point is on. */
|
|
188
224
|
function cornerNearestTo(frame, target) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
for (
|
|
192
|
-
|
|
193
|
-
|
|
225
|
+
var nearest = handlePointOf(frame, CORNER_HANDLES[0]);
|
|
226
|
+
var nearestDistance = distanceBetween(nearest, target);
|
|
227
|
+
for (var _i = 0, _a = CORNER_HANDLES.slice(1); _i < _a.length; _i++) {
|
|
228
|
+
var handle = _a[_i];
|
|
229
|
+
var point = handlePointOf(frame, handle);
|
|
230
|
+
var distance = distanceBetween(point, target);
|
|
194
231
|
if (distance < nearestDistance) {
|
|
195
232
|
nearest = point;
|
|
196
233
|
nearestDistance = distance;
|
|
@@ -200,52 +237,51 @@ function cornerNearestTo(frame, target) {
|
|
|
200
237
|
}
|
|
201
238
|
/** Drags a handle of the selection. Nothing changes until the pointer has gone `DRAG_THRESHOLD` pixels: a press and a double press are not a stretch. */
|
|
202
239
|
export function createResizeGesture(context, start, handle, frame, shapes) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
240
|
+
var engine = context.engine;
|
|
241
|
+
var startScene = engine.state.scene;
|
|
242
|
+
var corner = isCornerHandle(handle);
|
|
243
|
+
var single = shapes.length === 1 ? shapes[0] : null;
|
|
207
244
|
// An arrow stretched with these shapes comes off the shapes it is tied to that are not stretched with it.
|
|
208
|
-
|
|
245
|
+
var stretchedIds = new Set(shapes.map(function (shape) { return shape.id; }));
|
|
209
246
|
// A circle, an icon, a picture and a text keep their proportions when a corner is dragged.
|
|
210
|
-
|
|
247
|
+
var keepsAspect = !!single &&
|
|
211
248
|
(((single.type === 'path' || single.type === 'ellipse') && single.aspectLocked) ||
|
|
212
249
|
(corner && (single.type === 'image' || single.type === 'text')));
|
|
213
250
|
// A text's corner scales its letters, and the box the letters make is not where the hand is. The hand is hidden for the
|
|
214
251
|
// drag and an arrow is drawn on the corner instead, so the person sees what is being held.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
252
|
+
var drawsOwnPointer = ENABLE_TEXT_VIRTUAL_CURSOR && corner && (single === null || single === void 0 ? void 0 : single.type) === 'text';
|
|
253
|
+
var direction = handleDirection(handle);
|
|
254
|
+
var arrowAngle = (Math.atan2(direction.y, direction.x) * 180) / Math.PI + frame.rotation;
|
|
218
255
|
engine.setCursor(cursorForHandle(handle, frame.rotation));
|
|
219
|
-
|
|
220
|
-
|
|
256
|
+
var started = false;
|
|
257
|
+
var last = start;
|
|
221
258
|
// The handle follows the pointer by the distance the press was from it. A handle's target reaches well past the 8 px
|
|
222
259
|
// square that is drawn (more for a finger), and the frame must not jump that far to the pointer on the first move.
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
260
|
+
var handleInWorld = handlePointOf(frame, handle);
|
|
261
|
+
var pressInWorld = worldOf(context, start);
|
|
262
|
+
var grabOffset = { x: handleInWorld.x - pressInWorld.x, y: handleInWorld.y - pressInWorld.y };
|
|
263
|
+
var apply = function (input) {
|
|
264
|
+
var pointerInWorld = worldOf(context, input);
|
|
265
|
+
var handleTarget = { x: pointerInWorld.x + grabOffset.x, y: pointerInWorld.y + grabOffset.y };
|
|
266
|
+
var resized = computeResizedFrame(frame, handle, handleTarget, {
|
|
230
267
|
fromCenter: input.altKey,
|
|
231
268
|
keepAspect: input.shiftKey || keepsAspect,
|
|
232
269
|
allowFlip: true
|
|
233
270
|
});
|
|
234
|
-
|
|
271
|
+
var next = fitAll(context, applyFrameResize(shapes, frame, resized, corner)).map(function (shape) { return releaseUnmovedEnds(shape, stretchedIds); });
|
|
235
272
|
engine.applyScene(withShapes(startScene, next), 'transient');
|
|
236
|
-
|
|
273
|
+
var after = selectionFrameOf(next);
|
|
237
274
|
engine.setOverlay({
|
|
238
275
|
dragging: 'resize',
|
|
239
276
|
readout: after ? { kind: 'size', width: Math.round(after.width), height: Math.round(after.height) } : null,
|
|
240
277
|
virtualCursor: drawsOwnPointer && after
|
|
241
|
-
? {
|
|
242
|
-
: null
|
|
278
|
+
? __assign(__assign({}, worldToScreen(engine.state.viewport, cornerNearestTo(after, handleTarget))), { angle: arrowAngle }) : null
|
|
243
279
|
});
|
|
244
280
|
};
|
|
245
281
|
return {
|
|
246
282
|
kind: 'resize',
|
|
247
283
|
pointerId: start.pointerId,
|
|
248
|
-
move(input) {
|
|
284
|
+
move: function (input) {
|
|
249
285
|
last = input;
|
|
250
286
|
if (!started) {
|
|
251
287
|
if (distanceBetween({ x: start.x, y: start.y }, { x: input.x, y: input.y }) < DRAG_THRESHOLD)
|
|
@@ -256,21 +292,21 @@ export function createResizeGesture(context, start, handle, frame, shapes) {
|
|
|
256
292
|
}
|
|
257
293
|
apply(input);
|
|
258
294
|
},
|
|
259
|
-
end() {
|
|
295
|
+
end: function () {
|
|
260
296
|
if (started) {
|
|
261
297
|
engine.clearOverlay();
|
|
262
298
|
engine.commit();
|
|
263
299
|
}
|
|
264
300
|
engine.setCursor(cursorForTool(engine.state.tool));
|
|
265
301
|
},
|
|
266
|
-
cancel() {
|
|
302
|
+
cancel: function () {
|
|
267
303
|
if (started)
|
|
268
304
|
engine.revertToCommitted();
|
|
269
305
|
engine.setCursor(cursorForTool(engine.state.tool));
|
|
270
306
|
},
|
|
271
|
-
modifiersChanged(modifiers) {
|
|
307
|
+
modifiersChanged: function (modifiers) {
|
|
272
308
|
if (started)
|
|
273
|
-
apply({
|
|
309
|
+
apply(__assign(__assign({}, last), modifiers));
|
|
274
310
|
}
|
|
275
311
|
};
|
|
276
312
|
}
|
|
@@ -281,33 +317,34 @@ export function createResizeGesture(context, start, handle, frame, shapes) {
|
|
|
281
317
|
* the pointer has gone `DRAG_THRESHOLD` pixels. `source` is where the press landed: the dot (the pointer is a hand that
|
|
282
318
|
* holds it) or the zone outside a corner (the turning arrow).
|
|
283
319
|
*/
|
|
284
|
-
export function createRotateGesture(context, start, frame, shapes, source
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
320
|
+
export function createRotateGesture(context, start, frame, shapes, source) {
|
|
321
|
+
if (source === void 0) { source = 'corner'; }
|
|
322
|
+
var engine = context.engine;
|
|
323
|
+
var startScene = engine.state.scene;
|
|
324
|
+
var center = frameCenter(frame);
|
|
325
|
+
var startAngle = angleFromCenter(center, worldOf(context, start));
|
|
326
|
+
var single = shapes.length === 1 ? shapes[0] : null;
|
|
290
327
|
// An arrow turned with these shapes comes off the shapes it is tied to that are not turned with it.
|
|
291
|
-
|
|
328
|
+
var turnedIds = new Set(shapes.map(function (shape) { return shape.id; }));
|
|
292
329
|
engine.setCursor(source === 'dot' ? 'grabbing' : ROTATE_CURSOR);
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
330
|
+
var started = false;
|
|
331
|
+
var last = start;
|
|
332
|
+
var apply = function (input) {
|
|
333
|
+
var delta = angleFromCenter(center, worldOf(context, input)) - startAngle;
|
|
297
334
|
if (input.shiftKey || input.ctrlKey || input.metaKey) {
|
|
298
335
|
delta = single
|
|
299
336
|
? snapAngle(single.rotation + delta, ROTATION_SNAP_DEGREES) - single.rotation
|
|
300
337
|
: snapAngle(delta, ROTATION_SNAP_DEGREES);
|
|
301
338
|
}
|
|
302
|
-
|
|
339
|
+
var turned = rotateShapesAbout(shapes, center, delta).map(function (shape) { return releaseUnmovedEnds(shape, turnedIds); });
|
|
303
340
|
engine.applyScene(withShapes(startScene, turned), 'transient');
|
|
304
|
-
|
|
341
|
+
var shown = single ? normalizeDegrees(single.rotation + delta) : normalizeDegrees(delta);
|
|
305
342
|
engine.setOverlay({ dragging: 'rotate', readout: { kind: 'angle', degrees: Math.round(shown) % 360 } });
|
|
306
343
|
};
|
|
307
344
|
return {
|
|
308
345
|
kind: 'rotate',
|
|
309
346
|
pointerId: start.pointerId,
|
|
310
|
-
move(input) {
|
|
347
|
+
move: function (input) {
|
|
311
348
|
last = input;
|
|
312
349
|
if (!started) {
|
|
313
350
|
if (distanceBetween({ x: start.x, y: start.y }, { x: input.x, y: input.y }) < DRAG_THRESHOLD)
|
|
@@ -316,21 +353,21 @@ export function createRotateGesture(context, start, frame, shapes, source = 'cor
|
|
|
316
353
|
}
|
|
317
354
|
apply(input);
|
|
318
355
|
},
|
|
319
|
-
end() {
|
|
356
|
+
end: function () {
|
|
320
357
|
if (started) {
|
|
321
358
|
engine.clearOverlay();
|
|
322
359
|
engine.commit();
|
|
323
360
|
}
|
|
324
361
|
engine.setCursor(cursorForTool(engine.state.tool));
|
|
325
362
|
},
|
|
326
|
-
cancel() {
|
|
363
|
+
cancel: function () {
|
|
327
364
|
if (started)
|
|
328
365
|
engine.revertToCommitted();
|
|
329
366
|
engine.setCursor(cursorForTool(engine.state.tool));
|
|
330
367
|
},
|
|
331
|
-
modifiersChanged(modifiers) {
|
|
368
|
+
modifiersChanged: function (modifiers) {
|
|
332
369
|
if (started)
|
|
333
|
-
apply({
|
|
370
|
+
apply(__assign(__assign({}, last), modifiers));
|
|
334
371
|
}
|
|
335
372
|
};
|
|
336
373
|
}
|
|
@@ -349,41 +386,42 @@ export function createRotateGesture(context, start, frame, shapes, source = 'cor
|
|
|
349
386
|
* ties it to nothing. The shape the other end is tied to is passed over: the two ends of an arrow are never tied to the same shape.
|
|
350
387
|
*/
|
|
351
388
|
export function createArrowHandleGesture(context, start, arrow, handle) {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
389
|
+
var engine = context.engine;
|
|
390
|
+
var startScene = engine.state.scene;
|
|
391
|
+
var startPoints = arrowPointsInWorld(arrow);
|
|
392
|
+
var otherEndBinding = handle === 'start' ? bindingOfEnd(arrow.arrow, 'end') : handle === 'end' ? bindingOfEnd(arrow.arrow, 'start') : null;
|
|
393
|
+
var passedOver = otherEndBinding ? new Set([otherEndBinding.targetId]) : undefined;
|
|
394
|
+
var grabbed = handle === 'start' ? startPoints.start : handle === 'end' ? startPoints.end : startPoints.middle;
|
|
395
|
+
var pressWorld = worldOf(context, start);
|
|
359
396
|
// Where the handle is, from where the pointer is: the pointer carries this much of an offset the whole way.
|
|
360
|
-
|
|
397
|
+
var offset = { x: grabbed.x - pressWorld.x, y: grabbed.y - pressWorld.y };
|
|
361
398
|
engine.setCursor('grabbing');
|
|
362
399
|
engine.setArrowHandleHover(handle);
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
400
|
+
var started = false;
|
|
401
|
+
var last = start;
|
|
402
|
+
var apply = function (input) {
|
|
403
|
+
var _a, _b, _c;
|
|
404
|
+
var pointer = worldOf(context, input);
|
|
405
|
+
var target = { x: pointer.x + offset.x, y: pointer.y + offset.y };
|
|
406
|
+
var changed;
|
|
407
|
+
var pick = null;
|
|
370
408
|
if (handle === 'bend') {
|
|
371
409
|
changed = reshapeArrow(arrow, { bend: bendTowards(startPoints.start, startPoints.end, target) });
|
|
372
410
|
}
|
|
373
411
|
else {
|
|
374
|
-
|
|
375
|
-
|
|
412
|
+
var fixed = handle === 'start' ? startPoints.end : startPoints.start;
|
|
413
|
+
var moved = input.shiftKey ? snapPointAround(fixed, target, ARROW_SNAP_DEGREES) : target;
|
|
376
414
|
if (!input.altKey && !input.shiftKey) {
|
|
377
415
|
pick = pickArrowBinding(startScene, target, { zoom: engine.state.viewport.zoom, ignore: passedOver });
|
|
378
416
|
}
|
|
379
417
|
// The end is where the hand puts it; the engine draws a tied end from its shape (`reconcileArrowBindings`) in the same step.
|
|
380
|
-
|
|
418
|
+
var change = handle === 'start' ? { start: moved, startBinding: (_a = pick === null || pick === void 0 ? void 0 : pick.binding) !== null && _a !== void 0 ? _a : null } : { end: moved, endBinding: (_b = pick === null || pick === void 0 ? void 0 : pick.binding) !== null && _b !== void 0 ? _b : null };
|
|
381
419
|
changed = reshapeArrow(arrow, change);
|
|
382
420
|
}
|
|
383
421
|
engine.applyScene(withShapes(startScene, [changed]), 'transient');
|
|
384
|
-
engine.setOverlay({ arrowBind: pick
|
|
422
|
+
engine.setOverlay({ arrowBind: (_c = pick === null || pick === void 0 ? void 0 : pick.hint) !== null && _c !== void 0 ? _c : null });
|
|
385
423
|
};
|
|
386
|
-
|
|
424
|
+
var finish = function () {
|
|
387
425
|
engine.setOverlay({ arrowBind: null });
|
|
388
426
|
engine.setArrowHandleHover(null);
|
|
389
427
|
engine.setCursor(cursorForTool(engine.state.tool));
|
|
@@ -391,7 +429,7 @@ export function createArrowHandleGesture(context, start, arrow, handle) {
|
|
|
391
429
|
return {
|
|
392
430
|
kind: 'arrow-handle',
|
|
393
431
|
pointerId: start.pointerId,
|
|
394
|
-
move(input) {
|
|
432
|
+
move: function (input) {
|
|
395
433
|
last = input;
|
|
396
434
|
if (!started) {
|
|
397
435
|
if (distanceBetween({ x: start.x, y: start.y }, { x: input.x, y: input.y }) < DRAG_THRESHOLD)
|
|
@@ -400,41 +438,41 @@ export function createArrowHandleGesture(context, start, arrow, handle) {
|
|
|
400
438
|
}
|
|
401
439
|
apply(input);
|
|
402
440
|
},
|
|
403
|
-
end() {
|
|
441
|
+
end: function () {
|
|
404
442
|
if (started)
|
|
405
443
|
engine.commit();
|
|
406
444
|
finish();
|
|
407
445
|
},
|
|
408
|
-
cancel() {
|
|
446
|
+
cancel: function () {
|
|
409
447
|
if (started)
|
|
410
448
|
engine.revertToCommitted();
|
|
411
449
|
finish();
|
|
412
450
|
},
|
|
413
|
-
modifiersChanged(modifiers) {
|
|
451
|
+
modifiersChanged: function (modifiers) {
|
|
414
452
|
if (started)
|
|
415
|
-
apply({
|
|
453
|
+
apply(__assign(__assign({}, last), modifiers));
|
|
416
454
|
}
|
|
417
455
|
};
|
|
418
456
|
}
|
|
419
457
|
// ──────────────────────────────────────────────────────────── marquee
|
|
420
458
|
/** What a marquee that touches nothing hands to the overlay: the one shared empty list. */
|
|
421
|
-
|
|
459
|
+
var NO_UNITS = Object.freeze([]);
|
|
422
460
|
/**
|
|
423
461
|
* Drags a rectangle over the board. While it is dragged, what it touches is outlined the way the unit under the pointer is
|
|
424
462
|
* (the overlay's `marqueeHover`), so the person sees what the release will take; the selection is made at the release, from
|
|
425
463
|
* the same units (added to the ones that were selected when Shift was held at the press).
|
|
426
464
|
*/
|
|
427
465
|
export function createMarqueeGesture(context, start) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
466
|
+
var engine = context.engine;
|
|
467
|
+
var startWorld = worldOf(context, start);
|
|
468
|
+
var base = start.shiftKey ? __spreadArray([], engine.state.selectedIds, true) : [];
|
|
469
|
+
var started = false;
|
|
432
470
|
// The units the marquee takes now. The board is handed the very same list for as long as they are the same units, so a
|
|
433
471
|
// marquee that grows over nothing new wakes nothing (see `erasingMarks.ts`).
|
|
434
|
-
|
|
472
|
+
var wouldSelect = NO_UNITS;
|
|
435
473
|
/** The selection a release at this rectangle would make: made as `select` makes it (a group once, no repeats). */
|
|
436
|
-
|
|
437
|
-
|
|
474
|
+
var selectionFor = function (rect) {
|
|
475
|
+
var units = normalizeSelection(engine.state.scene, __spreadArray(__spreadArray([], base, true), engine.hitTestRect(rect, 'intersect'), true));
|
|
438
476
|
if (units.length === 0)
|
|
439
477
|
return NO_UNITS;
|
|
440
478
|
return sameIds(units, wouldSelect) ? wouldSelect : units;
|
|
@@ -442,23 +480,23 @@ export function createMarqueeGesture(context, start) {
|
|
|
442
480
|
return {
|
|
443
481
|
kind: 'marquee',
|
|
444
482
|
pointerId: start.pointerId,
|
|
445
|
-
move(input) {
|
|
483
|
+
move: function (input) {
|
|
446
484
|
if (!started) {
|
|
447
485
|
if (distanceBetween({ x: start.x, y: start.y }, { x: input.x, y: input.y }) < DRAG_THRESHOLD)
|
|
448
486
|
return;
|
|
449
487
|
started = true;
|
|
450
488
|
}
|
|
451
|
-
|
|
489
|
+
var rect = rectFromPoints(startWorld, worldOf(context, input));
|
|
452
490
|
wouldSelect = selectionFor(rect);
|
|
453
491
|
engine.setOverlay({ marquee: rect, marqueeHover: wouldSelect });
|
|
454
492
|
},
|
|
455
|
-
end(input) {
|
|
493
|
+
end: function (input) {
|
|
456
494
|
// A press that never became a drag selects nothing (it cleared the selection when it began).
|
|
457
495
|
if (started)
|
|
458
496
|
engine.select(selectionFor(rectFromPoints(startWorld, worldOf(context, input))));
|
|
459
497
|
engine.setOverlay({ marquee: null, marqueeHover: NO_UNITS });
|
|
460
498
|
},
|
|
461
|
-
cancel() {
|
|
499
|
+
cancel: function () {
|
|
462
500
|
// Nothing was selected while it was dragged, so there is nothing to put back.
|
|
463
501
|
engine.setOverlay({ marquee: null, marqueeHover: NO_UNITS });
|
|
464
502
|
}
|
|
@@ -466,17 +504,18 @@ export function createMarqueeGesture(context, start) {
|
|
|
466
504
|
}
|
|
467
505
|
// ──────────────────────────────────────────────────────────── pan
|
|
468
506
|
/** Drags the view. `onTap` is what a press that never moved does (a finger on empty board clears the selection). */
|
|
469
|
-
export function createPanGesture(context, start, options
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
507
|
+
export function createPanGesture(context, start, options) {
|
|
508
|
+
if (options === void 0) { options = {}; }
|
|
509
|
+
var engine = context.engine;
|
|
510
|
+
var lastX = start.x;
|
|
511
|
+
var lastY = start.y;
|
|
512
|
+
var moved = false;
|
|
474
513
|
engine.setCursor('grabbing');
|
|
475
|
-
|
|
514
|
+
var restore = function () { return engine.setCursor(cursorForTool(engine.state.tool)); };
|
|
476
515
|
return {
|
|
477
516
|
kind: 'pan',
|
|
478
517
|
pointerId: start.pointerId,
|
|
479
|
-
move(input) {
|
|
518
|
+
move: function (input) {
|
|
480
519
|
if (!moved && distanceBetween({ x: start.x, y: start.y }, { x: input.x, y: input.y }) >= DRAG_THRESHOLD)
|
|
481
520
|
moved = true;
|
|
482
521
|
if (!moved)
|
|
@@ -485,67 +524,88 @@ export function createPanGesture(context, start, options = {}) {
|
|
|
485
524
|
lastX = input.x;
|
|
486
525
|
lastY = input.y;
|
|
487
526
|
},
|
|
488
|
-
end() {
|
|
527
|
+
end: function () {
|
|
528
|
+
var _a;
|
|
489
529
|
restore();
|
|
490
530
|
if (!moved)
|
|
491
|
-
options.onTap
|
|
531
|
+
(_a = options.onTap) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
492
532
|
},
|
|
493
533
|
cancel: restore
|
|
494
534
|
};
|
|
495
535
|
}
|
|
496
536
|
// ──────────────────────────────────────────────────────────── ink
|
|
497
537
|
/** A pen whose pressure never moves by more than this has none to report, and draws as a mouse does. */
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
|
|
538
|
+
var PEN_PRESSURE_SPREAD = 0.02;
|
|
539
|
+
/**
|
|
540
|
+
* The pressure a straight line (Shift) is drawn at when the device reports none (a mouse, a finger): the one a stroke drawn by
|
|
541
|
+
* hand settles at as soon as the hand moves at an ordinary pace. The straight line is then as thick as the lines drawn by hand
|
|
542
|
+
* beside it (a width of 3 is about 3 px on the screen, and not the 6.6 px of a pen pressing at its middle), and as thick at one
|
|
543
|
+
* end as at the other.
|
|
544
|
+
*/
|
|
545
|
+
var STRAIGHT_LINE_PRESSURE = 0;
|
|
501
546
|
/**
|
|
502
547
|
* Draws with the brush. The line is as thick as the hand presses: a pen's own pressure, or, for a mouse or a finger, the time the
|
|
503
|
-
* hand spends (a slow stroke swells, a quick one thins). Shift draws a straight line from where the pointer went down
|
|
548
|
+
* hand spends (a slow stroke swells, a quick one thins). Shift draws a straight line from where the pointer went down to the pointer,
|
|
549
|
+
* with the colour and the thickness of the lines drawn without Shift: the brush is the same, held at one pressure. The colour, the
|
|
550
|
+
* width and the opacity of the line are the pen's (`EngineState.penStyle`), which the settings panel sets before a line is drawn.
|
|
504
551
|
*/
|
|
505
552
|
export function createDrawGesture(context, start) {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
553
|
+
var engine = context.engine;
|
|
554
|
+
var strokeId = engine.services.createId('obj');
|
|
555
|
+
var isPen = start.pointerType === 'pen';
|
|
556
|
+
// How the line is drawn (its colour, its width, how much of the board shows through it) is the pen as it was set when the press
|
|
557
|
+
// began: a line already being drawn is not changed by a panel that is touched meanwhile.
|
|
558
|
+
var _a = engine.state.penStyle, color = _a.color, strokeWidth = _a.width, opacity = _a.opacity;
|
|
559
|
+
var samples = [];
|
|
560
|
+
var leastPressure = Infinity;
|
|
561
|
+
var mostPressure = -Infinity;
|
|
562
|
+
// What a pen has reported so far, to find the pressure a straight line is held at.
|
|
563
|
+
var pressureTotal = 0;
|
|
564
|
+
var pressureCount = 0;
|
|
565
|
+
var straight = start.shiftKey;
|
|
566
|
+
var lastScreen = { x: start.x, y: start.y };
|
|
567
|
+
var lastInput = start;
|
|
568
|
+
var takeSample = function (input) {
|
|
569
|
+
var world = worldOf(context, input);
|
|
517
570
|
// Only a pen's pressure means anything: a mouse and a finger report one fixed value while they are down.
|
|
518
571
|
if (isPen && typeof input.pressure === 'number') {
|
|
519
572
|
leastPressure = Math.min(leastPressure, input.pressure);
|
|
520
573
|
mostPressure = Math.max(mostPressure, input.pressure);
|
|
521
|
-
|
|
574
|
+
pressureTotal += input.pressure;
|
|
575
|
+
pressureCount += 1;
|
|
576
|
+
samples.push(__assign(__assign({}, world), { pressure: input.pressure }));
|
|
522
577
|
}
|
|
523
578
|
else {
|
|
524
579
|
samples.push(world);
|
|
525
580
|
}
|
|
526
581
|
};
|
|
527
582
|
takeSample(start);
|
|
528
|
-
|
|
529
|
-
|
|
583
|
+
var readsPressure = function () { return isPen && mostPressure - leastPressure >= PEN_PRESSURE_SPREAD; };
|
|
584
|
+
var isStraight = function () { return straight && samples.length > 1; };
|
|
530
585
|
/** The line the hand drew: the samples, or just their two ends when Shift holds it straight. */
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
//
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
586
|
+
var lineDrawn = function () { return (isStraight() ? [samples[0], samples[samples.length - 1]] : samples); };
|
|
587
|
+
var build = function (finished) {
|
|
588
|
+
// The brush of the lines beside it: a pen that reports its pressure draws with the pen's brush, anything else with the mouse's.
|
|
589
|
+
var brushKind = readsPressure() ? 'pen' : 'speed';
|
|
590
|
+
var look = { createId: function () { return strokeId; }, color: color, strokeWidth: strokeWidth, opacity: opacity, pressure: brushKind, finished: finished };
|
|
591
|
+
if (!isStraight())
|
|
592
|
+
return buildBrushStroke(samples, look);
|
|
593
|
+
// A straight line has two ends and an even width: one pressure all along (the pen's own average, or the mouse's usual one), and
|
|
594
|
+
// it is drawn all the way to the pointer, not trailing behind it as a hand-drawn line does while it is being drawn.
|
|
595
|
+
var steadyPressure = brushKind === 'pen' && pressureCount > 0 ? pressureTotal / pressureCount : STRAIGHT_LINE_PRESSURE;
|
|
596
|
+
return buildBrushStroke(lineDrawn(), __assign(__assign({}, look), { steadyPressure: steadyPressure }));
|
|
538
597
|
};
|
|
539
|
-
|
|
598
|
+
var showPreview = function () { return engine.setOverlay({ preview: build(false) }); };
|
|
540
599
|
showPreview();
|
|
541
600
|
return {
|
|
542
601
|
kind: 'draw',
|
|
543
602
|
pointerId: start.pointerId,
|
|
544
|
-
move(input) {
|
|
603
|
+
move: function (input) {
|
|
545
604
|
lastInput = input;
|
|
546
605
|
straight = input.shiftKey;
|
|
547
|
-
|
|
548
|
-
for (
|
|
606
|
+
var moved = input.coalesced && input.coalesced.length > 0 ? input.coalesced : [input];
|
|
607
|
+
for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) {
|
|
608
|
+
var sample = moved_1[_i];
|
|
549
609
|
// A new sample closer than a pixel to the last one adds nothing the eye can see.
|
|
550
610
|
if (Math.hypot(sample.x - lastScreen.x, sample.y - lastScreen.y) < 1)
|
|
551
611
|
continue;
|
|
@@ -554,21 +614,26 @@ export function createDrawGesture(context, start) {
|
|
|
554
614
|
}
|
|
555
615
|
showPreview();
|
|
556
616
|
},
|
|
557
|
-
end(input) {
|
|
617
|
+
end: function (input) {
|
|
618
|
+
var _a, _b;
|
|
558
619
|
straight = input.shiftKey;
|
|
559
|
-
|
|
620
|
+
// A straight line ends where the pointer was let go, even when that is a little beyond the last move (a fast flick). Only the
|
|
621
|
+
// position is taken: a pen reports no pressure once it is lifted, and the line holds one pressure anyway.
|
|
622
|
+
if (isStraight() && Math.hypot(input.x - lastScreen.x, input.y - lastScreen.y) >= 1)
|
|
623
|
+
takeSample({ x: input.x, y: input.y });
|
|
624
|
+
var stroke = build(true);
|
|
560
625
|
engine.clearOverlay();
|
|
561
626
|
if (!stroke)
|
|
562
627
|
return;
|
|
563
628
|
engine.addObjects([stroke]);
|
|
564
|
-
context.options.onStrokeFinished
|
|
629
|
+
(_b = (_a = context.options).onStrokeFinished) === null || _b === void 0 ? void 0 : _b.call(_a, stroke, lineDrawn());
|
|
565
630
|
},
|
|
566
|
-
cancel() {
|
|
631
|
+
cancel: function () {
|
|
567
632
|
engine.clearOverlay();
|
|
568
633
|
},
|
|
569
|
-
modifiersChanged(modifiers) {
|
|
634
|
+
modifiersChanged: function (modifiers) {
|
|
570
635
|
straight = modifiers.shiftKey;
|
|
571
|
-
lastInput = {
|
|
636
|
+
lastInput = __assign(__assign({}, lastInput), modifiers);
|
|
572
637
|
showPreview();
|
|
573
638
|
}
|
|
574
639
|
};
|
|
@@ -583,57 +648,60 @@ export function createDrawGesture(context, start) {
|
|
|
583
648
|
* default arrow, tied to nothing; the two ends are never tied to the same shape.
|
|
584
649
|
*/
|
|
585
650
|
export function createShapeGesture(context, start, kind, libraryKey) {
|
|
586
|
-
|
|
587
|
-
|
|
651
|
+
var engine = context.engine;
|
|
652
|
+
var id = engine.services.createId('obj');
|
|
588
653
|
// One colour for the whole drag: a random fill must not change on every frame.
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
654
|
+
var colorSeed = engine.services.random();
|
|
655
|
+
var startWorld = worldOf(context, start);
|
|
656
|
+
var dragged = false;
|
|
657
|
+
var last = start;
|
|
658
|
+
var pickAt = function (point, ignore) {
|
|
659
|
+
return pickArrowBinding(engine.state.scene, point, { zoom: engine.state.viewport.zoom, ignore: ignore });
|
|
660
|
+
};
|
|
594
661
|
// The shape the tail of an arrow would be tied to, from the moment of the press.
|
|
595
|
-
|
|
662
|
+
var tailPick = kind === 'arrow' && !start.altKey ? pickAt(startWorld) : null;
|
|
596
663
|
if (tailPick)
|
|
597
664
|
engine.setOverlay({ arrowBind: tailPick.hint });
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
665
|
+
var build = function (input) {
|
|
666
|
+
var _a, _b;
|
|
667
|
+
var end = worldOf(context, input);
|
|
668
|
+
var fromCenter = input.altKey && kind !== 'arrow' && dragged;
|
|
669
|
+
var shape = buildDraggedShape({
|
|
670
|
+
kind: kind,
|
|
603
671
|
start: fromCenter ? { x: 2 * startWorld.x - end.x, y: 2 * startWorld.y - end.y } : startWorld,
|
|
604
|
-
end,
|
|
672
|
+
end: end,
|
|
605
673
|
constrain: input.shiftKey,
|
|
606
|
-
dragged,
|
|
607
|
-
libraryKey,
|
|
674
|
+
dragged: dragged,
|
|
675
|
+
libraryKey: libraryKey,
|
|
608
676
|
wireframe: engine.wireframeMode,
|
|
609
|
-
createId: ()
|
|
610
|
-
random: ()
|
|
677
|
+
createId: function () { return id; },
|
|
678
|
+
random: function () { return colorSeed; },
|
|
611
679
|
workspacePaint: engine.workspacePaintForNewShape(engine.wireframeMode)
|
|
612
680
|
});
|
|
613
681
|
if (kind !== 'arrow' || !dragged || input.altKey || shape.type !== 'path' || !isArrow(shape))
|
|
614
|
-
return { shape, hint: null };
|
|
615
|
-
|
|
616
|
-
|
|
682
|
+
return { shape: shape, hint: null };
|
|
683
|
+
var tail = tailPick === null || tailPick === void 0 ? void 0 : tailPick.binding;
|
|
684
|
+
var headPick = input.shiftKey ? null : pickAt(end, tail ? new Set([tail.targetId]) : undefined);
|
|
617
685
|
if (!tail && !headPick)
|
|
618
|
-
return { shape, hint: null };
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
return { shape: tied, hint: headPick
|
|
686
|
+
return { shape: shape, hint: null };
|
|
687
|
+
var index = engine.sceneIndex();
|
|
688
|
+
var tied = positionBoundArrow(reshapeArrow(shape, { startBinding: tail !== null && tail !== void 0 ? tail : null, endBinding: (_a = headPick === null || headPick === void 0 ? void 0 : headPick.binding) !== null && _a !== void 0 ? _a : null }), function (targetId) { return index.get(targetId); });
|
|
689
|
+
return { shape: tied, hint: (_b = headPick === null || headPick === void 0 ? void 0 : headPick.hint) !== null && _b !== void 0 ? _b : null };
|
|
622
690
|
};
|
|
623
691
|
return {
|
|
624
692
|
kind: 'shape',
|
|
625
693
|
pointerId: start.pointerId,
|
|
626
|
-
move(input) {
|
|
694
|
+
move: function (input) {
|
|
627
695
|
last = input;
|
|
628
696
|
if (!dragged && distanceBetween({ x: start.x, y: start.y }, { x: input.x, y: input.y }) >= MIN_DRAW_DISTANCE)
|
|
629
697
|
dragged = true;
|
|
630
698
|
if (dragged) {
|
|
631
|
-
|
|
699
|
+
var _a = build(input), shape = _a.shape, hint = _a.hint;
|
|
632
700
|
engine.setOverlay({ preview: shape, arrowBind: hint });
|
|
633
701
|
}
|
|
634
702
|
},
|
|
635
|
-
end(input) {
|
|
636
|
-
|
|
703
|
+
end: function (input) {
|
|
704
|
+
var shape = build(input).shape;
|
|
637
705
|
engine.clearOverlay();
|
|
638
706
|
engine.addObjects([shape]);
|
|
639
707
|
if (engine.state.stickyTool) {
|
|
@@ -644,13 +712,13 @@ export function createShapeGesture(context, start, kind, libraryKey) {
|
|
|
644
712
|
engine.select([shape.id]);
|
|
645
713
|
}
|
|
646
714
|
},
|
|
647
|
-
cancel() {
|
|
715
|
+
cancel: function () {
|
|
648
716
|
engine.clearOverlay();
|
|
649
717
|
},
|
|
650
|
-
modifiersChanged(modifiers) {
|
|
718
|
+
modifiersChanged: function (modifiers) {
|
|
651
719
|
if (!dragged)
|
|
652
720
|
return;
|
|
653
|
-
|
|
721
|
+
var _a = build(__assign(__assign({}, last), modifiers)), shape = _a.shape, hint = _a.hint;
|
|
654
722
|
engine.setOverlay({ preview: shape, arrowBind: hint });
|
|
655
723
|
}
|
|
656
724
|
};
|
|
@@ -658,35 +726,35 @@ export function createShapeGesture(context, start, kind, libraryKey) {
|
|
|
658
726
|
// ──────────────────────────────────────────────────────────── text
|
|
659
727
|
/** A click makes a label that grows with its text, a drag makes a box of that width. Then the text is edited. */
|
|
660
728
|
export function createTextGesture(context, start) {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
729
|
+
var engine = context.engine;
|
|
730
|
+
var startWorld = worldOf(context, start);
|
|
731
|
+
var dragged = false;
|
|
664
732
|
return {
|
|
665
733
|
kind: 'text',
|
|
666
734
|
pointerId: start.pointerId,
|
|
667
|
-
move(input) {
|
|
735
|
+
move: function (input) {
|
|
668
736
|
if (!dragged && distanceBetween({ x: start.x, y: start.y }, { x: input.x, y: input.y }) >= MIN_DRAW_DISTANCE)
|
|
669
737
|
dragged = true;
|
|
670
738
|
if (dragged)
|
|
671
739
|
engine.setOverlay({ textDraft: rectFromPoints(startWorld, worldOf(context, input)) });
|
|
672
740
|
},
|
|
673
|
-
end(input) {
|
|
741
|
+
end: function (input) {
|
|
674
742
|
engine.setOverlay({ textDraft: null });
|
|
675
743
|
if (!dragged) {
|
|
676
744
|
engine.createText(startWorld);
|
|
677
745
|
return;
|
|
678
746
|
}
|
|
679
|
-
|
|
747
|
+
var rect = rectFromPoints(startWorld, worldOf(context, input));
|
|
680
748
|
engine.createText({ x: rect.x, y: rect.y }, { width: rect.width });
|
|
681
749
|
},
|
|
682
|
-
cancel() {
|
|
750
|
+
cancel: function () {
|
|
683
751
|
engine.setOverlay({ textDraft: null });
|
|
684
752
|
}
|
|
685
753
|
};
|
|
686
754
|
}
|
|
687
755
|
// ──────────────────────────────────────────────────────────── eraser
|
|
688
756
|
/** The most spots along one sweep of the eraser that are tested for shapes (a flick across a huge board stays affordable). */
|
|
689
|
-
|
|
757
|
+
var ERASER_MAX_STEPS_PER_SWEEP = 400;
|
|
690
758
|
/**
|
|
691
759
|
* Marks what the pointer passes over and removes it when the pointer is released.
|
|
692
760
|
*
|
|
@@ -698,44 +766,48 @@ const ERASER_MAX_STEPS_PER_SWEEP = 400;
|
|
|
698
766
|
* one by one. A press that does not move marks what lies under it and removes that on release (with Ctrl or Cmd only the top shape).
|
|
699
767
|
*/
|
|
700
768
|
export function createEraseGesture(context, start) {
|
|
701
|
-
|
|
769
|
+
var engine = context.engine;
|
|
702
770
|
// The scene stays as it was at the press: nothing is removed until the release.
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
771
|
+
var scene = engine.state.scene;
|
|
772
|
+
var index = engine.sceneIndex(scene);
|
|
773
|
+
var startWorld = worldOf(context, start);
|
|
774
|
+
var zoom = function () { return engine.state.viewport.zoom; };
|
|
775
|
+
var marked = [];
|
|
708
776
|
// What the hit tests look through: the cards that are never erased, and what is marked already.
|
|
709
|
-
|
|
710
|
-
for (
|
|
777
|
+
var skipped = new Set();
|
|
778
|
+
for (var _i = 0, scene_1 = scene; _i < scene_1.length; _i++) {
|
|
779
|
+
var object = scene_1[_i];
|
|
711
780
|
if (object.type === 'widget' || engine.state.pending[object.id])
|
|
712
781
|
skipped.add(object.id);
|
|
713
782
|
}
|
|
714
783
|
// The groups the press began inside of: their members are taken one by one instead of the group as a whole.
|
|
715
|
-
|
|
716
|
-
for (
|
|
784
|
+
var enteredGroups = new Set();
|
|
785
|
+
for (var _a = 0, scene_2 = scene; _a < scene_2.length; _a++) {
|
|
786
|
+
var object = scene_2[_a];
|
|
717
787
|
if (object.type !== 'group')
|
|
718
788
|
continue;
|
|
719
|
-
|
|
789
|
+
var box = boundsOfObjects(scene, [object.id]);
|
|
720
790
|
if (box && rectContainsPoint(box, startWorld))
|
|
721
791
|
enteredGroups.add(object.id);
|
|
722
792
|
}
|
|
723
793
|
/** What goes with a shape: the outermost group above it that the press did not begin inside of, else the shape itself. */
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
794
|
+
var unitOf = function (shapeId) {
|
|
795
|
+
var _a;
|
|
796
|
+
var unit = index.get(shapeId);
|
|
797
|
+
var visited = new Set();
|
|
727
798
|
while (unit && unit.parentId !== null && !visited.has(unit.id)) {
|
|
728
799
|
visited.add(unit.id);
|
|
729
|
-
|
|
800
|
+
var parent = index.get(unit.parentId);
|
|
730
801
|
if (!parent || enteredGroups.has(parent.id))
|
|
731
802
|
break;
|
|
732
803
|
unit = parent;
|
|
733
804
|
}
|
|
734
|
-
return unit
|
|
805
|
+
return (_a = unit === null || unit === void 0 ? void 0 : unit.id) !== null && _a !== void 0 ? _a : shapeId;
|
|
735
806
|
};
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
for (
|
|
807
|
+
var marksChanged = false;
|
|
808
|
+
var markUnitOf = function (shapeId) {
|
|
809
|
+
for (var _i = 0, _a = leafShapesOf(scene, [unitOf(shapeId)]); _i < _a.length; _i++) {
|
|
810
|
+
var shape = _a[_i];
|
|
739
811
|
if (skipped.has(shape.id))
|
|
740
812
|
continue;
|
|
741
813
|
skipped.add(shape.id);
|
|
@@ -744,9 +816,10 @@ export function createEraseGesture(context, start) {
|
|
|
744
816
|
}
|
|
745
817
|
};
|
|
746
818
|
/** Marks the shapes under a spot (all of them, or only the top one). */
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
819
|
+
var markAt = function (world, onlyTop) {
|
|
820
|
+
if (onlyTop === void 0) { onlyTop = false; }
|
|
821
|
+
for (var guard = 0; guard < 64; guard += 1) {
|
|
822
|
+
var hit = hitTestLeaf(scene, world, { zoom: zoom(), tolerancePixels: ERASER_RADIUS, ignore: skipped });
|
|
750
823
|
if (!hit)
|
|
751
824
|
break;
|
|
752
825
|
markUnitOf(hit.id);
|
|
@@ -756,18 +829,18 @@ export function createEraseGesture(context, start) {
|
|
|
756
829
|
break;
|
|
757
830
|
}
|
|
758
831
|
};
|
|
759
|
-
|
|
832
|
+
var lastWorld = startWorld;
|
|
760
833
|
/** Marks what lies along the way from where the eraser was to where it is. */
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
for (
|
|
765
|
-
|
|
834
|
+
var sweepTo = function (to) {
|
|
835
|
+
var screenLength = distanceBetween(lastWorld, to) * zoom();
|
|
836
|
+
var steps = Math.min(ERASER_MAX_STEPS_PER_SWEEP, Math.max(1, Math.ceil(screenLength / (ERASER_RADIUS / 2))));
|
|
837
|
+
for (var step = 1; step <= steps; step += 1) {
|
|
838
|
+
var progress = step / steps;
|
|
766
839
|
markAt({ x: lastWorld.x + (to.x - lastWorld.x) * progress, y: lastWorld.y + (to.y - lastWorld.y) * progress });
|
|
767
840
|
}
|
|
768
841
|
lastWorld = to;
|
|
769
842
|
};
|
|
770
|
-
|
|
843
|
+
var showMarks = function () {
|
|
771
844
|
if (!marksChanged)
|
|
772
845
|
return;
|
|
773
846
|
marksChanged = false;
|
|
@@ -776,8 +849,8 @@ export function createEraseGesture(context, start) {
|
|
|
776
849
|
// The press itself marks what is under it, so a click shows what it is about to remove.
|
|
777
850
|
markAt(startWorld, start.ctrlKey || start.metaKey);
|
|
778
851
|
showMarks();
|
|
779
|
-
|
|
780
|
-
|
|
852
|
+
var dragging = false;
|
|
853
|
+
var beginDragging = function () {
|
|
781
854
|
dragging = true;
|
|
782
855
|
engine.beginScribble();
|
|
783
856
|
// A drag takes everything under the spot where it began, also after a click that took only the top shape.
|
|
@@ -786,21 +859,22 @@ export function createEraseGesture(context, start) {
|
|
|
786
859
|
return {
|
|
787
860
|
kind: 'erase',
|
|
788
861
|
pointerId: start.pointerId,
|
|
789
|
-
move(input) {
|
|
862
|
+
move: function (input) {
|
|
790
863
|
if (!dragging) {
|
|
791
864
|
if (distanceBetween({ x: start.x, y: start.y }, { x: input.x, y: input.y }) < DRAG_THRESHOLD)
|
|
792
865
|
return;
|
|
793
866
|
beginDragging();
|
|
794
867
|
}
|
|
795
|
-
|
|
796
|
-
for (
|
|
797
|
-
|
|
868
|
+
var samples = input.coalesced && input.coalesced.length > 0 ? input.coalesced : [input];
|
|
869
|
+
for (var _i = 0, samples_1 = samples; _i < samples_1.length; _i++) {
|
|
870
|
+
var sample = samples_1[_i];
|
|
871
|
+
var world = worldOf(context, sample);
|
|
798
872
|
sweepTo(world);
|
|
799
873
|
engine.extendScribble(world);
|
|
800
874
|
}
|
|
801
875
|
showMarks();
|
|
802
876
|
},
|
|
803
|
-
end(input) {
|
|
877
|
+
end: function (input) {
|
|
804
878
|
// The release can come with a last position no move reported.
|
|
805
879
|
if (dragging)
|
|
806
880
|
sweepTo(worldOf(context, input));
|
|
@@ -809,7 +883,7 @@ export function createEraseGesture(context, start) {
|
|
|
809
883
|
if (marked.length > 0)
|
|
810
884
|
engine.removeObjects(marked);
|
|
811
885
|
},
|
|
812
|
-
cancel() {
|
|
886
|
+
cancel: function () {
|
|
813
887
|
engine.stopScribble();
|
|
814
888
|
engine.clearOverlay();
|
|
815
889
|
}
|