js-draw 1.19.1 → 1.20.1
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 +52 -1
- package/dist/Editor.css +49 -7
- 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 +11 -3
- 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 +11 -3
- 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/docs/img/readme-images/unsupported-elements--in-editor.png +0 -0
- package/package.json +2 -2
- package/src/toolbar/EdgeToolbar.scss +8 -3
- package/src/toolbar/widgets/components/makeFileInput.scss +3 -2
- 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`
         | 
| @@ -123,7 +172,7 @@ For example, although `js-draw` doesn't support `<circle/>` elements, | |
| 123 172 | 
             
            ```
         | 
| 124 173 | 
             
            renders as
         | 
| 125 174 |  | 
| 126 | 
            -
             | 
| 175 | 
            +
            <img alt="screenshot of the image editor, displaying a green checkmark. The circle is invisible" src="docs/img/readme-images/unsupported-elements--in-editor.png" width="600"/>
         | 
| 127 176 |  | 
| 128 177 | 
             
            but exports to
         | 
| 129 178 | 
             
            ```xml
         | 
| @@ -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
    
    | @@ -232,8 +232,9 @@ | |
| 232 232 | 
             
              	in srgb, var(--foreground-color-1), transparent
         | 
| 233 233 | 
             
              );
         | 
| 234 234 | 
             
            }
         | 
| 235 | 
            -
            .toolbar-element .toolbar--file-input-container > label  | 
| 236 | 
            -
               | 
| 235 | 
            +
            .toolbar-element .toolbar--file-input-container > label .cancel-button {
         | 
| 236 | 
            +
              padding-left: 3px;
         | 
| 237 | 
            +
              padding-right: 3px;
         | 
| 237 238 | 
             
            }
         | 
| 238 239 | 
             
            .toolbar-element .toolbar--file-input-container > label > .toolbar--file-input-description {
         | 
| 239 240 | 
             
              background-color: var(--background-color-3);
         | 
| @@ -318,13 +319,21 @@ | |
| 318 319 | 
             
            }
         | 
| 319 320 |  | 
| 320 321 | 
             
            :root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list {
         | 
| 321 | 
            -
              overflow-y: auto;
         | 
| 322 | 
            -
              scroll-snap-type: y mandatory;
         | 
| 323 322 | 
             
              height: min(200px, 50vh);
         | 
| 323 | 
            +
              position: relative;
         | 
| 324 | 
            +
              display: flex;
         | 
| 325 | 
            +
              align-items: center;
         | 
| 326 | 
            +
            }
         | 
| 327 | 
            +
            :root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .scroller {
         | 
| 324 328 | 
             
              display: flex;
         | 
| 325 329 | 
             
              flex-direction: column;
         | 
| 330 | 
            +
              overflow-y: auto;
         | 
| 331 | 
            +
              scroll-snap-type: y mandatory;
         | 
| 332 | 
            +
              height: 100%;
         | 
| 333 | 
            +
              width: 100%;
         | 
| 334 | 
            +
              flex-grow: 1;
         | 
| 326 335 | 
             
            }
         | 
| 327 | 
            -
            :root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .item {
         | 
| 336 | 
            +
            :root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .scroller > .item {
         | 
| 328 337 | 
             
              height: 100%;
         | 
| 329 338 | 
             
              width: 100%;
         | 
| 330 339 | 
             
              flex-shrink: 0;
         | 
| @@ -338,6 +347,34 @@ | |
| 338 347 | 
             
            :root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.-empty {
         | 
| 339 348 | 
             
              display: none;
         | 
| 340 349 | 
             
            }
         | 
| 350 | 
            +
            :root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .page-markers {
         | 
| 351 | 
            +
              overflow: hidden;
         | 
| 352 | 
            +
              display: flex;
         | 
| 353 | 
            +
              flex-direction: column;
         | 
| 354 | 
            +
              align-items: center;
         | 
| 355 | 
            +
              max-height: 100%;
         | 
| 356 | 
            +
              min-height: 0;
         | 
| 357 | 
            +
            }
         | 
| 358 | 
            +
            :root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .page-markers.-one-element {
         | 
| 359 | 
            +
              visibility: hidden;
         | 
| 360 | 
            +
            }
         | 
| 361 | 
            +
            :root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .page-markers > .marker {
         | 
| 362 | 
            +
              padding: 2px;
         | 
| 363 | 
            +
              opacity: 0.1;
         | 
| 364 | 
            +
              cursor: pointer;
         | 
| 365 | 
            +
              left: 0;
         | 
| 366 | 
            +
              transition: left 0.2s ease;
         | 
| 367 | 
            +
            }
         | 
| 368 | 
            +
            :root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .page-markers > .marker > .content {
         | 
| 369 | 
            +
              background-color: var(--foreground-color-1);
         | 
| 370 | 
            +
              border-radius: 2px;
         | 
| 371 | 
            +
              padding: 2px;
         | 
| 372 | 
            +
            }
         | 
| 373 | 
            +
            :root .toolbar-snapped-scroll-list.toolbar-snapped-scroll-list.toolbar-snapped-scroll-list > .page-markers > .marker.-active {
         | 
| 374 | 
            +
              position: relative;
         | 
| 375 | 
            +
              left: 2px;
         | 
| 376 | 
            +
              opacity: 0.2;
         | 
| 377 | 
            +
            }
         | 
| 341 378 |  | 
| 342 379 | 
             
            /* The *main* root toolbar element */
         | 
| 343 380 | 
             
            .toolbar-root {
         | 
| @@ -913,14 +950,19 @@ | |
| 913 950 | 
             
              box-shadow: none;
         | 
| 914 951 | 
             
              border: none;
         | 
| 915 952 | 
             
              padding: 10px;
         | 
| 916 | 
            -
              color: var(--foreground-color-1);
         | 
| 917 953 | 
             
              transition: 0.2s ease box-shadow;
         | 
| 918 954 | 
             
              font-weight: bold;
         | 
| 919 955 | 
             
              color: var(--primary-action-foreground-color);
         | 
| 920 956 | 
             
            }
         | 
| 921 | 
            -
            .toolbar-edgemenu-container button:hover {
         | 
| 957 | 
            +
            .toolbar-edgemenu-container button:not(:disabled):hover {
         | 
| 922 958 | 
             
              box-shadow: 0 1px 2px var(--shadow-color);
         | 
| 923 959 | 
             
            }
         | 
| 960 | 
            +
            .toolbar-edgemenu-container button:disabled {
         | 
| 961 | 
            +
              opacity: 0.5;
         | 
| 962 | 
            +
              font-weight: unset;
         | 
| 963 | 
            +
              cursor: unset;
         | 
| 964 | 
            +
              color: var(--foreground-color-1);
         | 
| 965 | 
            +
            }
         | 
| 924 966 | 
             
            .toolbar-edgemenu-container .toolbar-grid-selector .choice-button {
         | 
| 925 967 | 
             
              --button-label-hover-offset-y: var(--button-size);
         | 
| 926 968 | 
             
            }
         |