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,187 @@
|
|
1
|
+
import Colorpicker from '@/ui/tools/colorpicker';
|
2
|
+
import Range from '@/ui/tools/range';
|
3
|
+
import Submenu from '@/ui/submenuBase';
|
4
|
+
import templateHtml from '@/ui/template/submenu/draw';
|
5
|
+
import { assignmentForDestroy, getRgb } from '@/util';
|
6
|
+
import { defaultDrawRangeValues, eventNames, selectorNames } from '@/consts';
|
7
|
+
|
8
|
+
const DRAW_OPACITY = 0.7;
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Draw ui class
|
12
|
+
* @class
|
13
|
+
* @ignore
|
14
|
+
*/
|
15
|
+
class Draw extends Submenu {
|
16
|
+
constructor(subMenuElement, { locale, makeSvgIcon, menuBarPosition, usageStatistics }) {
|
17
|
+
super(subMenuElement, {
|
18
|
+
locale,
|
19
|
+
name: 'draw',
|
20
|
+
makeSvgIcon,
|
21
|
+
menuBarPosition,
|
22
|
+
templateHtml,
|
23
|
+
usageStatistics,
|
24
|
+
});
|
25
|
+
|
26
|
+
this._els = {
|
27
|
+
lineSelectButton: this.selector('.tie-draw-line-select-button'),
|
28
|
+
drawColorPicker: new Colorpicker(this.selector('.tie-draw-color'), {
|
29
|
+
defaultColor: '#00a9ff',
|
30
|
+
toggleDirection: this.toggleDirection,
|
31
|
+
usageStatistics: this.usageStatistics,
|
32
|
+
}),
|
33
|
+
drawRange: new Range(
|
34
|
+
{
|
35
|
+
slider: this.selector('.tie-draw-range'),
|
36
|
+
input: this.selector('.tie-draw-range-value'),
|
37
|
+
},
|
38
|
+
defaultDrawRangeValues
|
39
|
+
),
|
40
|
+
};
|
41
|
+
|
42
|
+
this.type = null;
|
43
|
+
this.color = this._els.drawColorPicker.color;
|
44
|
+
this.width = this._els.drawRange.value;
|
45
|
+
|
46
|
+
this.colorPickerInputBox = this._els.drawColorPicker.colorpickerElement.querySelector(
|
47
|
+
selectorNames.COLOR_PICKER_INPUT_BOX
|
48
|
+
);
|
49
|
+
}
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Destroys the instance.
|
53
|
+
*/
|
54
|
+
destroy() {
|
55
|
+
this._removeEvent();
|
56
|
+
this._els.drawColorPicker.destroy();
|
57
|
+
this._els.drawRange.destroy();
|
58
|
+
|
59
|
+
assignmentForDestroy(this);
|
60
|
+
}
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Add event for draw
|
64
|
+
* @param {Object} actions - actions for crop
|
65
|
+
* @param {Function} actions.setDrawMode - set draw mode
|
66
|
+
*/
|
67
|
+
addEvent(actions) {
|
68
|
+
this.eventHandler.changeDrawType = this._changeDrawType.bind(this);
|
69
|
+
|
70
|
+
this.actions = actions;
|
71
|
+
this._els.lineSelectButton.addEventListener('click', this.eventHandler.changeDrawType);
|
72
|
+
this._els.drawColorPicker.on('change', this._changeDrawColor.bind(this));
|
73
|
+
this._els.drawRange.on('change', this._changeDrawRange.bind(this));
|
74
|
+
|
75
|
+
this.colorPickerInputBox.addEventListener(
|
76
|
+
eventNames.FOCUS,
|
77
|
+
this._onStartEditingInputBox.bind(this)
|
78
|
+
);
|
79
|
+
this.colorPickerInputBox.addEventListener(
|
80
|
+
eventNames.BLUR,
|
81
|
+
this._onStopEditingInputBox.bind(this)
|
82
|
+
);
|
83
|
+
}
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Remove event
|
87
|
+
* @private
|
88
|
+
*/
|
89
|
+
_removeEvent() {
|
90
|
+
this._els.lineSelectButton.removeEventListener('click', this.eventHandler.changeDrawType);
|
91
|
+
this._els.drawColorPicker.off();
|
92
|
+
this._els.drawRange.off();
|
93
|
+
|
94
|
+
this.colorPickerInputBox.removeEventListener(
|
95
|
+
eventNames.FOCUS,
|
96
|
+
this._onStartEditingInputBox.bind(this)
|
97
|
+
);
|
98
|
+
this.colorPickerInputBox.removeEventListener(
|
99
|
+
eventNames.BLUR,
|
100
|
+
this._onStopEditingInputBox.bind(this)
|
101
|
+
);
|
102
|
+
}
|
103
|
+
|
104
|
+
/**
|
105
|
+
* set draw mode - action runner
|
106
|
+
*/
|
107
|
+
setDrawMode() {
|
108
|
+
this.actions.setDrawMode(this.type, {
|
109
|
+
width: this.width,
|
110
|
+
color: getRgb(this.color, DRAW_OPACITY),
|
111
|
+
});
|
112
|
+
}
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Returns the menu to its default state.
|
116
|
+
*/
|
117
|
+
changeStandbyMode() {
|
118
|
+
this.type = null;
|
119
|
+
this.actions.stopDrawingMode();
|
120
|
+
this.actions.changeSelectableAll(true);
|
121
|
+
this._els.lineSelectButton.classList.remove('free');
|
122
|
+
this._els.lineSelectButton.classList.remove('line');
|
123
|
+
}
|
124
|
+
|
125
|
+
/**
|
126
|
+
* Executed when the menu starts.
|
127
|
+
*/
|
128
|
+
changeStartMode() {
|
129
|
+
this.type = 'free';
|
130
|
+
this._els.lineSelectButton.classList.add('free');
|
131
|
+
this.setDrawMode();
|
132
|
+
}
|
133
|
+
|
134
|
+
/**
|
135
|
+
* Change draw type event
|
136
|
+
* @param {object} event - line select event
|
137
|
+
* @private
|
138
|
+
*/
|
139
|
+
_changeDrawType(event) {
|
140
|
+
const button = event.target.closest('.tui-image-editor-button');
|
141
|
+
if (button) {
|
142
|
+
const lineType = this.getButtonType(button, ['free', 'line']);
|
143
|
+
this.actions.discardSelection();
|
144
|
+
|
145
|
+
if (this.type === lineType) {
|
146
|
+
this.changeStandbyMode();
|
147
|
+
|
148
|
+
return;
|
149
|
+
}
|
150
|
+
|
151
|
+
this.changeStandbyMode();
|
152
|
+
this.type = lineType;
|
153
|
+
this._els.lineSelectButton.classList.add(lineType);
|
154
|
+
this.setDrawMode();
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Change drawing color
|
160
|
+
* @param {string} color - select drawing color
|
161
|
+
* @private
|
162
|
+
*/
|
163
|
+
_changeDrawColor(color) {
|
164
|
+
this.color = color || 'transparent';
|
165
|
+
if (!this.type) {
|
166
|
+
this.changeStartMode();
|
167
|
+
} else {
|
168
|
+
this.setDrawMode();
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
/**
|
173
|
+
* Change drawing Range
|
174
|
+
* @param {number} value - select drawing range
|
175
|
+
* @private
|
176
|
+
*/
|
177
|
+
_changeDrawRange(value) {
|
178
|
+
this.width = value;
|
179
|
+
if (!this.type) {
|
180
|
+
this.changeStartMode();
|
181
|
+
} else {
|
182
|
+
this.setDrawMode();
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}
|
186
|
+
|
187
|
+
export default Draw;
|
@@ -0,0 +1,510 @@
|
|
1
|
+
import forEach from 'tui-code-snippet/collection/forEach';
|
2
|
+
import forEachArray from 'tui-code-snippet/collection/forEachArray';
|
3
|
+
import isExisty from 'tui-code-snippet/type/isExisty';
|
4
|
+
import Colorpicker from '@/ui/tools/colorpicker';
|
5
|
+
import Range from '@/ui/tools/range';
|
6
|
+
import Submenu from '@/ui/submenuBase';
|
7
|
+
import templateHtml from '@/ui/template/submenu/filter';
|
8
|
+
import { toInteger, toCamelCase, assignmentForDestroy } from '@/util';
|
9
|
+
import { defaultFilterRangeValues as FILTER_RANGE, eventNames, selectorNames } from '@/consts';
|
10
|
+
|
11
|
+
const PICKER_CONTROL_HEIGHT = '130px';
|
12
|
+
const BLEND_OPTIONS = ['add', 'diff', 'subtract', 'multiply', 'screen', 'lighten', 'darken'];
|
13
|
+
const FILTER_OPTIONS = [
|
14
|
+
'grayscale',
|
15
|
+
'invert',
|
16
|
+
'sepia',
|
17
|
+
'vintage',
|
18
|
+
'blur',
|
19
|
+
'sharpen',
|
20
|
+
'emboss',
|
21
|
+
'remove-white',
|
22
|
+
'brightness',
|
23
|
+
'noise',
|
24
|
+
'pixelate',
|
25
|
+
'color-filter',
|
26
|
+
'tint',
|
27
|
+
'multiply',
|
28
|
+
'blend',
|
29
|
+
];
|
30
|
+
const filterNameMap = {
|
31
|
+
grayscale: 'grayscale',
|
32
|
+
invert: 'invert',
|
33
|
+
sepia: 'sepia',
|
34
|
+
blur: 'blur',
|
35
|
+
sharpen: 'sharpen',
|
36
|
+
emboss: 'emboss',
|
37
|
+
removeWhite: 'removeColor',
|
38
|
+
brightness: 'brightness',
|
39
|
+
contrast: 'contrast',
|
40
|
+
saturation: 'saturation',
|
41
|
+
vintage: 'vintage',
|
42
|
+
polaroid: 'polaroid',
|
43
|
+
noise: 'noise',
|
44
|
+
pixelate: 'pixelate',
|
45
|
+
colorFilter: 'removeColor',
|
46
|
+
tint: 'blendColor',
|
47
|
+
multiply: 'blendColor',
|
48
|
+
blend: 'blendColor',
|
49
|
+
hue: 'hue',
|
50
|
+
gamma: 'gamma',
|
51
|
+
};
|
52
|
+
const RANGE_INSTANCE_NAMES = [
|
53
|
+
'removewhiteDistanceRange',
|
54
|
+
'colorfilterThresholdRange',
|
55
|
+
'pixelateRange',
|
56
|
+
'noiseRange',
|
57
|
+
'brightnessRange',
|
58
|
+
'tintOpacity',
|
59
|
+
];
|
60
|
+
const COLORPICKER_INSTANCE_NAMES = ['filterBlendColor', 'filterMultiplyColor', 'filterTintColor'];
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Filter ui class
|
64
|
+
* @class
|
65
|
+
* @ignore
|
66
|
+
*/
|
67
|
+
class Filter extends Submenu {
|
68
|
+
constructor(subMenuElement, { locale, menuBarPosition, usageStatistics }) {
|
69
|
+
super(subMenuElement, {
|
70
|
+
locale,
|
71
|
+
name: 'filter',
|
72
|
+
menuBarPosition,
|
73
|
+
templateHtml,
|
74
|
+
usageStatistics,
|
75
|
+
});
|
76
|
+
|
77
|
+
this.selectBoxShow = false;
|
78
|
+
|
79
|
+
this.checkedMap = {};
|
80
|
+
this._makeControlElement();
|
81
|
+
}
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Destroys the instance.
|
85
|
+
*/
|
86
|
+
destroy() {
|
87
|
+
this._removeEvent();
|
88
|
+
this._destroyToolInstance();
|
89
|
+
|
90
|
+
assignmentForDestroy(this);
|
91
|
+
}
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Remove event for filter
|
95
|
+
*/
|
96
|
+
_removeEvent() {
|
97
|
+
forEach(FILTER_OPTIONS, (filter) => {
|
98
|
+
const filterCheckElement = this.selector(`.tie-${filter}`);
|
99
|
+
const filterNameCamelCase = toCamelCase(filter);
|
100
|
+
|
101
|
+
filterCheckElement.removeEventListener('change', this.eventHandler[filterNameCamelCase]);
|
102
|
+
});
|
103
|
+
|
104
|
+
forEach([...RANGE_INSTANCE_NAMES, ...COLORPICKER_INSTANCE_NAMES], (instanceName) => {
|
105
|
+
this._els[instanceName].off();
|
106
|
+
});
|
107
|
+
|
108
|
+
this._els.blendType.removeEventListener('change', this.eventHandler.changeBlendFilter);
|
109
|
+
this._els.blendType.removeEventListener('click', this.eventHandler.changeBlendFilter);
|
110
|
+
|
111
|
+
forEachArray(
|
112
|
+
this.colorPickerInputBoxes,
|
113
|
+
(inputBox) => {
|
114
|
+
inputBox.removeEventListener(eventNames.FOCUS, this._onStartEditingInputBox.bind(this));
|
115
|
+
inputBox.removeEventListener(eventNames.BLUR, this._onStopEditingInputBox.bind(this));
|
116
|
+
},
|
117
|
+
this
|
118
|
+
);
|
119
|
+
}
|
120
|
+
|
121
|
+
_destroyToolInstance() {
|
122
|
+
forEach([...RANGE_INSTANCE_NAMES, ...COLORPICKER_INSTANCE_NAMES], (instanceName) => {
|
123
|
+
this._els[instanceName].destroy();
|
124
|
+
});
|
125
|
+
}
|
126
|
+
|
127
|
+
/**
|
128
|
+
* Add event for filter
|
129
|
+
* @param {Object} actions - actions for crop
|
130
|
+
* @param {Function} actions.applyFilter - apply filter option
|
131
|
+
*/
|
132
|
+
addEvent({ applyFilter }) {
|
133
|
+
const changeFilterState = (filterName) =>
|
134
|
+
this._changeFilterState.bind(this, applyFilter, filterName);
|
135
|
+
const changeFilterStateForRange = (filterName) => (value, isLast) =>
|
136
|
+
this._changeFilterState(applyFilter, filterName, isLast);
|
137
|
+
|
138
|
+
this.eventHandler = {
|
139
|
+
changeBlendFilter: changeFilterState('blend'),
|
140
|
+
blandTypeClick: (event) => event.stopPropagation(),
|
141
|
+
};
|
142
|
+
|
143
|
+
forEach(FILTER_OPTIONS, (filter) => {
|
144
|
+
const filterCheckElement = this.selector(`.tie-${filter}`);
|
145
|
+
const filterNameCamelCase = toCamelCase(filter);
|
146
|
+
this.checkedMap[filterNameCamelCase] = filterCheckElement;
|
147
|
+
this.eventHandler[filterNameCamelCase] = changeFilterState(filterNameCamelCase);
|
148
|
+
|
149
|
+
filterCheckElement.addEventListener('change', this.eventHandler[filterNameCamelCase]);
|
150
|
+
});
|
151
|
+
|
152
|
+
this._els.removewhiteDistanceRange.on('change', changeFilterStateForRange('removeWhite'));
|
153
|
+
this._els.colorfilterThresholdRange.on('change', changeFilterStateForRange('colorFilter'));
|
154
|
+
this._els.pixelateRange.on('change', changeFilterStateForRange('pixelate'));
|
155
|
+
this._els.noiseRange.on('change', changeFilterStateForRange('noise'));
|
156
|
+
this._els.brightnessRange.on('change', changeFilterStateForRange('brightness'));
|
157
|
+
|
158
|
+
this._els.filterBlendColor.on('change', this.eventHandler.changeBlendFilter);
|
159
|
+
this._els.filterMultiplyColor.on('change', changeFilterState('multiply'));
|
160
|
+
this._els.filterTintColor.on('change', changeFilterState('tint'));
|
161
|
+
this._els.tintOpacity.on('change', changeFilterStateForRange('tint'));
|
162
|
+
this._els.filterMultiplyColor.on('changeShow', this.colorPickerChangeShow.bind(this));
|
163
|
+
this._els.filterTintColor.on('changeShow', this.colorPickerChangeShow.bind(this));
|
164
|
+
this._els.filterBlendColor.on('changeShow', this.colorPickerChangeShow.bind(this));
|
165
|
+
|
166
|
+
this._els.blendType.addEventListener('change', this.eventHandler.changeBlendFilter);
|
167
|
+
this._els.blendType.addEventListener('click', this.eventHandler.blandTypeClick);
|
168
|
+
|
169
|
+
forEachArray(
|
170
|
+
this.colorPickerInputBoxes,
|
171
|
+
(inputBox) => {
|
172
|
+
inputBox.addEventListener(eventNames.FOCUS, this._onStartEditingInputBox.bind(this));
|
173
|
+
inputBox.addEventListener(eventNames.BLUR, this._onStopEditingInputBox.bind(this));
|
174
|
+
},
|
175
|
+
this
|
176
|
+
);
|
177
|
+
}
|
178
|
+
|
179
|
+
/**
|
180
|
+
* Set filter for undo changed
|
181
|
+
* @param {Object} changedFilterInfos - changed command infos
|
182
|
+
* @param {string} type - filter type
|
183
|
+
* @param {string} action - add or remove
|
184
|
+
* @param {Object} options - filter options
|
185
|
+
*/
|
186
|
+
setFilterState(changedFilterInfos) {
|
187
|
+
const { type, options, action } = changedFilterInfos;
|
188
|
+
const filterName = this._getFilterNameFromOptions(type, options);
|
189
|
+
const isRemove = action === 'remove';
|
190
|
+
|
191
|
+
if (!isRemove) {
|
192
|
+
this._setFilterState(filterName, options);
|
193
|
+
}
|
194
|
+
|
195
|
+
this.checkedMap[filterName].checked = !isRemove;
|
196
|
+
}
|
197
|
+
|
198
|
+
/**
|
199
|
+
* Init all filter's checkbox to unchecked state
|
200
|
+
*/
|
201
|
+
initFilterCheckBoxState() {
|
202
|
+
forEach(
|
203
|
+
this.checkedMap,
|
204
|
+
(filter) => {
|
205
|
+
filter.checked = false;
|
206
|
+
},
|
207
|
+
this
|
208
|
+
);
|
209
|
+
}
|
210
|
+
|
211
|
+
/**
|
212
|
+
* Set filter for undo changed
|
213
|
+
* @param {string} filterName - filter name
|
214
|
+
* @param {Object} options - filter options
|
215
|
+
* @private
|
216
|
+
*/
|
217
|
+
// eslint-disable-next-line complexity
|
218
|
+
_setFilterState(filterName, options) {
|
219
|
+
if (filterName === 'colorFilter') {
|
220
|
+
this._els.colorfilterThresholdRange.value = options.distance;
|
221
|
+
} else if (filterName === 'removeWhite') {
|
222
|
+
this._els.removewhiteDistanceRange.value = options.distance;
|
223
|
+
} else if (filterName === 'pixelate') {
|
224
|
+
this._els.pixelateRange.value = options.blocksize;
|
225
|
+
} else if (filterName === 'brightness') {
|
226
|
+
this._els.brightnessRange.value = options.brightness;
|
227
|
+
} else if (filterName === 'noise') {
|
228
|
+
this._els.noiseRange.value = options.noise;
|
229
|
+
} else if (filterName === 'tint') {
|
230
|
+
this._els.tintOpacity.value = options.alpha;
|
231
|
+
this._els.filterTintColor.color = options.color;
|
232
|
+
} else if (filterName === 'blend') {
|
233
|
+
this._els.filterBlendColor.color = options.color;
|
234
|
+
} else if (filterName === 'multiply') {
|
235
|
+
this._els.filterMultiplyColor.color = options.color;
|
236
|
+
}
|
237
|
+
}
|
238
|
+
|
239
|
+
/**
|
240
|
+
* Get filter name
|
241
|
+
* @param {string} type - filter type
|
242
|
+
* @param {Object} options - filter options
|
243
|
+
* @returns {string} filter name
|
244
|
+
* @private
|
245
|
+
*/
|
246
|
+
_getFilterNameFromOptions(type, options) {
|
247
|
+
let filterName = type;
|
248
|
+
|
249
|
+
if (type === 'removeColor') {
|
250
|
+
filterName = isExisty(options.useAlpha) ? 'removeWhite' : 'colorFilter';
|
251
|
+
} else if (type === 'blendColor') {
|
252
|
+
filterName = {
|
253
|
+
add: 'blend',
|
254
|
+
multiply: 'multiply',
|
255
|
+
tint: 'tint',
|
256
|
+
}[options.mode];
|
257
|
+
}
|
258
|
+
|
259
|
+
return filterName;
|
260
|
+
}
|
261
|
+
|
262
|
+
/**
|
263
|
+
* Add event for filter
|
264
|
+
* @param {Function} applyFilter - actions for firter
|
265
|
+
* @param {string} filterName - filter name
|
266
|
+
* @param {boolean} [isLast] - Is last change
|
267
|
+
*/
|
268
|
+
_changeFilterState(applyFilter, filterName, isLast = true) {
|
269
|
+
const apply = this.checkedMap[filterName].checked;
|
270
|
+
const type = filterNameMap[filterName];
|
271
|
+
|
272
|
+
const checkboxGroup = this.checkedMap[filterName].closest('.tui-image-editor-checkbox-group');
|
273
|
+
if (checkboxGroup) {
|
274
|
+
if (apply) {
|
275
|
+
checkboxGroup.classList.remove('tui-image-editor-disabled');
|
276
|
+
} else {
|
277
|
+
checkboxGroup.classList.add('tui-image-editor-disabled');
|
278
|
+
}
|
279
|
+
}
|
280
|
+
applyFilter(apply, type, this._getFilterOption(filterName), !isLast);
|
281
|
+
}
|
282
|
+
|
283
|
+
/**
|
284
|
+
* Get filter option
|
285
|
+
* @param {String} type - filter type
|
286
|
+
* @returns {Object} filter option object
|
287
|
+
* @private
|
288
|
+
*/
|
289
|
+
// eslint-disable-next-line complexity
|
290
|
+
_getFilterOption(type) {
|
291
|
+
const option = {};
|
292
|
+
switch (type) {
|
293
|
+
case 'removeWhite':
|
294
|
+
option.color = '#FFFFFF';
|
295
|
+
option.useAlpha = false;
|
296
|
+
option.distance = parseFloat(this._els.removewhiteDistanceRange.value);
|
297
|
+
break;
|
298
|
+
case 'colorFilter':
|
299
|
+
option.color = '#FFFFFF';
|
300
|
+
option.distance = parseFloat(this._els.colorfilterThresholdRange.value);
|
301
|
+
break;
|
302
|
+
case 'pixelate':
|
303
|
+
option.blocksize = toInteger(this._els.pixelateRange.value);
|
304
|
+
break;
|
305
|
+
case 'noise':
|
306
|
+
option.noise = toInteger(this._els.noiseRange.value);
|
307
|
+
break;
|
308
|
+
case 'brightness':
|
309
|
+
option.brightness = parseFloat(this._els.brightnessRange.value);
|
310
|
+
break;
|
311
|
+
case 'blend':
|
312
|
+
option.mode = 'add';
|
313
|
+
option.color = this._els.filterBlendColor.color;
|
314
|
+
option.mode = this._els.blendType.value;
|
315
|
+
break;
|
316
|
+
case 'multiply':
|
317
|
+
option.mode = 'multiply';
|
318
|
+
option.color = this._els.filterMultiplyColor.color;
|
319
|
+
break;
|
320
|
+
case 'tint':
|
321
|
+
option.mode = 'tint';
|
322
|
+
option.color = this._els.filterTintColor.color;
|
323
|
+
option.alpha = this._els.tintOpacity.value;
|
324
|
+
break;
|
325
|
+
case 'blur':
|
326
|
+
option.blur = this._els.blurRange.value;
|
327
|
+
break;
|
328
|
+
default:
|
329
|
+
break;
|
330
|
+
}
|
331
|
+
|
332
|
+
return option;
|
333
|
+
}
|
334
|
+
|
335
|
+
/**
|
336
|
+
* Make submenu range and colorpicker control
|
337
|
+
* @private
|
338
|
+
*/
|
339
|
+
_makeControlElement() {
|
340
|
+
this._els = {
|
341
|
+
removewhiteDistanceRange: new Range(
|
342
|
+
{ slider: this.selector('.tie-removewhite-distance-range') },
|
343
|
+
FILTER_RANGE.removewhiteDistanceRange
|
344
|
+
),
|
345
|
+
brightnessRange: new Range(
|
346
|
+
{ slider: this.selector('.tie-brightness-range') },
|
347
|
+
FILTER_RANGE.brightnessRange
|
348
|
+
),
|
349
|
+
noiseRange: new Range({ slider: this.selector('.tie-noise-range') }, FILTER_RANGE.noiseRange),
|
350
|
+
pixelateRange: new Range(
|
351
|
+
{ slider: this.selector('.tie-pixelate-range') },
|
352
|
+
FILTER_RANGE.pixelateRange
|
353
|
+
),
|
354
|
+
colorfilterThresholdRange: new Range(
|
355
|
+
{ slider: this.selector('.tie-colorfilter-threshold-range') },
|
356
|
+
FILTER_RANGE.colorfilterThresholdRange
|
357
|
+
),
|
358
|
+
filterTintColor: new Colorpicker(this.selector('.tie-filter-tint-color'), {
|
359
|
+
defaultColor: '#03bd9e',
|
360
|
+
toggleDirection: this.toggleDirection,
|
361
|
+
usageStatistics: this.usageStatistics,
|
362
|
+
}),
|
363
|
+
filterMultiplyColor: new Colorpicker(this.selector('.tie-filter-multiply-color'), {
|
364
|
+
defaultColor: '#515ce6',
|
365
|
+
toggleDirection: this.toggleDirection,
|
366
|
+
usageStatistics: this.usageStatistics,
|
367
|
+
}),
|
368
|
+
filterBlendColor: new Colorpicker(this.selector('.tie-filter-blend-color'), {
|
369
|
+
defaultColor: '#ffbb3b',
|
370
|
+
toggleDirection: this.toggleDirection,
|
371
|
+
usageStatistics: this.usageStatistics,
|
372
|
+
}),
|
373
|
+
blurRange: FILTER_RANGE.blurFilterRange,
|
374
|
+
};
|
375
|
+
|
376
|
+
this._els.tintOpacity = this._pickerWithRange(this._els.filterTintColor.pickerControl);
|
377
|
+
this._els.blendType = this._pickerWithSelectbox(this._els.filterBlendColor.pickerControl);
|
378
|
+
|
379
|
+
this.colorPickerControls.push(this._els.filterTintColor);
|
380
|
+
this.colorPickerControls.push(this._els.filterMultiplyColor);
|
381
|
+
this.colorPickerControls.push(this._els.filterBlendColor);
|
382
|
+
|
383
|
+
this.colorPickerInputBoxes = [];
|
384
|
+
this.colorPickerInputBoxes.push(
|
385
|
+
this._els.filterTintColor.colorpickerElement.querySelector(
|
386
|
+
selectorNames.COLOR_PICKER_INPUT_BOX
|
387
|
+
)
|
388
|
+
);
|
389
|
+
this.colorPickerInputBoxes.push(
|
390
|
+
this._els.filterMultiplyColor.colorpickerElement.querySelector(
|
391
|
+
selectorNames.COLOR_PICKER_INPUT_BOX
|
392
|
+
)
|
393
|
+
);
|
394
|
+
this.colorPickerInputBoxes.push(
|
395
|
+
this._els.filterBlendColor.colorpickerElement.querySelector(
|
396
|
+
selectorNames.COLOR_PICKER_INPUT_BOX
|
397
|
+
)
|
398
|
+
);
|
399
|
+
}
|
400
|
+
|
401
|
+
/**
|
402
|
+
* Make submenu control for picker & range mixin
|
403
|
+
* @param {HTMLElement} pickerControl - pickerControl dom element
|
404
|
+
* @returns {Range}
|
405
|
+
* @private
|
406
|
+
*/
|
407
|
+
_pickerWithRange(pickerControl) {
|
408
|
+
const rangeWrap = document.createElement('div');
|
409
|
+
const rangeLabel = document.createElement('label');
|
410
|
+
const slider = document.createElement('div');
|
411
|
+
|
412
|
+
slider.id = 'tie-filter-tint-opacity';
|
413
|
+
rangeLabel.innerHTML = 'Opacity';
|
414
|
+
rangeWrap.appendChild(rangeLabel);
|
415
|
+
rangeWrap.appendChild(slider);
|
416
|
+
pickerControl.appendChild(rangeWrap);
|
417
|
+
pickerControl.style.height = PICKER_CONTROL_HEIGHT;
|
418
|
+
|
419
|
+
return new Range({ slider }, FILTER_RANGE.tintOpacityRange);
|
420
|
+
}
|
421
|
+
|
422
|
+
/**
|
423
|
+
* Make submenu control for picker & selectbox
|
424
|
+
* @param {HTMLElement} pickerControl - pickerControl dom element
|
425
|
+
* @returns {HTMLElement}
|
426
|
+
* @private
|
427
|
+
*/
|
428
|
+
_pickerWithSelectbox(pickerControl) {
|
429
|
+
const selectlistWrap = document.createElement('div');
|
430
|
+
const selectlist = document.createElement('select');
|
431
|
+
const optionlist = document.createElement('ul');
|
432
|
+
|
433
|
+
selectlistWrap.className = 'tui-image-editor-selectlist-wrap';
|
434
|
+
optionlist.className = 'tui-image-editor-selectlist';
|
435
|
+
|
436
|
+
selectlistWrap.appendChild(selectlist);
|
437
|
+
selectlistWrap.appendChild(optionlist);
|
438
|
+
|
439
|
+
this._makeSelectOptionList(selectlist);
|
440
|
+
|
441
|
+
pickerControl.appendChild(selectlistWrap);
|
442
|
+
pickerControl.style.height = PICKER_CONTROL_HEIGHT;
|
443
|
+
|
444
|
+
this._drawSelectOptionList(selectlist, optionlist);
|
445
|
+
this._pickerWithSelectboxForAddEvent(selectlist, optionlist);
|
446
|
+
|
447
|
+
return selectlist;
|
448
|
+
}
|
449
|
+
|
450
|
+
/**
|
451
|
+
* Make selectbox option list custom style
|
452
|
+
* @param {HTMLElement} selectlist - selectbox element
|
453
|
+
* @param {HTMLElement} optionlist - custom option list item element
|
454
|
+
* @private
|
455
|
+
*/
|
456
|
+
_drawSelectOptionList(selectlist, optionlist) {
|
457
|
+
const options = selectlist.querySelectorAll('option');
|
458
|
+
forEach(options, (option) => {
|
459
|
+
const optionElement = document.createElement('li');
|
460
|
+
optionElement.innerHTML = option.innerHTML;
|
461
|
+
optionElement.setAttribute('data-item', option.value);
|
462
|
+
optionlist.appendChild(optionElement);
|
463
|
+
});
|
464
|
+
}
|
465
|
+
|
466
|
+
/**
|
467
|
+
* custom selectbox custom event
|
468
|
+
* @param {HTMLElement} selectlist - selectbox element
|
469
|
+
* @param {HTMLElement} optionlist - custom option list item element
|
470
|
+
* @private
|
471
|
+
*/
|
472
|
+
_pickerWithSelectboxForAddEvent(selectlist, optionlist) {
|
473
|
+
optionlist.addEventListener('click', (event) => {
|
474
|
+
const optionValue = event.target.getAttribute('data-item');
|
475
|
+
const fireEvent = document.createEvent('HTMLEvents');
|
476
|
+
|
477
|
+
selectlist.querySelector(`[value="${optionValue}"]`).selected = true;
|
478
|
+
fireEvent.initEvent('change', true, true);
|
479
|
+
|
480
|
+
selectlist.dispatchEvent(fireEvent);
|
481
|
+
|
482
|
+
this.selectBoxShow = false;
|
483
|
+
optionlist.style.display = 'none';
|
484
|
+
});
|
485
|
+
|
486
|
+
selectlist.addEventListener('mousedown', (event) => {
|
487
|
+
event.preventDefault();
|
488
|
+
this.selectBoxShow = !this.selectBoxShow;
|
489
|
+
optionlist.style.display = this.selectBoxShow ? 'block' : 'none';
|
490
|
+
optionlist.setAttribute('data-selectitem', selectlist.value);
|
491
|
+
optionlist.querySelector(`[data-item='${selectlist.value}']`).classList.add('active');
|
492
|
+
});
|
493
|
+
}
|
494
|
+
|
495
|
+
/**
|
496
|
+
* Make option list for select control
|
497
|
+
* @param {HTMLElement} selectlist - blend option select list element
|
498
|
+
* @private
|
499
|
+
*/
|
500
|
+
_makeSelectOptionList(selectlist) {
|
501
|
+
forEach(BLEND_OPTIONS, (option) => {
|
502
|
+
const selectOption = document.createElement('option');
|
503
|
+
selectOption.setAttribute('value', option);
|
504
|
+
selectOption.innerHTML = option.replace(/^[a-z]/, ($0) => $0.toUpperCase());
|
505
|
+
selectlist.appendChild(selectOption);
|
506
|
+
});
|
507
|
+
}
|
508
|
+
}
|
509
|
+
|
510
|
+
export default Filter;
|