ace-colorpicker-rpk 0.0.12

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 (238) hide show
  1. package/.babelrc +30 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.md +35 -0
  3. package/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
  4. package/ChangeLogs.md +22 -0
  5. package/LICENSE +21 -0
  6. package/README.md +117 -0
  7. package/addon/ace-colorpicker.css +1074 -0
  8. package/addon/ace-colorpicker.js +9602 -0
  9. package/addon/sample/colorpicker.html +199 -0
  10. package/config/rollup.config.dev.js +52 -0
  11. package/config/rollup.config.prod.js +53 -0
  12. package/dist/ace-colorpicker.css +1074 -0
  13. package/dist/ace-colorpicker.js +9736 -0
  14. package/dist/ace-colorpicker.min.js +1 -0
  15. package/gl.html +56 -0
  16. package/index.html +172 -0
  17. package/package.json +87 -0
  18. package/resources/image/ace-editor.png +0 -0
  19. package/resources/image/colorpaletts.png +0 -0
  20. package/resources/image/colorpicker.png +0 -0
  21. package/resources/image/grapes.jpg +0 -0
  22. package/resources/image/palette-type.png +0 -0
  23. package/resources/image/scalecolors-title.png +0 -0
  24. package/resources/image/scalecolors.png +0 -0
  25. package/resources/image/screen-shot.png +0 -0
  26. package/resources/image/sketch-type.png +0 -0
  27. package/src/colorpicker/BaseBox.js +94 -0
  28. package/src/colorpicker/BaseColorPicker.js +404 -0
  29. package/src/colorpicker/BaseModule.js +19 -0
  30. package/src/colorpicker/BaseSlider.js +97 -0
  31. package/src/colorpicker/BaseStore.js +71 -0
  32. package/src/colorpicker/UIElement.js +46 -0
  33. package/src/colorpicker/VerticalSlider.js +57 -0
  34. package/src/colorpicker/chromedevtool/ColorControl.js +47 -0
  35. package/src/colorpicker/chromedevtool/index.js +36 -0
  36. package/src/colorpicker/index.js +37 -0
  37. package/src/colorpicker/macos/ColorControl.js +47 -0
  38. package/src/colorpicker/macos/index.js +38 -0
  39. package/src/colorpicker/mini/ColorControl.js +40 -0
  40. package/src/colorpicker/mini/index.js +24 -0
  41. package/src/colorpicker/mini-vertical/ColorControl.js +35 -0
  42. package/src/colorpicker/mini-vertical/index.js +23 -0
  43. package/src/colorpicker/module/ColorManager.js +111 -0
  44. package/src/colorpicker/module/ColorSetsList.js +132 -0
  45. package/src/colorpicker/ring/ColorControl.js +47 -0
  46. package/src/colorpicker/ring/index.js +42 -0
  47. package/src/colorpicker/ui/ColorInformation.js +216 -0
  48. package/src/colorpicker/ui/ColorPalette.js +130 -0
  49. package/src/colorpicker/ui/ColorRing.js +68 -0
  50. package/src/colorpicker/ui/ColorSetsChooser.js +96 -0
  51. package/src/colorpicker/ui/ColorWheel.js +257 -0
  52. package/src/colorpicker/ui/CurrentColorSets.js +81 -0
  53. package/src/colorpicker/ui/CurrentColorSetsContextMenu.js +63 -0
  54. package/src/colorpicker/ui/control/Hue.js +40 -0
  55. package/src/colorpicker/ui/control/Opacity.js +65 -0
  56. package/src/colorpicker/ui/control/Value.js +50 -0
  57. package/src/colorpicker/ui/control/VerticalHue.js +39 -0
  58. package/src/colorpicker/ui/control/VerticalOpacity.js +55 -0
  59. package/src/colorpicker/vscode/ColorControl.js +40 -0
  60. package/src/colorpicker/vscode/index.js +82 -0
  61. package/src/colorpicker/xd/ColorControl.js +36 -0
  62. package/src/colorpicker/xd/index.js +36 -0
  63. package/src/extension/ace/colorview.js +198 -0
  64. package/src/extension/ace/index.js +11 -0
  65. package/src/index.js +12 -0
  66. package/src/scss/colorpicker.scss +65 -0
  67. package/src/scss/colorview.scss +32 -0
  68. package/src/scss/component/button.scss +33 -0
  69. package/src/scss/component/colorchooser.scss +141 -0
  70. package/src/scss/component/colorsets-contextmenu.scss +33 -0
  71. package/src/scss/component/colorsets.scss +89 -0
  72. package/src/scss/component/control.scss +93 -0
  73. package/src/scss/component/gradient-editor.scss +260 -0
  74. package/src/scss/component/gradient-picker.scss +241 -0
  75. package/src/scss/component/information.scss +141 -0
  76. package/src/scss/component/palette.scss +45 -0
  77. package/src/scss/index.scss +5 -0
  78. package/src/scss/mixins.scss +21 -0
  79. package/src/scss/themes/macos.scss +71 -0
  80. package/src/scss/themes/mini-vertical.scss +94 -0
  81. package/src/scss/themes/mini.scss +76 -0
  82. package/src/scss/themes/palette.scss +85 -0
  83. package/src/scss/themes/ring.scss +57 -0
  84. package/src/scss/themes/sketch.scss +172 -0
  85. package/src/scss/themes/vscode.scss +93 -0
  86. package/src/scss/themes/xd.scss +88 -0
  87. package/src/util/Blender.js +29 -0
  88. package/src/util/Canvas.js +128 -0
  89. package/src/util/Color.js +27 -0
  90. package/src/util/ColorNames.js +14 -0
  91. package/src/util/Dom.js +361 -0
  92. package/src/util/Event.js +30 -0
  93. package/src/util/EventMachin.js +349 -0
  94. package/src/util/GL.js +8 -0
  95. package/src/util/HueColor.js +49 -0
  96. package/src/util/ImageFilter.js +9 -0
  97. package/src/util/ImageLoader.js +137 -0
  98. package/src/util/Kmeans.js +237 -0
  99. package/src/util/Matrix.js +196 -0
  100. package/src/util/State.js +42 -0
  101. package/src/util/blend/composite.js +124 -0
  102. package/src/util/blend/non-separable.js +118 -0
  103. package/src/util/blend/separable.js +76 -0
  104. package/src/util/filter/StackBlur.js +517 -0
  105. package/src/util/filter/functions.js +829 -0
  106. package/src/util/filter/image/crop.js +16 -0
  107. package/src/util/filter/image/flipH.js +23 -0
  108. package/src/util/filter/image/flipV.js +25 -0
  109. package/src/util/filter/image/histogram.js +45 -0
  110. package/src/util/filter/image/index.js +18 -0
  111. package/src/util/filter/image/resize.js +18 -0
  112. package/src/util/filter/image/rotate.js +39 -0
  113. package/src/util/filter/image/rotateDegree.js +53 -0
  114. package/src/util/filter/index.js +11 -0
  115. package/src/util/filter/matrix/blur.js +12 -0
  116. package/src/util/filter/matrix/emboss.js +17 -0
  117. package/src/util/filter/matrix/gaussian-blur-5x.js +17 -0
  118. package/src/util/filter/matrix/gaussian-blur.js +16 -0
  119. package/src/util/filter/matrix/grayscale2.js +16 -0
  120. package/src/util/filter/matrix/index.js +58 -0
  121. package/src/util/filter/matrix/kirsch-horizontal.js +13 -0
  122. package/src/util/filter/matrix/kirsch-vertical.js +13 -0
  123. package/src/util/filter/matrix/laplacian-5x.js +16 -0
  124. package/src/util/filter/matrix/laplacian.js +14 -0
  125. package/src/util/filter/matrix/motion-blur-2.js +18 -0
  126. package/src/util/filter/matrix/motion-blur-3.js +19 -0
  127. package/src/util/filter/matrix/motion-blur.js +18 -0
  128. package/src/util/filter/matrix/negative.js +16 -0
  129. package/src/util/filter/matrix/normal.js +11 -0
  130. package/src/util/filter/matrix/sepia2.js +16 -0
  131. package/src/util/filter/matrix/sharpen.js +14 -0
  132. package/src/util/filter/matrix/sobel-horizontal.js +11 -0
  133. package/src/util/filter/matrix/sobel-vertical.js +11 -0
  134. package/src/util/filter/matrix/stack-blur.js +15 -0
  135. package/src/util/filter/matrix/transparency.js +16 -0
  136. package/src/util/filter/matrix/unsharp-masking.js +16 -0
  137. package/src/util/filter/multi/index.js +9 -0
  138. package/src/util/filter/multi/kirsch.js +7 -0
  139. package/src/util/filter/multi/sobel.js +7 -0
  140. package/src/util/filter/multi/vintage.js +7 -0
  141. package/src/util/filter/pixel/bitonal.js +24 -0
  142. package/src/util/filter/pixel/brightness.js +19 -0
  143. package/src/util/filter/pixel/brownie.js +23 -0
  144. package/src/util/filter/pixel/clip.js +21 -0
  145. package/src/util/filter/pixel/contrast.js +18 -0
  146. package/src/util/filter/pixel/gamma.js +13 -0
  147. package/src/util/filter/pixel/gradient.js +52 -0
  148. package/src/util/filter/pixel/grayscale.js +27 -0
  149. package/src/util/filter/pixel/hue.js +28 -0
  150. package/src/util/filter/pixel/index.js +52 -0
  151. package/src/util/filter/pixel/invert.js +16 -0
  152. package/src/util/filter/pixel/kodachrome.js +23 -0
  153. package/src/util/filter/pixel/matrix.js +28 -0
  154. package/src/util/filter/pixel/noise.js +24 -0
  155. package/src/util/filter/pixel/opacity.js +14 -0
  156. package/src/util/filter/pixel/polaroid.js +23 -0
  157. package/src/util/filter/pixel/saturation.js +30 -0
  158. package/src/util/filter/pixel/sepia.js +28 -0
  159. package/src/util/filter/pixel/shade.js +21 -0
  160. package/src/util/filter/pixel/shift.js +23 -0
  161. package/src/util/filter/pixel/solarize.js +23 -0
  162. package/src/util/filter/pixel/technicolor.js +23 -0
  163. package/src/util/filter/pixel/threshold-color.js +35 -0
  164. package/src/util/filter/pixel/threshold.js +7 -0
  165. package/src/util/filter/pixel/tint.js +20 -0
  166. package/src/util/functions/formatter.js +99 -0
  167. package/src/util/functions/fromCMYK.js +17 -0
  168. package/src/util/functions/fromHSL.js +52 -0
  169. package/src/util/functions/fromHSV.js +64 -0
  170. package/src/util/functions/fromLAB.js +99 -0
  171. package/src/util/functions/fromRGB.js +220 -0
  172. package/src/util/functions/fromYCrCb.js +16 -0
  173. package/src/util/functions/func.js +194 -0
  174. package/src/util/functions/image.js +145 -0
  175. package/src/util/functions/math.js +56 -0
  176. package/src/util/functions/mixin.js +164 -0
  177. package/src/util/functions/parser.js +294 -0
  178. package/src/util/gl/filter/index.js +9 -0
  179. package/src/util/gl/filter/matrix/blur.js +9 -0
  180. package/src/util/gl/filter/matrix/emboss.js +17 -0
  181. package/src/util/gl/filter/matrix/gaussian-blur-5x.js +15 -0
  182. package/src/util/gl/filter/matrix/gaussian-blur.js +19 -0
  183. package/src/util/gl/filter/matrix/grayscale2.js +13 -0
  184. package/src/util/gl/filter/matrix/index.js +55 -0
  185. package/src/util/gl/filter/matrix/kirsch-horizontal.js +11 -0
  186. package/src/util/gl/filter/matrix/kirsch-vertical.js +11 -0
  187. package/src/util/gl/filter/matrix/laplacian-5x.js +13 -0
  188. package/src/util/gl/filter/matrix/laplacian.js +11 -0
  189. package/src/util/gl/filter/matrix/motion-blur-2.js +17 -0
  190. package/src/util/gl/filter/matrix/motion-blur-3.js +17 -0
  191. package/src/util/gl/filter/matrix/motion-blur.js +17 -0
  192. package/src/util/gl/filter/matrix/negative.js +13 -0
  193. package/src/util/gl/filter/matrix/normal.js +8 -0
  194. package/src/util/gl/filter/matrix/sepia2.js +13 -0
  195. package/src/util/gl/filter/matrix/sharpen.js +11 -0
  196. package/src/util/gl/filter/matrix/sobel-horizontal.js +11 -0
  197. package/src/util/gl/filter/matrix/sobel-vertical.js +11 -0
  198. package/src/util/gl/filter/matrix/transparency.js +13 -0
  199. package/src/util/gl/filter/matrix/unsharp-masking.js +14 -0
  200. package/src/util/gl/filter/multi/index.js +9 -0
  201. package/src/util/gl/filter/multi/kirsch.js +7 -0
  202. package/src/util/gl/filter/multi/sobel.js +7 -0
  203. package/src/util/gl/filter/multi/vintage.js +7 -0
  204. package/src/util/gl/filter/pixel/bitonal.js +22 -0
  205. package/src/util/gl/filter/pixel/brightness.js +14 -0
  206. package/src/util/gl/filter/pixel/brownie.js +11 -0
  207. package/src/util/gl/filter/pixel/chaos.js +20 -0
  208. package/src/util/gl/filter/pixel/clip.js +20 -0
  209. package/src/util/gl/filter/pixel/contrast.js +16 -0
  210. package/src/util/gl/filter/pixel/gamma.js +16 -0
  211. package/src/util/gl/filter/pixel/gradient.js +59 -0
  212. package/src/util/gl/filter/pixel/grayscale.js +22 -0
  213. package/src/util/gl/filter/pixel/hue.js +19 -0
  214. package/src/util/gl/filter/pixel/index.js +54 -0
  215. package/src/util/gl/filter/pixel/invert.js +18 -0
  216. package/src/util/gl/filter/pixel/kodachrome.js +11 -0
  217. package/src/util/gl/filter/pixel/matrix.js +29 -0
  218. package/src/util/gl/filter/pixel/noise.js +18 -0
  219. package/src/util/gl/filter/pixel/opacity.js +17 -0
  220. package/src/util/gl/filter/pixel/polaroid.js +11 -0
  221. package/src/util/gl/filter/pixel/saturation.js +20 -0
  222. package/src/util/gl/filter/pixel/sepia.js +19 -0
  223. package/src/util/gl/filter/pixel/shade.js +20 -0
  224. package/src/util/gl/filter/pixel/shift.js +11 -0
  225. package/src/util/gl/filter/pixel/solarize.js +21 -0
  226. package/src/util/gl/filter/pixel/technicolor.js +11 -0
  227. package/src/util/gl/filter/pixel/threshold-color.js +15 -0
  228. package/src/util/gl/filter/pixel/threshold.js +7 -0
  229. package/src/util/gl/filter/pixel/tint.js +25 -0
  230. package/src/util/gl/filter/util.js +185 -0
  231. package/src/util/gl/functions.js +158 -0
  232. package/src/util/gl/index.js +543 -0
  233. package/src/util/index.js +17 -0
  234. package/stand.html +975 -0
  235. package/test/util.Blend.spec.js +15 -0
  236. package/test/util.Color.spec.js +200 -0
  237. package/test/util.Filter.spec.js +12 -0
  238. package/test/util.ImageFilter.spec.js +16 -0
