js-draw 0.17.3 → 0.17.4
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 +6 -1
- package/README.md +17 -8
- package/dist/bundle.js +1 -1
- package/dist/src/Editor.d.ts +57 -1
- package/dist/src/Editor.js +61 -24
- package/dist/src/EditorImage.d.ts +4 -2
- package/dist/src/EditorImage.js +4 -2
- package/dist/src/SVGLoader.d.ts +4 -0
- package/dist/src/SVGLoader.js +4 -0
- package/dist/src/lib.d.ts +2 -1
- package/dist/src/lib.js +2 -1
- package/dist/src/rendering/lib.d.ts +2 -0
- package/dist/src/rendering/lib.js +2 -0
- package/dist/src/rendering/renderers/CanvasRenderer.d.ts +25 -0
- package/dist/src/rendering/renderers/CanvasRenderer.js +27 -0
- package/dist/src/rendering/renderers/SVGRenderer.d.ts +15 -0
- package/dist/src/rendering/renderers/SVGRenderer.js +27 -1
- package/dist/src/testing/lib.d.ts +2 -0
- package/dist/src/testing/lib.js +2 -0
- package/dist/src/testing/sendPenEvent.d.ts +12 -0
- package/dist/src/testing/sendPenEvent.js +19 -0
- package/dist/src/testing/sendTouchEvent.d.ts +36 -0
- package/dist/src/testing/sendTouchEvent.js +36 -0
- package/dist/src/toolbar/widgets/DocumentPropertiesWidget.js +4 -2
- package/dist/src/toolbar/widgets/PenToolWidget.js +1 -0
- package/dist/src/toolbar/widgets/TextToolWidget.js +4 -1
- package/dist/src/tools/SelectionTool/SelectionTool.js +5 -6
- package/package.json +1 -1
- package/src/Editor.ts +62 -28
- package/src/EditorImage.ts +4 -2
- package/src/SVGLoader.ts +4 -0
- package/src/lib.ts +2 -1
- package/src/rendering/lib.ts +2 -0
- package/src/rendering/renderers/CanvasRenderer.ts +27 -0
- package/src/rendering/renderers/SVGRenderer.ts +32 -1
- package/src/testing/lib.ts +3 -0
- package/src/testing/sendPenEvent.ts +31 -0
- package/src/testing/sendTouchEvent.ts +36 -1
- package/src/toolbar/toolbar.css +5 -0
- package/src/toolbar/widgets/DocumentPropertiesWidget.ts +4 -2
- package/src/toolbar/widgets/PenToolWidget.ts +1 -0
- package/src/toolbar/widgets/TextToolWidget.ts +4 -1
- package/src/tools/Eraser.test.ts +11 -10
- package/src/tools/PanZoom.test.ts +1 -1
- package/src/tools/Pen.test.ts +63 -62
- package/src/tools/SelectionTool/SelectionTool.test.ts +15 -14
- package/src/tools/SelectionTool/SelectionTool.ts +5 -7
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# 0.17.4
|
2
|
+
* Fix `CanvasRenderer` and `SVGRenderer` not exported.
|
3
|
+
* Fix pasting images copied from js-draw into some external apps.
|
4
|
+
* Pasting selected items from `js-draw` still doesn't work for many apps.
|
5
|
+
|
1
6
|
# 0.17.3
|
2
7
|
* Fix `isRestylableComponent` not exported.
|
3
8
|
* Add a method to get the `Editor`'s average background color.
|
@@ -8,7 +13,7 @@
|
|
8
13
|
- This was causing duplicated `TextComponent`s to have, in part, the same styles as the original, even after attempting to restyle them with the restyle tool.
|
9
14
|
- Find tool: Don't add viewport transformations to the undo stack.
|
10
15
|
- Collaborative editing: Fix changing background size/location not synced between editors.
|
11
|
-
-
|
16
|
+
- Upgrades dependencies to latest versions ([see commit for details](https://github.com/personalizedrefrigerator/js-draw/commit/427a64037320ca96232d47f268258206398f3796))
|
12
17
|
|
13
18
|
# 0.17.1
|
14
19
|
* Bug fixes
|
package/README.md
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
|
5
5
|

|
6
6
|
|
7
|
-
For example usage, see [one of the examples](https://github.com/personalizedrefrigerator/js-draw/blob/main/docs/examples.md) or read [the
|
7
|
+
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/modules/lib.html).
|
8
8
|
|
9
9
|
# API
|
10
10
|
|
11
|
-
To use `js-draw`,
|
11
|
+
To use `js-draw`,
|
12
12
|
|
13
13
|
## Creating an `Editor`
|
14
14
|
|
@@ -33,14 +33,14 @@ import 'js-draw/bundle';
|
|
33
33
|
|
34
34
|
const editor = new Editor(document.body);
|
35
35
|
```
|
36
|
-
`js-draw/bundle` is a version of the editor pre-processed by `Webpack`. As such, `import`ing it applies editor-specific CSS to the document.
|
36
|
+
`js-draw/bundle` is a version of the editor pre-processed by `Webpack`. As such, `import`ing or including it with a `<script src="..."></script>` tag applies editor-specific CSS to the document.
|
37
37
|
|
38
38
|
### Without a bundler
|
39
39
|
|
40
40
|
If you're not using a bundler, consider using the pre-bundled editor:
|
41
41
|
```html
|
42
|
-
<!-- Replace 0.
|
43
|
-
<script src="https://cdn.jsdelivr.net/npm/js-draw@0.
|
42
|
+
<!-- Replace 0.17.3 with the latest version of js-draw -->
|
43
|
+
<script src="https://cdn.jsdelivr.net/npm/js-draw@0.17.3/dist/bundle.js"></script>
|
44
44
|
<script>
|
45
45
|
const editor = new jsdraw.Editor(document.body);
|
46
46
|
editor.addToolbar();
|
@@ -65,6 +65,15 @@ toolbar.addActionButton('Save', () => {
|
|
65
65
|
console.log('The saved SVG:', svgElem.outerHTML);
|
66
66
|
});
|
67
67
|
```
|
68
|
+
or alternatively, with an icon,
|
69
|
+
```ts
|
70
|
+
toolbar.addActionButton({
|
71
|
+
label: 'Save'
|
72
|
+
icon: editor.icons.makeSaveIcon(),
|
73
|
+
}, () => {
|
74
|
+
// Save content here.
|
75
|
+
});
|
76
|
+
```
|
68
77
|
|
69
78
|
## Loading from an SVG
|
70
79
|
|
@@ -95,7 +104,7 @@ renders as
|
|
95
104
|
|
96
105
|

|
97
106
|
|
98
|
-
but exports to
|
107
|
+
but exports to
|
99
108
|
```xml
|
100
109
|
<svg viewBox="156 74 200 150" width="200" height="150" version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg"><g><path d="M156,150M156,150Q190,190 209,217L213,215Q193,187 160,148M209,217M209,217Q212,218 236,178L232,176Q210,215 213,215M236,178M236,178Q240,171 307,95L305,93Q237,168 232,176M307,95M307,95Q312,90 329,78L327,74Q309,87 305,93" fill="#07a837"></path></g><circle cx="200" cy="100" r="40" fill="red"></circle></svg>
|
101
110
|
```
|
@@ -158,7 +167,7 @@ const editor = new Editor(document.body, {
|
|
158
167
|
select: 'Selecciona',
|
159
168
|
thicknessLabel: 'Tamaño: ',
|
160
169
|
colorLabel: 'Color: ',
|
161
|
-
|
170
|
+
|
162
171
|
...
|
163
172
|
},
|
164
173
|
});
|
@@ -205,4 +214,4 @@ body .imageEditorContainer {
|
|
205
214
|
--secondary-foreground-color: black;
|
206
215
|
}
|
207
216
|
```
|
208
|
-
disables the dark theme and creates a theme that
|
217
|
+
disables the dark theme and creates a theme that primarily uses yellow/green colors.
|