suneditor 2.46.2 → 3.0.0-alpha.2

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 (289) hide show
  1. package/.eslintignore +7 -0
  2. package/.eslintrc.json +64 -0
  3. package/CONTRIBUTING.md +36 -0
  4. package/LICENSE.txt +1 -1
  5. package/README.md +11 -1560
  6. package/package.json +94 -70
  7. package/src/assets/icons/_default.js +194 -0
  8. package/src/assets/suneditor-content.css +642 -0
  9. package/src/assets/suneditor.css +3378 -0
  10. package/src/core/base/eventHandlers/handler_toolbar.js +114 -0
  11. package/src/core/base/eventHandlers/handler_ww_clipboard.js +31 -0
  12. package/src/core/base/eventHandlers/handler_ww_dragDrop.js +69 -0
  13. package/src/core/base/eventHandlers/handler_ww_key_input.js +978 -0
  14. package/src/core/base/eventHandlers/handler_ww_mouse.js +118 -0
  15. package/src/core/base/eventManager.js +1129 -0
  16. package/src/core/base/events.js +320 -0
  17. package/src/core/base/history.js +301 -0
  18. package/src/core/class/char.js +146 -0
  19. package/src/core/class/component.js +624 -0
  20. package/src/core/class/format.js +3255 -0
  21. package/src/core/class/html.js +1621 -0
  22. package/src/core/class/menu.js +260 -0
  23. package/src/core/class/nodeTransform.js +379 -0
  24. package/src/core/class/notice.js +42 -0
  25. package/src/core/class/offset.js +578 -0
  26. package/src/core/class/selection.js +508 -0
  27. package/src/core/class/shortcuts.js +38 -0
  28. package/src/core/class/toolbar.js +440 -0
  29. package/src/core/class/viewer.js +646 -0
  30. package/src/core/editor.js +1588 -0
  31. package/src/core/section/actives.js +107 -0
  32. package/src/core/section/constructor.js +1237 -0
  33. package/src/core/section/context.js +97 -0
  34. package/src/editorInjector/_classes.js +22 -0
  35. package/src/editorInjector/_core.js +28 -0
  36. package/src/editorInjector/index.js +13 -0
  37. package/src/helper/converter.js +313 -0
  38. package/src/helper/domUtils.js +1177 -0
  39. package/src/helper/env.js +250 -0
  40. package/src/helper/index.js +19 -0
  41. package/src/helper/numbers.js +68 -0
  42. package/src/helper/unicode.js +43 -0
  43. package/src/langs/ckb.js +161 -0
  44. package/src/langs/cs.js +161 -0
  45. package/src/langs/da.js +161 -0
  46. package/src/langs/de.js +162 -0
  47. package/src/langs/en.js +199 -0
  48. package/src/langs/es.js +162 -0
  49. package/src/langs/fa.js +159 -0
  50. package/src/langs/fr.js +161 -0
  51. package/src/langs/he.js +162 -0
  52. package/src/{lang → langs}/index.js +0 -2
  53. package/src/langs/it.js +162 -0
  54. package/src/langs/ja.js +162 -0
  55. package/src/langs/ko.js +162 -0
  56. package/src/langs/lv.js +162 -0
  57. package/src/langs/nl.js +162 -0
  58. package/src/langs/pl.js +162 -0
  59. package/src/langs/pt_br.js +162 -0
  60. package/src/langs/ro.js +162 -0
  61. package/src/langs/ru.js +162 -0
  62. package/src/langs/se.js +162 -0
  63. package/src/langs/tr.js +159 -0
  64. package/src/langs/ua.js +162 -0
  65. package/src/langs/ur.js +162 -0
  66. package/src/langs/zh_cn.js +162 -0
  67. package/src/modules/ApiManager.js +168 -0
  68. package/src/modules/ColorPicker.js +302 -0
  69. package/src/modules/Controller.js +315 -0
  70. package/src/modules/Figure.js +1174 -0
  71. package/src/modules/FileBrowser.js +271 -0
  72. package/src/modules/FileManager.js +290 -0
  73. package/src/modules/HueSlider.js +513 -0
  74. package/src/modules/Modal.js +177 -0
  75. package/src/modules/ModalAnchorEditor.js +494 -0
  76. package/src/modules/SelectMenu.js +447 -0
  77. package/src/modules/_DragHandle.js +16 -0
  78. package/src/modules/index.js +14 -0
  79. package/src/plugins/command/blockquote.js +47 -47
  80. package/src/plugins/command/exportPdf.js +168 -0
  81. package/src/plugins/command/fileUpload.js +389 -0
  82. package/src/plugins/command/list_bulleted.js +112 -0
  83. package/src/plugins/command/list_numbered.js +115 -0
  84. package/src/plugins/dropdown/align.js +143 -0
  85. package/src/plugins/dropdown/backgroundColor.js +73 -0
  86. package/src/plugins/dropdown/font.js +113 -0
  87. package/src/plugins/dropdown/fontColor.js +73 -0
  88. package/src/plugins/dropdown/formatBlock.js +141 -0
  89. package/src/plugins/dropdown/hr.js +111 -0
  90. package/src/plugins/dropdown/layout.js +72 -0
  91. package/src/plugins/dropdown/lineHeight.js +114 -0
  92. package/src/plugins/dropdown/list.js +107 -0
  93. package/src/plugins/dropdown/paragraphStyle.js +117 -0
  94. package/src/plugins/dropdown/table.js +2810 -0
  95. package/src/plugins/dropdown/template.js +71 -0
  96. package/src/plugins/dropdown/textStyle.js +137 -0
  97. package/src/plugins/field/mention.js +172 -0
  98. package/src/plugins/fileBrowser/imageGallery.js +76 -59
  99. package/src/plugins/index.js +86 -24
  100. package/src/plugins/input/fontSize.js +357 -0
  101. package/src/plugins/modal/audio.js +492 -0
  102. package/src/plugins/modal/image.js +1062 -0
  103. package/src/plugins/modal/link.js +211 -0
  104. package/src/plugins/modal/math.js +347 -0
  105. package/src/plugins/modal/video.js +870 -0
  106. package/src/suneditor.js +62 -67
  107. package/src/themes/test.css +61 -0
  108. package/typings/CommandPlugin.d.ts +8 -0
  109. package/typings/DialogPlugin.d.ts +20 -0
  110. package/typings/FileBrowserPlugin.d.ts +30 -0
  111. package/typings/Lang.d.ts +124 -0
  112. package/typings/Module.d.ts +15 -0
  113. package/typings/Plugin.d.ts +42 -0
  114. package/typings/SubmenuPlugin.d.ts +8 -0
  115. package/typings/_classes.d.ts +17 -0
  116. package/typings/_colorPicker.d.ts +60 -0
  117. package/typings/_core.d.ts +55 -0
  118. package/typings/align.d.ts +5 -0
  119. package/{src/plugins/dialog → typings}/audio.d.ts +1 -1
  120. package/typings/backgroundColor.d.ts +5 -0
  121. package/{src/plugins/command → typings}/blockquote.d.ts +1 -1
  122. package/typings/char.d.ts +39 -0
  123. package/typings/component.d.ts +38 -0
  124. package/typings/context.d.ts +39 -0
  125. package/typings/converter.d.ts +33 -0
  126. package/typings/dialog.d.ts +28 -0
  127. package/typings/domUtils.d.ts +361 -0
  128. package/typings/editor.d.ts +7 -0
  129. package/typings/editor.ts +542 -0
  130. package/typings/env.d.ts +70 -0
  131. package/typings/eventManager.d.ts +37 -0
  132. package/typings/events.d.ts +262 -0
  133. package/typings/fileBrowser.d.ts +42 -0
  134. package/typings/fileManager.d.ts +67 -0
  135. package/typings/font.d.ts +5 -0
  136. package/typings/fontColor.d.ts +5 -0
  137. package/typings/fontSize.d.ts +5 -0
  138. package/typings/format.d.ts +191 -0
  139. package/typings/formatBlock.d.ts +5 -0
  140. package/typings/history.d.ts +48 -0
  141. package/typings/horizontalRule.d.ts +5 -0
  142. package/{src/plugins/dialog → typings}/image.d.ts +1 -1
  143. package/{src/plugins/fileBrowser → typings}/imageGallery.d.ts +1 -1
  144. package/typings/index.d.ts +21 -0
  145. package/{src/plugins/modules/index.d.ts → typings/index.modules.d.ts} +3 -3
  146. package/typings/index.plugins.d.ts +58 -0
  147. package/typings/lineHeight.d.ts +5 -0
  148. package/{src/plugins/dialog → typings}/link.d.ts +1 -1
  149. package/typings/list.d.ts +5 -0
  150. package/{src/plugins/dialog → typings}/math.d.ts +1 -1
  151. package/typings/mediaContainer.d.ts +25 -0
  152. package/typings/node.d.ts +57 -0
  153. package/typings/notice.d.ts +16 -0
  154. package/typings/numbers.d.ts +29 -0
  155. package/typings/offset.d.ts +24 -0
  156. package/typings/options.d.ts +589 -0
  157. package/typings/paragraphStyle.d.ts +5 -0
  158. package/typings/resizing.d.ts +141 -0
  159. package/typings/selection.d.ts +94 -0
  160. package/typings/shortcuts.d.ts +13 -0
  161. package/typings/suneditor.d.ts +9 -0
  162. package/typings/table.d.ts +5 -0
  163. package/typings/template.d.ts +5 -0
  164. package/typings/textStyle.d.ts +5 -0
  165. package/typings/toolbar.d.ts +32 -0
  166. package/typings/unicode.d.ts +25 -0
  167. package/{src/plugins/dialog → typings}/video.d.ts +1 -1
  168. package/dist/css/suneditor.min.css +0 -1
  169. package/dist/suneditor.min.js +0 -2
  170. package/src/assets/css/suneditor-contents.css +0 -562
  171. package/src/assets/css/suneditor.css +0 -566
  172. package/src/assets/defaultIcons.js +0 -103
  173. package/src/lang/Lang.d.ts +0 -144
  174. package/src/lang/ckb.d.ts +0 -5
  175. package/src/lang/ckb.js +0 -188
  176. package/src/lang/cs.d.ts +0 -5
  177. package/src/lang/cs.js +0 -188
  178. package/src/lang/da.d.ts +0 -5
  179. package/src/lang/da.js +0 -191
  180. package/src/lang/de.d.ts +0 -5
  181. package/src/lang/de.js +0 -188
  182. package/src/lang/en.d.ts +0 -5
  183. package/src/lang/en.js +0 -188
  184. package/src/lang/es.d.ts +0 -5
  185. package/src/lang/es.js +0 -188
  186. package/src/lang/fa.d.ts +0 -5
  187. package/src/lang/fa.js +0 -188
  188. package/src/lang/fr.d.ts +0 -5
  189. package/src/lang/fr.js +0 -188
  190. package/src/lang/he.d.ts +0 -5
  191. package/src/lang/he.js +0 -188
  192. package/src/lang/index.d.ts +0 -23
  193. package/src/lang/it.d.ts +0 -5
  194. package/src/lang/it.js +0 -188
  195. package/src/lang/ja.d.ts +0 -5
  196. package/src/lang/ja.js +0 -188
  197. package/src/lang/ko.d.ts +0 -5
  198. package/src/lang/ko.js +0 -188
  199. package/src/lang/lv.d.ts +0 -5
  200. package/src/lang/lv.js +0 -188
  201. package/src/lang/nl.d.ts +0 -5
  202. package/src/lang/nl.js +0 -188
  203. package/src/lang/pl.d.ts +0 -5
  204. package/src/lang/pl.js +0 -188
  205. package/src/lang/pt_br.d.ts +0 -5
  206. package/src/lang/pt_br.js +0 -189
  207. package/src/lang/ro.d.ts +0 -5
  208. package/src/lang/ro.js +0 -188
  209. package/src/lang/ru.d.ts +0 -5
  210. package/src/lang/ru.js +0 -188
  211. package/src/lang/se.d.ts +0 -5
  212. package/src/lang/se.js +0 -191
  213. package/src/lang/tr.d.ts +0 -5
  214. package/src/lang/tr.js +0 -191
  215. package/src/lang/ua.d.ts +0 -5
  216. package/src/lang/ua.js +0 -188
  217. package/src/lang/ur.d.ts +0 -5
  218. package/src/lang/ur.js +0 -188
  219. package/src/lang/zh_cn.d.ts +0 -5
  220. package/src/lang/zh_cn.js +0 -187
  221. package/src/lib/constructor.js +0 -954
  222. package/src/lib/context.d.ts +0 -42
  223. package/src/lib/context.js +0 -71
  224. package/src/lib/core.d.ts +0 -1135
  225. package/src/lib/core.js +0 -9395
  226. package/src/lib/history.d.ts +0 -48
  227. package/src/lib/history.js +0 -219
  228. package/src/lib/util.d.ts +0 -678
  229. package/src/lib/util.js +0 -2131
  230. package/src/options.d.ts +0 -608
  231. package/src/plugins/CommandPlugin.d.ts +0 -8
  232. package/src/plugins/DialogPlugin.d.ts +0 -20
  233. package/src/plugins/FileBrowserPlugin.d.ts +0 -30
  234. package/src/plugins/Module.d.ts +0 -15
  235. package/src/plugins/Plugin.d.ts +0 -42
  236. package/src/plugins/SubmenuPlugin.d.ts +0 -8
  237. package/src/plugins/dialog/audio.js +0 -559
  238. package/src/plugins/dialog/image.js +0 -1126
  239. package/src/plugins/dialog/link.js +0 -223
  240. package/src/plugins/dialog/math.js +0 -295
  241. package/src/plugins/dialog/mention.js +0 -242
  242. package/src/plugins/dialog/video.js +0 -979
  243. package/src/plugins/index.d.ts +0 -79
  244. package/src/plugins/modules/_anchor.js +0 -461
  245. package/src/plugins/modules/_colorPicker.d.ts +0 -60
  246. package/src/plugins/modules/_colorPicker.js +0 -201
  247. package/src/plugins/modules/_notice.d.ts +0 -21
  248. package/src/plugins/modules/_notice.js +0 -72
  249. package/src/plugins/modules/_selectMenu.js +0 -119
  250. package/src/plugins/modules/component.d.ts +0 -25
  251. package/src/plugins/modules/component.js +0 -81
  252. package/src/plugins/modules/dialog.d.ts +0 -28
  253. package/src/plugins/modules/dialog.js +0 -175
  254. package/src/plugins/modules/fileBrowser.d.ts +0 -42
  255. package/src/plugins/modules/fileBrowser.js +0 -374
  256. package/src/plugins/modules/fileManager.d.ts +0 -67
  257. package/src/plugins/modules/fileManager.js +0 -326
  258. package/src/plugins/modules/index.js +0 -9
  259. package/src/plugins/modules/resizing.d.ts +0 -154
  260. package/src/plugins/modules/resizing.js +0 -903
  261. package/src/plugins/submenu/align.d.ts +0 -5
  262. package/src/plugins/submenu/align.js +0 -160
  263. package/src/plugins/submenu/font.d.ts +0 -5
  264. package/src/plugins/submenu/font.js +0 -123
  265. package/src/plugins/submenu/fontColor.d.ts +0 -5
  266. package/src/plugins/submenu/fontColor.js +0 -101
  267. package/src/plugins/submenu/fontSize.d.ts +0 -5
  268. package/src/plugins/submenu/fontSize.js +0 -112
  269. package/src/plugins/submenu/formatBlock.d.ts +0 -5
  270. package/src/plugins/submenu/formatBlock.js +0 -273
  271. package/src/plugins/submenu/hiliteColor.d.ts +0 -5
  272. package/src/plugins/submenu/hiliteColor.js +0 -102
  273. package/src/plugins/submenu/horizontalRule.d.ts +0 -5
  274. package/src/plugins/submenu/horizontalRule.js +0 -98
  275. package/src/plugins/submenu/lineHeight.d.ts +0 -5
  276. package/src/plugins/submenu/lineHeight.js +0 -104
  277. package/src/plugins/submenu/list.d.ts +0 -5
  278. package/src/plugins/submenu/list.js +0 -456
  279. package/src/plugins/submenu/paragraphStyle.d.ts +0 -5
  280. package/src/plugins/submenu/paragraphStyle.js +0 -135
  281. package/src/plugins/submenu/table.d.ts +0 -5
  282. package/src/plugins/submenu/table.js +0 -1431
  283. package/src/plugins/submenu/template.d.ts +0 -5
  284. package/src/plugins/submenu/template.js +0 -72
  285. package/src/plugins/submenu/textStyle.d.ts +0 -5
  286. package/src/plugins/submenu/textStyle.js +0 -167
  287. package/src/suneditor.d.ts +0 -9
  288. package/src/suneditor_build.js +0 -18
  289. /package/{src/plugins/dialog → typings}/mention.d.ts +0 -0
