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.
Files changed (374) hide show
  1. package/README.md +193 -0
  2. package/dist/svg/icon-a.svg +376 -0
  3. package/dist/svg/icon-b.svg +369 -0
  4. package/dist/svg/icon-c.svg +369 -0
  5. package/dist/svg/icon-d.svg +369 -0
  6. package/dist/tui-image-editor.css +6 -0
  7. package/dist/tui-image-editor.js +62329 -0
  8. package/dist/tui-image-editor.min.css +5 -0
  9. package/dist/tui-image-editor.min.js +15 -0
  10. package/index.d.ts +334 -0
  11. package/package.json +52 -0
  12. package/src/css/buttons.styl +102 -0
  13. package/src/css/checkbox.styl +86 -0
  14. package/src/css/colorpicker.styl +98 -0
  15. package/src/css/gridtable.styl +45 -0
  16. package/src/css/icon.styl +44 -0
  17. package/src/css/index.styl +17 -0
  18. package/src/css/main.styl +163 -0
  19. package/src/css/position.styl +309 -0
  20. package/src/css/range.styl +91 -0
  21. package/src/css/submenu.styl +168 -0
  22. package/src/index.js +29 -0
  23. package/src/js/action.js +686 -0
  24. package/src/js/command/addIcon.js +42 -0
  25. package/src/js/command/addImageObject.js +34 -0
  26. package/src/js/command/addObject.js +43 -0
  27. package/src/js/command/addShape.js +51 -0
  28. package/src/js/command/addText.js +73 -0
  29. package/src/js/command/applyFilter.js +95 -0
  30. package/src/js/command/changeIconColor.js +48 -0
  31. package/src/js/command/changeSelection.js +31 -0
  32. package/src/js/command/changeShape.js +84 -0
  33. package/src/js/command/changeText.js +44 -0
  34. package/src/js/command/changeTextStyle.js +80 -0
  35. package/src/js/command/clearObjects.js +33 -0
  36. package/src/js/command/flip.js +36 -0
  37. package/src/js/command/loadImage.js +58 -0
  38. package/src/js/command/removeFilter.js +38 -0
  39. package/src/js/command/removeObject.js +37 -0
  40. package/src/js/command/resize.js +41 -0
  41. package/src/js/command/resizeCanvasDimension.js +40 -0
  42. package/src/js/command/rotate.js +64 -0
  43. package/src/js/command/setObjectPosition.js +50 -0
  44. package/src/js/command/setObjectProperties.js +55 -0
  45. package/src/js/component/cropper.js +407 -0
  46. package/src/js/component/filter.js +229 -0
  47. package/src/js/component/flip.js +146 -0
  48. package/src/js/component/freeDrawing.js +144 -0
  49. package/src/js/component/icon.js +246 -0
  50. package/src/js/component/imageLoader.js +84 -0
  51. package/src/js/component/line.js +205 -0
  52. package/src/js/component/resize.js +103 -0
  53. package/src/js/component/rotation.js +91 -0
  54. package/src/js/component/shape.js +601 -0
  55. package/src/js/component/text.js +572 -0
  56. package/src/js/component/zoom.js +708 -0
  57. package/src/js/consts.js +404 -0
  58. package/src/js/drawingMode/cropper.js +35 -0
  59. package/src/js/drawingMode/freeDrawing.js +36 -0
  60. package/src/js/drawingMode/icon.js +35 -0
  61. package/src/js/drawingMode/lineDrawing.js +36 -0
  62. package/src/js/drawingMode/resize.js +35 -0
  63. package/src/js/drawingMode/shape.js +35 -0
  64. package/src/js/drawingMode/text.js +35 -0
  65. package/src/js/drawingMode/zoom.js +37 -0
  66. package/src/js/extension/arrowLine.js +172 -0
  67. package/src/js/extension/blur.js +29 -0
  68. package/src/js/extension/colorFilter.js +104 -0
  69. package/src/js/extension/cropzone.js +568 -0
  70. package/src/js/extension/emboss.js +29 -0
  71. package/src/js/extension/mask.js +90 -0
  72. package/src/js/extension/sharpen.js +29 -0
  73. package/src/js/factory/command.js +36 -0
  74. package/src/js/factory/errorMessage.js +27 -0
  75. package/src/js/graphics.js +1539 -0
  76. package/src/js/helper/imagetracer.js +1396 -0
  77. package/src/js/helper/selectionModifyHelper.js +86 -0
  78. package/src/js/helper/shapeFilterFillHelper.js +564 -0
  79. package/src/js/helper/shapeResizeHelper.js +237 -0
  80. package/src/js/imageEditor.js +1795 -0
  81. package/src/js/interface/command.js +131 -0
  82. package/src/js/interface/component.js +127 -0
  83. package/src/js/interface/drawingMode.js +47 -0
  84. package/src/js/invoker.js +292 -0
  85. package/src/js/polyfill.js +498 -0
  86. package/src/js/ui/crop.js +139 -0
  87. package/src/js/ui/draw.js +187 -0
  88. package/src/js/ui/filter.js +510 -0
  89. package/src/js/ui/flip.js +87 -0
  90. package/src/js/ui/history.js +171 -0
  91. package/src/js/ui/icon.js +191 -0
  92. package/src/js/ui/locale/locale.js +19 -0
  93. package/src/js/ui/mask.js +96 -0
  94. package/src/js/ui/panelMenu.js +130 -0
  95. package/src/js/ui/resize.js +241 -0
  96. package/src/js/ui/rotate.js +123 -0
  97. package/src/js/ui/shape.js +265 -0
  98. package/src/js/ui/submenuBase.js +122 -0
  99. package/src/js/ui/template/controls.js +21 -0
  100. package/src/js/ui/template/mainContainer.js +38 -0
  101. package/src/js/ui/template/style.js +146 -0
  102. package/src/js/ui/template/submenu/crop.js +73 -0
  103. package/src/js/ui/template/submenu/draw.js +42 -0
  104. package/src/js/ui/template/submenu/filter.js +157 -0
  105. package/src/js/ui/template/submenu/flip.js +41 -0
  106. package/src/js/ui/template/submenu/history.js +22 -0
  107. package/src/js/ui/template/submenu/icon.js +108 -0
  108. package/src/js/ui/template/submenu/mask.js +30 -0
  109. package/src/js/ui/template/submenu/resize.js +54 -0
  110. package/src/js/ui/template/submenu/rotate.js +32 -0
  111. package/src/js/ui/template/submenu/shape.js +45 -0
  112. package/src/js/ui/template/submenu/text.js +67 -0
  113. package/src/js/ui/template/submenu/zoom.js +41 -0
  114. package/src/js/ui/text.js +279 -0
  115. package/src/js/ui/theme/standard.js +220 -0
  116. package/src/js/ui/theme/theme.js +249 -0
  117. package/src/js/ui/tools/colorpicker.js +250 -0
  118. package/src/js/ui/tools/range.js +390 -0
  119. package/src/js/ui.js +858 -0
  120. package/src/js/util.js +551 -0
  121. package/src/svg/default.svg +335 -0
  122. package/src/svg/icon-a/ic-apply.svg +6 -0
  123. package/src/svg/icon-a/ic-cancel.svg +6 -0
  124. package/src/svg/icon-a/ic-color-transparent-w.svg +12 -0
  125. package/src/svg/icon-a/ic-crop.svg +7 -0
  126. package/src/svg/icon-a/ic-delete-all.svg +6 -0
  127. package/src/svg/icon-a/ic-delete.svg +6 -0
  128. package/src/svg/icon-a/ic-draw-free.svg +5 -0
  129. package/src/svg/icon-a/ic-draw-line.svg +5 -0
  130. package/src/svg/icon-a/ic-draw.svg +6 -0
  131. package/src/svg/icon-a/ic-filter.svg +7 -0
  132. package/src/svg/icon-a/ic-flip-reset.svg +7 -0
  133. package/src/svg/icon-a/ic-flip-x.svg +6 -0
  134. package/src/svg/icon-a/ic-flip-y.svg +6 -0
  135. package/src/svg/icon-a/ic-flip.svg +6 -0
  136. package/src/svg/icon-a/ic-history-check.svg +5 -0
  137. package/src/svg/icon-a/ic-history-crop.svg +7 -0
  138. package/src/svg/icon-a/ic-history-delete.svg +9 -0
  139. package/src/svg/icon-a/ic-history-draw.svg +7 -0
  140. package/src/svg/icon-a/ic-history-filter.svg +8 -0
  141. package/src/svg/icon-a/ic-history-flip.svg +6 -0
  142. package/src/svg/icon-a/ic-history-group.svg +9 -0
  143. package/src/svg/icon-a/ic-history-icon.svg +6 -0
  144. package/src/svg/icon-a/ic-history-load.svg +7 -0
  145. package/src/svg/icon-a/ic-history-mask.svg +9 -0
  146. package/src/svg/icon-a/ic-history-resize.svg +12 -0
  147. package/src/svg/icon-a/ic-history-rotate.svg +16 -0
  148. package/src/svg/icon-a/ic-history-shape.svg +7 -0
  149. package/src/svg/icon-a/ic-history-text.svg +8 -0
  150. package/src/svg/icon-a/ic-history.svg +6 -0
  151. package/src/svg/icon-a/ic-icon-arrow-2.svg +5 -0
  152. package/src/svg/icon-a/ic-icon-arrow-3.svg +5 -0
  153. package/src/svg/icon-a/ic-icon-arrow.svg +5 -0
  154. package/src/svg/icon-a/ic-icon-bubble.svg +5 -0
  155. package/src/svg/icon-a/ic-icon-heart.svg +5 -0
  156. package/src/svg/icon-a/ic-icon-load.svg +8 -0
  157. package/src/svg/icon-a/ic-icon-location.svg +8 -0
  158. package/src/svg/icon-a/ic-icon-polygon.svg +5 -0
  159. package/src/svg/icon-a/ic-icon-star-2.svg +5 -0
  160. package/src/svg/icon-a/ic-icon-star.svg +5 -0
  161. package/src/svg/icon-a/ic-icon.svg +5 -0
  162. package/src/svg/icon-a/ic-mask-load.svg +8 -0
  163. package/src/svg/icon-a/ic-mask.svg +6 -0
  164. package/src/svg/icon-a/ic-redo.svg +7 -0
  165. package/src/svg/icon-a/ic-reset.svg +7 -0
  166. package/src/svg/icon-a/ic-resize.svg +13 -0
  167. package/src/svg/icon-a/ic-rotate-clockwise.svg +7 -0
  168. package/src/svg/icon-a/ic-rotate-counterclockwise.svg +7 -0
  169. package/src/svg/icon-a/ic-rotate.svg +7 -0
  170. package/src/svg/icon-a/ic-shape-circle.svg +5 -0
  171. package/src/svg/icon-a/ic-shape-rectangle.svg +5 -0
  172. package/src/svg/icon-a/ic-shape-triangle.svg +5 -0
  173. package/src/svg/icon-a/ic-shape.svg +6 -0
  174. package/src/svg/icon-a/ic-text-align-center.svg +6 -0
  175. package/src/svg/icon-a/ic-text-align-left.svg +6 -0
  176. package/src/svg/icon-a/ic-text-align-right.svg +6 -0
  177. package/src/svg/icon-a/ic-text-bold.svg +7 -0
  178. package/src/svg/icon-a/ic-text-italic.svg +6 -0
  179. package/src/svg/icon-a/ic-text-underline.svg +7 -0
  180. package/src/svg/icon-a/ic-text.svg +7 -0
  181. package/src/svg/icon-a/ic-undo.svg +7 -0
  182. package/src/svg/icon-a/ic-zoom-hand.svg +8 -0
  183. package/src/svg/icon-a/ic-zoom-zoom-in.svg +10 -0
  184. package/src/svg/icon-a/ic-zoom-zoom-out.svg +9 -0
  185. package/src/svg/icon-a/img-bi.svg +5 -0
  186. package/src/svg/icon-b/ic-apply.svg +6 -0
  187. package/src/svg/icon-b/ic-cancel.svg +6 -0
  188. package/src/svg/icon-b/ic-crop.svg +7 -0
  189. package/src/svg/icon-b/ic-delete-all.svg +6 -0
  190. package/src/svg/icon-b/ic-delete.svg +6 -0
  191. package/src/svg/icon-b/ic-draw-free.svg +5 -0
  192. package/src/svg/icon-b/ic-draw-line.svg +5 -0
  193. package/src/svg/icon-b/ic-draw.svg +6 -0
  194. package/src/svg/icon-b/ic-filter.svg +7 -0
  195. package/src/svg/icon-b/ic-flip-reset.svg +7 -0
  196. package/src/svg/icon-b/ic-flip-x.svg +6 -0
  197. package/src/svg/icon-b/ic-flip-y.svg +6 -0
  198. package/src/svg/icon-b/ic-flip.svg +6 -0
  199. package/src/svg/icon-b/ic-history-check.svg +5 -0
  200. package/src/svg/icon-b/ic-history-crop.svg +7 -0
  201. package/src/svg/icon-b/ic-history-delete.svg +9 -0
  202. package/src/svg/icon-b/ic-history-draw.svg +7 -0
  203. package/src/svg/icon-b/ic-history-filter.svg +8 -0
  204. package/src/svg/icon-b/ic-history-flip.svg +6 -0
  205. package/src/svg/icon-b/ic-history-group.svg +9 -0
  206. package/src/svg/icon-b/ic-history-icon.svg +6 -0
  207. package/src/svg/icon-b/ic-history-load.svg +7 -0
  208. package/src/svg/icon-b/ic-history-mask.svg +9 -0
  209. package/src/svg/icon-b/ic-history-resize.svg +12 -0
  210. package/src/svg/icon-b/ic-history-rotate.svg +16 -0
  211. package/src/svg/icon-b/ic-history-shape.svg +7 -0
  212. package/src/svg/icon-b/ic-history-text.svg +8 -0
  213. package/src/svg/icon-b/ic-history.svg +6 -0
  214. package/src/svg/icon-b/ic-icon-arrow-2.svg +5 -0
  215. package/src/svg/icon-b/ic-icon-arrow-3.svg +5 -0
  216. package/src/svg/icon-b/ic-icon-arrow.svg +5 -0
  217. package/src/svg/icon-b/ic-icon-bubble.svg +5 -0
  218. package/src/svg/icon-b/ic-icon-heart.svg +5 -0
  219. package/src/svg/icon-b/ic-icon-load.svg +8 -0
  220. package/src/svg/icon-b/ic-icon-location.svg +8 -0
  221. package/src/svg/icon-b/ic-icon-polygon.svg +5 -0
  222. package/src/svg/icon-b/ic-icon-star-2.svg +5 -0
  223. package/src/svg/icon-b/ic-icon-star.svg +5 -0
  224. package/src/svg/icon-b/ic-icon.svg +5 -0
  225. package/src/svg/icon-b/ic-mask-load.svg +8 -0
  226. package/src/svg/icon-b/ic-mask.svg +6 -0
  227. package/src/svg/icon-b/ic-redo.svg +7 -0
  228. package/src/svg/icon-b/ic-reset.svg +7 -0
  229. package/src/svg/icon-b/ic-resize.svg +13 -0
  230. package/src/svg/icon-b/ic-rotate-clockwise.svg +7 -0
  231. package/src/svg/icon-b/ic-rotate-counterclockwise.svg +7 -0
  232. package/src/svg/icon-b/ic-rotate.svg +7 -0
  233. package/src/svg/icon-b/ic-shape-circle.svg +5 -0
  234. package/src/svg/icon-b/ic-shape-rectangle.svg +5 -0
  235. package/src/svg/icon-b/ic-shape-triangle.svg +5 -0
  236. package/src/svg/icon-b/ic-shape.svg +6 -0
  237. package/src/svg/icon-b/ic-text-align-center.svg +6 -0
  238. package/src/svg/icon-b/ic-text-align-left.svg +6 -0
  239. package/src/svg/icon-b/ic-text-align-right.svg +6 -0
  240. package/src/svg/icon-b/ic-text-bold.svg +7 -0
  241. package/src/svg/icon-b/ic-text-italic.svg +6 -0
  242. package/src/svg/icon-b/ic-text-underline.svg +7 -0
  243. package/src/svg/icon-b/ic-text.svg +7 -0
  244. package/src/svg/icon-b/ic-undo.svg +7 -0
  245. package/src/svg/icon-b/ic-zoom-hand.svg +8 -0
  246. package/src/svg/icon-b/ic-zoom-zoom-in.svg +12 -0
  247. package/src/svg/icon-b/ic-zoom-zoom-out.svg +11 -0
  248. package/src/svg/icon-b/img-bi.svg +5 -0
  249. package/src/svg/icon-c/ic-apply.svg +6 -0
  250. package/src/svg/icon-c/ic-cancel.svg +6 -0
  251. package/src/svg/icon-c/ic-crop.svg +7 -0
  252. package/src/svg/icon-c/ic-delete-all.svg +6 -0
  253. package/src/svg/icon-c/ic-delete.svg +6 -0
  254. package/src/svg/icon-c/ic-draw-free.svg +5 -0
  255. package/src/svg/icon-c/ic-draw-line.svg +5 -0
  256. package/src/svg/icon-c/ic-draw.svg +6 -0
  257. package/src/svg/icon-c/ic-filter.svg +7 -0
  258. package/src/svg/icon-c/ic-flip-reset.svg +7 -0
  259. package/src/svg/icon-c/ic-flip-x.svg +6 -0
  260. package/src/svg/icon-c/ic-flip-y.svg +6 -0
  261. package/src/svg/icon-c/ic-flip.svg +6 -0
  262. package/src/svg/icon-c/ic-history-check.svg +5 -0
  263. package/src/svg/icon-c/ic-history-crop.svg +7 -0
  264. package/src/svg/icon-c/ic-history-delete.svg +9 -0
  265. package/src/svg/icon-c/ic-history-draw.svg +7 -0
  266. package/src/svg/icon-c/ic-history-filter.svg +8 -0
  267. package/src/svg/icon-c/ic-history-flip.svg +6 -0
  268. package/src/svg/icon-c/ic-history-group.svg +9 -0
  269. package/src/svg/icon-c/ic-history-icon.svg +6 -0
  270. package/src/svg/icon-c/ic-history-load.svg +7 -0
  271. package/src/svg/icon-c/ic-history-mask.svg +9 -0
  272. package/src/svg/icon-c/ic-history-resize.svg +12 -0
  273. package/src/svg/icon-c/ic-history-rotate.svg +16 -0
  274. package/src/svg/icon-c/ic-history-shape.svg +7 -0
  275. package/src/svg/icon-c/ic-history-text.svg +8 -0
  276. package/src/svg/icon-c/ic-history.svg +6 -0
  277. package/src/svg/icon-c/ic-icon-arrow-2.svg +5 -0
  278. package/src/svg/icon-c/ic-icon-arrow-3.svg +5 -0
  279. package/src/svg/icon-c/ic-icon-arrow.svg +5 -0
  280. package/src/svg/icon-c/ic-icon-bubble.svg +5 -0
  281. package/src/svg/icon-c/ic-icon-heart.svg +5 -0
  282. package/src/svg/icon-c/ic-icon-load.svg +8 -0
  283. package/src/svg/icon-c/ic-icon-location.svg +8 -0
  284. package/src/svg/icon-c/ic-icon-polygon.svg +5 -0
  285. package/src/svg/icon-c/ic-icon-star-2.svg +5 -0
  286. package/src/svg/icon-c/ic-icon-star.svg +5 -0
  287. package/src/svg/icon-c/ic-icon.svg +5 -0
  288. package/src/svg/icon-c/ic-mask-load.svg +8 -0
  289. package/src/svg/icon-c/ic-mask.svg +6 -0
  290. package/src/svg/icon-c/ic-redo.svg +7 -0
  291. package/src/svg/icon-c/ic-reset.svg +7 -0
  292. package/src/svg/icon-c/ic-resize.svg +13 -0
  293. package/src/svg/icon-c/ic-rotate-clockwise.svg +7 -0
  294. package/src/svg/icon-c/ic-rotate-counterclockwise.svg +7 -0
  295. package/src/svg/icon-c/ic-rotate.svg +7 -0
  296. package/src/svg/icon-c/ic-shape-circle.svg +5 -0
  297. package/src/svg/icon-c/ic-shape-rectangle.svg +5 -0
  298. package/src/svg/icon-c/ic-shape-triangle.svg +5 -0
  299. package/src/svg/icon-c/ic-shape.svg +6 -0
  300. package/src/svg/icon-c/ic-text-align-center.svg +6 -0
  301. package/src/svg/icon-c/ic-text-align-left.svg +6 -0
  302. package/src/svg/icon-c/ic-text-align-right.svg +6 -0
  303. package/src/svg/icon-c/ic-text-bold.svg +7 -0
  304. package/src/svg/icon-c/ic-text-italic.svg +6 -0
  305. package/src/svg/icon-c/ic-text-underline.svg +7 -0
  306. package/src/svg/icon-c/ic-text.svg +7 -0
  307. package/src/svg/icon-c/ic-undo.svg +7 -0
  308. package/src/svg/icon-c/ic-zoom-hand.svg +8 -0
  309. package/src/svg/icon-c/ic-zoom-zoom-in.svg +12 -0
  310. package/src/svg/icon-c/ic-zoom-zoom-out.svg +11 -0
  311. package/src/svg/icon-c/img-bi.svg +5 -0
  312. package/src/svg/icon-d/ic-apply.svg +6 -0
  313. package/src/svg/icon-d/ic-cancel.svg +6 -0
  314. package/src/svg/icon-d/ic-crop.svg +7 -0
  315. package/src/svg/icon-d/ic-delete-all.svg +6 -0
  316. package/src/svg/icon-d/ic-delete.svg +6 -0
  317. package/src/svg/icon-d/ic-draw-free.svg +5 -0
  318. package/src/svg/icon-d/ic-draw-line.svg +5 -0
  319. package/src/svg/icon-d/ic-draw.svg +6 -0
  320. package/src/svg/icon-d/ic-filter.svg +7 -0
  321. package/src/svg/icon-d/ic-flip-reset.svg +7 -0
  322. package/src/svg/icon-d/ic-flip-x.svg +6 -0
  323. package/src/svg/icon-d/ic-flip-y.svg +6 -0
  324. package/src/svg/icon-d/ic-flip.svg +6 -0
  325. package/src/svg/icon-d/ic-history-check.svg +5 -0
  326. package/src/svg/icon-d/ic-history-crop.svg +7 -0
  327. package/src/svg/icon-d/ic-history-delete.svg +9 -0
  328. package/src/svg/icon-d/ic-history-draw.svg +7 -0
  329. package/src/svg/icon-d/ic-history-filter.svg +8 -0
  330. package/src/svg/icon-d/ic-history-flip.svg +6 -0
  331. package/src/svg/icon-d/ic-history-group.svg +9 -0
  332. package/src/svg/icon-d/ic-history-icon.svg +6 -0
  333. package/src/svg/icon-d/ic-history-load.svg +7 -0
  334. package/src/svg/icon-d/ic-history-mask.svg +9 -0
  335. package/src/svg/icon-d/ic-history-resize.svg +12 -0
  336. package/src/svg/icon-d/ic-history-rotate.svg +16 -0
  337. package/src/svg/icon-d/ic-history-shape.svg +7 -0
  338. package/src/svg/icon-d/ic-history-text.svg +8 -0
  339. package/src/svg/icon-d/ic-history.svg +6 -0
  340. package/src/svg/icon-d/ic-icon-arrow-2.svg +5 -0
  341. package/src/svg/icon-d/ic-icon-arrow-3.svg +5 -0
  342. package/src/svg/icon-d/ic-icon-arrow.svg +5 -0
  343. package/src/svg/icon-d/ic-icon-bubble.svg +5 -0
  344. package/src/svg/icon-d/ic-icon-heart.svg +5 -0
  345. package/src/svg/icon-d/ic-icon-load.svg +8 -0
  346. package/src/svg/icon-d/ic-icon-location.svg +8 -0
  347. package/src/svg/icon-d/ic-icon-polygon.svg +5 -0
  348. package/src/svg/icon-d/ic-icon-star-2.svg +5 -0
  349. package/src/svg/icon-d/ic-icon-star.svg +5 -0
  350. package/src/svg/icon-d/ic-icon.svg +5 -0
  351. package/src/svg/icon-d/ic-mask-load.svg +8 -0
  352. package/src/svg/icon-d/ic-mask.svg +6 -0
  353. package/src/svg/icon-d/ic-redo.svg +7 -0
  354. package/src/svg/icon-d/ic-reset.svg +7 -0
  355. package/src/svg/icon-d/ic-resize.svg +13 -0
  356. package/src/svg/icon-d/ic-rotate-clockwise.svg +7 -0
  357. package/src/svg/icon-d/ic-rotate-counterclockwise.svg +7 -0
  358. package/src/svg/icon-d/ic-rotate.svg +7 -0
  359. package/src/svg/icon-d/ic-shape-circle.svg +5 -0
  360. package/src/svg/icon-d/ic-shape-rectangle.svg +5 -0
  361. package/src/svg/icon-d/ic-shape-triangle.svg +5 -0
  362. package/src/svg/icon-d/ic-shape.svg +6 -0
  363. package/src/svg/icon-d/ic-text-align-center.svg +6 -0
  364. package/src/svg/icon-d/ic-text-align-left.svg +6 -0
  365. package/src/svg/icon-d/ic-text-align-right.svg +6 -0
  366. package/src/svg/icon-d/ic-text-bold.svg +7 -0
  367. package/src/svg/icon-d/ic-text-italic.svg +6 -0
  368. package/src/svg/icon-d/ic-text-underline.svg +7 -0
  369. package/src/svg/icon-d/ic-text.svg +7 -0
  370. package/src/svg/icon-d/ic-undo.svg +7 -0
  371. package/src/svg/icon-d/ic-zoom-hand.svg +8 -0
  372. package/src/svg/icon-d/ic-zoom-zoom-in.svg +12 -0
  373. package/src/svg/icon-d/ic-zoom-zoom-out.svg +11 -0
  374. 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;