js-draw 0.20.0 → 0.22.0
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/CHANGELOG.md +17 -0
- package/README.md +4 -4
- package/dist/bundle.js +1 -1
- package/dist/bundledStyles.js +1 -1
- package/dist/cjs/src/Color4.js +2 -2
- package/dist/cjs/src/Editor.d.ts +5 -4
- package/dist/cjs/src/Editor.js +25 -7
- package/dist/cjs/src/EditorImage.js +8 -2
- package/dist/cjs/src/Viewport.js +1 -1
- package/dist/cjs/src/commands/Command.js +1 -1
- package/dist/cjs/src/commands/SerializableCommand.js +1 -1
- package/dist/cjs/src/components/AbstractComponent.d.ts +13 -1
- package/dist/cjs/src/components/AbstractComponent.js +25 -10
- package/dist/cjs/src/components/Stroke.d.ts +1 -0
- package/dist/cjs/src/components/Stroke.js +14 -1
- package/dist/cjs/src/components/TextComponent.js +1 -1
- package/dist/cjs/src/components/util/StrokeSmoother.js +12 -14
- package/dist/cjs/src/localizations/de.js +1 -1
- package/dist/cjs/src/math/LineSegment2.d.ts +2 -0
- package/dist/cjs/src/math/LineSegment2.js +4 -0
- package/dist/cjs/src/math/Mat33.js +1 -1
- package/dist/cjs/src/math/Path.d.ts +24 -3
- package/dist/cjs/src/math/Path.js +225 -4
- package/dist/cjs/src/math/Rect2.js +5 -4
- package/dist/cjs/src/math/Vec3.js +1 -1
- package/dist/cjs/src/math/polynomial/QuadraticBezier.d.ts +1 -1
- package/dist/cjs/src/math/polynomial/QuadraticBezier.js +3 -4
- package/dist/cjs/src/rendering/Display.d.ts +1 -1
- package/dist/cjs/src/rendering/Display.js +1 -2
- package/dist/cjs/src/toolbar/HTMLToolbar.d.ts +2 -0
- package/dist/cjs/src/toolbar/HTMLToolbar.js +71 -5
- package/dist/cjs/src/toolbar/widgets/BaseToolWidget.d.ts +0 -1
- package/dist/cjs/src/toolbar/widgets/BaseToolWidget.js +0 -1
- package/dist/cjs/src/toolbar/widgets/BaseWidget.d.ts +5 -0
- package/dist/cjs/src/toolbar/widgets/BaseWidget.js +17 -5
- package/dist/cjs/src/toolbar/widgets/DocumentPropertiesWidget.js +1 -1
- package/dist/cjs/src/toolbar/widgets/EraserToolWidget.js +1 -1
- package/dist/cjs/src/toolbar/widgets/InsertImageWidget.js +1 -1
- package/dist/cjs/src/toolbar/widgets/PenToolWidget.js +1 -1
- package/dist/cjs/src/toolbar/widgets/TextToolWidget.js +1 -1
- package/dist/cjs/src/tools/SelectionTool/Selection.js +5 -2
- package/dist/cjs/src/tools/SelectionTool/SelectionTool.js +1 -1
- package/dist/cjs/src/types.d.ts +2 -0
- package/dist/mjs/src/Color4.mjs +2 -1
- package/dist/mjs/src/Editor.d.ts +5 -4
- package/dist/mjs/src/Editor.mjs +25 -7
- package/dist/mjs/src/EditorImage.mjs +10 -2
- package/dist/mjs/src/Viewport.mjs +2 -1
- package/dist/mjs/src/commands/Command.mjs +2 -1
- package/dist/mjs/src/commands/SerializableCommand.mjs +2 -1
- package/dist/mjs/src/components/AbstractComponent.d.ts +13 -1
- package/dist/mjs/src/components/AbstractComponent.mjs +26 -10
- package/dist/mjs/src/components/Stroke.d.ts +1 -0
- package/dist/mjs/src/components/Stroke.mjs +14 -1
- package/dist/mjs/src/components/TextComponent.mjs +2 -1
- package/dist/mjs/src/components/util/StrokeSmoother.mjs +12 -14
- package/dist/mjs/src/localizations/de.mjs +1 -1
- package/dist/mjs/src/math/LineSegment2.d.ts +2 -0
- package/dist/mjs/src/math/LineSegment2.mjs +4 -0
- package/dist/mjs/src/math/Mat33.mjs +2 -1
- package/dist/mjs/src/math/Path.d.ts +24 -3
- package/dist/mjs/src/math/Path.mjs +226 -4
- package/dist/mjs/src/math/Rect2.mjs +6 -4
- package/dist/mjs/src/math/Vec3.mjs +2 -1
- package/dist/mjs/src/math/polynomial/QuadraticBezier.d.ts +1 -1
- package/dist/mjs/src/math/polynomial/QuadraticBezier.mjs +3 -4
- package/dist/mjs/src/rendering/Display.d.ts +1 -1
- package/dist/mjs/src/rendering/Display.mjs +1 -2
- package/dist/mjs/src/toolbar/HTMLToolbar.d.ts +2 -0
- package/dist/mjs/src/toolbar/HTMLToolbar.mjs +73 -6
- package/dist/mjs/src/toolbar/widgets/BaseToolWidget.d.ts +0 -1
- package/dist/mjs/src/toolbar/widgets/BaseToolWidget.mjs +0 -1
- package/dist/mjs/src/toolbar/widgets/BaseWidget.d.ts +5 -0
- package/dist/mjs/src/toolbar/widgets/BaseWidget.mjs +17 -5
- package/dist/mjs/src/toolbar/widgets/DocumentPropertiesWidget.mjs +2 -1
- package/dist/mjs/src/toolbar/widgets/EraserToolWidget.mjs +2 -1
- package/dist/mjs/src/toolbar/widgets/InsertImageWidget.mjs +2 -1
- package/dist/mjs/src/toolbar/widgets/PenToolWidget.mjs +2 -1
- package/dist/mjs/src/toolbar/widgets/TextToolWidget.mjs +2 -1
- package/dist/mjs/src/tools/SelectionTool/Selection.mjs +6 -2
- package/dist/mjs/src/tools/SelectionTool/SelectionTool.mjs +2 -1
- package/dist/mjs/src/types.d.ts +2 -0
- package/package.json +12 -12
- package/src/Coloris.css +52 -0
- package/src/Editor.css +12 -0
- package/src/toolbar/toolbar.css +16 -0
- package/tsconfig-typedoc.json +7 -0
- package/tsconfig.json +2 -0
- package/typedoc.json +1 -0
@@ -27,7 +27,7 @@ import EditorImage from '../../EditorImage.mjs';
|
|
27
27
|
const updateChunkSize = 100;
|
28
28
|
const maxPreviewElemCount = 500;
|
29
29
|
// @internal
|
30
|
-
|
30
|
+
class Selection {
|
31
31
|
constructor(startPoint, editor) {
|
32
32
|
this.editor = editor;
|
33
33
|
this.transform = Mat33.identity;
|
@@ -125,6 +125,9 @@ export default class Selection {
|
|
125
125
|
this.transform = Mat33.identity;
|
126
126
|
// Make the commands undo-able
|
127
127
|
this.editor.dispatch(new Selection.ApplyTransformationCommand(this, selectedElems, fullTransform));
|
128
|
+
// Clear renderings of any in-progress transformations
|
129
|
+
const wetInkRenderer = this.editor.display.getWetInkRenderer();
|
130
|
+
wetInkRenderer.clear();
|
128
131
|
}
|
129
132
|
// Preview the effects of the current transformation on the selection
|
130
133
|
previewTransformCmds() {
|
@@ -442,7 +445,7 @@ Selection.ApplyTransformationCommand = class extends SerializableCommand {
|
|
442
445
|
(_b = this.selection) === null || _b === void 0 ? void 0 : _b.setTransform(this.fullTransform.inverse(), false);
|
443
446
|
(_c = this.selection) === null || _c === void 0 ? void 0 : _c.updateUI();
|
444
447
|
yield editor.asyncUnapplyCommands(this.transformCommands, updateChunkSize, true);
|
445
|
-
(_d = this.selection) === null || _d === void 0 ? void 0 : _d.setTransform(Mat33.identity);
|
448
|
+
(_d = this.selection) === null || _d === void 0 ? void 0 : _d.setTransform(Mat33.identity, false);
|
446
449
|
(_e = this.selection) === null || _e === void 0 ? void 0 : _e.recomputeRegion();
|
447
450
|
(_f = this.selection) === null || _f === void 0 ? void 0 : _f.updateUI();
|
448
451
|
});
|
@@ -457,3 +460,4 @@ Selection.ApplyTransformationCommand = class extends SerializableCommand {
|
|
457
460
|
return localizationTable.transformedElements(this.selectedElemIds.length);
|
458
461
|
}
|
459
462
|
};
|
463
|
+
export default Selection;
|
@@ -9,7 +9,7 @@ import TextComponent from '../../components/TextComponent.mjs';
|
|
9
9
|
export const cssPrefix = 'selection-tool-';
|
10
10
|
// Allows users to select/transform portions of the `EditorImage`.
|
11
11
|
// With respect to `extend`ing, `SelectionTool` is not stable.
|
12
|
-
|
12
|
+
class SelectionTool extends BaseTool {
|
13
13
|
constructor(editor, description) {
|
14
14
|
super(editor.notifier, description);
|
15
15
|
this.editor = editor;
|
@@ -396,3 +396,4 @@ SelectionTool.handleableKeys = [
|
|
396
396
|
'i', 'I', 'o', 'O',
|
397
397
|
'Control', 'Meta',
|
398
398
|
];
|
399
|
+
export default SelectionTool;
|
package/dist/mjs/src/types.d.ts
CHANGED
@@ -9,6 +9,8 @@ import Pointer from './Pointer';
|
|
9
9
|
import Color4 from './Color4';
|
10
10
|
import Command from './commands/Command';
|
11
11
|
import BaseWidget from './toolbar/widgets/BaseWidget';
|
12
|
+
export type HTMLPointerEventName = 'pointerdown' | 'pointermove' | 'pointerup' | 'pointercancel';
|
13
|
+
export type HTMLPointerEventFilter = (eventName: HTMLPointerEventName, event: PointerEvent) => boolean;
|
12
14
|
export interface PointerEvtListener {
|
13
15
|
onPointerDown(event: PointerEvt): boolean;
|
14
16
|
onPointerMove(event: PointerEvt): void;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "js-draw",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.22.0",
|
4
4
|
"description": "Draw pictures using a pen, touchscreen, or mouse! JS-draw is a drawing library for JavaScript and TypeScript. ",
|
5
5
|
"types": "./dist/mjs/src/lib.d.ts",
|
6
6
|
"main": "./dist/cjs/src/lib.js",
|
@@ -87,27 +87,27 @@
|
|
87
87
|
},
|
88
88
|
"devDependencies": {
|
89
89
|
"@types/bezier-js": "^4.1.0",
|
90
|
-
"@types/jest": "^29.
|
91
|
-
"@types/jsdom": "^21.1.
|
92
|
-
"@types/node": "^18.15.
|
93
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
94
|
-
"@typescript-eslint/parser": "^5.
|
90
|
+
"@types/jest": "^29.5.0",
|
91
|
+
"@types/jsdom": "^21.1.1",
|
92
|
+
"@types/node": "^18.15.11",
|
93
|
+
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
94
|
+
"@typescript-eslint/parser": "^5.57.1",
|
95
95
|
"css-loader": "^6.7.3",
|
96
|
-
"eslint": "^8.
|
96
|
+
"eslint": "^8.38.0",
|
97
97
|
"husky": "^8.0.3",
|
98
98
|
"jest": "^29.5.0",
|
99
99
|
"jest-environment-jsdom": "^29.5.0",
|
100
100
|
"jsdom": "^21.1.1",
|
101
|
-
"lint-staged": "^13.2.
|
101
|
+
"lint-staged": "^13.2.1",
|
102
102
|
"pinst": "^3.0.0",
|
103
103
|
"style-loader": "^3.3.2",
|
104
104
|
"terser-webpack-plugin": "^5.3.7",
|
105
|
-
"ts-jest": "^29.0
|
105
|
+
"ts-jest": "^29.1.0",
|
106
106
|
"ts-loader": "^9.4.2",
|
107
107
|
"ts-node": "^10.9.1",
|
108
|
-
"typedoc": "^0.
|
109
|
-
"typescript": "^
|
110
|
-
"webpack": "^5.
|
108
|
+
"typedoc": "^0.24.1",
|
109
|
+
"typescript": "^5.0.4",
|
110
|
+
"webpack": "^5.78.0"
|
111
111
|
},
|
112
112
|
"bugs": {
|
113
113
|
"url": "https://github.com/personalizedrefrigerator/js-draw/issues"
|
package/src/Coloris.css
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
/* Imports Coloris' CSS and makes additional changes to the color picker */
|
3
|
+
|
4
|
+
#clr-picker {
|
5
|
+
--clr-slider-size: 30px;
|
6
|
+
}
|
7
|
+
|
8
|
+
/* Coloris: Try to avoid scrolling instead of updating the color input. */
|
9
|
+
#clr-picker #clr-color-area, #clr-picker .clr_hue {
|
10
|
+
touch-action: none;
|
11
|
+
}
|
12
|
+
|
13
|
+
/* Increase space between inputs */
|
14
|
+
#clr-picker .clr-alpha {
|
15
|
+
margin-top: 15px;
|
16
|
+
margin-bottom: 15px;
|
17
|
+
}
|
18
|
+
|
19
|
+
/* Increase size of input thumb to make it easier to select colors. */
|
20
|
+
#clr-picker.clr-picker input[type="range"]::-moz-range-thumb {
|
21
|
+
width: var(--clr-slider-size);
|
22
|
+
height: var(--clr-slider-size);
|
23
|
+
}
|
24
|
+
|
25
|
+
/* Also apply to Chrome/iOS */
|
26
|
+
#clr-picker.clr-picker input[type="range"]::-webkit-slider-thumb {
|
27
|
+
/*
|
28
|
+
Note: This doesn't seem to take effect in iOS if it's combined with the
|
29
|
+
::-moz-range-thumb rule above
|
30
|
+
*/
|
31
|
+
width: var(--clr-slider-size);
|
32
|
+
height: var(--clr-slider-size);
|
33
|
+
}
|
34
|
+
|
35
|
+
#clr-picker.clr-picker input[type="range"]::-webkit-slider-runnable-track {
|
36
|
+
height: var(--clr-slider-size);
|
37
|
+
}
|
38
|
+
|
39
|
+
#clr-picker.clr-picker input[type="range"]::-moz-range-track {
|
40
|
+
height: var(--clr-slider-size);
|
41
|
+
}
|
42
|
+
|
43
|
+
/*
|
44
|
+
Debugging: Uncommenting this rule makes Coloris' sliders more
|
45
|
+
visible.
|
46
|
+
|
47
|
+
#clr-picker.clr-picker input[type="range"] {
|
48
|
+
opacity: 0.5;
|
49
|
+
-webkit-appearance: auto;
|
50
|
+
appearance: auto;
|
51
|
+
}
|
52
|
+
*/
|
package/src/Editor.css
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
2
|
@import url('./toolbar/toolbar.css');
|
3
3
|
@import url('./tools/tools.css');
|
4
|
+
@import url('./Coloris.css');
|
4
5
|
|
5
6
|
.imageEditorContainer {
|
6
7
|
/* Deafult colors for the editor */
|
@@ -84,3 +85,14 @@
|
|
84
85
|
overflow: visible;
|
85
86
|
z-index: 5;
|
86
87
|
}
|
88
|
+
|
89
|
+
@media print {
|
90
|
+
.imageEditorContainer .loadingMessage {
|
91
|
+
display: none;
|
92
|
+
}
|
93
|
+
|
94
|
+
.imageEditorContainer .imageEditorRenderArea canvas {
|
95
|
+
width: 100%;
|
96
|
+
height: initial;
|
97
|
+
}
|
98
|
+
}
|
package/src/toolbar/toolbar.css
CHANGED
@@ -74,6 +74,7 @@
|
|
74
74
|
margin-right: 3px;
|
75
75
|
|
76
76
|
min-width: 40px;
|
77
|
+
max-width: 105px;
|
77
78
|
width: min-content;
|
78
79
|
font-size: 1em;
|
79
80
|
}
|
@@ -82,6 +83,12 @@
|
|
82
83
|
cursor: inherit;
|
83
84
|
}
|
84
85
|
|
86
|
+
/* Decrease the font size of labels in the main toolbar if they're long. */
|
87
|
+
:not(.toolbar-dropdown) > .toolbar-toolContainer >
|
88
|
+
.toolbar-button > label.long-label {
|
89
|
+
font-size: 0.75em;
|
90
|
+
}
|
91
|
+
|
85
92
|
.toolbar-dropdown > .toolbar-toolContainer > button,
|
86
93
|
.toolbar-dropdown > .toolbar-toolContainer > .toolbar-button {
|
87
94
|
width: 6em;
|
@@ -160,6 +167,8 @@
|
|
160
167
|
bottom: 0;
|
161
168
|
right: 0;
|
162
169
|
|
170
|
+
touch-action: none;
|
171
|
+
|
163
172
|
background-color: var(--primary-background-color);
|
164
173
|
opacity: 0.3;
|
165
174
|
}
|
@@ -210,4 +219,11 @@
|
|
210
219
|
.toolbar-spacedList > * {
|
211
220
|
padding-bottom: 5px;
|
212
221
|
padding-top: 5px;
|
222
|
+
}
|
223
|
+
|
224
|
+
@media print {
|
225
|
+
/* Hide the toolbar on print. */
|
226
|
+
.toolbar-root {
|
227
|
+
display: none;
|
228
|
+
}
|
213
229
|
}
|
package/tsconfig.json
CHANGED