@@ -1,79 +0,0 @@
1
- // command
2
- import { CommandPlugin } from "./CommandPlugin";
3
- import blockquote from "./command/blockquote";
4
-
5
- // submenu
6
- import { SubmenuPlugin } from "./SubmenuPlugin";
7
- import align from "./submenu/align";
8
- import font from "./submenu/font";
9
- import fontSize from "./submenu/fontSize";
10
- import fontColor from "./submenu/fontColor";
11
- import hiliteColor from "./submenu/hiliteColor";
12
- import horizontalRule from "./submenu/horizontalRule";
13
- import list from "./submenu/list";
14
- import table from "./submenu/table";
15
- import formatBlock from "./submenu/formatBlock";
16
- import lineHeight from "./submenu/lineHeight";
17
- import template from "./submenu/template";
18
- import paragraphStyle from "./submenu/paragraphStyle";
19
- import textStyle from "./submenu/textStyle";
20
-
21
- // dialog
22
- import { DialogPlugin } from "./DialogPlugin";
23
- import link from "./dialog/link";
24
- import image from "./dialog/image";
25
- import video from "./dialog/video";
26
- import audio from "./dialog/audio";
27
- import math from "./dialog/math";
28
-
29
- // file browser
30
- import { FileBrowserPlugin } from "./FileBrowserPlugin";
31
- import imageGallery from "./fileBrowser/imageGallery";
32
-
33
- declare const _default: {
34
- blockquote: CommandPlugin;
35
- align: SubmenuPlugin;
36
- font: SubmenuPlugin;
37
- fontSize: SubmenuPlugin;
38
- fontColor: SubmenuPlugin;
39
- hiliteColor: SubmenuPlugin;
40
- horizontalRule: SubmenuPlugin;
41
- list: SubmenuPlugin;
42
- table: SubmenuPlugin;
43
- formatBlock: SubmenuPlugin;
44
- lineHeight: SubmenuPlugin;
45
- template: SubmenuPlugin;
46
- paragraphStyle: SubmenuPlugin;
47
- textStyle: SubmenuPlugin;
48
- link: DialogPlugin;
49
- image: DialogPlugin;
50
- video: DialogPlugin;
51
- audio: DialogPlugin;
52
- math: DialogPlugin;
53
- imageGallery: FileBrowserPlugin;
54
- };
55
-
56
- export {
57
- blockquote,
58
- align,
59
- font,
60
- fontSize,
61
- fontColor,
62
- hiliteColor,
63
- horizontalRule,
64
- list,
65
- table,
66
- formatBlock,
67
- lineHeight,
68
- template,
69
- paragraphStyle,
70
- textStyle,
71
- link,
72
- image,
73
- video,
74
- audio,
75
- math,
76
- imageGallery,
77
- };
78
-
79
- export default _default;
@@ -1,461 +0,0 @@
1
- /*
2
- * wysiwyg web editor
3
- *
4
- * suneditor.js
5
- * Copyright 2017 JiHong Lee.
6
- * MIT license.
7
- */
8
- 'use strict';
9
-
10
- import selectMenu from './_selectMenu';
11
-
12
- export default {
13
- name: 'anchor',
14
- add: function (core) {
15
- core.addModule([selectMenu]);
16
-
17
- core.context.anchor = {
18
- caller: {},
19
- forms: this.setDialogForm(core),
20
- host: (core._w.location.origin + core._w.location.pathname).replace(/\/$/, ''),
21
- callerContext: null
22
- };
23
- },
24
-
25
- /** dialog */
26
- setDialogForm: function (core) {
27
- const lang = core.lang;
28
- const relList = core.options.linkRel;
29
- const defaultRel = (core.options.linkRelDefault.default || '').split(' ');
30
- const icons = core.icons;
31
- const forms = core.util.createElement('DIV');
32
-
33
- let html = '<div class="se-dialog-body">' +
34
- '<div class="se-dialog-form">' +
35
- '<label>' + lang.dialogBox.linkBox.url + '</label>' +
36
- '<div class="se-dialog-form-files">' +
37
- '<input class="se-input-form se-input-url" type="text" placeholder="' + (core.options.protocol || '') + '" />' +
38
- '<button type="button" class="se-btn se-dialog-files-edge-button _se_bookmark_button" title="' + lang.dialogBox.linkBox.bookmark + '" aria-label="' + lang.dialogBox.linkBox.bookmark + '">' + icons.bookmark + '</button>' +
39
- core.plugins.selectMenu.setForm() +
40
- '</div>' +
41
- '<div class="se-anchor-preview-form">' +
42
- '<span class="se-svg se-anchor-preview-icon _se_anchor_bookmark_icon">' + icons.bookmark + '</span>' +
43
- '<span class="se-svg se-anchor-preview-icon _se_anchor_download_icon">' + icons.download + '</span>' +
44
- '<pre class="se-link-preview"></pre>' +
45
- '</div>' +
46
- '</div>' +
47
- '<div class="se-dialog-form">' +
48
- '<label>' + lang.dialogBox.linkBox.text + '</label><input class="se-input-form _se_anchor_text" type="text" />' +
49
- '</div>' +
50
- '<div class="se-dialog-form-footer">' +
51
- '<label><input type="checkbox" class="se-dialog-btn-check _se_anchor_check" />&nbsp;' + lang.dialogBox.linkBox.newWindowCheck + '</label>' +
52
- '<label><input type="checkbox" class="se-dialog-btn-check _se_anchor_download" />&nbsp;' + lang.dialogBox.linkBox.downloadLinkCheck + '</label>';
53
- if (relList.length > 0) {
54
- html += '<div class="se-anchor-rel"><button type="button" class="se-btn se-btn-select se-anchor-rel-btn">&lt;rel&gt;</button>' +
55
- '<div class="se-anchor-rel-wrapper"><pre class="se-link-preview se-anchor-rel-preview"></pre></div>' +
56
- '<div class="se-list-layer">' +
57
- '<div class="se-list-inner">' +
58
- '<ul class="se-list-basic se-list-checked">';
59
- for (let i = 0, len = relList.length, rel; i < len; i++) {
60
- rel = relList[i];
61
- html += '<li><button type="button" class="se-btn-list' + (defaultRel.indexOf(rel) > -1 ? ' se-checked' : '') + '" data-command="' + rel + '" title="' + rel + '" aria-label="' + rel + '"><span class="se-svg">' + icons.checked + '</span>' + rel + '</button></li>';
62
- }
63
- html += '</ul></div></div></div>';
64
- }
65
-
66
- html += '</div></div>';
67
-
68
- forms.innerHTML = html;
69
- return forms;
70
- },
71
-
72
- initEvent: function (pluginName, forms) {
73
- const anchorPlugin = this.plugins.anchor;
74
- const context = this.context.anchor.caller[pluginName] = {
75
- modal: forms,
76
- urlInput: null,
77
- linkDefaultRel: this.options.linkRelDefault,
78
- defaultRel: this.options.linkRelDefault.default || '',
79
- currentRel: [],
80
- linkAnchor: null,
81
- linkValue: '',
82
- _change: false,
83
- callerName: pluginName
84
- };
85
-
86
- if (typeof context.linkDefaultRel.default === 'string') context.linkDefaultRel.default = context.linkDefaultRel.default.trim();
87
- if (typeof context.linkDefaultRel.check_new_window === 'string') context.linkDefaultRel.check_new_window = context.linkDefaultRel.check_new_window.trim();
88
- if (typeof context.linkDefaultRel.check_bookmark === 'string') context.linkDefaultRel.check_bookmark = context.linkDefaultRel.check_bookmark.trim();
89
-
90
- context.urlInput = forms.querySelector('.se-input-url');
91
- context.anchorText = forms.querySelector('._se_anchor_text');
92
- context.newWindowCheck = forms.querySelector('._se_anchor_check');
93
- context.downloadCheck = forms.querySelector('._se_anchor_download');
94
- context.download = forms.querySelector('._se_anchor_download_icon');
95
- context.preview = forms.querySelector('.se-link-preview');
96
- context.bookmark = forms.querySelector('._se_anchor_bookmark_icon');
97
- context.bookmarkButton = forms.querySelector('._se_bookmark_button');
98
-
99
- this.plugins.selectMenu.initEvent.call(this, pluginName, forms);
100
- const listContext = this.context.selectMenu.caller[pluginName];
101
-
102
- /** rel */
103
- if (this.options.linkRel.length > 0) {
104
- context.relButton = forms.querySelector('.se-anchor-rel-btn');
105
- context.relList = forms.querySelector('.se-list-layer');
106
- context.relPreview = forms.querySelector('.se-anchor-rel-preview');
107
- context.relButton.addEventListener('click', anchorPlugin.onClick_relButton.bind(this, context));
108
- context.relList.addEventListener('click', anchorPlugin.onClick_relList.bind(this, context));
109
- }
110
-
111
- context.newWindowCheck.addEventListener('change', anchorPlugin.onChange_newWindowCheck.bind(this, context));
112
- context.downloadCheck.addEventListener('change', anchorPlugin.onChange_downloadCheck.bind(this, context));
113
- context.anchorText.addEventListener('input', anchorPlugin.onChangeAnchorText.bind(this, context));
114
- context.urlInput.addEventListener('input', anchorPlugin.onChangeUrlInput.bind(this, context));
115
- context.urlInput.addEventListener('keydown', anchorPlugin.onKeyDownUrlInput.bind(this, listContext));
116
- context.urlInput.addEventListener('focus', anchorPlugin.onFocusUrlInput.bind(this, context, listContext));
117
- context.urlInput.addEventListener('blur', anchorPlugin.onBlurUrlInput.bind(this, listContext));
118
- context.bookmarkButton.addEventListener('click', anchorPlugin.onClick_bookmarkButton.bind(this, context));
119
- },
120
-
121
- on: function (contextAnchor, update) {
122
- const anchorPlugin = this.plugins.anchor;
123
-
124
- if (!update) {
125
- anchorPlugin.init.call(this, contextAnchor);
126
- contextAnchor.anchorText.value = this.getSelection().toString().trim();
127
- contextAnchor.newWindowCheck.checked = this.options.linkTargetNewWindow;
128
- } else if (contextAnchor.linkAnchor) {
129
- this.context.dialog.updateModal = true;
130
- const href = contextAnchor.linkAnchor.getAttribute('href');
131
- contextAnchor.linkValue = contextAnchor.preview.textContent = contextAnchor.urlInput.value = anchorPlugin.selfPathBookmark.call(this, href) ? href.substr(href.lastIndexOf('#')) : href;
132
- contextAnchor.anchorText.value = contextAnchor.linkAnchor.textContent;
133
- contextAnchor.newWindowCheck.checked = (/_blank/i.test(contextAnchor.linkAnchor.target) ? true : false);
134
- contextAnchor.downloadCheck.checked = contextAnchor.linkAnchor.download;
135
- }
136
-
137
- this.context.anchor.callerContext = contextAnchor;
138
- anchorPlugin.setRel.call(this, contextAnchor, (update && contextAnchor.linkAnchor) ? contextAnchor.linkAnchor.rel : contextAnchor.defaultRel);
139
- anchorPlugin.setLinkPreview.call(this, contextAnchor, contextAnchor.linkValue);
140
- this.plugins.selectMenu.on.call(this, contextAnchor.callerName, this.plugins.anchor.setHeaderBookmark);
141
- },
142
-
143
- selfPathBookmark: function(path) {
144
- const href = this._w.location.href.replace(/\/$/, '');
145
- return path.indexOf('#') === 0 || (path.indexOf(href) === 0 && path.indexOf('#') === (href.indexOf("#") === -1 ? href.length : href.substr(0, href.indexOf("#")).length));
146
- },
147
-
148
- _closeRelMenu: null,
149
- toggleRelList: function (contextAnchor, show) {
150
- if (!show) {
151
- if (this.plugins.anchor._closeRelMenu) this.plugins.anchor._closeRelMenu();
152
- } else {
153
- const target = contextAnchor.relButton;
154
- const relList = contextAnchor.relList;
155
- this.util.addClass(target, 'active');
156
- relList.style.visibility = 'hidden';
157
- relList.style.display = 'block';
158
- if (!this.options.rtl) relList.style.left = (target.offsetLeft + target.offsetWidth + 1) + 'px';
159
- else relList.style.left = (target.offsetLeft - relList.offsetWidth - 1) + 'px';
160
- relList.style.top = (target.offsetTop + (target.offsetHeight / 2) - (relList.offsetHeight / 2)) + 'px';
161
- relList.style.visibility = '';
162
-
163
- this.plugins.anchor._closeRelMenu = function (context, target, e) {
164
- if (e && (context.relButton.contains(e.target) || context.relList.contains(e.target))) return;
165
- this.util.removeClass(target, 'active');
166
- context.relList.style.display = 'none';
167
- this.modalForm.removeEventListener('click', this.plugins.anchor._closeRelMenu);
168
- this.plugins.anchor._closeRelMenu = null;
169
- }.bind(this, contextAnchor, target);
170
-
171
- this.modalForm.addEventListener('click', this.plugins.anchor._closeRelMenu);
172
- }
173
- },
174
-
175
- onClick_relButton: function (contextAnchor, e) {
176
- this.plugins.anchor.toggleRelList.call(this, contextAnchor, !this.util.hasClass(e.target, 'active'));
177
- },
178
-
179
- onClick_relList: function (contextAnchor, e) {
180
- const target = e.target;
181
- const cmd = target.getAttribute('data-command');
182
- if (!cmd) return;
183
-
184
- const current = contextAnchor.currentRel;
185
- const checked = this.util.toggleClass(target, 'se-checked');
186
- const index = current.indexOf(cmd);
187
- if (checked) {
188
- if (index === -1) current.push(cmd);
189
- } else {
190
- if (index > -1) current.splice(index, 1);
191
- }
192
-
193
- contextAnchor.relPreview.title = contextAnchor.relPreview.textContent = current.join(' ');
194
- },
195
-
196
- setRel: function (contextAnchor, relAttr) {
197
- const relListEl = contextAnchor.relList;
198
- const rels = contextAnchor.currentRel = !relAttr ? [] : relAttr.split(' ');
199
- if (!relListEl) return;
200
-
201
- const checkedRel = relListEl.querySelectorAll('button');
202
- for (let i = 0, len = checkedRel.length, cmd; i < len; i++) {
203
- cmd = checkedRel[i].getAttribute('data-command');
204
- if (rels.indexOf(cmd) > -1) {
205
- this.util.addClass(checkedRel[i], 'se-checked');
206
- } else {
207
- this.util.removeClass(checkedRel[i], 'se-checked');
208
- }
209
- }
210
-
211
- contextAnchor.relPreview.title = contextAnchor.relPreview.textContent = rels.join(' ');
212
- },
213
-
214
- createHeaderList: function (contextAnchor, contextList, urlValue) {
215
- const headers = this.util.getListChildren(this.context.element.wysiwyg, function(current) {
216
- return /h[1-6]/i.test(current.nodeName);
217
- });
218
- if (headers.length === 0) return;
219
-
220
- const valueRegExp = new this._w.RegExp('^' + urlValue.replace(/^#/, ''), 'i');
221
- const list = [];
222
- let html = '';
223
- for(let i = 0, len = headers.length, h; i < len; i++) {
224
- h = headers[i];
225
- if (!valueRegExp.test(h.textContent)) continue;
226
- list.push(h);
227
- html += '<li class="se-select-item" data-index="' + i + '">' + h.textContent + '</li>';
228
- }
229
-
230
- if (list.length === 0) {
231
- this.plugins.selectMenu.close.call(this, contextList);
232
- } else {
233
- this.plugins.selectMenu.createList(contextList, list, html);
234
- this.plugins.selectMenu.open.call(this, contextList, this.plugins.anchor._setMenuListPosition.bind(this, contextAnchor));
235
- }
236
- },
237
-
238
- _setMenuListPosition: function (contextAnchor, list) {
239
- list.style.top = (contextAnchor.urlInput.offsetHeight + 1) + 'px';
240
- },
241
-
242
- onKeyDownUrlInput: function (contextList, e) {
243
- const keyCode = e.keyCode;
244
- switch (keyCode) {
245
- case 38: // up
246
- e.preventDefault();
247
- e.stopPropagation();
248
- this.plugins.selectMenu.moveItem.call(this, contextList, -1);
249
- break;
250
- case 40: // down
251
- e.preventDefault();
252
- e.stopPropagation();
253
- this.plugins.selectMenu.moveItem.call(this, contextList, 1);
254
- break;
255
- case 13: // enter
256
- if (contextList.index > -1) {
257
- e.preventDefault();
258
- e.stopPropagation();
259
- this.plugins.anchor.setHeaderBookmark.call(this, this.plugins.selectMenu.getItem(contextList, null));
260
- }
261
- break;
262
- }
263
- },
264
-
265
- setHeaderBookmark: function (header) {
266
- const contextAnchor = this.context.anchor.callerContext;
267
- const id = header.id || 'h_' + this._w.Math.random().toString().replace(/.+\./, '');
268
- header.id = id;
269
- contextAnchor.urlInput.value = '#' + id;
270
-
271
- if (!contextAnchor.anchorText.value.trim() || !contextAnchor._change) {
272
- contextAnchor.anchorText.value = header.textContent;
273
- }
274
-
275
- this.plugins.anchor.setLinkPreview.call(this, contextAnchor, contextAnchor.urlInput.value);
276
- this.plugins.selectMenu.close.call(this, this.context.selectMenu.callerContext);
277
- this.context.anchor.callerContext.urlInput.focus();
278
- },
279
-
280
- onChangeAnchorText: function (contextAnchor, e) {
281
- contextAnchor._change = !!e.target.value.trim();
282
- },
283
-
284
- onChangeUrlInput: function (contextAnchor, e) {
285
- const value = e.target.value.trim();
286
- this.plugins.anchor.setLinkPreview.call(this, contextAnchor, value);
287
-
288
- if (this.plugins.anchor.selfPathBookmark.call(this, value)) this.plugins.anchor.createHeaderList.call(this, contextAnchor, this.context.selectMenu.callerContext, value);
289
- else this.plugins.selectMenu.close.call(this, this.context.selectMenu.callerContext);
290
- },
291
-
292
- onFocusUrlInput: function (contextAnchor, contextLink) {
293
- const value = contextAnchor.urlInput.value;
294
- if (this.plugins.anchor.selfPathBookmark.call(this, value)) this.plugins.anchor.createHeaderList.call(this, contextAnchor, contextLink, value);
295
- },
296
-
297
- onBlurUrlInput: function (contextList) {
298
- this.plugins.selectMenu.close.call(this, contextList);
299
- },
300
-
301
- setLinkPreview: function (context, value) {
302
- const preview = context.preview;
303
- const protocol = this.options.linkProtocol;
304
- const noPrefix = this.options.linkNoPrefix;
305
- const reservedProtocol = /^(mailto\:|tel\:|sms\:|https*\:\/\/|#)/.test(value) || value.indexOf(protocol) === 0;
306
- const sameProtocol = !protocol ? false : this._w.RegExp('^' + this.util.escapeStringRegexp(value.substr(0, protocol.length))).test(protocol);
307
- value = context.linkValue = preview.textContent = !value ? '' : noPrefix ? value : (protocol && !reservedProtocol && !sameProtocol) ? protocol + value : reservedProtocol ? value : /^www\./.test(value) ? 'http://' + value : this.context.anchor.host + (/^\//.test(value) ? '' : '/') + value;
308
-
309
- if (this.plugins.anchor.selfPathBookmark.call(this, value)) {
310
- context.bookmark.style.display = 'block';
311
- this.util.addClass(context.bookmarkButton, 'active');
312
- } else {
313
- context.bookmark.style.display = 'none';
314
- this.util.removeClass(context.bookmarkButton, 'active');
315
- }
316
-
317
- if (!this.plugins.anchor.selfPathBookmark.call(this, value) && context.downloadCheck.checked) {
318
- context.download.style.display = 'block';
319
- } else {
320
- context.download.style.display = 'none';
321
- }
322
- },
323
-
324
- setCtx: function (anchor, contextAnchor) {
325
- if (!anchor) return;
326
- contextAnchor.linkAnchor = anchor;
327
- contextAnchor.linkValue = anchor.href;
328
- contextAnchor.currentRel = anchor.rel.split(" ");
329
- },
330
-
331
- updateAnchor: function (anchor, url, displayText, contextAnchor, notText) {
332
- // download
333
- if (!this.plugins.anchor.selfPathBookmark.call(this, url) && contextAnchor.downloadCheck.checked) {
334
- anchor.setAttribute('download', displayText || url);
335
- } else {
336
- anchor.removeAttribute('download');
337
- }
338
-
339
- // new window
340
- if (contextAnchor.newWindowCheck.checked) anchor.target = '_blank';
341
- else anchor.removeAttribute('target');
342
-
343
- // rel
344
- const rel = contextAnchor.currentRel.join(' ');
345
- if (!rel) anchor.removeAttribute('rel');
346
- else anchor.rel = rel;
347
-
348
- // set url
349
- anchor.href = url;
350
- if (notText) {
351
- if (anchor.children.length === 0) anchor.textContent = '';
352
- } else {
353
- anchor.textContent = displayText;
354
- }
355
- },
356
-
357
- createAnchor: function (contextAnchor, notText) {
358
- if (contextAnchor.linkValue.length === 0) return null;
359
-
360
- const url = contextAnchor.linkValue;
361
- const anchor = contextAnchor.anchorText;
362
- const displayText = anchor.value.length === 0 ? url : anchor.value;
363
-
364
- const oA = contextAnchor.linkAnchor || this.util.createElement('A');
365
- this.plugins.anchor.updateAnchor.call(this, oA, url, displayText, contextAnchor, notText);
366
-
367
- contextAnchor.linkValue = contextAnchor.preview.textContent = contextAnchor.urlInput.value = contextAnchor.anchorText.value = '';
368
-
369
- return oA;
370
- },
371
-
372
- onClick_bookmarkButton: function (contextAnchor) {
373
- let url = contextAnchor.urlInput.value;
374
- if (this.plugins.anchor.selfPathBookmark.call(this, url)) {
375
- url = url.substr(1);
376
- contextAnchor.bookmark.style.display = 'none';
377
- this.util.removeClass(contextAnchor.bookmarkButton, 'active');
378
- this.plugins.selectMenu.close.call(this, this.context.selectMenu.callerContext);
379
- } else {
380
- url = '#' + url;
381
- contextAnchor.bookmark.style.display = 'block';
382
- this.util.addClass(contextAnchor.bookmarkButton, 'active');
383
- contextAnchor.downloadCheck.checked = false;
384
- contextAnchor.download.style.display = 'none';
385
- this.plugins.anchor.createHeaderList.call(this, contextAnchor, this.context.selectMenu.callerContext, url);
386
- }
387
-
388
- contextAnchor.urlInput.value = url;
389
- this.plugins.anchor.setLinkPreview.call(this, contextAnchor, url);
390
- contextAnchor.urlInput.focus();
391
- },
392
-
393
- onChange_newWindowCheck: function (contextAnchor, e) {
394
- if (typeof contextAnchor.linkDefaultRel.check_new_window !== 'string') return;
395
- if (e.target.checked) {
396
- this.plugins.anchor.setRel.call(this, contextAnchor, this.plugins.anchor._relMerge.call(this, contextAnchor, contextAnchor.linkDefaultRel.check_new_window));
397
- } else {
398
- this.plugins.anchor.setRel.call(this, contextAnchor, this.plugins.anchor._relDelete.call(this, contextAnchor, contextAnchor.linkDefaultRel.check_new_window));
399
- }
400
- },
401
-
402
- onChange_downloadCheck: function (contextAnchor, e) {
403
- if (e.target.checked) {
404
- contextAnchor.download.style.display = 'block';
405
- contextAnchor.bookmark.style.display = 'none';
406
- this.util.removeClass(contextAnchor.bookmarkButton, 'active');
407
- contextAnchor.linkValue = contextAnchor.preview.textContent = contextAnchor.urlInput.value = contextAnchor.urlInput.value.replace(/^\#+/, '');
408
- if (typeof contextAnchor.linkDefaultRel.check_bookmark === 'string') {
409
- this.plugins.anchor.setRel.call(this, contextAnchor, this.plugins.anchor._relMerge.call(this, contextAnchor, contextAnchor.linkDefaultRel.check_bookmark));
410
- }
411
- } else {
412
- contextAnchor.download.style.display = 'none';
413
- if (typeof contextAnchor.linkDefaultRel.check_bookmark === 'string') {
414
- this.plugins.anchor.setRel.call(this, contextAnchor, this.plugins.anchor._relDelete.call(this, contextAnchor, contextAnchor.linkDefaultRel.check_bookmark));
415
- }
416
- }
417
- },
418
-
419
- _relMerge: function (contextAnchor, relAttr) {
420
- const current = contextAnchor.currentRel;
421
- if (!relAttr) return current.join(' ');
422
-
423
- if (/^only\:/.test(relAttr)) {
424
- relAttr = relAttr.replace(/^only\:/, '').trim();
425
- contextAnchor.currentRel = relAttr.split(' ');
426
- return relAttr;
427
- }
428
-
429
- const rels = relAttr.split(' ');
430
- for (let i = 0, len = rels.length, index; i < len; i++) {
431
- index = current.indexOf(rels[i]);
432
- if (index === -1) current.push(rels[i]);
433
- }
434
-
435
- return current.join(' ');
436
- },
437
-
438
- _relDelete: function (contextAnchor, relAttr) {
439
- if (!relAttr) return contextAnchor.currentRel.join(' ');
440
- if (/^only\:/.test(relAttr)) relAttr = relAttr.replace(/^only\:/, '').trim();
441
-
442
- const rels = contextAnchor.currentRel.join(' ').replace(this._w.RegExp(relAttr + '\\s*'), '');
443
- contextAnchor.currentRel = rels.split(' ');
444
- return rels;
445
- },
446
-
447
- init: function (contextAnchor) {
448
- contextAnchor.linkAnchor = null;
449
- contextAnchor.linkValue = contextAnchor.preview.textContent = contextAnchor.urlInput.value = '';
450
- contextAnchor.anchorText.value = '';
451
- contextAnchor.newWindowCheck.checked = false;
452
- contextAnchor.downloadCheck.checked = false;
453
- contextAnchor._change = false;
454
- this.plugins.anchor.setRel.call(this, contextAnchor, contextAnchor.defaultRel);
455
- if (contextAnchor.relList) {
456
- this.plugins.anchor.toggleRelList.call(this, contextAnchor, false);
457
- }
458
- this.context.anchor.callerContext = null;
459
- this.plugins.selectMenu.init.call(this, this.context.selectMenu.callerContext);
460
- }
461
- };
@@ -1,60 +0,0 @@
1
- import SunEditor from '../../lib/core';
2
- import { Module } from '../Module';
3
-
4
- declare interface _colorPicker extends Module {
5
- /**
6
- * @description Create color list
7
- * @param core Core object
8
- * @param makeColor this._makeColorList
9
- * @returns HTML string
10
- */
11
- createColorList(core: SunEditor, makeColor: Function): string;
12
-
13
- /**
14
- * @description Displays or resets the currently selected color at color list.
15
- * @param node Current Selected node
16
- * @param color Color value
17
- */
18
- init(node: Node, color: string): void;
19
-
20
- /**
21
- * @description Store color values
22
- * @param hexColorStr Hax color value
23
- */
24
- setCurrentColor(hexColorStr: string): void;
25
-
26
- /**
27
- * @description Set color at input element
28
- * @param hexColorStr Hax color value
29
- */
30
- setInputText(hexColorStr: string): void;
31
-
32
- /**
33
- * @description Gets color value at color property of node
34
- * @param node Selected node
35
- * @returns
36
- */
37
- getColorInNode(node: Node): string;
38
-
39
- /**
40
- * @description Function to check hex format color
41
- * @param str Color value
42
- */
43
- isHexColor(str: string): boolean;
44
-
45
- /**
46
- * @description Function to convert hex format to a rgb color
47
- * @param rgb RGB color format
48
- * @returns
49
- */
50
- rgb2hex(rgb: string): string;
51
-
52
- /**
53
- * @description Converts color values of other formats to hex color values and returns.
54
- * @param colorName Color value
55
- * @returns
56
- */
57
- colorName2hex(colorName: string): string;
58
- }
59
-
60
- export default _colorPicker;