js-draw 1.19.1 → 1.20.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/README.md +51 -0
- package/dist/Editor.css +46 -5
- package/dist/bundle.js +2 -2
- package/dist/bundledStyles.js +1 -1
- package/dist/cjs/SVGLoader/index.js +3 -1
- package/dist/cjs/image/EditorImage.d.ts +2 -1
- package/dist/cjs/image/EditorImage.js +101 -5
- package/dist/cjs/rendering/renderers/CanvasRenderer.js +4 -4
- package/dist/cjs/toolbar/localization.d.ts +1 -0
- package/dist/cjs/toolbar/localization.js +1 -0
- package/dist/cjs/toolbar/widgets/InsertImageWidget/ImageWrapper.d.ts +1 -0
- package/dist/cjs/toolbar/widgets/InsertImageWidget/ImageWrapper.js +7 -0
- package/dist/cjs/toolbar/widgets/InsertImageWidget/index.js +10 -2
- package/dist/cjs/toolbar/widgets/components/makeFileInput.js +12 -1
- package/dist/cjs/toolbar/widgets/components/makeSnappedList.js +69 -4
- package/dist/cjs/tools/Eraser.js +22 -5
- package/dist/cjs/tools/PanZoom.d.ts +54 -0
- package/dist/cjs/tools/PanZoom.js +54 -2
- package/dist/cjs/util/ReactiveValue.d.ts +4 -0
- package/dist/cjs/util/ReactiveValue.js +5 -0
- package/dist/cjs/version.js +1 -1
- package/dist/mjs/SVGLoader/index.mjs +3 -1
- package/dist/mjs/image/EditorImage.d.ts +2 -1
- package/dist/mjs/image/EditorImage.mjs +101 -5
- package/dist/mjs/rendering/renderers/CanvasRenderer.mjs +4 -4
- package/dist/mjs/toolbar/localization.d.ts +1 -0
- package/dist/mjs/toolbar/localization.mjs +1 -0
- package/dist/mjs/toolbar/widgets/InsertImageWidget/ImageWrapper.d.ts +1 -0
- package/dist/mjs/toolbar/widgets/InsertImageWidget/ImageWrapper.mjs +7 -0
- package/dist/mjs/toolbar/widgets/InsertImageWidget/index.mjs +10 -2
- package/dist/mjs/toolbar/widgets/components/makeFileInput.mjs +12 -1
- package/dist/mjs/toolbar/widgets/components/makeSnappedList.mjs +69 -4
- package/dist/mjs/tools/Eraser.mjs +22 -5
- package/dist/mjs/tools/PanZoom.d.ts +54 -0
- package/dist/mjs/tools/PanZoom.mjs +54 -2
- package/dist/mjs/util/ReactiveValue.d.ts +4 -0
- package/dist/mjs/util/ReactiveValue.mjs +5 -0
- package/dist/mjs/version.mjs +1 -1
- package/package.json +2 -2
- package/src/toolbar/EdgeToolbar.scss +8 -3
- package/src/toolbar/widgets/components/makeSnappedList.scss +58 -12
package/README.md
CHANGED
@@ -15,6 +15,55 @@
|
|
15
15
|
|
16
16
|
For example usage, see [one of the examples](https://github.com/personalizedrefrigerator/js-draw/blob/main/docs/examples.md) or read [the documentation](https://personalizedrefrigerator.github.io/js-draw/typedoc/).
|
17
17
|
|
18
|
+
# Features
|
19
|
+
|
20
|
+
## Very large zoom range
|
21
|
+
|
22
|
+
A core feature of `js-draw` is its [large zoom range](https://personalizedrefrigerator.github.io/js-draw/typedoc/interfaces/js_draw.EditorSettings.html#maxZoom) (from roughly 10⁻¹⁰x to 10¹⁰x).
|
23
|
+
|
24
|
+
<details open><summary><strong>Demo</strong></summary>
|
25
|
+
|
26
|
+
<video src="https://github.com/personalizedrefrigerator/js-draw/assets/46334387/f1c4afea-d7c8-4c36-835b-e01f2a646424" alt="Video: Shows zooming out further and further" controls></video>
|
27
|
+
|
28
|
+
</details>
|
29
|
+
|
30
|
+
Applications using `js-draw` can adjust this zoom range with custom [EditorSettings](https://personalizedrefrigerator.github.io/js-draw/typedoc/interfaces/js_draw.EditorSettings.html).
|
31
|
+
|
32
|
+
## Touchscreen and stylus support
|
33
|
+
|
34
|
+
`js-draw` supports touchscreen pinch zoom and rotate gestures. To simplify editing, screen rotation snaps to multiples of 90 degrees.
|
35
|
+
|
36
|
+
<details><summary><strong>Demo</strong></summary>
|
37
|
+
|
38
|
+
<video src="https://github.com/personalizedrefrigerator/js-draw/assets/46334387/1f4ebeb1-9d2f-4884-9410-9fb1d5e455ee" alt="Video: Shows canvas being rotated" controls></video>
|
39
|
+
|
40
|
+
</details>
|
41
|
+
|
42
|
+
It's also possible to disable touch drawing. This can be useful when drawing with a stylus and can be done with either [PanZoomTool.setMode](https://personalizedrefrigerator.github.io/js-draw/typedoc/classes/js_draw.PanZoomTool.html#setMode) or, by a user, with the "hand" tool menu:
|
43
|
+
|
44
|
+
<img alt="screenshot: Hand tool menu at the bottom of the screen includes 'lock rotation' and 'touchscreen panning'. 'Touchscreen panning' is highlighted." src="https://github.com/personalizedrefrigerator/js-draw/assets/46334387/d96e2df5-6132-4122-954d-d25402754bc2" width="400"/>
|
45
|
+
|
46
|
+
## User-configurable tools
|
47
|
+
|
48
|
+
With the default toolbar, users can change the pen style, color, and more:
|
49
|
+
|
50
|
+
<img alt="screenshot: Pen configuration menu includes pen size, color, type, stabilization, autocorrect,..." src="https://github.com/personalizedrefrigerator/js-draw/assets/46334387/476ad0e4-1f95-43bf-925d-549292d141e3" width="400"/>
|
51
|
+
|
52
|
+
It's possible for applications using `js-draw` to [add custom pen types](https://personalizedrefrigerator.github.io/js-draw/typedoc/modules/Additional_Documentation.CustomizingTools__.html) that can also be customized in this way. It's also possible to [save the toolbar state](https://github.com/personalizedrefrigerator/js-draw/blob/main/docs/examples/example-save-restore-toolbar-state/example.ts) and restore it after reloading the app.
|
53
|
+
|
54
|
+
## More features
|
55
|
+
|
56
|
+
`js-draw` also supports:
|
57
|
+
|
58
|
+
- <details><summary>Partial stroke erasing</summary>
|
59
|
+
|
60
|
+
<video src="https://github.com/personalizedrefrigerator/js-draw/assets/46334387/c8c2b8d5-5537-4df8-a8b5-899c2d7ea5ce"></video>
|
61
|
+
|
62
|
+
</details>
|
63
|
+
- [Collaborative editing](https://github.com/personalizedrefrigerator/js-draw/tree/main/docs/examples/example-collaborative)
|
64
|
+
- Saving to and loading from a subset of SVG
|
65
|
+
|
66
|
+
|
18
67
|
# API
|
19
68
|
|
20
69
|
## Creating an `Editor`
|
@@ -329,6 +378,8 @@ body .imageEditorContainer {
|
|
329
378
|
```
|
330
379
|
disables the dark theme and creates a theme that primarily uses yellow/green colors.
|
331
380
|
|
381
|
+
See also [adjustEditorThemeForContrast](https://personalizedrefrigerator.github.io/js-draw/typedoc/functions/js_draw.adjustEditorThemeForContrast.html).
|
382
|
+
|
332
383
|
# Examples and resources
|
333
384
|
|
334
385
|
- [Examples](https://github.com/personalizedrefrigerator/js-draw/blob/main/docs/examples.md)
|
package/dist/Editor.css
CHANGED
@@ -318,13 +318,21 @@
|
|
318
318
|
}
|
319
319
|
|
320
320
|
:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list {
|
321
|
-
overflow-y: auto;
|
322
|
-
scroll-snap-type: y mandatory;
|
323
321
|
height: min(200px, 50vh);
|
322
|
+
position: relative;
|
323
|
+
display: flex;
|
324
|
+
align-items: center;
|
325
|
+
}
|
326
|
+
:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .scroller {
|
324
327
|
display: flex;
|
325
328
|
flex-direction: column;
|
329
|
+
overflow-y: auto;
|
330
|
+
scroll-snap-type: y mandatory;
|
331
|
+
height: 100%;
|
332
|
+
width: 100%;
|
333
|
+
flex-grow: 1;
|
326
334
|
}
|
327
|
-
:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .item {
|
335
|
+
:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .scroller > .item {
|
328
336
|
height: 100%;
|
329
337
|
width: 100%;
|
330
338
|
flex-shrink: 0;
|
@@ -338,6 +346,34 @@
|
|
338
346
|
:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.-empty {
|
339
347
|
display: none;
|
340
348
|
}
|
349
|
+
:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .page-markers {
|
350
|
+
overflow: hidden;
|
351
|
+
display: flex;
|
352
|
+
flex-direction: column;
|
353
|
+
align-items: center;
|
354
|
+
max-height: 100%;
|
355
|
+
min-height: 0;
|
356
|
+
}
|
357
|
+
:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .page-markers.-one-element {
|
358
|
+
visibility: hidden;
|
359
|
+
}
|
360
|
+
:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .page-markers > .marker {
|
361
|
+
padding: 2px;
|
362
|
+
opacity: 0.1;
|
363
|
+
cursor: pointer;
|
364
|
+
left: 0;
|
365
|
+
transition: left 0.2s ease;
|
366
|
+
}
|
367
|
+
:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .page-markers > .marker > .content {
|
368
|
+
background-color: var(--foreground-color-1);
|
369
|
+
border-radius: 2px;
|
370
|
+
padding: 2px;
|
371
|
+
}
|
372
|
+
:root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .page-markers > .marker.-active {
|
373
|
+
position: relative;
|
374
|
+
left: 2px;
|
375
|
+
opacity: 0.2;
|
376
|
+
}
|
341
377
|
|
342
378
|
/* The *main* root toolbar element */
|
343
379
|
.toolbar-root {
|
@@ -913,14 +949,19 @@
|
|
913
949
|
box-shadow: none;
|
914
950
|
border: none;
|
915
951
|
padding: 10px;
|
916
|
-
color: var(--foreground-color-1);
|
917
952
|
transition: 0.2s ease box-shadow;
|
918
953
|
font-weight: bold;
|
919
954
|
color: var(--primary-action-foreground-color);
|
920
955
|
}
|
921
|
-
.toolbar-edgemenu-container button:hover {
|
956
|
+
.toolbar-edgemenu-container button:not(:disabled):hover {
|
922
957
|
box-shadow: 0 1px 2px var(--shadow-color);
|
923
958
|
}
|
959
|
+
.toolbar-edgemenu-container button:disabled {
|
960
|
+
opacity: 0.5;
|
961
|
+
font-weight: unset;
|
962
|
+
cursor: unset;
|
963
|
+
color: var(--foreground-color-1);
|
964
|
+
}
|
924
965
|
.toolbar-edgemenu-container .toolbar-grid-selector .choice-button {
|
925
966
|
--button-label-hover-offset-y: var(--button-size);
|
926
967
|
}
|