js-draw 0.17.2 → 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.
Files changed (51) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/README.md +17 -8
  3. package/dist/bundle.js +1 -1
  4. package/dist/src/Editor.d.ts +62 -1
  5. package/dist/src/Editor.js +75 -24
  6. package/dist/src/EditorImage.d.ts +4 -2
  7. package/dist/src/EditorImage.js +4 -2
  8. package/dist/src/SVGLoader.d.ts +4 -0
  9. package/dist/src/SVGLoader.js +4 -0
  10. package/dist/src/components/lib.d.ts +2 -2
  11. package/dist/src/components/lib.js +2 -2
  12. package/dist/src/lib.d.ts +2 -1
  13. package/dist/src/lib.js +2 -1
  14. package/dist/src/rendering/lib.d.ts +2 -0
  15. package/dist/src/rendering/lib.js +2 -0
  16. package/dist/src/rendering/renderers/CanvasRenderer.d.ts +25 -0
  17. package/dist/src/rendering/renderers/CanvasRenderer.js +27 -0
  18. package/dist/src/rendering/renderers/SVGRenderer.d.ts +15 -0
  19. package/dist/src/rendering/renderers/SVGRenderer.js +27 -1
  20. package/dist/src/testing/lib.d.ts +2 -0
  21. package/dist/src/testing/lib.js +2 -0
  22. package/dist/src/testing/sendPenEvent.d.ts +12 -0
  23. package/dist/src/testing/sendPenEvent.js +19 -0
  24. package/dist/src/testing/sendTouchEvent.d.ts +36 -0
  25. package/dist/src/testing/sendTouchEvent.js +36 -0
  26. package/dist/src/toolbar/widgets/DocumentPropertiesWidget.d.ts +0 -1
  27. package/dist/src/toolbar/widgets/DocumentPropertiesWidget.js +5 -20
  28. package/dist/src/toolbar/widgets/PenToolWidget.js +1 -0
  29. package/dist/src/toolbar/widgets/TextToolWidget.js +4 -1
  30. package/dist/src/tools/SelectionTool/SelectionTool.js +5 -6
  31. package/package.json +1 -1
  32. package/src/Editor.ts +78 -28
  33. package/src/EditorImage.ts +4 -2
  34. package/src/SVGLoader.ts +4 -0
  35. package/src/components/lib.ts +2 -1
  36. package/src/lib.ts +2 -1
  37. package/src/rendering/lib.ts +2 -0
  38. package/src/rendering/renderers/CanvasRenderer.ts +27 -0
  39. package/src/rendering/renderers/SVGRenderer.ts +32 -1
  40. package/src/testing/lib.ts +3 -0
  41. package/src/testing/sendPenEvent.ts +31 -0
  42. package/src/testing/sendTouchEvent.ts +36 -1
  43. package/src/toolbar/toolbar.css +5 -0
  44. package/src/toolbar/widgets/DocumentPropertiesWidget.ts +5 -23
  45. package/src/toolbar/widgets/PenToolWidget.ts +1 -0
  46. package/src/toolbar/widgets/TextToolWidget.ts +4 -1
  47. package/src/tools/Eraser.test.ts +11 -10
  48. package/src/tools/PanZoom.test.ts +1 -1
  49. package/src/tools/Pen.test.ts +63 -62
  50. package/src/tools/SelectionTool/SelectionTool.test.ts +15 -14
  51. package/src/tools/SelectionTool/SelectionTool.ts +5 -7
package/CHANGELOG.md CHANGED
@@ -1,10 +1,19 @@
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
+
6
+ # 0.17.3
7
+ * Fix `isRestylableComponent` not exported.
8
+ * Add a method to get the `Editor`'s average background color.
9
+
1
10
  # 0.17.2
2
11
  * Bug fixes
3
12
  - TextComponent: Fix sub-components not cloning when cloning a parent `TextComponent`
4
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.
5
14
  - Find tool: Don't add viewport transformations to the undo stack.
6
15
  - Collaborative editing: Fix changing background size/location not synced between editors.
7
- - Upgrade dependencies to latest versions ([see commit for details](https://github.com/personalizedrefrigerator/js-draw/commit/427a64037320ca96232d47f268258206398f3796))
16
+ - Upgrades dependencies to latest versions ([see commit for details](https://github.com/personalizedrefrigerator/js-draw/commit/427a64037320ca96232d47f268258206398f3796))
8
17
 
9
18
  # 0.17.1
10
19
  * Bug fixes
package/README.md CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  ![](docs/img/js-draw.jpg)
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 (work-in-progress) documentation](https://personalizedrefrigerator.github.io/js-draw/typedoc/modules/lib.html).
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.2.3 with the latest version of js-draw -->
43
- <script src="https://cdn.jsdelivr.net/npm/js-draw@0.2.3/dist/bundle.js"></script>
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
  ![screenshot of the image editor, displaying a green checkmark. The circle is invisible](docs/img/unsupported-elements--in-editor.png)
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 primarially uses yellow/green colors.
217
+ disables the dark theme and creates a theme that primarily uses yellow/green colors.