ding-image-editor 3.15.3
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 +193 -0
- package/dist/svg/icon-a.svg +376 -0
- package/dist/svg/icon-b.svg +369 -0
- package/dist/svg/icon-c.svg +369 -0
- package/dist/svg/icon-d.svg +369 -0
- package/dist/tui-image-editor.css +6 -0
- package/dist/tui-image-editor.js +62329 -0
- package/dist/tui-image-editor.min.css +5 -0
- package/dist/tui-image-editor.min.js +15 -0
- package/index.d.ts +334 -0
- package/package.json +52 -0
- package/src/css/buttons.styl +102 -0
- package/src/css/checkbox.styl +86 -0
- package/src/css/colorpicker.styl +98 -0
- package/src/css/gridtable.styl +45 -0
- package/src/css/icon.styl +44 -0
- package/src/css/index.styl +17 -0
- package/src/css/main.styl +163 -0
- package/src/css/position.styl +309 -0
- package/src/css/range.styl +91 -0
- package/src/css/submenu.styl +168 -0
- package/src/index.js +29 -0
- package/src/js/action.js +686 -0
- package/src/js/command/addIcon.js +42 -0
- package/src/js/command/addImageObject.js +34 -0
- package/src/js/command/addObject.js +43 -0
- package/src/js/command/addShape.js +51 -0
- package/src/js/command/addText.js +73 -0
- package/src/js/command/applyFilter.js +95 -0
- package/src/js/command/changeIconColor.js +48 -0
- package/src/js/command/changeSelection.js +31 -0
- package/src/js/command/changeShape.js +84 -0
- package/src/js/command/changeText.js +44 -0
- package/src/js/command/changeTextStyle.js +80 -0
- package/src/js/command/clearObjects.js +33 -0
- package/src/js/command/flip.js +36 -0
- package/src/js/command/loadImage.js +58 -0
- package/src/js/command/removeFilter.js +38 -0
- package/src/js/command/removeObject.js +37 -0
- package/src/js/command/resize.js +41 -0
- package/src/js/command/resizeCanvasDimension.js +40 -0
- package/src/js/command/rotate.js +64 -0
- package/src/js/command/setObjectPosition.js +50 -0
- package/src/js/command/setObjectProperties.js +55 -0
- package/src/js/component/cropper.js +407 -0
- package/src/js/component/filter.js +229 -0
- package/src/js/component/flip.js +146 -0
- package/src/js/component/freeDrawing.js +144 -0
- package/src/js/component/icon.js +246 -0
- package/src/js/component/imageLoader.js +84 -0
- package/src/js/component/line.js +205 -0
- package/src/js/component/resize.js +103 -0
- package/src/js/component/rotation.js +91 -0
- package/src/js/component/shape.js +601 -0
- package/src/js/component/text.js +572 -0
- package/src/js/component/zoom.js +708 -0
- package/src/js/consts.js +404 -0
- package/src/js/drawingMode/cropper.js +35 -0
- package/src/js/drawingMode/freeDrawing.js +36 -0
- package/src/js/drawingMode/icon.js +35 -0
- package/src/js/drawingMode/lineDrawing.js +36 -0
- package/src/js/drawingMode/resize.js +35 -0
- package/src/js/drawingMode/shape.js +35 -0
- package/src/js/drawingMode/text.js +35 -0
- package/src/js/drawingMode/zoom.js +37 -0
- package/src/js/extension/arrowLine.js +172 -0
- package/src/js/extension/blur.js +29 -0
- package/src/js/extension/colorFilter.js +104 -0
- package/src/js/extension/cropzone.js +568 -0
- package/src/js/extension/emboss.js +29 -0
- package/src/js/extension/mask.js +90 -0
- package/src/js/extension/sharpen.js +29 -0
- package/src/js/factory/command.js +36 -0
- package/src/js/factory/errorMessage.js +27 -0
- package/src/js/graphics.js +1539 -0
- package/src/js/helper/imagetracer.js +1396 -0
- package/src/js/helper/selectionModifyHelper.js +86 -0
- package/src/js/helper/shapeFilterFillHelper.js +564 -0
- package/src/js/helper/shapeResizeHelper.js +237 -0
- package/src/js/imageEditor.js +1795 -0
- package/src/js/interface/command.js +131 -0
- package/src/js/interface/component.js +127 -0
- package/src/js/interface/drawingMode.js +47 -0
- package/src/js/invoker.js +292 -0
- package/src/js/polyfill.js +498 -0
- package/src/js/ui/crop.js +139 -0
- package/src/js/ui/draw.js +187 -0
- package/src/js/ui/filter.js +510 -0
- package/src/js/ui/flip.js +87 -0
- package/src/js/ui/history.js +171 -0
- package/src/js/ui/icon.js +191 -0
- package/src/js/ui/locale/locale.js +19 -0
- package/src/js/ui/mask.js +96 -0
- package/src/js/ui/panelMenu.js +130 -0
- package/src/js/ui/resize.js +241 -0
- package/src/js/ui/rotate.js +123 -0
- package/src/js/ui/shape.js +265 -0
- package/src/js/ui/submenuBase.js +122 -0
- package/src/js/ui/template/controls.js +21 -0
- package/src/js/ui/template/mainContainer.js +38 -0
- package/src/js/ui/template/style.js +146 -0
- package/src/js/ui/template/submenu/crop.js +73 -0
- package/src/js/ui/template/submenu/draw.js +42 -0
- package/src/js/ui/template/submenu/filter.js +157 -0
- package/src/js/ui/template/submenu/flip.js +41 -0
- package/src/js/ui/template/submenu/history.js +22 -0
- package/src/js/ui/template/submenu/icon.js +108 -0
- package/src/js/ui/template/submenu/mask.js +30 -0
- package/src/js/ui/template/submenu/resize.js +54 -0
- package/src/js/ui/template/submenu/rotate.js +32 -0
- package/src/js/ui/template/submenu/shape.js +45 -0
- package/src/js/ui/template/submenu/text.js +67 -0
- package/src/js/ui/template/submenu/zoom.js +41 -0
- package/src/js/ui/text.js +279 -0
- package/src/js/ui/theme/standard.js +220 -0
- package/src/js/ui/theme/theme.js +249 -0
- package/src/js/ui/tools/colorpicker.js +250 -0
- package/src/js/ui/tools/range.js +390 -0
- package/src/js/ui.js +858 -0
- package/src/js/util.js +551 -0
- package/src/svg/default.svg +335 -0
- package/src/svg/icon-a/ic-apply.svg +6 -0
- package/src/svg/icon-a/ic-cancel.svg +6 -0
- package/src/svg/icon-a/ic-color-transparent-w.svg +12 -0
- package/src/svg/icon-a/ic-crop.svg +7 -0
- package/src/svg/icon-a/ic-delete-all.svg +6 -0
- package/src/svg/icon-a/ic-delete.svg +6 -0
- package/src/svg/icon-a/ic-draw-free.svg +5 -0
- package/src/svg/icon-a/ic-draw-line.svg +5 -0
- package/src/svg/icon-a/ic-draw.svg +6 -0
- package/src/svg/icon-a/ic-filter.svg +7 -0
- package/src/svg/icon-a/ic-flip-reset.svg +7 -0
- package/src/svg/icon-a/ic-flip-x.svg +6 -0
- package/src/svg/icon-a/ic-flip-y.svg +6 -0
- package/src/svg/icon-a/ic-flip.svg +6 -0
- package/src/svg/icon-a/ic-history-check.svg +5 -0
- package/src/svg/icon-a/ic-history-crop.svg +7 -0
- package/src/svg/icon-a/ic-history-delete.svg +9 -0
- package/src/svg/icon-a/ic-history-draw.svg +7 -0
- package/src/svg/icon-a/ic-history-filter.svg +8 -0
- package/src/svg/icon-a/ic-history-flip.svg +6 -0
- package/src/svg/icon-a/ic-history-group.svg +9 -0
- package/src/svg/icon-a/ic-history-icon.svg +6 -0
- package/src/svg/icon-a/ic-history-load.svg +7 -0
- package/src/svg/icon-a/ic-history-mask.svg +9 -0
- package/src/svg/icon-a/ic-history-resize.svg +12 -0
- package/src/svg/icon-a/ic-history-rotate.svg +16 -0
- package/src/svg/icon-a/ic-history-shape.svg +7 -0
- package/src/svg/icon-a/ic-history-text.svg +8 -0
- package/src/svg/icon-a/ic-history.svg +6 -0
- package/src/svg/icon-a/ic-icon-arrow-2.svg +5 -0
- package/src/svg/icon-a/ic-icon-arrow-3.svg +5 -0
- package/src/svg/icon-a/ic-icon-arrow.svg +5 -0
- package/src/svg/icon-a/ic-icon-bubble.svg +5 -0
- package/src/svg/icon-a/ic-icon-heart.svg +5 -0
- package/src/svg/icon-a/ic-icon-load.svg +8 -0
- package/src/svg/icon-a/ic-icon-location.svg +8 -0
- package/src/svg/icon-a/ic-icon-polygon.svg +5 -0
- package/src/svg/icon-a/ic-icon-star-2.svg +5 -0
- package/src/svg/icon-a/ic-icon-star.svg +5 -0
- package/src/svg/icon-a/ic-icon.svg +5 -0
- package/src/svg/icon-a/ic-mask-load.svg +8 -0
- package/src/svg/icon-a/ic-mask.svg +6 -0
- package/src/svg/icon-a/ic-redo.svg +7 -0
- package/src/svg/icon-a/ic-reset.svg +7 -0
- package/src/svg/icon-a/ic-resize.svg +13 -0
- package/src/svg/icon-a/ic-rotate-clockwise.svg +7 -0
- package/src/svg/icon-a/ic-rotate-counterclockwise.svg +7 -0
- package/src/svg/icon-a/ic-rotate.svg +7 -0
- package/src/svg/icon-a/ic-shape-circle.svg +5 -0
- package/src/svg/icon-a/ic-shape-rectangle.svg +5 -0
- package/src/svg/icon-a/ic-shape-triangle.svg +5 -0
- package/src/svg/icon-a/ic-shape.svg +6 -0
- package/src/svg/icon-a/ic-text-align-center.svg +6 -0
- package/src/svg/icon-a/ic-text-align-left.svg +6 -0
- package/src/svg/icon-a/ic-text-align-right.svg +6 -0
- package/src/svg/icon-a/ic-text-bold.svg +7 -0
- package/src/svg/icon-a/ic-text-italic.svg +6 -0
- package/src/svg/icon-a/ic-text-underline.svg +7 -0
- package/src/svg/icon-a/ic-text.svg +7 -0
- package/src/svg/icon-a/ic-undo.svg +7 -0
- package/src/svg/icon-a/ic-zoom-hand.svg +8 -0
- package/src/svg/icon-a/ic-zoom-zoom-in.svg +10 -0
- package/src/svg/icon-a/ic-zoom-zoom-out.svg +9 -0
- package/src/svg/icon-a/img-bi.svg +5 -0
- package/src/svg/icon-b/ic-apply.svg +6 -0
- package/src/svg/icon-b/ic-cancel.svg +6 -0
- package/src/svg/icon-b/ic-crop.svg +7 -0
- package/src/svg/icon-b/ic-delete-all.svg +6 -0
- package/src/svg/icon-b/ic-delete.svg +6 -0
- package/src/svg/icon-b/ic-draw-free.svg +5 -0
- package/src/svg/icon-b/ic-draw-line.svg +5 -0
- package/src/svg/icon-b/ic-draw.svg +6 -0
- package/src/svg/icon-b/ic-filter.svg +7 -0
- package/src/svg/icon-b/ic-flip-reset.svg +7 -0
- package/src/svg/icon-b/ic-flip-x.svg +6 -0
- package/src/svg/icon-b/ic-flip-y.svg +6 -0
- package/src/svg/icon-b/ic-flip.svg +6 -0
- package/src/svg/icon-b/ic-history-check.svg +5 -0
- package/src/svg/icon-b/ic-history-crop.svg +7 -0
- package/src/svg/icon-b/ic-history-delete.svg +9 -0
- package/src/svg/icon-b/ic-history-draw.svg +7 -0
- package/src/svg/icon-b/ic-history-filter.svg +8 -0
- package/src/svg/icon-b/ic-history-flip.svg +6 -0
- package/src/svg/icon-b/ic-history-group.svg +9 -0
- package/src/svg/icon-b/ic-history-icon.svg +6 -0
- package/src/svg/icon-b/ic-history-load.svg +7 -0
- package/src/svg/icon-b/ic-history-mask.svg +9 -0
- package/src/svg/icon-b/ic-history-resize.svg +12 -0
- package/src/svg/icon-b/ic-history-rotate.svg +16 -0
- package/src/svg/icon-b/ic-history-shape.svg +7 -0
- package/src/svg/icon-b/ic-history-text.svg +8 -0
- package/src/svg/icon-b/ic-history.svg +6 -0
- package/src/svg/icon-b/ic-icon-arrow-2.svg +5 -0
- package/src/svg/icon-b/ic-icon-arrow-3.svg +5 -0
- package/src/svg/icon-b/ic-icon-arrow.svg +5 -0
- package/src/svg/icon-b/ic-icon-bubble.svg +5 -0
- package/src/svg/icon-b/ic-icon-heart.svg +5 -0
- package/src/svg/icon-b/ic-icon-load.svg +8 -0
- package/src/svg/icon-b/ic-icon-location.svg +8 -0
- package/src/svg/icon-b/ic-icon-polygon.svg +5 -0
- package/src/svg/icon-b/ic-icon-star-2.svg +5 -0
- package/src/svg/icon-b/ic-icon-star.svg +5 -0
- package/src/svg/icon-b/ic-icon.svg +5 -0
- package/src/svg/icon-b/ic-mask-load.svg +8 -0
- package/src/svg/icon-b/ic-mask.svg +6 -0
- package/src/svg/icon-b/ic-redo.svg +7 -0
- package/src/svg/icon-b/ic-reset.svg +7 -0
- package/src/svg/icon-b/ic-resize.svg +13 -0
- package/src/svg/icon-b/ic-rotate-clockwise.svg +7 -0
- package/src/svg/icon-b/ic-rotate-counterclockwise.svg +7 -0
- package/src/svg/icon-b/ic-rotate.svg +7 -0
- package/src/svg/icon-b/ic-shape-circle.svg +5 -0
- package/src/svg/icon-b/ic-shape-rectangle.svg +5 -0
- package/src/svg/icon-b/ic-shape-triangle.svg +5 -0
- package/src/svg/icon-b/ic-shape.svg +6 -0
- package/src/svg/icon-b/ic-text-align-center.svg +6 -0
- package/src/svg/icon-b/ic-text-align-left.svg +6 -0
- package/src/svg/icon-b/ic-text-align-right.svg +6 -0
- package/src/svg/icon-b/ic-text-bold.svg +7 -0
- package/src/svg/icon-b/ic-text-italic.svg +6 -0
- package/src/svg/icon-b/ic-text-underline.svg +7 -0
- package/src/svg/icon-b/ic-text.svg +7 -0
- package/src/svg/icon-b/ic-undo.svg +7 -0
- package/src/svg/icon-b/ic-zoom-hand.svg +8 -0
- package/src/svg/icon-b/ic-zoom-zoom-in.svg +12 -0
- package/src/svg/icon-b/ic-zoom-zoom-out.svg +11 -0
- package/src/svg/icon-b/img-bi.svg +5 -0
- package/src/svg/icon-c/ic-apply.svg +6 -0
- package/src/svg/icon-c/ic-cancel.svg +6 -0
- package/src/svg/icon-c/ic-crop.svg +7 -0
- package/src/svg/icon-c/ic-delete-all.svg +6 -0
- package/src/svg/icon-c/ic-delete.svg +6 -0
- package/src/svg/icon-c/ic-draw-free.svg +5 -0
- package/src/svg/icon-c/ic-draw-line.svg +5 -0
- package/src/svg/icon-c/ic-draw.svg +6 -0
- package/src/svg/icon-c/ic-filter.svg +7 -0
- package/src/svg/icon-c/ic-flip-reset.svg +7 -0
- package/src/svg/icon-c/ic-flip-x.svg +6 -0
- package/src/svg/icon-c/ic-flip-y.svg +6 -0
- package/src/svg/icon-c/ic-flip.svg +6 -0
- package/src/svg/icon-c/ic-history-check.svg +5 -0
- package/src/svg/icon-c/ic-history-crop.svg +7 -0
- package/src/svg/icon-c/ic-history-delete.svg +9 -0
- package/src/svg/icon-c/ic-history-draw.svg +7 -0
- package/src/svg/icon-c/ic-history-filter.svg +8 -0
- package/src/svg/icon-c/ic-history-flip.svg +6 -0
- package/src/svg/icon-c/ic-history-group.svg +9 -0
- package/src/svg/icon-c/ic-history-icon.svg +6 -0
- package/src/svg/icon-c/ic-history-load.svg +7 -0
- package/src/svg/icon-c/ic-history-mask.svg +9 -0
- package/src/svg/icon-c/ic-history-resize.svg +12 -0
- package/src/svg/icon-c/ic-history-rotate.svg +16 -0
- package/src/svg/icon-c/ic-history-shape.svg +7 -0
- package/src/svg/icon-c/ic-history-text.svg +8 -0
- package/src/svg/icon-c/ic-history.svg +6 -0
- package/src/svg/icon-c/ic-icon-arrow-2.svg +5 -0
- package/src/svg/icon-c/ic-icon-arrow-3.svg +5 -0
- package/src/svg/icon-c/ic-icon-arrow.svg +5 -0
- package/src/svg/icon-c/ic-icon-bubble.svg +5 -0
- package/src/svg/icon-c/ic-icon-heart.svg +5 -0
- package/src/svg/icon-c/ic-icon-load.svg +8 -0
- package/src/svg/icon-c/ic-icon-location.svg +8 -0
- package/src/svg/icon-c/ic-icon-polygon.svg +5 -0
- package/src/svg/icon-c/ic-icon-star-2.svg +5 -0
- package/src/svg/icon-c/ic-icon-star.svg +5 -0
- package/src/svg/icon-c/ic-icon.svg +5 -0
- package/src/svg/icon-c/ic-mask-load.svg +8 -0
- package/src/svg/icon-c/ic-mask.svg +6 -0
- package/src/svg/icon-c/ic-redo.svg +7 -0
- package/src/svg/icon-c/ic-reset.svg +7 -0
- package/src/svg/icon-c/ic-resize.svg +13 -0
- package/src/svg/icon-c/ic-rotate-clockwise.svg +7 -0
- package/src/svg/icon-c/ic-rotate-counterclockwise.svg +7 -0
- package/src/svg/icon-c/ic-rotate.svg +7 -0
- package/src/svg/icon-c/ic-shape-circle.svg +5 -0
- package/src/svg/icon-c/ic-shape-rectangle.svg +5 -0
- package/src/svg/icon-c/ic-shape-triangle.svg +5 -0
- package/src/svg/icon-c/ic-shape.svg +6 -0
- package/src/svg/icon-c/ic-text-align-center.svg +6 -0
- package/src/svg/icon-c/ic-text-align-left.svg +6 -0
- package/src/svg/icon-c/ic-text-align-right.svg +6 -0
- package/src/svg/icon-c/ic-text-bold.svg +7 -0
- package/src/svg/icon-c/ic-text-italic.svg +6 -0
- package/src/svg/icon-c/ic-text-underline.svg +7 -0
- package/src/svg/icon-c/ic-text.svg +7 -0
- package/src/svg/icon-c/ic-undo.svg +7 -0
- package/src/svg/icon-c/ic-zoom-hand.svg +8 -0
- package/src/svg/icon-c/ic-zoom-zoom-in.svg +12 -0
- package/src/svg/icon-c/ic-zoom-zoom-out.svg +11 -0
- package/src/svg/icon-c/img-bi.svg +5 -0
- package/src/svg/icon-d/ic-apply.svg +6 -0
- package/src/svg/icon-d/ic-cancel.svg +6 -0
- package/src/svg/icon-d/ic-crop.svg +7 -0
- package/src/svg/icon-d/ic-delete-all.svg +6 -0
- package/src/svg/icon-d/ic-delete.svg +6 -0
- package/src/svg/icon-d/ic-draw-free.svg +5 -0
- package/src/svg/icon-d/ic-draw-line.svg +5 -0
- package/src/svg/icon-d/ic-draw.svg +6 -0
- package/src/svg/icon-d/ic-filter.svg +7 -0
- package/src/svg/icon-d/ic-flip-reset.svg +7 -0
- package/src/svg/icon-d/ic-flip-x.svg +6 -0
- package/src/svg/icon-d/ic-flip-y.svg +6 -0
- package/src/svg/icon-d/ic-flip.svg +6 -0
- package/src/svg/icon-d/ic-history-check.svg +5 -0
- package/src/svg/icon-d/ic-history-crop.svg +7 -0
- package/src/svg/icon-d/ic-history-delete.svg +9 -0
- package/src/svg/icon-d/ic-history-draw.svg +7 -0
- package/src/svg/icon-d/ic-history-filter.svg +8 -0
- package/src/svg/icon-d/ic-history-flip.svg +6 -0
- package/src/svg/icon-d/ic-history-group.svg +9 -0
- package/src/svg/icon-d/ic-history-icon.svg +6 -0
- package/src/svg/icon-d/ic-history-load.svg +7 -0
- package/src/svg/icon-d/ic-history-mask.svg +9 -0
- package/src/svg/icon-d/ic-history-resize.svg +12 -0
- package/src/svg/icon-d/ic-history-rotate.svg +16 -0
- package/src/svg/icon-d/ic-history-shape.svg +7 -0
- package/src/svg/icon-d/ic-history-text.svg +8 -0
- package/src/svg/icon-d/ic-history.svg +6 -0
- package/src/svg/icon-d/ic-icon-arrow-2.svg +5 -0
- package/src/svg/icon-d/ic-icon-arrow-3.svg +5 -0
- package/src/svg/icon-d/ic-icon-arrow.svg +5 -0
- package/src/svg/icon-d/ic-icon-bubble.svg +5 -0
- package/src/svg/icon-d/ic-icon-heart.svg +5 -0
- package/src/svg/icon-d/ic-icon-load.svg +8 -0
- package/src/svg/icon-d/ic-icon-location.svg +8 -0
- package/src/svg/icon-d/ic-icon-polygon.svg +5 -0
- package/src/svg/icon-d/ic-icon-star-2.svg +5 -0
- package/src/svg/icon-d/ic-icon-star.svg +5 -0
- package/src/svg/icon-d/ic-icon.svg +5 -0
- package/src/svg/icon-d/ic-mask-load.svg +8 -0
- package/src/svg/icon-d/ic-mask.svg +6 -0
- package/src/svg/icon-d/ic-redo.svg +7 -0
- package/src/svg/icon-d/ic-reset.svg +7 -0
- package/src/svg/icon-d/ic-resize.svg +13 -0
- package/src/svg/icon-d/ic-rotate-clockwise.svg +7 -0
- package/src/svg/icon-d/ic-rotate-counterclockwise.svg +7 -0
- package/src/svg/icon-d/ic-rotate.svg +7 -0
- package/src/svg/icon-d/ic-shape-circle.svg +5 -0
- package/src/svg/icon-d/ic-shape-rectangle.svg +5 -0
- package/src/svg/icon-d/ic-shape-triangle.svg +5 -0
- package/src/svg/icon-d/ic-shape.svg +6 -0
- package/src/svg/icon-d/ic-text-align-center.svg +6 -0
- package/src/svg/icon-d/ic-text-align-left.svg +6 -0
- package/src/svg/icon-d/ic-text-align-right.svg +6 -0
- package/src/svg/icon-d/ic-text-bold.svg +7 -0
- package/src/svg/icon-d/ic-text-italic.svg +6 -0
- package/src/svg/icon-d/ic-text-underline.svg +7 -0
- package/src/svg/icon-d/ic-text.svg +7 -0
- package/src/svg/icon-d/ic-undo.svg +7 -0
- package/src/svg/icon-d/ic-zoom-hand.svg +8 -0
- package/src/svg/icon-d/ic-zoom-zoom-in.svg +12 -0
- package/src/svg/icon-d/ic-zoom-zoom-out.svg +11 -0
- package/src/svg/icon-d/img-bi.svg +5 -0
@@ -0,0 +1,241 @@
|
|
1
|
+
import Submenu from '@/ui/submenuBase';
|
2
|
+
import templateHtml from '@/ui/template/submenu/resize';
|
3
|
+
import { assignmentForDestroy, toInteger } from '@/util';
|
4
|
+
import Range from '@/ui/tools/range';
|
5
|
+
import { defaultResizePixelValues } from '@/consts';
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Resize ui class
|
9
|
+
* @class
|
10
|
+
* @ignore
|
11
|
+
*/
|
12
|
+
class Resize extends Submenu {
|
13
|
+
constructor(subMenuElement, { locale, makeSvgIcon, menuBarPosition, usageStatistics }) {
|
14
|
+
super(subMenuElement, {
|
15
|
+
locale,
|
16
|
+
name: 'resize',
|
17
|
+
makeSvgIcon,
|
18
|
+
menuBarPosition,
|
19
|
+
templateHtml,
|
20
|
+
usageStatistics,
|
21
|
+
});
|
22
|
+
|
23
|
+
this.status = 'active';
|
24
|
+
|
25
|
+
this._lockState = false;
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Original dimensions
|
29
|
+
* @type {Object}
|
30
|
+
* @private
|
31
|
+
*/
|
32
|
+
this._originalDimensions = null;
|
33
|
+
|
34
|
+
this._els = {
|
35
|
+
widthRange: new Range(
|
36
|
+
{
|
37
|
+
slider: this.selector('.tie-width-range'),
|
38
|
+
input: this.selector('.tie-width-range-value'),
|
39
|
+
},
|
40
|
+
defaultResizePixelValues
|
41
|
+
),
|
42
|
+
heightRange: new Range(
|
43
|
+
{
|
44
|
+
slider: this.selector('.tie-height-range'),
|
45
|
+
input: this.selector('.tie-height-range-value'),
|
46
|
+
},
|
47
|
+
defaultResizePixelValues
|
48
|
+
),
|
49
|
+
lockAspectRatio: this.selector('.tie-lock-aspect-ratio'),
|
50
|
+
apply: this.selector('.tie-resize-button .apply'),
|
51
|
+
cancel: this.selector('.tie-resize-button .cancel'),
|
52
|
+
};
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Executed when the menu starts.
|
57
|
+
*/
|
58
|
+
changeStartMode() {
|
59
|
+
this.actions.modeChange('resize');
|
60
|
+
const dimensions = this.actions.getCurrentDimensions();
|
61
|
+
|
62
|
+
this._originalDimensions = dimensions;
|
63
|
+
|
64
|
+
this.setWidthValue(dimensions.width);
|
65
|
+
this.setHeightValue(dimensions.height);
|
66
|
+
this.setLimit({
|
67
|
+
minWidth: defaultResizePixelValues.min,
|
68
|
+
minHeight: defaultResizePixelValues.min,
|
69
|
+
maxWidth: dimensions.width,
|
70
|
+
maxHeight: dimensions.height,
|
71
|
+
});
|
72
|
+
}
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Returns the menu to its default state.
|
76
|
+
*/
|
77
|
+
changeStandbyMode() {
|
78
|
+
this.actions.stopDrawingMode();
|
79
|
+
this.actions.reset(true);
|
80
|
+
}
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Set dimension limits
|
84
|
+
* @param {object} limits - expect dimension limits for change
|
85
|
+
*/
|
86
|
+
setLimit(limits) {
|
87
|
+
this._els.widthRange.min = this.calcMinValue(limits.minWidth);
|
88
|
+
this._els.heightRange.min = this.calcMinValue(limits.minHeight);
|
89
|
+
this._els.widthRange.max = this.calcMaxValue(limits.maxWidth);
|
90
|
+
this._els.heightRange.max = this.calcMaxValue(limits.maxHeight);
|
91
|
+
}
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Calculate max value
|
95
|
+
* @param {number} maxValue - max value
|
96
|
+
* @returns {number}
|
97
|
+
*/
|
98
|
+
calcMaxValue(maxValue) {
|
99
|
+
if (maxValue <= 0) {
|
100
|
+
maxValue = defaultResizePixelValues.max;
|
101
|
+
}
|
102
|
+
|
103
|
+
return maxValue;
|
104
|
+
}
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Calculate min value
|
108
|
+
* @param {number} minValue - min value
|
109
|
+
* @returns {number}
|
110
|
+
*/
|
111
|
+
calcMinValue(minValue) {
|
112
|
+
if (minValue <= 0) {
|
113
|
+
minValue = defaultResizePixelValues.min;
|
114
|
+
}
|
115
|
+
|
116
|
+
return minValue;
|
117
|
+
}
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Set width value
|
121
|
+
* @param {number} value - expect value for widthRange change
|
122
|
+
* @param {boolean} trigger - fire change event control
|
123
|
+
*/
|
124
|
+
setWidthValue(value, trigger = false) {
|
125
|
+
this._els.widthRange.value = value;
|
126
|
+
if (trigger) {
|
127
|
+
this._els.widthRange.trigger('change');
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Set height value
|
133
|
+
* @param {number} value - expect value for heightRange change
|
134
|
+
* @param {boolean} trigger - fire change event control
|
135
|
+
*/
|
136
|
+
setHeightValue(value, trigger = false) {
|
137
|
+
this._els.heightRange.value = value;
|
138
|
+
if (trigger) {
|
139
|
+
this._els.heightRange.trigger('change');
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Destroys the instance.
|
145
|
+
*/
|
146
|
+
destroy() {
|
147
|
+
this._removeEvent();
|
148
|
+
|
149
|
+
assignmentForDestroy(this);
|
150
|
+
}
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Add event for resize
|
154
|
+
* @param {Object} actions - actions for resize
|
155
|
+
* @param {Function} actions.resize - resize action
|
156
|
+
* @param {Function} actions.preview - preview action
|
157
|
+
* @param {Function} actions.getCurrentDimensions - Get current dimensions action
|
158
|
+
* @param {Function} actions.modeChange - change mode
|
159
|
+
* @param {Function} actions.stopDrawingMode - stop drawing mode
|
160
|
+
* @param {Function} actions.lockAspectRatio - lock aspect ratio
|
161
|
+
* @param {Function} actions.reset - reset action
|
162
|
+
*/
|
163
|
+
addEvent(actions) {
|
164
|
+
this._els.widthRange.on('change', this._changeWidthRangeHandler.bind(this));
|
165
|
+
this._els.heightRange.on('change', this._changeHeightRangeHandler.bind(this));
|
166
|
+
this._els.lockAspectRatio.addEventListener('change', this._changeLockAspectRatio.bind(this));
|
167
|
+
|
168
|
+
const apply = this._applyEventHandler.bind(this);
|
169
|
+
const cancel = this._cancelEventHandler.bind(this);
|
170
|
+
|
171
|
+
this.eventHandler = {
|
172
|
+
apply,
|
173
|
+
cancel,
|
174
|
+
};
|
175
|
+
|
176
|
+
this.actions = actions;
|
177
|
+
this._els.apply.addEventListener('click', apply);
|
178
|
+
this._els.cancel.addEventListener('click', cancel);
|
179
|
+
}
|
180
|
+
|
181
|
+
/**
|
182
|
+
* Change width
|
183
|
+
* @param {number} value - width range value
|
184
|
+
* @private
|
185
|
+
*/
|
186
|
+
_changeWidthRangeHandler(value) {
|
187
|
+
this.actions.preview('width', toInteger(value), this._lockState);
|
188
|
+
}
|
189
|
+
|
190
|
+
/**
|
191
|
+
* Change height
|
192
|
+
* @param {number} value - height range value
|
193
|
+
* @private
|
194
|
+
*/
|
195
|
+
_changeHeightRangeHandler(value) {
|
196
|
+
this.actions.preview('height', toInteger(value), this._lockState);
|
197
|
+
}
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Change lock aspect ratio state
|
201
|
+
* @param {Event} event - aspect ratio check event
|
202
|
+
* @private
|
203
|
+
*/
|
204
|
+
_changeLockAspectRatio(event) {
|
205
|
+
this._lockState = event.target.checked;
|
206
|
+
this.actions.lockAspectRatio(this._lockState);
|
207
|
+
}
|
208
|
+
|
209
|
+
/**
|
210
|
+
* Remove event
|
211
|
+
* @private
|
212
|
+
*/
|
213
|
+
_removeEvent() {
|
214
|
+
this._els.apply.removeEventListener('click', this.eventHandler.apply);
|
215
|
+
this._els.cancel.removeEventListener('click', this.eventHandler.cancel);
|
216
|
+
}
|
217
|
+
|
218
|
+
_applyEventHandler() {
|
219
|
+
this.actions.resize();
|
220
|
+
this._els.apply.classList.remove('active');
|
221
|
+
}
|
222
|
+
|
223
|
+
_cancelEventHandler() {
|
224
|
+
this.actions.reset();
|
225
|
+
this._els.cancel.classList.remove('active');
|
226
|
+
}
|
227
|
+
|
228
|
+
/**
|
229
|
+
* Change apply button status
|
230
|
+
* @param {Boolean} enableStatus - apply button status
|
231
|
+
*/
|
232
|
+
changeApplyButtonStatus(enableStatus) {
|
233
|
+
if (enableStatus) {
|
234
|
+
this._els.apply.classList.add('active');
|
235
|
+
} else {
|
236
|
+
this._els.apply.classList.remove('active');
|
237
|
+
}
|
238
|
+
}
|
239
|
+
}
|
240
|
+
|
241
|
+
export default Resize;
|
@@ -0,0 +1,123 @@
|
|
1
|
+
import Range from '@/ui/tools/range';
|
2
|
+
import Submenu from '@/ui/submenuBase';
|
3
|
+
import templateHtml from '@/ui/template/submenu/rotate';
|
4
|
+
import { toInteger, assignmentForDestroy } from '@/util';
|
5
|
+
import { defaultRotateRangeValues } from '@/consts';
|
6
|
+
|
7
|
+
const CLOCKWISE = 30;
|
8
|
+
const COUNTERCLOCKWISE = -30;
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Rotate ui class
|
12
|
+
* @class
|
13
|
+
* @ignore
|
14
|
+
*/
|
15
|
+
class Rotate extends Submenu {
|
16
|
+
constructor(subMenuElement, { locale, makeSvgIcon, menuBarPosition, usageStatistics }) {
|
17
|
+
super(subMenuElement, {
|
18
|
+
locale,
|
19
|
+
name: 'rotate',
|
20
|
+
makeSvgIcon,
|
21
|
+
menuBarPosition,
|
22
|
+
templateHtml,
|
23
|
+
usageStatistics,
|
24
|
+
});
|
25
|
+
this._value = 0;
|
26
|
+
|
27
|
+
this._els = {
|
28
|
+
rotateButton: this.selector('.tie-rotate-button'),
|
29
|
+
rotateRange: new Range(
|
30
|
+
{
|
31
|
+
slider: this.selector('.tie-rotate-range'),
|
32
|
+
input: this.selector('.tie-rotate-range-value'),
|
33
|
+
},
|
34
|
+
defaultRotateRangeValues
|
35
|
+
),
|
36
|
+
};
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Destroys the instance.
|
41
|
+
*/
|
42
|
+
destroy() {
|
43
|
+
this._removeEvent();
|
44
|
+
this._els.rotateRange.destroy();
|
45
|
+
|
46
|
+
assignmentForDestroy(this);
|
47
|
+
}
|
48
|
+
|
49
|
+
setRangeBarAngle(type, angle) {
|
50
|
+
let resultAngle = angle;
|
51
|
+
|
52
|
+
if (type === 'rotate') {
|
53
|
+
resultAngle = parseInt(this._els.rotateRange.value, 10) + angle;
|
54
|
+
}
|
55
|
+
|
56
|
+
this._setRangeBarRatio(resultAngle);
|
57
|
+
}
|
58
|
+
|
59
|
+
_setRangeBarRatio(angle) {
|
60
|
+
this._els.rotateRange.value = angle;
|
61
|
+
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Add event for rotate
|
65
|
+
* @param {Object} actions - actions for crop
|
66
|
+
* @param {Function} actions.rotate - rotate action
|
67
|
+
* @param {Function} actions.setAngle - set angle action
|
68
|
+
*/
|
69
|
+
addEvent(actions) {
|
70
|
+
this.eventHandler.rotationAngleChanged = this._changeRotateForButton.bind(this);
|
71
|
+
|
72
|
+
// {rotate, setAngle}
|
73
|
+
this.actions = actions;
|
74
|
+
this._els.rotateButton.addEventListener('click', this.eventHandler.rotationAngleChanged);
|
75
|
+
this._els.rotateRange.on('change', this._changeRotateForRange.bind(this));
|
76
|
+
}
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Remove event
|
80
|
+
* @private
|
81
|
+
*/
|
82
|
+
_removeEvent() {
|
83
|
+
this._els.rotateButton.removeEventListener('click', this.eventHandler.rotationAngleChanged);
|
84
|
+
this._els.rotateRange.off();
|
85
|
+
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Change rotate for range
|
89
|
+
* @param {number} value - angle value
|
90
|
+
* @param {boolean} isLast - Is last change
|
91
|
+
* @private
|
92
|
+
*/
|
93
|
+
_changeRotateForRange(value, isLast) {
|
94
|
+
const angle = toInteger(value);
|
95
|
+
this.actions.setAngle(angle, !isLast);
|
96
|
+
this._value = angle;
|
97
|
+
}
|
98
|
+
|
99
|
+
/**
|
100
|
+
* Change rotate for button
|
101
|
+
* @param {object} event - add button event object
|
102
|
+
* @private
|
103
|
+
*/
|
104
|
+
_changeRotateForButton(event) {
|
105
|
+
const button = event.target.closest('.tui-image-editor-button');
|
106
|
+
const angle = this._els.rotateRange.value;
|
107
|
+
|
108
|
+
if (button) {
|
109
|
+
const rotateType = this.getButtonType(button, ['counterclockwise', 'clockwise']);
|
110
|
+
const rotateAngle = {
|
111
|
+
clockwise: CLOCKWISE,
|
112
|
+
counterclockwise: COUNTERCLOCKWISE,
|
113
|
+
}[rotateType];
|
114
|
+
const newAngle = parseInt(angle, 10) + rotateAngle;
|
115
|
+
const isRotatable = newAngle >= -360 && newAngle <= 360;
|
116
|
+
if (isRotatable) {
|
117
|
+
this.actions.rotate(rotateAngle);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
export default Rotate;
|
@@ -0,0 +1,265 @@
|
|
1
|
+
import forEachArray from 'tui-code-snippet/collection/forEachArray';
|
2
|
+
import Colorpicker from '@/ui/tools/colorpicker';
|
3
|
+
import Range from '@/ui/tools/range';
|
4
|
+
import Submenu from '@/ui/submenuBase';
|
5
|
+
import templateHtml from '@/ui/template/submenu/shape';
|
6
|
+
import { toInteger, assignmentForDestroy } from '@/util';
|
7
|
+
import { defaultShapeStrokeValues, eventNames, selectorNames } from '@/consts';
|
8
|
+
|
9
|
+
const SHAPE_DEFAULT_OPTION = {
|
10
|
+
stroke: '#ffbb3b',
|
11
|
+
fill: '',
|
12
|
+
strokeWidth: 3,
|
13
|
+
};
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Shape ui class
|
17
|
+
* @class
|
18
|
+
* @ignore
|
19
|
+
*/
|
20
|
+
class Shape extends Submenu {
|
21
|
+
constructor(subMenuElement, { locale, makeSvgIcon, menuBarPosition, usageStatistics }) {
|
22
|
+
super(subMenuElement, {
|
23
|
+
locale,
|
24
|
+
name: 'shape',
|
25
|
+
makeSvgIcon,
|
26
|
+
menuBarPosition,
|
27
|
+
templateHtml,
|
28
|
+
usageStatistics,
|
29
|
+
});
|
30
|
+
this.type = null;
|
31
|
+
this.options = SHAPE_DEFAULT_OPTION;
|
32
|
+
|
33
|
+
this._els = {
|
34
|
+
shapeSelectButton: this.selector('.tie-shape-button'),
|
35
|
+
shapeColorButton: this.selector('.tie-shape-color-button'),
|
36
|
+
strokeRange: new Range(
|
37
|
+
{
|
38
|
+
slider: this.selector('.tie-stroke-range'),
|
39
|
+
input: this.selector('.tie-stroke-range-value'),
|
40
|
+
},
|
41
|
+
defaultShapeStrokeValues
|
42
|
+
),
|
43
|
+
fillColorpicker: new Colorpicker(this.selector('.tie-color-fill'), {
|
44
|
+
defaultColor: '',
|
45
|
+
toggleDirection: this.toggleDirection,
|
46
|
+
usageStatistics: this.usageStatistics,
|
47
|
+
}),
|
48
|
+
strokeColorpicker: new Colorpicker(this.selector('.tie-color-stroke'), {
|
49
|
+
defaultColor: '#ffbb3b',
|
50
|
+
toggleDirection: this.toggleDirection,
|
51
|
+
usageStatistics: this.usageStatistics,
|
52
|
+
}),
|
53
|
+
};
|
54
|
+
|
55
|
+
this.colorPickerControls.push(this._els.fillColorpicker);
|
56
|
+
this.colorPickerControls.push(this._els.strokeColorpicker);
|
57
|
+
|
58
|
+
this.colorPickerInputBoxes = [];
|
59
|
+
this.colorPickerInputBoxes.push(
|
60
|
+
this._els.fillColorpicker.colorpickerElement.querySelector(
|
61
|
+
selectorNames.COLOR_PICKER_INPUT_BOX
|
62
|
+
)
|
63
|
+
);
|
64
|
+
this.colorPickerInputBoxes.push(
|
65
|
+
this._els.strokeColorpicker.colorpickerElement.querySelector(
|
66
|
+
selectorNames.COLOR_PICKER_INPUT_BOX
|
67
|
+
)
|
68
|
+
);
|
69
|
+
}
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Destroys the instance.
|
73
|
+
*/
|
74
|
+
destroy() {
|
75
|
+
this._removeEvent();
|
76
|
+
this._els.strokeRange.destroy();
|
77
|
+
this._els.fillColorpicker.destroy();
|
78
|
+
this._els.strokeColorpicker.destroy();
|
79
|
+
|
80
|
+
assignmentForDestroy(this);
|
81
|
+
}
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Add event for shape
|
85
|
+
* @param {Object} actions - actions for shape
|
86
|
+
* @param {Function} actions.changeShape - change shape mode
|
87
|
+
* @param {Function} actions.setDrawingShape - set drawing shape
|
88
|
+
*/
|
89
|
+
addEvent(actions) {
|
90
|
+
this.eventHandler.shapeTypeSelected = this._changeShapeHandler.bind(this);
|
91
|
+
this.actions = actions;
|
92
|
+
|
93
|
+
this._els.shapeSelectButton.addEventListener('click', this.eventHandler.shapeTypeSelected);
|
94
|
+
this._els.strokeRange.on('change', this._changeStrokeRangeHandler.bind(this));
|
95
|
+
this._els.fillColorpicker.on('change', this._changeFillColorHandler.bind(this));
|
96
|
+
this._els.strokeColorpicker.on('change', this._changeStrokeColorHandler.bind(this));
|
97
|
+
this._els.fillColorpicker.on('changeShow', this.colorPickerChangeShow.bind(this));
|
98
|
+
this._els.strokeColorpicker.on('changeShow', this.colorPickerChangeShow.bind(this));
|
99
|
+
|
100
|
+
forEachArray(
|
101
|
+
this.colorPickerInputBoxes,
|
102
|
+
(inputBox) => {
|
103
|
+
inputBox.addEventListener(eventNames.FOCUS, this._onStartEditingInputBox.bind(this));
|
104
|
+
inputBox.addEventListener(eventNames.BLUR, this._onStopEditingInputBox.bind(this));
|
105
|
+
},
|
106
|
+
this
|
107
|
+
);
|
108
|
+
}
|
109
|
+
|
110
|
+
/**
|
111
|
+
* Remove event
|
112
|
+
* @private
|
113
|
+
*/
|
114
|
+
_removeEvent() {
|
115
|
+
this._els.shapeSelectButton.removeEventListener('click', this.eventHandler.shapeTypeSelected);
|
116
|
+
this._els.strokeRange.off();
|
117
|
+
this._els.fillColorpicker.off();
|
118
|
+
this._els.strokeColorpicker.off();
|
119
|
+
|
120
|
+
forEachArray(
|
121
|
+
this.colorPickerInputBoxes,
|
122
|
+
(inputBox) => {
|
123
|
+
inputBox.removeEventListener(eventNames.FOCUS, this._onStartEditingInputBox.bind(this));
|
124
|
+
inputBox.removeEventListener(eventNames.BLUR, this._onStopEditingInputBox.bind(this));
|
125
|
+
},
|
126
|
+
this
|
127
|
+
);
|
128
|
+
}
|
129
|
+
|
130
|
+
/**
|
131
|
+
* Set Shape status
|
132
|
+
* @param {Object} options - options of shape status
|
133
|
+
* @param {string} strokeWidth - stroke width
|
134
|
+
* @param {string} strokeColor - stroke color
|
135
|
+
* @param {string} fillColor - fill color
|
136
|
+
*/
|
137
|
+
setShapeStatus({ strokeWidth, strokeColor, fillColor }) {
|
138
|
+
this._els.strokeRange.value = strokeWidth;
|
139
|
+
this._els.strokeColorpicker.color = strokeColor;
|
140
|
+
this._els.fillColorpicker.color = fillColor;
|
141
|
+
this.options.stroke = strokeColor;
|
142
|
+
this.options.fill = fillColor;
|
143
|
+
this.options.strokeWidth = strokeWidth;
|
144
|
+
|
145
|
+
this.actions.setDrawingShape(this.type, { strokeWidth });
|
146
|
+
}
|
147
|
+
|
148
|
+
/**
|
149
|
+
* Executed when the menu starts.
|
150
|
+
*/
|
151
|
+
changeStartMode() {
|
152
|
+
this.actions.stopDrawingMode();
|
153
|
+
}
|
154
|
+
|
155
|
+
/**
|
156
|
+
* Returns the menu to its default state.
|
157
|
+
*/
|
158
|
+
changeStandbyMode() {
|
159
|
+
this.type = null;
|
160
|
+
this.actions.changeSelectableAll(true);
|
161
|
+
this._els.shapeSelectButton.classList.remove('circle');
|
162
|
+
this._els.shapeSelectButton.classList.remove('triangle');
|
163
|
+
this._els.shapeSelectButton.classList.remove('rect');
|
164
|
+
}
|
165
|
+
|
166
|
+
/**
|
167
|
+
* set range stroke max value
|
168
|
+
* @param {number} maxValue - expect max value for change
|
169
|
+
*/
|
170
|
+
setMaxStrokeValue(maxValue) {
|
171
|
+
let strokeMaxValue = maxValue;
|
172
|
+
if (strokeMaxValue <= 0) {
|
173
|
+
strokeMaxValue = defaultShapeStrokeValues.max;
|
174
|
+
}
|
175
|
+
this._els.strokeRange.max = strokeMaxValue;
|
176
|
+
}
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Set stroke value
|
180
|
+
* @param {number} value - expect value for strokeRange change
|
181
|
+
*/
|
182
|
+
setStrokeValue(value) {
|
183
|
+
this._els.strokeRange.value = value;
|
184
|
+
this._els.strokeRange.trigger('change');
|
185
|
+
}
|
186
|
+
|
187
|
+
/**
|
188
|
+
* Get stroke value
|
189
|
+
* @returns {number} - stroke range value
|
190
|
+
*/
|
191
|
+
getStrokeValue() {
|
192
|
+
return this._els.strokeRange.value;
|
193
|
+
}
|
194
|
+
|
195
|
+
/**
|
196
|
+
* Change icon color
|
197
|
+
* @param {object} event - add button event object
|
198
|
+
* @private
|
199
|
+
*/
|
200
|
+
_changeShapeHandler(event) {
|
201
|
+
const button = event.target.closest('.tui-image-editor-button');
|
202
|
+
if (button) {
|
203
|
+
this.actions.stopDrawingMode();
|
204
|
+
this.actions.discardSelection();
|
205
|
+
const shapeType = this.getButtonType(button, ['circle', 'triangle', 'rect']);
|
206
|
+
|
207
|
+
if (this.type === shapeType) {
|
208
|
+
this.changeStandbyMode();
|
209
|
+
|
210
|
+
return;
|
211
|
+
}
|
212
|
+
this.changeStandbyMode();
|
213
|
+
this.type = shapeType;
|
214
|
+
event.currentTarget.classList.add(shapeType);
|
215
|
+
this.actions.changeSelectableAll(false);
|
216
|
+
this.actions.modeChange('shape');
|
217
|
+
}
|
218
|
+
}
|
219
|
+
|
220
|
+
/**
|
221
|
+
* Change stroke range
|
222
|
+
* @param {number} value - stroke range value
|
223
|
+
* @param {boolean} isLast - Is last change
|
224
|
+
* @private
|
225
|
+
*/
|
226
|
+
_changeStrokeRangeHandler(value, isLast) {
|
227
|
+
this.options.strokeWidth = toInteger(value);
|
228
|
+
this.actions.changeShape(
|
229
|
+
{
|
230
|
+
strokeWidth: value,
|
231
|
+
},
|
232
|
+
!isLast
|
233
|
+
);
|
234
|
+
|
235
|
+
this.actions.setDrawingShape(this.type, this.options);
|
236
|
+
}
|
237
|
+
|
238
|
+
/**
|
239
|
+
* Change shape color
|
240
|
+
* @param {string} color - fill color
|
241
|
+
* @private
|
242
|
+
*/
|
243
|
+
_changeFillColorHandler(color) {
|
244
|
+
color = color || 'transparent';
|
245
|
+
this.options.fill = color;
|
246
|
+
this.actions.changeShape({
|
247
|
+
fill: color,
|
248
|
+
});
|
249
|
+
}
|
250
|
+
|
251
|
+
/**
|
252
|
+
* Change shape stroke color
|
253
|
+
* @param {string} color - fill color
|
254
|
+
* @private
|
255
|
+
*/
|
256
|
+
_changeStrokeColorHandler(color) {
|
257
|
+
color = color || 'transparent';
|
258
|
+
this.options.stroke = color;
|
259
|
+
this.actions.changeShape({
|
260
|
+
stroke: color,
|
261
|
+
});
|
262
|
+
}
|
263
|
+
}
|
264
|
+
|
265
|
+
export default Shape;
|