@@ -0,0 +1,82 @@
1
+ import BaseColorPicker from '../BaseColorPicker'
2
+
3
+ import ColorControl from './ColorControl'
4
+ import ColorPalette from '../ui/ColorPalette'
5
+ import Color from '../../util/Color'
6
+
7
+ export default class VSCodePicker extends BaseColorPicker {
8
+
9
+ template () {
10
+ return /*html*/`
11
+ <div class='colorpicker-body'>
12
+ <div class='color-view'>
13
+ <div class='color-view-container' ref="$colorview"></div>
14
+ </div>
15
+ <div class='color-tool'>
16
+ <div target="palette"></div>
17
+ <div target="control"></div>
18
+ </div>
19
+ </div>
20
+ `
21
+ }
22
+
23
+ components() {
24
+ return {
25
+ palette: ColorPalette,
26
+ control: ColorControl
27
+ }
28
+ }
29
+
30
+ initColorWithoutChangeEvent (color) {
31
+ this.$store.dispatch('/initColor', color);
32
+ this.refresh();
33
+ }
34
+
35
+ setBackgroundColor () {
36
+ var color = this.$store.dispatch('/toColor')
37
+ var rgb = this.$store.rgb;
38
+ var bValue = Color.brightness(rgb.r,rgb.g,rgb.b);
39
+
40
+ this.refs.$colorview.css({
41
+ "background-color": color,
42
+ 'color': bValue > 127 ? 'black': 'white'
43
+ });
44
+ this.refs.$colorview.html(color);
45
+ }
46
+
47
+ 'click $colorview' (e) {
48
+ this.nextFormat()
49
+ }
50
+
51
+ nextFormat() {
52
+ var current_format = this.$store.format || 'hex';
53
+
54
+ var next_format = 'hex';
55
+ if (current_format == 'hex') {
56
+ next_format = 'rgb';
57
+ } else if (current_format == 'rgb') {
58
+ next_format = 'hsl';
59
+ } else if (current_format == 'hsl') {
60
+ next_format = 'hex';
61
+ }
62
+
63
+ this.$store.dispatch('/changeFormat', next_format);
64
+ this.$store.emit('lastUpdateColor')
65
+ this.refresh();
66
+ }
67
+
68
+ refresh () {
69
+ this.setBackgroundColor()
70
+ }
71
+
72
+ '@changeColor' () {
73
+ this.refresh()
74
+ }
75
+
76
+ '@initColor' () {
77
+ this.refresh()
78
+ }
79
+
80
+
81
+
82
+ }
@@ -0,0 +1,36 @@
1
+ import Hue from '../ui/control/VerticalHue';
2
+ import Opacity from '../ui/control/VerticalOpacity'
3
+ import UIElement from '../UIElement';
4
+
5
+ export default class ColorControl extends UIElement {
6
+
7
+ components () {
8
+ return { Hue, Opacity }
9
+ }
10
+
11
+ template () {
12
+ return `
13
+ <div class="control">
14
+ <div target="Hue" ></div>
15
+ <div target="Opacity" ></div>
16
+ </div>
17
+ `
18
+ }
19
+
20
+ refresh () {
21
+ this.setColorUI();
22
+ }
23
+
24
+ setColorUI() {
25
+ this.Hue.setColorUI()
26
+ this.Opacity.setColorUI()
27
+ }
28
+
29
+ '@changeColor' () {
30
+ this.refresh()
31
+ }
32
+
33
+ '@initColor' () { this.refresh() }
34
+
35
+ }
36
+
@@ -0,0 +1,36 @@
1
+ import BaseColorPicker from '../BaseColorPicker'
2
+
3
+ import ColorControl from './ColorControl'
4
+ import ColorInformation from '../ui/ColorInformation'
5
+ import ColorPalette from '../ui/ColorPalette'
6
+ import ColorSetsChooser from '../ui/ColorSetsChooser'
7
+ import CurrentColorSets from '../ui/CurrentColorSets'
8
+ import CurrentColorSetsContextMenu from '../ui/CurrentColorSetsContextMenu'
9
+
10
+ export default class XDColorPicker extends BaseColorPicker {
11
+
12
+ template () {
13
+ return `
14
+ <div class='colorpicker-body'>
15
+ <div target="palette"></div>
16
+ <div target="control"></div>
17
+ <div target="information"></div>
18
+ <div target="currentColorSets"></div>
19
+ <div target="colorSetsChooser"></div>
20
+ <div target="contextMenu"></div>
21
+ </div>
22
+ `
23
+ }
24
+
25
+ components() {
26
+ return {
27
+ palette: ColorPalette,
28
+ control: ColorControl,
29
+ information: ColorInformation,
30
+ currentColorSets: CurrentColorSets,
31
+ colorSetsChooser: ColorSetsChooser,
32
+ contextMenu: CurrentColorSetsContextMenu
33
+ }
34
+ }
35
+
36
+ }
@@ -0,0 +1,198 @@
1
+ import Color from '../../util/Color'
2
+ import ColorPicker from '../../colorpicker/index';
3
+ import { brightness } from '../../util/functions/fromRGB';
4
+ import Dom from '../../util/Dom';
5
+ import { debounce } from '../../util/functions/func';
6
+
7
+ const colorpicker_token_class = 'ace_color';
8
+ const colorpicker_container_class = 'ace-colorpicker'
9
+
10
+ export default class ColorView {
11
+ constructor(ace, editor, opt = {
12
+ type: 'vscode',
13
+ showDelay: 300,
14
+ containerClass: colorpicker_container_class
15
+ }) {
16
+ this.opt = opt;
17
+ this.ace = ace;
18
+ this.editor = editor;
19
+
20
+ this.colorpicker = ColorPicker.create(this.opt);
21
+ this.init_event();
22
+
23
+ }
24
+
25
+ get_brightness(colorString) {
26
+ const colorObj = Color.parse(colorString);
27
+ const fontColorString = brightness(colorObj.r, colorObj.g, colorObj.b) > 127 ? "#000" : "#fff";
28
+
29
+ return fontColorString;
30
+ }
31
+
32
+ mouse_over(evt) {
33
+ const $colorElement = new Dom(evt.target);
34
+ this.__colorview_check_target = evt.target;
35
+
36
+ if ($colorElement.hasClass(colorpicker_token_class)) {
37
+ this.openDebouncedColorPicker(evt);
38
+ }
39
+
40
+ }
41
+
42
+ init_mouse_event() {
43
+
44
+ const { renderer } = this.editor;
45
+ const { content } = renderer;
46
+
47
+ this.openDebouncedColorPicker = debounce(this.open_color_picker.bind(this), this.opt.showDelay);
48
+
49
+ this.onMouseOver = this.mouse_over.bind(this);
50
+
51
+ // content.addEventListener('mouseover', this.onMouseOver);
52
+ content.addEventListener('mousemove', this.onMouseOver);
53
+
54
+ }
55
+
56
+
57
+ init_event() {
58
+
59
+ const { renderer, session } = this.editor;
60
+ const { content } = renderer;
61
+
62
+ this.init_mouse_event();
63
+
64
+ let rules = session.$mode.$highlightRules.getRules();
65
+ for (let stateName in rules) {
66
+ if (Object.prototype.hasOwnProperty.call(rules, stateName)) {
67
+ rules[stateName].unshift({
68
+ token: "color",
69
+ regex: '#(?:[\\da-f]{8})|#(?:[\\da-f]{3}){1,2}|rgb\\((?:\\s*\\d{1,3},\\s*){2}\\d{1,3}\\s*\\)|rgba\\((?:\\s*\\d{1,3},\\s*){3}\\d*\\.?\\d+\\s*\\)|hsl\\(\\s*\\d{1,3}(?:,\\s*\\d{1,3}%){2}\\s*\\)|hsla\\(\\s*\\d{1,3}(?:,\\s*\\d{1,3}%){2},\\s*\\d*\\.?\\d+\\s*\\)'
70
+ });
71
+
72
+ // FIXME: Exception handling when the highlight does not turn into color due to the scss function name
73
+ // LINK : https://github.com/ajaxorg/ace/blob/cbcb78c3a7c5e642d615a9f5665a44dbb94d3e92/lib/ace/mode/scss_highlight_rules.js#L43-L48
74
+ rules[stateName].unshift({
75
+ token: "color",
76
+ regex: "blue|green|red"
77
+ });
78
+
79
+ }
80
+ }
81
+ // force recreation of tokenizer
82
+ session.$mode.$tokenizer = null;
83
+ session.bgTokenizer.setTokenizer(editor.session.$mode.getTokenizer());
84
+ // force re-highlight whole document
85
+ session.bgTokenizer.start(0);
86
+
87
+ // each editor render update, update all displayed colors
88
+ renderer.on('afterRender', () => {
89
+
90
+ // each time renderer updates, get all elements with ace_color class
91
+ var colors = content.getElementsByClassName(colorpicker_token_class);
92
+
93
+ // iterate through them and set their background color and font color accordingly
94
+ for (var i = 0, len = colors.length; i < len; i++) {
95
+
96
+ const colorString = colors[i].textContent;
97
+
98
+ if (colors[i].getAttribute('data-color') === colorString) {
99
+ // dont rerender the same color
100
+ continue;
101
+ }
102
+
103
+ const fontColorString = this.get_brightness(colorString);
104
+
105
+ colors[i].setAttribute("data-color", colorString);
106
+ colors[i].style.cssText = `
107
+ background-color: ${colorString};
108
+ color: ${fontColorString};
109
+ pointer-events: all;
110
+ `
111
+ }
112
+ });
113
+
114
+
115
+ }
116
+
117
+ destroy() {
118
+ const { renderer } = this.editor;
119
+ const { content } = renderer;
120
+
121
+ // content.removeEventListener('mouseover', this.onMouseOver);
122
+ content.removeEventListener('mousemove', this.onMouseOver);
123
+ }
124
+
125
+ open_color_picker(evt) {
126
+ // check wheather event.target is equals this.__colorview_check_target
127
+ if (evt.target !== this.__colorview_check_target) {
128
+ this.close_color_picker();
129
+ return;
130
+ }
131
+
132
+ const { Range } = this.ace;
133
+ const { renderer, session } = this.editor;
134
+ const { layerConfig } = renderer;
135
+
136
+ const screenPosition = renderer.screenToTextCoordinates(evt.clientX - layerConfig.padding, evt.clientY);
137
+ const token = session.getTokenAt(screenPosition.row, screenPosition.column);
138
+
139
+ if (!token || token.type.includes("color") === false) {
140
+ return;
141
+ }
142
+
143
+ const row = screenPosition.row;
144
+ const startColumn = token.start;
145
+ const colorString = token.value;
146
+
147
+ let prevColor = colorString;
148
+ const pos = renderer.textToScreenCoordinates(row, startColumn);
149
+
150
+ // support scrollTop
151
+ const scrollTop = Dom.getScrollTop()
152
+
153
+ this.colorpicker.show({
154
+ left: pos.pageX,
155
+ top: pos.pageY + scrollTop,
156
+ bottom: pos.pageY + scrollTop + layerConfig.lineHeight,
157
+ hideDelay: this.opt.hideDelay || 10
158
+ }, colorString, (newColor) => {
159
+ this.editor.session.replace(
160
+ new Range(row, startColumn, row, startColumn + prevColor.length),
161
+ newColor
162
+ );
163
+ prevColor = newColor;
164
+ });
165
+ }
166
+
167
+ close_color_picker() {
168
+ if (this.colorpicker) {
169
+ this.colorpicker.hide();
170
+ }
171
+ }
172
+
173
+ hide_delay_color_picker() {
174
+ if (this.colorpicker) {
175
+ this.colorpicker.runHideDelay();
176
+ }
177
+ }
178
+
179
+ key(lineNo, ch) {
180
+ return [lineNo, ch].join(":");
181
+ }
182
+
183
+
184
+ keyup(evt) {
185
+
186
+ if (this.colorpicker) {
187
+ if (evt.key == 'Escape') {
188
+ this.colorpicker.hide();
189
+ } else if (this.colorpicker.isShortCut == false) {
190
+ this.colorpicker.hide();
191
+ }
192
+ }
193
+ }
194
+
195
+
196
+ }
197
+
198
+
@@ -0,0 +1,11 @@
1
+ import AceColorView from './colorview'
2
+
3
+ function LOAD_ACE_COLORPICKER (ace, editor, opt) {
4
+
5
+ return new AceColorView(ace, editor, opt);
6
+
7
+ }
8
+
9
+ export default {
10
+ load: LOAD_ACE_COLORPICKER
11
+ }
package/src/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import './scss/index.scss'
2
+
3
+ import Util from './util/index'
4
+ import ColorPicker from './colorpicker/index'
5
+ import AceExtension from './extension/ace/index'
6
+
7
+
8
+ export default {
9
+ ...Util,
10
+ ...ColorPicker,
11
+ ...AceExtension
12
+ }
@@ -0,0 +1,65 @@
1
+
2
+ /* ace-colorpicker */
3
+
4
+ .ace-colorpicker {
5
+ position: relative;
6
+ width: 224px;
7
+ z-index: 1000;
8
+ display:inline-block;
9
+ border: 1px solid rgba(0, 0, 0, 0.2);
10
+ background-color: #fff;
11
+ border-radius: 3px;
12
+ box-shadow: 0 0px 10px 2px rgba(0, 0, 0, 0.12);
13
+
14
+ > .arrow {
15
+ position: absolute;
16
+ top: -10px;
17
+ left: 7px;
18
+ width: 0;
19
+ height: 0;
20
+ border-left: 10px solid transparent;
21
+ border-right: 10px solid transparent;
22
+ display:none;
23
+
24
+ border-bottom: 10px solid rgba(0, 0, 0, 0.2);
25
+ pointer-events: none;
26
+ &:after {
27
+ position: absolute;
28
+ content: "";
29
+ top: 1px;
30
+ left: -9px;
31
+ width: 0;
32
+ height: 0;
33
+ border-left: 9px solid transparent;
34
+ border-right: 9px solid transparent;
35
+
36
+ border-bottom: 9px solid white;
37
+ }
38
+ }
39
+
40
+ .colorpicker-body {
41
+ @import './component/button';
42
+ @import './component/palette';
43
+ @import './component/control';
44
+ @import './component/information';
45
+ @import './component/colorsets';
46
+ @import './component/colorchooser';
47
+
48
+ }
49
+
50
+ &.chromedevtool {
51
+
52
+ }
53
+
54
+ /* theme */
55
+ @import './themes/sketch';
56
+ @import './themes/palette';
57
+ @import './themes/macos';
58
+ @import './themes/mini';
59
+ @import './themes/mini-vertical';
60
+ @import './themes/ring';
61
+ @import './themes/xd';
62
+ @import './themes/vscode';
63
+ }
64
+
65
+ @import './component/colorsets-contextmenu';
@@ -0,0 +1,32 @@
1
+ /* codemirror colorview */
2
+
3
+ .ace-colorview {
4
+ position: absolute;
5
+ border : 1px solid #cecece;
6
+ display : inline-block;
7
+ box-sizing : border-box;
8
+ width : 10px;
9
+ height : 10px;
10
+ cursor: pointer;
11
+ vertical-align: middle;
12
+ transform: translateY(-50%);
13
+ pointer-events: all;
14
+ @include transparent-background();
15
+ padding: 10px 10px;
16
+ z-index: -100;
17
+
18
+ .ace-colorview-background {
19
+ content: "";
20
+ position: absolute;
21
+ left:0px;
22
+ right:0px;
23
+ bottom:0px;
24
+ top:0px;
25
+ }
26
+
27
+ &:hover {
28
+ border-color: #494949;
29
+ }
30
+ }
31
+
32
+
@@ -0,0 +1,33 @@
1
+ .arrow-button {
2
+ position: relative;
3
+ width: 10px;
4
+ height: 12px;
5
+ padding: 0px;
6
+ background-color: transparent;
7
+
8
+ &:before {
9
+ content: "";
10
+ display:inline-block;
11
+ position:absolute;
12
+ left:0px;
13
+ right:0px;
14
+ top:0px;
15
+ height:50%;
16
+ @include arrow_top(3px, black);
17
+ margin: 2px;
18
+ box-sizing:border-box;
19
+ }
20
+
21
+ &:after {
22
+ content: "";
23
+ display:inline-block;
24
+ position:absolute;
25
+ left:0px;
26
+ right:0px;
27
+ bottom:0px;
28
+ top:50%;
29
+ @include arrow_bottom(3px, black);
30
+ margin: 2px;
31
+ box-sizing:border-box;
32
+ }
33
+ }
@@ -0,0 +1,141 @@
1
+ .color-chooser {
2
+ position: absolute;
3
+ left: 0px;
4
+ right: 0px;
5
+ bottom: 0px;
6
+ top: 0px;
7
+ opacity: 0;
8
+ background-color: rgba(0, 0, 0, 0.5);
9
+ transition: opacity 0.05s ease-out;
10
+ pointer-events: none;
11
+
12
+ &.open {
13
+ opacity: 1;
14
+ pointer-events: all;
15
+ }
16
+
17
+ .color-chooser-container {
18
+ position: absolute;
19
+ top: 120px;
20
+ left:0px;
21
+ right:0px;
22
+ bottom:0px;
23
+ background-color: white;
24
+
25
+ .colorsets-item-header {
26
+ position: absolute;
27
+ top:0px;
28
+ left:0px;
29
+ right:0px;
30
+ height: 34px;
31
+ display:flex;
32
+ padding: 3px 0px;
33
+ box-sizing: border-box;
34
+ border-bottom: 1px solid rgba(0, 0, 0, 0.2);
35
+
36
+ .title {
37
+ flex: 2;
38
+ font-weight: bold;
39
+ font-size: 15px;
40
+ box-sizing: border-box;
41
+ margin-right: 30px;
42
+ vertical-align: middle;
43
+ margin: 0px;
44
+ padding: 5px;
45
+ padding-left:14px;
46
+ overflow: hidden;
47
+ text-overflow: ellipsis;
48
+ white-space: nowrap;
49
+ color:#000;
50
+ text-align: left;
51
+ }
52
+
53
+ .items {
54
+ flex:1;
55
+ text-align: right;
56
+ padding-right: 10px;
57
+ display:block;
58
+ height: 100%;
59
+ line-height: 2;
60
+ cursor:pointer;
61
+ }
62
+ }
63
+
64
+ .colorsets-list {
65
+ position: absolute;
66
+ top: 34px;
67
+ left:0px;
68
+ right:0px;
69
+ bottom:0px;
70
+ overflow: auto;
71
+
72
+ .colorsets-item {
73
+ cursor: pointer;
74
+
75
+ &:hover {
76
+ background-color: rgba(0, 0, 0, 0.05);
77
+ }
78
+
79
+ .title {
80
+ flex:2;
81
+ font-size: 14px;
82
+ box-sizing: border-box;
83
+ margin-right: 30px;
84
+ vertical-align: middle;
85
+ pointer-events: none;
86
+ margin: 0px;
87
+ padding: 5px;
88
+ padding-left:14px;
89
+ font-weight: normal;
90
+ font-size: 13px;
91
+ overflow: hidden;
92
+ text-overflow: ellipsis;
93
+ white-space: nowrap;
94
+ color:#000;
95
+ text-align: left;
96
+ }
97
+
98
+ .items {
99
+ flex:3;
100
+ display:block;
101
+ height: 100%;
102
+ line-height: 1.6;
103
+ cursor:pointer;
104
+ pointer-events: none;
105
+
106
+ .color-item {
107
+ width: 13px;
108
+ height: 13px;
109
+ border-radius:3px;
110
+ display:inline-block;
111
+ margin-right:10px;
112
+ @include transparent-background();
113
+ background-size: contain;
114
+ border: 1px solid rgba(221, 221, 221, 1);
115
+ overflow:hidden;
116
+ box-sizing:border-box;
117
+ cursor: pointer;
118
+ vertical-align: middle;
119
+
120
+ .color-view {
121
+ width: 100%;
122
+ height: 100%;
123
+ padding:0px;
124
+ margin:0px;
125
+ pointer-events: none;
126
+ }
127
+ }
128
+ }
129
+
130
+ display:flex;
131
+ padding: 3px 0px;
132
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
133
+
134
+
135
+ }
136
+
137
+ }
138
+ }
139
+
140
+
141
+ }
@@ -0,0 +1,33 @@
1
+
2
+ .colorsets-contextmenu {
3
+ position:fixed;
4
+ padding-top:4px;
5
+ padding-bottom:4px;
6
+ border-radius: 6px;
7
+ background-color: #ececec;
8
+ border: 1px solid rgba(204, 204, 204, 1);
9
+ display: none;
10
+ list-style: none;
11
+ font-size: 13px;
12
+ padding-left: 0px;
13
+ padding-right: 0px;
14
+ &.show {
15
+ display:inline-block;
16
+ }
17
+
18
+ .menu-item {
19
+ padding: 2px 20px;
20
+ cursor: default;
21
+
22
+ &:hover {
23
+ background-color: #5ea3fb;
24
+ color: white;
25
+ }
26
+ }
27
+
28
+ &.small {
29
+ .menu-item.small-hide {
30
+ display: none;
31
+ }
32
+ }
33
+ }