js-draw 0.0.5 → 0.0.8
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 +11 -0
- package/README.md +13 -0
- package/dist/build_tools/bundle.js +2 -2
- package/dist/bundle.js +1 -1
- package/dist/src/Editor.js +9 -1
- package/dist/src/EditorImage.d.ts +2 -2
- package/dist/src/SVGLoader.d.ts +2 -0
- package/dist/src/SVGLoader.js +15 -1
- package/dist/src/UndoRedoHistory.d.ts +2 -0
- package/dist/src/Viewport.d.ts +1 -1
- package/dist/src/components/SVGGlobalAttributesObject.d.ts +15 -0
- package/dist/src/components/SVGGlobalAttributesObject.js +29 -0
- package/dist/src/components/builders/FreehandLineBuilder.js +15 -3
- package/dist/src/geometry/Path.js +11 -0
- package/dist/src/htmlUtil.d.ts +1 -0
- package/dist/src/rendering/SVGRenderer.d.ts +2 -0
- package/dist/src/rendering/SVGRenderer.js +25 -0
- package/dist/src/tools/BaseTool.d.ts +4 -4
- package/dist/src/tools/SelectionTool.js +0 -1
- package/dist/src/tools/ToolController.d.ts +2 -1
- package/dist/src/tools/UndoRedoShortcut.d.ts +10 -0
- package/dist/src/tools/localization.d.ts +1 -0
- package/dist/src/types.d.ts +1 -0
- package/package.json +2 -2
- package/src/Editor.ts +12 -1
- package/src/EditorImage.test.ts +1 -4
- package/src/SVGLoader.ts +18 -1
- package/src/UndoRedoHistory.ts +8 -0
- package/src/components/SVGGlobalAttributesObject.ts +39 -0
- package/src/components/builders/FreehandLineBuilder.ts +23 -4
- package/src/geometry/Path.fromString.test.ts +11 -24
- package/src/geometry/Path.ts +13 -0
- package/src/rendering/SVGRenderer.ts +27 -0
- package/src/testing/createEditor.ts +4 -0
- package/src/tools/BaseTool.ts +5 -4
- package/src/tools/ToolController.ts +3 -0
- package/src/tools/UndoRedoShortcut.test.ts +53 -0
- package/src/tools/UndoRedoShortcut.ts +28 -0
- package/src/tools/localization.ts +2 -0
- package/src/types.ts +1 -0
package/CHANGELOG.md
CHANGED
@@ -1,4 +1,15 @@
|
|
1
1
|
|
2
|
+
# 0.0.8
|
3
|
+
* Map `ctrl+z` to undo, `ctrl+shift+Z` to redo.
|
4
|
+
|
5
|
+
# 0.0.7
|
6
|
+
* Preserve SVG global attributes when loading/saving images.
|
7
|
+
* This fixes a bug where lost information (e.g. a missing namespace) broke SVGs on export.
|
8
|
+
|
9
|
+
# 0.0.6
|
10
|
+
* Fixes a bug that caused saved images to grow in size after loading them, then re-saving.
|
11
|
+
* Stops the pressure decrease on pen-up events from preventing line/arrow objects from having variable width.
|
12
|
+
|
2
13
|
# 0.0.5
|
3
14
|
* Configuration options:
|
4
15
|
- Ability to disable touch panning
|
package/README.md
CHANGED
@@ -12,6 +12,7 @@ To use `js-draw`,
|
|
12
12
|
|
13
13
|
## Creating an `Editor`
|
14
14
|
|
15
|
+
### With a bundler that supports importing `.css` files
|
15
16
|
To create a new `Editor` and add it as a child of `document.body`,
|
16
17
|
```ts
|
17
18
|
import Editor from 'js-draw';
|
@@ -22,7 +23,17 @@ const editor = new Editor(document.body);
|
|
22
23
|
|
23
24
|
The `import js-draw/styles` step requires a bundler that can import `.css` files. For example, [`webpack` with `css-loader`.](https://webpack.js.org/loaders/css-loader/)
|
24
25
|
|
26
|
+
### With a bundler that doesn't support importing `.css` files
|
27
|
+
Import the pre-bundled version of the editor to apply CSS after loading the page.
|
28
|
+
```ts
|
29
|
+
import Editor from 'js-draw';
|
30
|
+
import 'js-draw/bundle';
|
31
|
+
|
32
|
+
const editor = new Editor(document.body);
|
33
|
+
```
|
34
|
+
`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.
|
25
35
|
|
36
|
+
### Without a bundler
|
26
37
|
If you're not using a bundler, consider using the pre-bundled editor:
|
27
38
|
```html
|
28
39
|
<!-- Replace 0.0.5 with the latest version of js-draw -->
|
@@ -34,6 +45,8 @@ If you're not using a bundler, consider using the pre-bundled editor:
|
|
34
45
|
</script>
|
35
46
|
```
|
36
47
|
|
48
|
+
**Note**: To ensure the CDN-hosted version of `js-draw` hasn't been tampered with, consider [including an `integrity="..."` attribute](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity). [Read more about using SRI with JSDelivr](https://www.jsdelivr.com/using-sri-with-dynamic-files).
|
49
|
+
|
37
50
|
|
38
51
|
## Adding a toolbar
|
39
52
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { dirname } from
|
2
|
-
import BundledFile from
|
1
|
+
import { dirname } from 'path';
|
2
|
+
import BundledFile from './BundledFile';
|
3
3
|
const rootDir = dirname(__dirname);
|
4
4
|
const mainBundle = new BundledFile('jsdraw', `${rootDir}/src/bundle/bundled.ts`, `${rootDir}/dist/bundle.js`);
|
5
5
|
void mainBundle.build();
|