suneditor 2.46.2 → 3.0.0-alpha.1

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 (290) 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 +174 -805
  6. package/dist/suneditor.min.css +1 -0
  7. package/dist/suneditor.min.js +1 -2
  8. package/package.json +96 -69
  9. package/src/assets/icons/_default.js +194 -0
  10. package/src/assets/suneditor-content.css +646 -0
  11. package/src/assets/suneditor.css +3378 -0
  12. package/src/core/base/eventHandlers/handler_toolbar.js +114 -0
  13. package/src/core/base/eventHandlers/handler_ww_clipboard.js +31 -0
  14. package/src/core/base/eventHandlers/handler_ww_dragDrop.js +69 -0
  15. package/src/core/base/eventHandlers/handler_ww_key_input.js +975 -0
  16. package/src/core/base/eventHandlers/handler_ww_mouse.js +118 -0
  17. package/src/core/base/eventManager.js +1115 -0
  18. package/src/core/base/events.js +320 -0
  19. package/src/core/base/history.js +301 -0
  20. package/src/core/class/char.js +146 -0
  21. package/src/core/class/component.js +627 -0
  22. package/src/core/class/format.js +3255 -0
  23. package/src/core/class/html.js +1621 -0
  24. package/src/core/class/menu.js +260 -0
  25. package/src/core/class/nodeTransform.js +379 -0
  26. package/src/core/class/notice.js +42 -0
  27. package/src/core/class/offset.js +578 -0
  28. package/src/core/class/selection.js +508 -0
  29. package/src/core/class/shortcuts.js +38 -0
  30. package/src/core/class/toolbar.js +440 -0
  31. package/src/core/class/viewer.js +646 -0
  32. package/src/core/editor.js +1593 -0
  33. package/src/core/section/actives.js +107 -0
  34. package/src/core/section/constructor.js +1237 -0
  35. package/src/core/section/context.js +97 -0
  36. package/src/editorInjector/_classes.js +22 -0
  37. package/src/editorInjector/_core.js +28 -0
  38. package/src/editorInjector/index.js +13 -0
  39. package/src/helper/converter.js +313 -0
  40. package/src/helper/domUtils.js +1177 -0
  41. package/src/helper/env.js +250 -0
  42. package/src/helper/index.js +19 -0
  43. package/src/helper/numbers.js +68 -0
  44. package/src/helper/unicode.js +43 -0
  45. package/src/langs/ckb.js +161 -0
  46. package/src/langs/cs.js +161 -0
  47. package/src/langs/da.js +161 -0
  48. package/src/langs/de.js +162 -0
  49. package/src/langs/en.js +199 -0
  50. package/src/langs/es.js +162 -0
  51. package/src/langs/fa.js +159 -0
  52. package/src/langs/fr.js +161 -0
  53. package/src/langs/he.js +162 -0
  54. package/src/{lang → langs}/index.js +0 -2
  55. package/src/langs/it.js +162 -0
  56. package/src/langs/ja.js +162 -0
  57. package/src/langs/ko.js +162 -0
  58. package/src/langs/lv.js +162 -0
  59. package/src/langs/nl.js +162 -0
  60. package/src/langs/pl.js +162 -0
  61. package/src/langs/pt_br.js +162 -0
  62. package/src/langs/ro.js +162 -0
  63. package/src/langs/ru.js +162 -0
  64. package/src/langs/se.js +162 -0
  65. package/src/langs/tr.js +159 -0
  66. package/src/langs/ua.js +162 -0
  67. package/src/langs/ur.js +162 -0
  68. package/src/langs/zh_cn.js +162 -0
  69. package/src/modules/ApiManager.js +168 -0
  70. package/src/modules/ColorPicker.js +302 -0
  71. package/src/modules/Controller.js +315 -0
  72. package/src/modules/Figure.js +1160 -0
  73. package/src/modules/FileBrowser.js +271 -0
  74. package/src/modules/FileManager.js +290 -0
  75. package/src/modules/HueSlider.js +513 -0
  76. package/src/modules/Modal.js +177 -0
  77. package/src/modules/ModalAnchorEditor.js +494 -0
  78. package/src/modules/SelectMenu.js +447 -0
  79. package/src/modules/_DragHandle.js +16 -0
  80. package/src/modules/index.js +14 -0
  81. package/src/plugins/command/blockquote.js +47 -47
  82. package/src/plugins/command/exportPdf.js +168 -0
  83. package/src/plugins/command/fileUpload.js +389 -0
  84. package/src/plugins/command/list_bulleted.js +112 -0
  85. package/src/plugins/command/list_numbered.js +115 -0
  86. package/src/plugins/dropdown/align.js +143 -0
  87. package/src/plugins/dropdown/backgroundColor.js +73 -0
  88. package/src/plugins/dropdown/font.js +113 -0
  89. package/src/plugins/dropdown/fontColor.js +73 -0
  90. package/src/plugins/dropdown/formatBlock.js +141 -0
  91. package/src/plugins/dropdown/hr.js +111 -0
  92. package/src/plugins/dropdown/layout.js +72 -0
  93. package/src/plugins/dropdown/lineHeight.js +114 -0
  94. package/src/plugins/dropdown/list.js +107 -0
  95. package/src/plugins/dropdown/paragraphStyle.js +117 -0
  96. package/src/plugins/dropdown/table.js +2810 -0
  97. package/src/plugins/dropdown/template.js +71 -0
  98. package/src/plugins/dropdown/textStyle.js +137 -0
  99. package/src/plugins/field/mention.js +172 -0
  100. package/src/plugins/fileBrowser/imageGallery.js +76 -59
  101. package/src/plugins/index.js +86 -24
  102. package/src/plugins/input/fontSize.js +357 -0
  103. package/src/plugins/modal/audio.js +510 -0
  104. package/src/plugins/modal/image.js +1062 -0
  105. package/src/plugins/modal/link.js +211 -0
  106. package/src/plugins/modal/math.js +347 -0
  107. package/src/plugins/modal/video.js +870 -0
  108. package/src/suneditor.js +62 -67
  109. package/src/themes/test.css +61 -0
  110. package/typings/CommandPlugin.d.ts +8 -0
  111. package/typings/DialogPlugin.d.ts +20 -0
  112. package/typings/FileBrowserPlugin.d.ts +30 -0
  113. package/typings/Lang.d.ts +124 -0
  114. package/typings/Module.d.ts +15 -0
  115. package/typings/Plugin.d.ts +42 -0
  116. package/typings/SubmenuPlugin.d.ts +8 -0
  117. package/typings/_classes.d.ts +17 -0
  118. package/typings/_colorPicker.d.ts +60 -0
  119. package/typings/_core.d.ts +55 -0
  120. package/typings/align.d.ts +5 -0
  121. package/{src/plugins/dialog → typings}/audio.d.ts +1 -1
  122. package/typings/backgroundColor.d.ts +5 -0
  123. package/{src/plugins/command → typings}/blockquote.d.ts +1 -1
  124. package/typings/char.d.ts +39 -0
  125. package/typings/component.d.ts +38 -0
  126. package/typings/context.d.ts +39 -0
  127. package/typings/converter.d.ts +33 -0
  128. package/typings/dialog.d.ts +28 -0
  129. package/typings/domUtils.d.ts +361 -0
  130. package/typings/editor.d.ts +7 -0
  131. package/typings/editor.ts +542 -0
  132. package/typings/env.d.ts +70 -0
  133. package/typings/eventManager.d.ts +37 -0
  134. package/typings/events.d.ts +262 -0
  135. package/typings/fileBrowser.d.ts +42 -0
  136. package/typings/fileManager.d.ts +67 -0
  137. package/typings/font.d.ts +5 -0
  138. package/typings/fontColor.d.ts +5 -0
  139. package/typings/fontSize.d.ts +5 -0
  140. package/typings/format.d.ts +191 -0
  141. package/typings/formatBlock.d.ts +5 -0
  142. package/typings/history.d.ts +48 -0
  143. package/typings/horizontalRule.d.ts +5 -0
  144. package/{src/plugins/dialog → typings}/image.d.ts +1 -1
  145. package/{src/plugins/fileBrowser → typings}/imageGallery.d.ts +1 -1
  146. package/typings/index.d.ts +21 -0
  147. package/{src/plugins/modules/index.d.ts → typings/index.modules.d.ts} +3 -3
  148. package/typings/index.plugins.d.ts +58 -0
  149. package/typings/lineHeight.d.ts +5 -0
  150. package/{src/plugins/dialog → typings}/link.d.ts +1 -1
  151. package/typings/list.d.ts +5 -0
  152. package/{src/plugins/dialog → typings}/math.d.ts +1 -1
  153. package/typings/mediaContainer.d.ts +25 -0
  154. package/typings/node.d.ts +57 -0
  155. package/typings/notice.d.ts +16 -0
  156. package/typings/numbers.d.ts +29 -0
  157. package/typings/offset.d.ts +24 -0
  158. package/typings/options.d.ts +589 -0
  159. package/typings/paragraphStyle.d.ts +5 -0
  160. package/typings/resizing.d.ts +141 -0
  161. package/typings/selection.d.ts +94 -0
  162. package/typings/shortcuts.d.ts +13 -0
  163. package/typings/suneditor.d.ts +9 -0
  164. package/typings/table.d.ts +5 -0
  165. package/typings/template.d.ts +5 -0
  166. package/typings/textStyle.d.ts +5 -0
  167. package/typings/toolbar.d.ts +32 -0
  168. package/typings/unicode.d.ts +25 -0
  169. package/{src/plugins/dialog → typings}/video.d.ts +1 -1
  170. package/dist/css/suneditor.min.css +0 -1
  171. package/src/assets/css/suneditor-contents.css +0 -562
  172. package/src/assets/css/suneditor.css +0 -566
  173. package/src/assets/defaultIcons.js +0 -103
  174. package/src/lang/Lang.d.ts +0 -144
  175. package/src/lang/ckb.d.ts +0 -5
  176. package/src/lang/ckb.js +0 -188
  177. package/src/lang/cs.d.ts +0 -5
  178. package/src/lang/cs.js +0 -188
  179. package/src/lang/da.d.ts +0 -5
  180. package/src/lang/da.js +0 -191
  181. package/src/lang/de.d.ts +0 -5
  182. package/src/lang/de.js +0 -188
  183. package/src/lang/en.d.ts +0 -5
  184. package/src/lang/en.js +0 -188
  185. package/src/lang/es.d.ts +0 -5
  186. package/src/lang/es.js +0 -188
  187. package/src/lang/fa.d.ts +0 -5
  188. package/src/lang/fa.js +0 -188
  189. package/src/lang/fr.d.ts +0 -5
  190. package/src/lang/fr.js +0 -188
  191. package/src/lang/he.d.ts +0 -5
  192. package/src/lang/he.js +0 -188
  193. package/src/lang/index.d.ts +0 -23
  194. package/src/lang/it.d.ts +0 -5
  195. package/src/lang/it.js +0 -188
  196. package/src/lang/ja.d.ts +0 -5
  197. package/src/lang/ja.js +0 -188
  198. package/src/lang/ko.d.ts +0 -5
  199. package/src/lang/ko.js +0 -188
  200. package/src/lang/lv.d.ts +0 -5
  201. package/src/lang/lv.js +0 -188
  202. package/src/lang/nl.d.ts +0 -5
  203. package/src/lang/nl.js +0 -188
  204. package/src/lang/pl.d.ts +0 -5
  205. package/src/lang/pl.js +0 -188
  206. package/src/lang/pt_br.d.ts +0 -5
  207. package/src/lang/pt_br.js +0 -189
  208. package/src/lang/ro.d.ts +0 -5
  209. package/src/lang/ro.js +0 -188
  210. package/src/lang/ru.d.ts +0 -5
  211. package/src/lang/ru.js +0 -188
  212. package/src/lang/se.d.ts +0 -5
  213. package/src/lang/se.js +0 -191
  214. package/src/lang/tr.d.ts +0 -5
  215. package/src/lang/tr.js +0 -191
  216. package/src/lang/ua.d.ts +0 -5
  217. package/src/lang/ua.js +0 -188
  218. package/src/lang/ur.d.ts +0 -5
  219. package/src/lang/ur.js +0 -188
  220. package/src/lang/zh_cn.d.ts +0 -5
  221. package/src/lang/zh_cn.js +0 -187
  222. package/src/lib/constructor.js +0 -954
  223. package/src/lib/context.d.ts +0 -42
  224. package/src/lib/context.js +0 -71
  225. package/src/lib/core.d.ts +0 -1135
  226. package/src/lib/core.js +0 -9395
  227. package/src/lib/history.d.ts +0 -48
  228. package/src/lib/history.js +0 -219
  229. package/src/lib/util.d.ts +0 -678
  230. package/src/lib/util.js +0 -2131
  231. package/src/options.d.ts +0 -608
  232. package/src/plugins/CommandPlugin.d.ts +0 -8
  233. package/src/plugins/DialogPlugin.d.ts +0 -20
  234. package/src/plugins/FileBrowserPlugin.d.ts +0 -30
  235. package/src/plugins/Module.d.ts +0 -15
  236. package/src/plugins/Plugin.d.ts +0 -42
  237. package/src/plugins/SubmenuPlugin.d.ts +0 -8
  238. package/src/plugins/dialog/audio.js +0 -559
  239. package/src/plugins/dialog/image.js +0 -1126
  240. package/src/plugins/dialog/link.js +0 -223
  241. package/src/plugins/dialog/math.js +0 -295
  242. package/src/plugins/dialog/mention.js +0 -242
  243. package/src/plugins/dialog/video.js +0 -979
  244. package/src/plugins/index.d.ts +0 -79
  245. package/src/plugins/modules/_anchor.js +0 -461
  246. package/src/plugins/modules/_colorPicker.d.ts +0 -60
  247. package/src/plugins/modules/_colorPicker.js +0 -201
  248. package/src/plugins/modules/_notice.d.ts +0 -21
  249. package/src/plugins/modules/_notice.js +0 -72
  250. package/src/plugins/modules/_selectMenu.js +0 -119
  251. package/src/plugins/modules/component.d.ts +0 -25
  252. package/src/plugins/modules/component.js +0 -81
  253. package/src/plugins/modules/dialog.d.ts +0 -28
  254. package/src/plugins/modules/dialog.js +0 -175
  255. package/src/plugins/modules/fileBrowser.d.ts +0 -42
  256. package/src/plugins/modules/fileBrowser.js +0 -374
  257. package/src/plugins/modules/fileManager.d.ts +0 -67
  258. package/src/plugins/modules/fileManager.js +0 -326
  259. package/src/plugins/modules/index.js +0 -9
  260. package/src/plugins/modules/resizing.d.ts +0 -154
  261. package/src/plugins/modules/resizing.js +0 -903
  262. package/src/plugins/submenu/align.d.ts +0 -5
  263. package/src/plugins/submenu/align.js +0 -160
  264. package/src/plugins/submenu/font.d.ts +0 -5
  265. package/src/plugins/submenu/font.js +0 -123
  266. package/src/plugins/submenu/fontColor.d.ts +0 -5
  267. package/src/plugins/submenu/fontColor.js +0 -101
  268. package/src/plugins/submenu/fontSize.d.ts +0 -5
  269. package/src/plugins/submenu/fontSize.js +0 -112
  270. package/src/plugins/submenu/formatBlock.d.ts +0 -5
  271. package/src/plugins/submenu/formatBlock.js +0 -273
  272. package/src/plugins/submenu/hiliteColor.d.ts +0 -5
  273. package/src/plugins/submenu/hiliteColor.js +0 -102
  274. package/src/plugins/submenu/horizontalRule.d.ts +0 -5
  275. package/src/plugins/submenu/horizontalRule.js +0 -98
  276. package/src/plugins/submenu/lineHeight.d.ts +0 -5
  277. package/src/plugins/submenu/lineHeight.js +0 -104
  278. package/src/plugins/submenu/list.d.ts +0 -5
  279. package/src/plugins/submenu/list.js +0 -456
  280. package/src/plugins/submenu/paragraphStyle.d.ts +0 -5
  281. package/src/plugins/submenu/paragraphStyle.js +0 -135
  282. package/src/plugins/submenu/table.d.ts +0 -5
  283. package/src/plugins/submenu/table.js +0 -1431
  284. package/src/plugins/submenu/template.d.ts +0 -5
  285. package/src/plugins/submenu/template.js +0 -72
  286. package/src/plugins/submenu/textStyle.d.ts +0 -5
  287. package/src/plugins/submenu/textStyle.js +0 -167
  288. package/src/suneditor.d.ts +0 -9
  289. package/src/suneditor_build.js +0 -18
  290. /package/{src/plugins/dialog → typings}/mention.d.ts +0 -0
package/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # SunEditor
2
- Vanilla javascript based WYSIWYG web editor, with no dependencies.
3
- SunEditor supports IE11 and all modern browsers with no dependencies and polyfill.
4
- Coded based on ES5 in supported by IE11.
2
+ Vanilla javscript based WYSIWYG web editor.
3
+ SunEditor supports all modern browsers except IE without any dependencies and polyfills.
5
4
 
6
- #### Demo : <a href="http://suneditor.com" target="_blank">suneditor.com</a>
5
+ #### 🌤 Demo : <a href="http://suneditor.com" target="_blank">suneditor.com</a> 🌤
6
+
7
+ ⭐ If you would like to contribute, please refer to [guidelines](/CONTRIBUTING.md) and a list of [open tasks](https://github.com/jihong88/suneditor/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22).⭐
7
8
 
8
9
  [![GitHub](https://img.shields.io/github/license/jihong88/suneditor.svg?style=flat-square)](https://github.com/JiHong88/SunEditor/blob/master/LICENSE.txt)
9
10
  [![GitHub release](https://img.shields.io/github/release/jihong88/suneditor.svg?style=flat-square)](https://github.com/JiHong88/SunEditor/releases)
10
11
  [![npm version](https://img.shields.io/npm/v/suneditor.svg?style=flat-square)](https://www.npmjs.com/package/suneditor)
11
- [![bower version](https://img.shields.io/bower/v/suneditor.svg?style=flat-square)](https://github.com/JiHong88/SunEditor/releases/latest)
12
12
  [![](https://data.jsdelivr.com/v1/package/npm/suneditor/badge)](https://www.jsdelivr.com/package/npm/suneditor)
13
13
  [![npm](https://img.shields.io/npm/dt/suneditor.svg?style=flat-square)](https://www.npmjs.com/package/suneditor)
14
14
  ![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/suneditor.svg?style=flat-square)
@@ -22,7 +22,7 @@ Coded based on ES5 in supported by IE11.
22
22
 
23
23
  ![WYSIWYG HTML Editor](http://suneditor.com/docs/screen-main-w.png?v=2700)
24
24
 
25
- ## Table of contents
25
+ ## Table of content
26
26
  - [Browser Support](#browser-support)
27
27
  - [Install](#install)
28
28
  - [Getting Started](#getting-started)
@@ -30,7 +30,6 @@ Coded based on ES5 in supported by IE11.
30
30
  - [Use import statement](#use-import-statement)
31
31
  - [Load only what you want](#1-load-only-what-you-want)
32
32
  - [Load all plugins](#2-load-all-plugins)
33
- - [Plugins can be used directly in the button list](#3-plugins-can-be-used-directly-in-the-button-list)
34
33
  - [Init function](#init-function)
35
34
  - [Use CodeMirror](#use-codemirror)
36
35
  - [Use KaTeX (math plugin)](#use-katex-math-plugin)
@@ -54,25 +53,21 @@ Coded based on ES5 in supported by IE11.
54
53
 
55
54
  | <img src="http://suneditor.com/docs/chrome-64.png" alt="Chrome" width="16px" height="16px" /> Chrome | <img src="http://suneditor.com/docs/mozilla-64.png" alt="Firefox" width="16px" height="16px" /> Firefox | <img src="http://suneditor.com/docs/opera-64.png" alt="Opera" width="16px" height="16px" /> Opera | <img src="http://suneditor.com/docs/safari-64.png" alt="Safari" width="16px" height="16px" /> Safari | <img src="http://suneditor.com/docs/edge-64.png" alt="Edge" width="16px" height="16px" /> Edge | <img src="http://suneditor.com/docs/explorer-64.png" alt="Explorer" width="16px" height="16px" /> Internet Explorer |
56
55
  |:---:|:---:|:---:|:---:|:---:|:---:|
57
- | Yes | Yes | Yes | Yes | Yes | 11+ |
56
+ | Yes | Yes | Yes | Yes | Yes | 11 |
58
57
 
59
58
  ## Install
60
59
  #### Npm
61
60
  ``` sh
62
61
  $ npm install suneditor --save
63
62
  ```
64
- #### Bower
65
- ``` sh
66
- $ bower install suneditor --save
67
- ```
68
63
  #### CDN
69
64
  ``` html
70
65
  <link href="https://cdn.jsdelivr.net/npm/suneditor@latest/dist/css/suneditor.min.css" rel="stylesheet">
71
- <!-- <link href="https://cdn.jsdelivr.net/npm/suneditor@latest/assets/css/suneditor.css" rel="stylesheet"> -->
72
- <!-- <link href="https://cdn.jsdelivr.net/npm/suneditor@latest/assets/css/suneditor-contents.css" rel="stylesheet"> -->
66
+ <!-- <link href="https://cdn.jsdelivr.net/npm/suneditor@latest/assets/suneditor.css" rel="stylesheet"> -->
67
+ <!-- <link href="https://cdn.jsdelivr.net/npm/suneditor@latest/assets/suneditor-content.css" rel="stylesheet"> -->
73
68
  <script src="https://cdn.jsdelivr.net/npm/suneditor@latest/dist/suneditor.min.js"></script>
74
69
  <!-- languages (Basic Language: English/en) -->
75
- <script src="https://cdn.jsdelivr.net/npm/suneditor@latest/src/lang/ko.js"></script>
70
+ <script src="https://cdn.jsdelivr.net/npm/suneditor@latest/src/langs/ko.js"></script>
76
71
  ```
77
72
  [jsdelivr/suneditor](https://www.jsdelivr.com/package/npm/suneditor)
78
73
 
@@ -97,19 +92,19 @@ const editor = SUNEDITOR.create((document.getElementById('sample') || 'sample'),
97
92
  });
98
93
  ```
99
94
 
100
- ### 3. Contents display
95
+ ### 3. Content display
101
96
  ```java
102
97
  When you display a document created by suneditor
103
- You need to include "src/assets/css/suneditor-contents.css" or "dist/css/suneditor.min.css" file.
98
+ You need to include "src/assets/suneditor-content.css" or "dist/css/suneditor.min.css" file.
104
99
  Then add "sun-editor-editable" to the class name of the Tag element that displays the content.
105
100
  If you are using RTL mode, you also need to add "se-rtl".
106
- In "suneditor-contents.css", you can define the style of all the tags created in suneditor.
101
+ In "suneditor-content.css", you can define the style of all the tags created in suneditor.
107
102
  ```
108
103
 
109
104
  ## When inserting custom tags in the editor
110
105
  ```text
111
106
  - Empty tags without meaning or tags that do not fit the editor's format are modified or deleted.
112
- Tags with the class name "se-component" or "__se__tag" of the top-level tag will not be deleted.
107
+ Tags with the class name "se-component" or "__se__block" of the top-level tag will not be deleted.
113
108
  "se-component" is the component type of the editor.
114
109
  Class name for wrapper tags such as images and videos.
115
110
  ```
@@ -119,19 +114,19 @@ In "suneditor-contents.css", you can define the style of all the tags created in
119
114
  ### 1. Load only what you want
120
115
  ```javascript
121
116
  import 'suneditor/dist/css/suneditor.min.css'
122
- // import 'suneditor/assets/css/suneditor.css'
123
- // import 'suneditor/assets/css/suneditor-contents.css'
117
+ // import 'suneditor/assets/suneditor.css'
118
+ // import 'suneditor/assets/suneditor-content.css'
124
119
  import suneditor from 'suneditor'
125
120
 
126
121
  // How to import plugins
127
- import image from 'suneditor/src/plugins/dialog/link'
128
- import list from 'suneditor/src/plugins/submenu/list'
122
+ import image from 'suneditor/src/plugins/modal/link'
123
+ import list from 'suneditor/src/plugins/dropdown/list'
129
124
  import {font, video} from 'suneditor/src/plugins'
130
125
 
131
126
  // How to import language files (default: en)
132
- import lang from 'suneditor/src/lang'
133
- import {ko} from 'suneditor/src/lang'
134
- import de from 'suneditor/src/lang/de'
127
+ import lang from 'suneditor/src/langs'
128
+ import {ko} from 'suneditor/src/langs'
129
+ import de from 'suneditor/src/langs/de'
135
130
 
136
131
  suneditor.create('sample', {
137
132
  plugins: [font, video, image, list],
@@ -155,44 +150,19 @@ suneditor.create('sample', {
155
150
  ['font', 'fontSize', 'formatBlock'],
156
151
  ['paragraphStyle', 'blockquote'],
157
152
  ['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
158
- ['fontColor', 'hiliteColor', 'textStyle'],
153
+ ['fontColor', 'backgroundColor', 'textStyle'],
159
154
  ['removeFormat'],
160
155
  '/', // Line break
161
156
  ['outdent', 'indent'],
162
- ['align', 'horizontalRule', 'list', 'lineHeight'],
157
+ ['align', 'horizontalLine', 'list', 'lineHeight'],
163
158
  ['table', 'link', 'image', 'video', 'audio' /** ,'math' */], // You must add the 'katex' library at options to use the 'math' plugin.
164
159
  /** ['imageGallery'] */ // You must add the "imageGalleryUrl".
165
160
  ['fullScreen', 'showBlocks', 'codeView'],
166
161
  ['preview', 'print'],
167
- ['save', 'template'],
162
+ ['save', 'template', 'layout'],
168
163
  /** ['dir', 'dir_ltr', 'dir_rtl'] */ // "dir": Toggle text direction, "dir_ltr": Right to Left, "dir_rtl": Left to Right
169
164
  ]
170
165
  })
171
-
172
- // You can also load what you want
173
- suneditor.create('sample', {
174
- plugins: [plugins.font],
175
- // Plugins can be used directly in the button list
176
- buttonList: [
177
- ['font', plugins.image]
178
- ]
179
- })
180
- ```
181
-
182
- ### 3. Plugins can be used directly in the button list
183
- ```javascript
184
- import 'suneditor/dist/css/suneditor.min.css'
185
- import suneditor from 'suneditor'
186
- import {align, font, fontSize, fontColor, hiliteColor,
187
- horizontalRule, image, template} from 'suneditor/src/plugins'
188
-
189
- suneditor.create('sample', {
190
- buttonList: [
191
- ['undo', 'redo', 'removeFormat'],
192
- [align, font, fontSize, fontColor, hiliteColor],
193
- [horizontalRule, image, template]
194
- ],
195
- })
196
166
  ```
197
167
 
198
168
  ## Init function
@@ -215,14 +185,14 @@ const initEditor = suneditor.init({
215
185
  'font', 'fontSize', 'formatBlock',
216
186
  'paragraphStyle', 'blockquote',
217
187
  'bold', 'underline', 'italic', 'strike', 'subscript', 'superscript',
218
- 'fontColor', 'hiliteColor', 'textStyle',
188
+ 'fontColor', 'backgroundColor', 'textStyle',
219
189
  'removeFormat',
220
190
  'outdent', 'indent',
221
- 'align', 'horizontalRule', 'list', 'lineHeight',
191
+ 'align', 'horizontalLine', 'list', 'lineHeight',
222
192
  'table', 'link', 'image', 'video', 'audio', /** 'math', */ // You must add the 'katex' library at options to use the 'math' plugin.
223
193
  /** 'imageGallery', */ // You must add the "imageGalleryUrl".
224
194
  'fullScreen', 'showBlocks', 'codeView',
225
- 'preview', 'print', 'save', 'template',
195
+ 'preview', 'print', 'save', 'template', 'layout',
226
196
  /** 'dir', 'dir_ltr', 'dir_rtl' */ // "dir": Toggle text direction, "dir_ltr": Right to Left, "dir_rtl": Left to Right
227
197
  ]
228
198
  ]
@@ -340,10 +310,10 @@ let editor = suneditor.create('sample', {
340
310
  })
341
311
 
342
312
  // if you would like to have this triggered when pressing @
343
- editor.core.callPlugin('mention');
313
+ editor.core.registerPlugin('mention');
344
314
  editor.onKeyDown = e => {
345
315
  if (e.key === '@') {
346
- editor.core.context.mention.open();
316
+ editor.core.mention.open();
347
317
  e.preventDefault();
348
318
  e.stopPropagation();
349
319
  }
@@ -359,21 +329,21 @@ let newMentions = editor.core.getMentions();
359
329
  plugins: [
360
330
  /** command */
361
331
  blockquote,
362
- /** Submenu */
332
+ /** Dropdown */
363
333
  align,
364
334
  font,
365
335
  fontColor,
366
336
  fontSize,
367
337
  formatBlock,
368
- hiliteColor,
369
- horizontalRule,
338
+ backgroundColor,
339
+ horizontalLine,
370
340
  lineHeight,
371
341
  list,
372
342
  paragraphStyle,
373
343
  table,
374
344
  template,
375
345
  textStyle,
376
- /** Dialog */
346
+ /** Modal */
377
347
  image,
378
348
  link,
379
349
  video,
@@ -393,89 +363,88 @@ plugins: [
393
363
  // Values
394
364
  strictMode : Option to disable clean mode, which checks the styles, classes, etc. of the editor content. default : false {Boolean}
395
365
  lang : language object. default : en {Object}
396
- defaultTag : Specifies default tag name of the editor. default: 'p' {String}
397
- textTags : You can change the tag of the default text button. default: { bold: 'STRONG', underline: 'U', italic: 'EM', strike: 'DEL' }
366
+ defaultLine : Specifies default tag name of the editor. default: 'p' {string}
367
+ convertTextTags : You can change the tag of the default text button. default: { bold: 'STRONG', underline: 'U', italic: 'EM', strike: 'DEL' }
398
368
  ex) {
399
369
  bold: 'b',
400
370
  strike: 's'
401
371
  }
402
372
  value : Initial value(html string) of the edit area.
403
- If not, the value of the "target textarea". default: null {String}
404
- allowedClassNames : Specifies the allowed class name, It can be specified in the form of a regular expression.
405
- Appended before the "default" value. (`${option}|${defaultValue}`) default: '^se-|__se__|katex';
406
- historyStackDelayTime : When recording the history stack, this is the delay time(miliseconds) since the last input. default: 400 {Number}
407
- frameAttrbutes : Specifies the properties of the editing area DIV. default: {} {Object}
373
+ If not, the value of the "target textarea". default: null {string}
374
+ historyStackDelayTime : When recording the history stack, this is the delay time(miliseconds) since the last input. default: 400 {number}
375
+ editableFrameAttributes : Specifies the properties of the editing area DIV. default: {} {Object}
408
376
  ex) {
409
377
  "spellcheck": false
410
378
  }
379
+ allowedClassNames : Specifies the allowed class name, It can be specified in the form of a regular expression.
380
+ Appended before the "default" value. (`${option}|${defaultValue}`) default: '^se-|__se__|katex';
411
381
 
412
382
  // Whitelist, Blacklist -----------------------------------------------------------------------------------------
413
383
  // (You can use regular expression syntax.)
414
- // _defaultTagsWhitelist : 'br|p|div|pre|blockquote|h1|h2|h3|h4|h5|h6|ol|ul|li|hr|figure|figcaption|img|iframe|audio|video|table|thead|tbody|tr|th|td|a|b|strong|var|i|em|u|ins|s|span|strike|del|sub|sup|code|svg|path|details|summary'
415
- addTagsWhitelist : Add tags to the default tags whitelist of editor. default: '' {String}
384
+ // __defaultElementWhitelist : 'br|p|div|pre|blockquote|h1|h2|h3|h4|h5|h6|ol|ul|li|hr|figure|figcaption|img|iframe|audio|video|table|thead|tbody|tr|th|td|a|b|strong|var|i|em|u|ins|s|span|strike|del|sub|sup|code|svg|path|details|summary'
385
+ elementWhitelist : Add tags to the default tags whitelist of editor. default: '' {string}
416
386
  ex) 'mark|canvas|label|select|option|input|//' // "//" This means HTML comments.
417
387
  ex) '*' // This means all tags are allowed. (Not available on "blacklist")
418
- tagsBlacklist : Blacklist of the editor default tags. default: null {String}
388
+ elementBlacklist : Blacklist of the editor default tags. default: null {string}
419
389
  ex) 'h1|h2'
420
- // _editorTagsWhitelist : _defaultTagsWhitelist + addTagsWhitelist - tagsBlacklist
421
- pasteTagsWhitelist : Whitelist of tags when pasting. default: _editorTagsWhitelist {String}
422
- ex) 'p|h1|h2|h3'
423
- ex) '*' // This means all tags are allowed. (Not available on "blacklist")
424
- pasteTagsBlacklist : Blacklist of tags when pasting. default: null {String}
425
- ex) 'h1|h2'
426
- attributesWhitelist : Add attributes whitelist of tags that should be kept undeleted from the editor. default: null {Object}
390
+ attributeWhitelist : Add attributes whitelist of tags that should be kept undeleted from the editor. default: null {Object}
427
391
  // -- Fixed whitelist --
428
392
  // Native attributes: 'contenteditable|colspan|rowspan|target|href|download|rel|src|alt|class|type|controls'
429
- // Editor attributes: 'data-format|data-size|data-file-size|data-file-name|data-origin|data-align|data-image-link|data-rotate|data-proportion|data-percentage|origin-size|data-exp|data-font-size'
393
+ // Editor attributes: 'data-se-*'
430
394
  ex) {
431
- 'all': 'style|data-.+', // Apply to all tags
395
+ '*': 'style|data-.+', // Apply to all tags
432
396
  'input': 'checked|name' // Apply to input tag
433
397
  '???': '*' // "*" === all attributes
434
398
  }
435
- attributesBlacklist : Add attribute blacklist of tags that should be deleted in editor. default: null {Object}
399
+ attributeBlacklist : Add attribute blacklist of tags that should be deleted in editor. default: null {Object}
436
400
  ex) {
437
- 'all': 'id', // Apply to all tags
401
+ '*': 'id', // Apply to all tags
438
402
  'input': 'style' // Apply to input tag
439
403
  '???': '*' // "*" === all attributes
440
404
  }
405
+ tagStyles : Add the allowable style items for each tag. default: {'table|td|th':'border|border-[a-z]+|background-color|text-align|float'}
406
+ ex) {
407
+ 'h1': 'id', // Apply to h1 tag
408
+ }
409
+ spanStyles : Add the span tag style
441
410
  // Layout-------------------------------------------------------------------------------------------------------
442
- mode : The mode of the editor ('classic', 'inline', 'balloon', 'balloon-always'). default: 'classic' {String}
411
+ mode : The mode of the editor ('classic', 'inline', 'balloon', 'balloon-always'). default: 'classic' {string}
443
412
  rtl : If true, the editor is set to RTL(Right To Left) mode. default: false {Boolean}
444
413
  lineAttrReset : Deletes other attributes except for the property set at the time of line break.
445
- If there is no value, no all attribute is deleted. default: '' {String}
414
+ If there is no value, no all attribute is deleted. default: '' {string}
446
415
  ex) 'class|style': Attributes other than "class" and "style" are deleted at line break.
447
416
  '*': All attributes are deleted at line break.
448
- toolbarWidth : The width of the toolbar. Applies only when the editor mode is
417
+ toolbar_width : The width of the toolbar. Applies only when the editor mode is
449
418
  'inline' or 'balloon' mode. default: 'auto' {Number|String}
450
- toolbarContainer: A custom HTML selector placing the toolbar inside.
419
+ toolbar_container: A custom HTML selector placing the toolbar inside.
451
420
  The class name of the element must be 'sun-editor'.
452
421
  Element or querySelector argument. default: null {Element|String}
453
422
  ex) document.querySelector('#id') || '#id'
454
- stickyToolbar : Top offset value of "sticky toolbar".
423
+ toolbar_sticky : Top offset value of "sticky toolbar".
455
424
  Set to 0, '0px', '50px'...
456
425
  If set to -1 or false or null to turn off. default: 0 {Number|String|Boolean}
457
- hideToolbar : The toolbar is rendered hidden. default: false {Boolean}
426
+ toolbar_hide : The toolbar is rendered hidden. default: false {Boolean}
458
427
  fullScreenOffset: Top offset value of "full Screen".
459
428
  Set to 0, '0px', '50px'... default: 0 {Number|String}
460
429
  iframe : Content will be placed in an iframe and isolated from the rest of the page. default: false {Boolean}
461
- fullPage : Allows the usage of HTML, HEAD, BODY tags and DOCTYPE declaration. default: false {Boolean}
462
- iframeAttributes : Attributes of the iframe. default: null {Object}
430
+ iframe_fullPage : Allows the usage of HTML, HEAD, BODY tags and DOCTYPE declaration. default: false {Boolean}
431
+ iframe_attributes : Attributes of the iframe. default: null {Object}
463
432
  ex) {'scrolling': 'no'}
464
- iframeCSSFileName : Name or Array of the CSS file to apply inside the iframe.
433
+ iframe_cssFileName : Name or Array of the CSS file to apply inside the iframe.
465
434
  You can also use regular expressions.
466
435
  Applied by searching by filename in the link tag of document,
467
436
  or put the URL value (".css" can be omitted). default: 'suneditor' {Array|String}
468
437
  ex) '.+' or ['suneditor', 'http://suneditor.com/sample/css/sample.css', '.+\\.min\\.css']
469
438
  previewTemplate : A template of the "preview".
470
- The {{contents}} part in the HTML string is replaced with the contents of the editor. default: null {String}
471
- ex) "<div style='width:auto; max-width:1080px; margin:auto;'><h1>Preview Template</h1> {{contents}} <div>_Footer_</div></div>"
439
+ The {content} part in the HTML string is replaced with the content of the editor. default: null {string}
440
+ ex) "<div style='width:auto; max-width:1080px; margin:auto;'><h1>Preview Template</h1> {content} <div>_Footer_</div></div>"
472
441
  printTemplate : A template of the "print".
473
- The {{contents}} part in the HTML string is replaced with the contents of the editor. default: null {String}
474
- ex) "<div style='width:auto; max-width:1080px; margin:auto;'><h1>Print Template</h1> {{contents}} <div>_Footer_</div></div>"
475
- codeMirror : If you put the CodeMirror object as an option, you can do Codeview using CodeMirror. default: null {Object}
442
+ The {content} part in the HTML string is replaced with the content of the editor. default: null {string}
443
+ ex) "<div style='width:auto; max-width:1080px; margin:auto;'><h1>Print Template</h1> {content} <div>_Footer_</div></div>"
444
+ codeMirror : https://codemirror.net/try/
445
+ codeMirror : If you put the CodeMirror object as an option, you can do Codeview using CodeMirror. default: null {Object}
476
446
  Use version 5.x.x // https://github.com/codemirror/CodeMirror
477
- ex) codeMirror: CodeMirror // Default option
478
- codeMirror: { // Custom option
447
+ codeMirror5: { // Custom option
479
448
  src: CodeMirror,
480
449
  options: {
481
450
  /** default options **
@@ -488,7 +457,6 @@ codeMirror : If you put the CodeMirror object as an option, you can do Code
488
457
  }
489
458
  katex : Required library for math plugins. default: null {Object}
490
459
  Use version 0.x.x // https://github.com/KaTeX/KaTeX
491
- ex) katex: katex // Default option
492
460
  katex: { // Custom option
493
461
  src: katex,
494
462
  options: {
@@ -505,31 +473,26 @@ mathFontSize : Math plugin font size list. default: [{.
505
473
  {text: '2.5', value: '2.5em'}
506
474
  ]
507
475
 
508
- // Display-------------------------------------------------------------------------------------------------------
509
- position : The position property of suneditor. default: null {String}
510
- display : The display property of suneditor. default: 'block' {String}
511
- popupDisplay : Size of background area when activating dialog window ('full'||'local') default: 'full' {String}
512
-
513
- // Bottom resizing bar-------------------------------------------------------------------------------------------
514
- resizingBar : Show the bottom resizing bar.
476
+ // Statusbar-------------------------------------------------------------------------------------------
477
+ statusbar : Show the bottom resizing bar.
515
478
  If 'height' value is 'auto', it will not be resized. default: true {Boolean}
516
- showPathLabel : Displays the current node structure to resizingBar. default: true {Boolean}
517
- resizeEnable : Enable/disable resize function of bottom resizing bar. default: true {Boolean}
518
- resizingBarContainer: A custom HTML selector placing the resizing bar inside.
479
+ statusbar_showPathLabel : Displays the current node structure to statusbar. default: true {Boolean}
480
+ statusbar_resizeEnable : Enable/disable resize function of bottom resizing bar. default: true {Boolean}
481
+ statusbar_container: A custom HTML selector placing the resizing bar inside.
519
482
  The class name of the element must be 'sun-editor'.
520
483
  Element or querySelector argument. default: null {Element|String}
521
484
  ex) document.querySelector('#id') || '#id'
522
485
 
523
486
  // Character count-----------------------------------------------------------------------------------------------
524
487
  charCounter : Shows the number of characters in the editor.
525
- If the maxCharCount option has a value, it becomes true. default: false {Boolean}
526
- charCounterType : Defines the calculation method of the "charCounter" option.
488
+ If the charCounter_max option has a value, it becomes true. default: false {boolean}
489
+ charCounter_type : Defines the calculation method of the "charCounter" option.
527
490
  'char': Characters length.
528
491
  'byte': Binary data size of characters.
529
- 'byte-html': Binary data size of the full HTML string. default: 'char' {String}
530
- charCounterLabel: Text to be displayed in the "charCounter" area of the bottom bar.
531
- Screen ex) 'charCounterLabel : 20/200'. default: null {String}
532
- maxCharCount : The maximum number of characters allowed to be inserted into the editor. default: null {Number}
492
+ 'byte-html': Binary data size of the full HTML string. default: 'char' {string}
493
+ charCounter_label: Text to be displayed in the "charCounter" area of the bottom bar.
494
+ Screen ex) 'charCounter_label : 20/200'. default: null {string}
495
+ charCounter_max : The maximum number of characters allowed to be inserted into the editor. default: null {number}
533
496
 
534
497
  // Width size----------------------------------------------------------------------------------------------------
535
498
  width : The width size of the editor. default: clientWidth||'100%' {Number|String}
@@ -546,10 +509,10 @@ maxHeight : The max-height size of the editor.
546
509
  Used when 'height' value is 'auto'. default: null {Number|String}
547
510
 
548
511
  // Editing area -------------------------------------------------------------------------------------------------
549
- className : Add a "class" to the editing area[.sun-editor-editable]. default: '' {String}
550
- defaultStyle : You can define the style of the editing area[.sun-editor-editable].
551
- It affects the entire editing area. default: '' {String}
552
- ('z-index', 'position' and 'width' properties apply to the top div.)
512
+ className : Add a "class" to the editing area[.sun-editor-editable]. default: '' {string}
513
+ editorStyle : You can define the style of the editing area[.sun-editor-editable].
514
+ It affects the entire editing area. default: '' {string}
515
+ ('z-index', 'position', 'display', 'width' properties apply to the top div.)
553
516
  ex) 'font-family: cursive; font-size: 10px;'
554
517
 
555
518
  // Defining menu items-------------------------------------------------------------------------------------------
@@ -562,21 +525,21 @@ fontSize : Change default font-size array. default: [..
562
525
  Default value: [
563
526
  8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72
564
527
  ]
565
- fontSizeUnit : The font size unit. default: 'px' {String}
528
+ fontSizeUnit : The font size unit. default: 'px' {string}
566
529
  alignItems : A list of drop-down options for the 'align' plugin. default: rtl === true ? ['right', 'center', 'left', 'justify'] : ['left', 'center', 'right', 'justify'] {Array}
567
530
  formats : Change default formatBlock array. default: [...] {Array}
568
531
  Default value: [
569
532
  'p', 'div', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'
570
- // "blockquote": range format, "pre": free format, "Other tags": replace format
533
+ // "blockquote": block, "pre": brBlock, "Other tags": line
571
534
  ],
572
535
  Custom: [{
573
536
  tag: 'div', // Tag name
574
537
  name: 'Custom div' || null, // default: tag name
575
- command: 'replace' || 'range' || 'free', // default: "replace"
576
- class: '__se__format__replace_xxx' || '__se__format__range_xxx' || '__se__format__free_xxx' || '__se__format__free__closure_xxx'
577
- // Class names must always begin with "__se__format__(replace, range, free)_"
538
+ command: 'line' || 'br-line' || 'block', // default: "replace"
539
+ class: '__se__format__line_xxx' || '__se__format__br_line_xxx' || '__se__format__block_xxx' || '__se__format__br_line_closure_xxx' || '__se__format__block_closure_xxx'
540
+ // Class names must always begin with "__se__format__(line, br_line, block)_"
578
541
  }]
579
- colorList : Change default color array of color picker. default: [..[..]..] {Array}
542
+ colorList_font, colorList_background : Change default color array of color picker. default: [..[..]..] {Array}
580
543
  Default value: [
581
544
  '#ff0000', '#ff5e00', '#ffe400', '#abf200', '#00d8ff', '#0055ff', '#6600ff', '#ff00dd', '#000000',
582
545
  '#ffd8d8', '#fae0d4', '#faf4c0', '#e4f7ba', '#d4f4fa', '#d9e5ff', '#e8d9ff', '#ffd9fa', '#f1f1f1',
@@ -625,7 +588,7 @@ paragraphStyles : You can apply custom class to format.
625
588
  class: '__se__customClass'
626
589
  }
627
590
  ]
628
- textStyles : You can apply custom style or class to selected text.
591
+ textStyles : You can apply custom class to selected text.
629
592
  ex(using a class)) '.sun-editor-editable .__se__customClass'
630
593
  '.sun-editor .__se__customClass' // If you want to apply styles to menu items as well
631
594
  Default value: [
@@ -634,42 +597,28 @@ textStyles : You can apply custom style or class to selected text.
634
597
  class: '__se__t-code',
635
598
  tag: 'code',
636
599
  },
637
- {
638
- name: 'Translucent', // Text style name
639
- style: 'opacity: 0.5;', // Style query
640
- tag: 'span', // Style tag name (default: span)
641
- _class: '' // You can control the style of the tags displayed in the menu by putting a class on the button of the menu.
642
- },
643
600
  {
644
601
  name: 'Shadow',
645
602
  class: '__se__t-shadow', // Class names (Class names must always begin with "__se__")
646
603
  tag: 'span'
647
604
  }
648
605
  ]
649
- ex) [
650
- 'Code', // The default value is called by name only and the name is called in the language file.
651
- {
652
- name: 'Emphasis',
653
- style: '-webkit-text-emphasis: filled;',
654
- tag: 'span'
655
- }
656
- ]
657
606
 
658
607
  // Image---------------------------------------------------------------------------------------------------------
659
608
  imageResizing : Can resize the image. default: true {Boolean}
660
609
  imageHeightShow : Choose whether the image height input is visible. default: true {Boolean}
661
610
  imageAlignShow : Choose whether the image align radio buttons are visible. default: true {Boolean}
662
- imageWidth : The default width size of the image frame. default: 'auto' {String}
663
- imageHeight : The default height size of the image frame. default: 'auto' {String}
611
+ imageWidth : The default width size of the image frame. default: 'auto' {string}
612
+ imageHeight : The default height size of the image frame. default: 'auto' {string}
664
613
  imageSizeOnlyPercentage : If true, image size can only be scaled by percentage. default: false {Boolean}
665
614
  imageRotation : Choose whether to image rotation buttons display.
666
615
  When "imageSizeOnlyPercentage" is "true" or or "imageHeightShow" is "false" the default value is false.
667
- If you want the button to be visible, put it a true. default: true {Boolean}
668
- imageFileInput : Choose whether to create a file input tag in the image upload window. default: true {Boolean}
616
+ If you want the button to be visible, put it a true. default: true {boolean}
617
+ imageFileInput : Choose whether to create a file input tag in the image upload window. default: true {boolean}
669
618
  imageUrlInput : Choose whether to create a image url input tag in the image upload window.
670
- If the value of imageFileInput is false, it will be unconditionally. default: true {Boolean}
619
+ If the value of imageFileInput is false, it will be unconditionally. default: true {boolean}
671
620
  imageUploadHeader : Http Header when uploading images. default: null {Object}
672
- imageUploadUrl : The image upload to server mapping address. default: null {String}
621
+ imageUploadUrl : The image upload to server mapping address. default: null {string}
673
622
  (When not used the "imageUploadUrl" option, image is enters base64 data)
674
623
  ex) "/editor/uploadImage"
675
624
  request format: {
@@ -687,14 +636,14 @@ imageUploadUrl : The image upload to server mapping address. default: nul
687
636
  ]
688
637
  }
689
638
  imageUploadSizeLimit: The size of the total uploadable images (in bytes).
690
- Invokes the "onImageUploadError" method. default: null {Number}
691
- imageMultipleFile: If true, multiple images can be selected. default: false {Boolean}
692
- imageAccept : Define the "accept" attribute of the input. default: "*" {String}
639
+ Invokes the "onImageUploadError" method. default: null {number}
640
+ imageMultipleFile: If true, multiple images can be selected. default: false {boolean}
641
+ imageAccept : Define the "accept" attribute of the input. default: "*" {string}
693
642
  ex) "*" or ".jpg, .png .."
694
643
  // Image - image gallery
695
644
  imageGalleryUrl : The url of the image gallery, if you use the image gallery.
696
645
  When "imageUrlInput" is true, an image gallery button is created in the image modal.
697
- You can also use it by adding "imageGallery" to the button list. default: null {String}
646
+ You can also use it by adding "imageGallery" to the button list. default: null {string}
698
647
  ex) "/editor/getGallery"
699
648
  response format: {
700
649
  "result": [
@@ -717,12 +666,12 @@ videoResizing : Can resize the video (iframe, video).
717
666
  videoHeightShow : Choose whether the video height input is visible. default: true {Boolean}
718
667
  videoAlignShow : Choose whether the video align radio buttons are visible. default: true {Boolean}
719
668
  videoRatioShow : Choose whether the video ratio options is visible. default: true {Boolean}
720
- videoWidth : The default width size of the video frame. default: '100%' {String}
721
- videoHeight : The default height size of the video frame. default: '56.25%' {String}
669
+ videoWidth : The default width size of the video frame. default: '100%' {string}
670
+ videoHeight : The default height size of the video frame. default: '56.25%' {string}
722
671
  videoSizeOnlyPercentage : If true, video size can only be scaled by percentage. default: false {Boolean}
723
672
  videoRotation : Choose whether to video rotation buttons display.
724
673
  When "videoSizeOnlyPercentage" is "true" or "videoHeightShow" is "false" the default value is false.
725
- If you want the button to be visible, put it a true. default: true {Boolean}
674
+ If you want the button to be visible, put it a true. default: true {boolean}
726
675
  videoRatio : The default aspect ratio of the video.
727
676
  Up to four decimal places are allowed. default: 0.5625 (16:9) {Float}
728
677
  videoRatioList : Video ratio selection options.
@@ -735,15 +684,15 @@ videoRatioList : Video ratio selection options.
735
684
  {name: 'Classic Film 3:2', value: 0.6666},
736
685
  {name: 'HD', value: 0.5625}
737
686
  ]
738
- youtubeQuery : The query string of a YouTube embedded URL. default: '' {String}
687
+ youtubeQuery : The query string of a YouTube embedded URL. default: '' {string}
739
688
  It takes precedence over the value user entered.
740
689
  ex) 'autoplay=1&mute=1&enablejsapi=1&controls=0&rel=0&modestbranding=1'
741
690
  // https://developers.google.com/youtube/player_parameters
742
- videoFileInput : Choose whether to create a file input tag in the video upload window. default: false {Boolean}
691
+ videoFileInput : Choose whether to create a file input tag in the video upload window. default: false {boolean}
743
692
  videoUrlInput : Choose whether to create a video url input tag in the video upload window.
744
- If the value of videoFileInput is false, it will be unconditionally. default: true {Boolean}
693
+ If the value of videoFileInput is false, it will be unconditionally. default: true {boolean}
745
694
  videoUploadHeader : Http Header when uploading videos. default: null {Object}
746
- videoUploadUrl : The video upload to server mapping address. default: null {String}
695
+ videoUploadUrl : The video upload to server mapping address. default: null {string}
747
696
  ex) "/editor/uploadVideo"
748
697
  request format: {
749
698
  "file-0": File,
@@ -761,23 +710,23 @@ videoUploadUrl : The video upload to server mapping address. default: nul
761
710
  ]
762
711
  }
763
712
  videoUploadSizeLimit: The size of the total uploadable videos (in bytes).
764
- Invokes the "onVideoUploadError" method. default: null {Number}
765
- videoMultipleFile: If true, multiple videos can be selected. default: false {Boolean}
713
+ Invokes the "onVideoUploadError" method. default: null {number}
714
+ videoMultipleFile: If true, multiple videos can be selected. default: false {boolean}
766
715
  videoTagAttrs : Define "Attributes" of the video tag. default: null {Object}
767
716
  ex) { poster: "http://suneditor.com/docs/loading.gif", autoplay: true }
768
717
  videoIframeAttrs : Define "Attributes" of the iframe tag. (Youtube, Vimeo). default: null {Object}
769
718
  ex) { style: "border: 2px solid red;" }
770
- videoAccept : Define the "accept" attribute of the input. default: "*" {String}
719
+ videoAccept : Define the "accept" attribute of the input. default: "*" {string}
771
720
  ex) "*" or ".mp4, .avi .."
772
721
 
773
722
  // Audio----------------------------------------------------------------------------------------------------------
774
- audioWidth : The default width size of the audio frame. default: '300px' {String}
775
- audioHeight : The default height size of the audio frame. default: '54px' {String}
776
- audioFileInput : Choose whether to create a file input tag in the audio upload window. default: false {Boolean}
723
+ audioWidth : The default width size of the audio frame. default: '300px' {string}
724
+ audioHeight : The default height size of the audio frame. default: '54px' {string}
725
+ audioFileInput : Choose whether to create a file input tag in the audio upload window. default: false {boolean}
777
726
  audioUrlInput : Choose whether to create a audio url input tag in the audio upload window.
778
- If the value of audioFileInput is false, it will be unconditionally. default: true {Boolean}
727
+ If the value of audioFileInput is false, it will be unconditionally. default: true {boolean}
779
728
  audioUploadHeader : Http Header when uploading audios. default: null {Object}
780
- audioUploadUrl : The audio upload to server mapping address. default: null {String}
729
+ audioUploadUrl : The audio upload to server mapping address. default: null {string}
781
730
  ex) "/editor/uploadAudio"
782
731
  request format: {
783
732
  "file-0": File,
@@ -795,21 +744,22 @@ audioUploadUrl : The audio upload to server mapping address. default: nul
795
744
  ]
796
745
  }
797
746
  audioUploadSizeLimit: The size of the total uploadable audios (in bytes).
798
- Invokes the "onAudioUploadError" method. default: null {Number}
799
- audioMultipleFile: If true, multiple audios can be selected. default: false {Boolean}
747
+ Invokes the "onAudioUploadError" method. default: null {number}
748
+ audioMultipleFile: If true, multiple audios can be selected. default: false {boolean}
800
749
  audioTagAttrs : Define "Attributes" of the audio tag. default: null {Object}
801
750
  ex) { controlslist: "nodownload", autoplay: true }
802
- videoAccept : Define the "accept" attribute of the input. default: "*" {String}
751
+ videoAccept : Define the "accept" attribute of the input. default: "*" {string}
803
752
  ex) "*" or ".mp3, .wav .."
804
753
 
805
754
  // Table----------------------------------------------------------------------------------------------------------
806
- tableCellControllerPosition : Define position to the table cell controller('cell', 'top'). default: 'cell' {String}
755
+ tableCellControllerPosition : Define position to the table cell controller('cell', 'top'). default: 'cell' {string}
807
756
 
757
+ // Url input
758
+ defaultUrlProtocol : Default protocol for the links. ('link', 'image', 'video', 'audio')
759
+ This applies to all plugins that enter the internet url. default: null {string}
760
+
808
761
  // Link-----------------------------------------------------------------------------------------------------------
809
762
  linkTargetNewWindow : Default checked value of the "Open in new window" checkbox. default: false {Boolean}
810
- linkProtocol : Default protocol for the links. ('link', 'image', 'video', 'audio')
811
- This applies to all plugins that enter the internet url. default: null {String}
812
- linkRel : Defines "rel" attribute list of anchor tag. default: [] {Array}
813
763
  // https://www.w3schools.com/tags/att_a_rel.asp
814
764
  ex) [
815
765
  'author',
@@ -835,28 +785,29 @@ linkRelDefault : Defines default "rel" attributes of anchor tag. default: {}
835
785
  linkRelDefault: {
836
786
  check_new_window: 'only:noreferrer noopener'
837
787
  }
788
+ linkRel : Defines "rel" attribute list of anchor tag. default: [] {Array}
838
789
  linkNoPrefix : If true, disables the automatic prefixing of the host URL to the value of the link. default: false {Boolean}
839
790
 
840
791
  // HR----------------------------------------------------------------------------------------------------
841
792
  hrItems : Defines the hr items.
842
793
  "class" or "style" must be specified.
843
794
  default: [
844
- {name: lang.toolbar.hr_solid, class: '__se__solid'},
845
- {name: lang.toolbar.hr_dashed, class: '__se__dashed'},
846
- {name: lang.toolbar.hr_dotted, class: '__se__dotted'}
795
+ {name: lang.hr_solid, class: '__se__solid'},
796
+ {name: lang.hr_dashed, class: '__se__dashed'},
797
+ {name: lang.hr_dotted, class: '__se__dotted'}
847
798
  ]
848
799
  ex) [ {name: "Outset", style: "border-style: outset;"} ]
849
800
 
850
801
 
851
802
  // Key actions----------------------------------------------------------------------------------------------------
852
- tabDisable : If true, disables the interaction of the editor and tab key. default: false {Boolean}
803
+ tabDisable : If true, disables the interaction of the editor and tab key. default: false {boolean}
853
804
  shortcutsDisable: You can disable shortcuts. default: [] {Array}
854
805
  ex) ['bold', 'strike', 'underline', 'italic', 'undo', 'indent', 'save']
855
- shortcutsHint : If false, hide the shortcuts hint. default: true {Boolean}
806
+ shortcutsHint : If false, hide the shortcuts hint. default: true {boolean}
856
807
 
857
808
  // Defining save button-------------------------------------------------------------------------------------------
858
809
  callBackSave : Callback functions that is called when the Save button is clicked.
859
- Arguments - (contents, isChanged). default: functions.save {Function}
810
+ Arguments - (content, isChanged). default: editorInstance.save {Function}
860
811
 
861
812
  // Templates Array------------------------------------------------------------------------------------------------
862
813
  templates : If you use a template plugin, add it.
@@ -871,11 +822,23 @@ templates : If you use a template plugin, add it.
871
822
  html: '<p>HTML source2</p>'
872
823
  }
873
824
  ]
825
+ layouts : If you use a layout plugin, add it.
826
+ Defines a list of templates. default: null {Array}
827
+ ex) [
828
+ {
829
+ name: 'Template-1',
830
+ html: '<p>HTML source1</p>'
831
+ },
832
+ {
833
+ name: 'Template-2',
834
+ html: '<p>HTML source2</p>'
835
+ }
836
+ ]
874
837
 
875
838
  // ETC------------------------------------------------------------------------------------------------------------
876
839
  __allowedScriptTag : Allows script tags. default: false {Boolean}
877
- placeholder : The placeholder text. default: null {String}
878
- mediaAutoSelect : Activate the media[image, video, audio] selection status immediately after inserting the media tag. default: true {Boolean}
840
+ placeholder : The placeholder text. default: null {string}
841
+ mediaAutoSelect : Activate the media[image, video, audio] selection status immediately after inserting the media tag. default: true {boolean}
879
842
  icons : You can redefine icons. default: null {Object}
880
843
  ex) {
881
844
  bold: '<span class="se-icon-text">B</span>',
@@ -890,15 +853,15 @@ buttonList : Defines button list to array {Array}
890
853
  // ['font', 'fontSize', 'formatBlock'],
891
854
  // ['paragraphStyle', 'blockquote'],
892
855
  ['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
893
- // ['fontColor', 'hiliteColor', 'textStyle'],
856
+ // ['fontColor', 'backgroundColor', 'textStyle'],
894
857
  ['removeFormat'],
895
858
  ['outdent', 'indent'],
896
- // ['align', 'horizontalRule', 'list', 'lineHeight'],
859
+ // ['align', 'horizontalLine', 'list', 'lineHeight'],
897
860
  // ['table', 'link', 'image', 'video', 'math'], // You must add the 'katex' library at options to use the 'math' plugin.
898
861
  // ['imageGallery'], // You must add the "imageGalleryUrl".
899
862
  ['fullScreen', 'showBlocks', 'codeView'],
900
863
  ['preview', 'print'],
901
- // ['save', 'template'],
864
+ // ['save', 'template', 'layout'],
902
865
  // ['dir', 'dir_ltr', 'dir_rtl'],
903
866
  // '/', Line break
904
867
  ]
@@ -926,23 +889,24 @@ buttonList : Defines button list to array {Array}
926
889
 
927
890
  ----------------- ex) More button: --------------------------------------------------------------------------------
928
891
  // The more button is defined as a string starting with a colon.(":").
929
- // :Identifier - Title attribute - Button's innerHTML
892
+ // :Title - Button's innerHTML
930
893
  /**
931
- * "Identifier": The button's identifier. Please specify uniquely.
932
- * "Title attribute": Title attribute of the button to be displayed as a tooltip.
894
+ * "Title": Title attribute of the button to be displayed as a tooltip.
895
+ * * lang.[options.lang.key] -> Use the text of the "lang" option.
896
+ * * xxx -> Text
933
897
  * "Button's innerHTML": Define the button's "innerHTML".
934
- * default.xxx -> Use the attributes of "defaultIcons".
935
- * (more_text, more_paragraph, more_plus, more_horizontal, more_vertical)
936
- * text.xxx -> Use the text.
937
- * xxx -> HTML
898
+ * * default.[defaultIcon] -> Use the attributes of "defaultIcons".
899
+ * * * default.[more_text, more_paragraph, more_plus, more_horizontal, more_vertical]
900
+ * * text.[xxx] -> Use the text.
901
+ * * xxx -> HTML
938
902
  */
939
903
  [
940
904
  ['undo', 'redo'],
941
- [':t-More Text-default.more_text', 'bold', 'underline', 'italic'],
942
- [':p-More Paragraph-default.more_paragraph', 'font', 'formatBlock', 'align', 'list'],
943
- [':r-More Rich-default.more_plus', 'table', 'link', 'image', 'video'],
944
- [':v-View-text.View', 'fullScreen', 'codeView', 'print'],
945
- ['-right', ':o-More Others-<i class="xxx"></i>', 'save', 'template'], // Used with alignment
905
+ [':lang.option_lang_text-default.more_text', 'bold', 'underline', 'italic'],
906
+ [':More Paragraph-default.more_paragraph', 'font', 'formatBlock', 'align', 'list'],
907
+ [':More Rich-default.more_plus', 'table', 'link', 'image', 'video'],
908
+ [':View-text.View', 'fullScreen', 'codeView', 'print'],
909
+ ['-right', ':More Others-<i class="xxx"></i>', 'save', 'template', 'layout'], // Used with alignment
946
910
  ]
947
911
 
948
912
  ----------------- ex) Responsive setting: -------------------------------------------------------------------------
@@ -955,637 +919,42 @@ buttonList : Defines button list to array {Array}
955
919
  ['font', 'fontSize', 'formatBlock'],
956
920
  ['paragraphStyle', 'blockquote'],
957
921
  ['bold', 'underline', 'italic', 'strike', 'subscript', 'superscript'],
958
- ['fontColor', 'hiliteColor', 'textStyle'],
922
+ ['fontColor', 'backgroundColor', 'textStyle'],
959
923
  ['removeFormat'],
960
924
  ['outdent', 'indent'],
961
- ['align', 'horizontalRule', 'list', 'lineHeight'],
925
+ ['align', 'horizontalLine', 'list', 'lineHeight'],
962
926
  ['table', 'link', 'image', 'video', 'audio', 'math'],
963
927
  ['imageGallery'],
964
928
  ['fullScreen', 'showBlocks', 'codeView'],
965
929
  ['preview', 'print'],
966
- ['save', 'template'],
930
+ ['save', 'template', 'layout'],
967
931
  ['-left', '#fix', 'dir_ltr', 'dir_rtl'],
968
932
  // (min-width:992px)
969
933
  ['%992', [
970
934
  ['undo', 'redo'],
971
- [':p-More Paragraph-default.more_paragraph', 'font', 'fontSize', 'formatBlock', 'paragraphStyle', 'blockquote'],
935
+ [':More Paragraph-default.more_paragraph', 'font', 'fontSize', 'formatBlock', 'paragraphStyle', 'blockquote'],
972
936
  ['bold', 'underline', 'italic', 'strike'],
973
- [':t-More Text-default.more_text', 'subscript', 'superscript', 'fontColor', 'hiliteColor', 'textStyle'],
937
+ [':More Text-default.more_text', 'subscript', 'superscript', 'fontColor', 'backgroundColor', 'textStyle'],
974
938
  ['removeFormat'],
975
939
  ['outdent', 'indent'],
976
- ['align', 'horizontalRule', 'list', 'lineHeight'],
940
+ ['align', 'horizontalLine', 'list', 'lineHeight'],
977
941
  ['-right', 'dir'],
978
- ['-right', ':i-More Misc-default.more_vertical', 'fullScreen', 'showBlocks', 'codeView', 'preview', 'print', 'save', 'template'],
979
- ['-right', ':r-More Rich-default.more_plus', 'table', 'link', 'image', 'video', 'audio', 'math', 'imageGallery']
942
+ ['-right', ':More Misc-default.more_vertical', 'fullScreen', 'showBlocks', 'codeView', 'preview', 'print', 'save', 'template', 'layout'],
943
+ ['-right', ':More Rich-default.more_plus', 'table', 'link', 'image', 'video', 'audio', 'math', 'imageGallery']
980
944
  ]],
981
945
  // (min-width:768px)
982
946
  ['%768', [
983
947
  ['undo', 'redo'],
984
- [':p-More Paragraph-default.more_paragraph', 'font', 'fontSize', 'formatBlock', 'paragraphStyle', 'blockquote'],
985
- [':t-More Text-default.more_text', 'bold', 'underline', 'italic', 'strike', 'subscript', 'superscript', 'fontColor', 'hiliteColor', 'textStyle', 'removeFormat'],
986
- [':e-More Line-default.more_horizontal', 'outdent', 'indent', 'align', 'horizontalRule', 'list', 'lineHeight'],
987
- [':r-More Rich-default.more_plus', 'table', 'link', 'image', 'video', 'audio', 'math', 'imageGallery'],
948
+ [':More Paragraph-default.more_paragraph', 'font', 'fontSize', 'formatBlock', 'paragraphStyle', 'blockquote'],
949
+ [':More Text-default.more_text', 'bold', 'underline', 'italic', 'strike', 'subscript', 'superscript', 'fontColor', 'backgroundColor', 'textStyle', 'removeFormat'],
950
+ [':More Line-default.more_horizontal', 'outdent', 'indent', 'align', 'horizontalLine', 'list', 'lineHeight'],
951
+ [':More Rich-default.more_plus', 'table', 'link', 'image', 'video', 'audio', 'math', 'imageGallery'],
988
952
  ['-right', 'dir'],
989
- ['-right', ':i-More Misc-default.more_vertical', 'fullScreen', 'showBlocks', 'codeView', 'preview', 'print', 'save', 'template']
953
+ ['-right', ':More Misc-default.more_vertical', 'fullScreen', 'showBlocks', 'codeView', 'preview', 'print', 'save', 'template', 'layout']
990
954
  ]]
991
955
  ]
992
956
 
993
957
  ```
994
958
 
995
- ## Functions
996
- ```javascript
997
- import suneditor from 'suneditor'
998
-
999
- const editor = suneditor.create('example');
1000
-
1001
- editor.core; // core object (The core object contains "util" and "functions".)
1002
- editor.util; // util object
1003
-
1004
- // Reset the buttons on the toolbar. (Editor is not reloaded)
1005
- // You cannot set a new plugin for the button.
1006
- editor.setToolbarButtons([
1007
- [':moreText-More Text-default.more_horizontal', 'bold', 'underline', 'strike', 'subscript', 'superscript'],
1008
- ['undo', 'redo']
1009
- ]);
1010
-
1011
- // Add or reset option property. (Editor is reloaded)
1012
- editor.setOptions({
1013
- minHeight: '300px',
1014
- buttonList: [
1015
- ['fontColor', 'hiliteColor']
1016
- ],
1017
- colorList: [
1018
- ['#ccc', '#dedede', 'OrangeRed', 'Orange', 'RoyalBlue', 'SaddleBrown']
1019
- ]
1020
- });
1021
-
1022
- // Set "options.defaultStyle" style.
1023
- // Define the style of the edit area
1024
- // It can also be defined with the "setOptions" method, but the "setDefaultStyle" method does not render the editor again.
1025
- editor.setDefaultStyle('font-family: cursive; font-size: 10px;');
1026
-
1027
- // Open a notice area
1028
- editor.noticeOpen('test notice');
1029
-
1030
- // Close a notice area
1031
- editor.noticeClose();
1032
-
1033
- // Copies the contents of the suneditor into a [textarea]
1034
- // * not working during enabled codeView mode
1035
- editor.save();
1036
-
1037
- // Gets the suneditor's context object. Contains settings, plugins, and cached element objects
1038
- editor.getContext();
1039
-
1040
- // Gets the contents of the suneditor
1041
- // * not working during enabled codeView mode
1042
- // onlyContents {Boolean}: Return only the contents of the body without headers when the "fullPage" option is true
1043
- editor.getContents(onlyContents: Boolean);
1044
- // Gets the current contents with containing parent div(div.sun-editor-editable).
1045
- // <div class="sun-editor-editable">{contents}</div>
1046
- editor.getFullContents(onlyContents: Boolean);
1047
-
1048
- // Gets only the text of the suneditor contents
1049
- // * not working during enabled codeView mode
1050
- editor.getText();
1051
-
1052
- // Gets a list of images uploaded to the editor
1053
- /**
1054
- * {
1055
- * element: image element
1056
- * src: imgage src
1057
- * index: data index
1058
- * name: file name
1059
- * size: file size
1060
- * select: select function
1061
- * delete: delete function
1062
- * }
1063
- **/
1064
- editor.getImagesInfo();
1065
-
1066
- // Gets uploaded files(plugin using fileManager) information list.
1067
- // image: [img], video: [video, iframe], audio: [audio]
1068
- // When the argument value is 'image', it is the same function as "getImagesInfo".
1069
- /**
1070
- * {
1071
- * element: image element
1072
- * src: imgage src
1073
- * index: data index
1074
- * name: file name
1075
- * size: file size
1076
- * select: select function
1077
- * delete: delete function
1078
- * }
1079
- * pluginName: Plugin name (image, video, audio)
1080
- **/
1081
- editor.getFilesInfo(pluginName);
1082
-
1083
- // Upload images using image plugin
1084
- // document.getElementById('example_files_input').files
1085
- editor.insertImage(FileList);
1086
-
1087
- // Inserts an HTML element or HTML string or plain string at the current cursor position
1088
- /**
1089
- * @param {Boolean} notCleaningData If true, inserts the HTML string without refining it with core.cleanHTML.
1090
- * @param {Boolean} checkCharCount If true, if "options.maxCharCount" is exceeded when "element" is added, null is returned without addition.
1091
- */
1092
- editor.insertHTML('<img src="http://suneditor.com/sample/img/sunset.jpg">', true, true);
1093
-
1094
- // Change the contents of the suneditor
1095
- editor.setContents('set contents');
1096
-
1097
- // Get the editor's number of characters or binary data size.
1098
- // You can use the "charCounterType" option format.
1099
- // If argument is no value, the currently set "charCounterType" option is used.
1100
- editor.getCharCount((null || 'char' || 'byte' || 'byte-html'));
1101
-
1102
- // Add content to the suneditor
1103
- editor.appendContents('append contents');
1104
-
1105
- // Switch to or off "ReadOnly" mode.
1106
- editor.readOnly(true || false)
1107
-
1108
- // Disable the suneditor
1109
- editor.disable();
1110
-
1111
- // Enable the suneditor
1112
- editor.enable();
1113
-
1114
- // Hide the suneditor
1115
- editor.hide();
1116
-
1117
- // Show the suneditor
1118
- editor.show();
1119
-
1120
- // Destroy the suneditor
1121
- editor.destroy();
1122
-
1123
- // Toolbar methods
1124
- // Disable the toolbar
1125
- editor.toolbar.disable();
1126
-
1127
- // Enable the toolbar
1128
- editor.toolbar.enable();
1129
-
1130
- // Hide the toolbar
1131
- editor.toolbar.hide();
1132
-
1133
- // Show the toolbar
1134
- editor.toolbar.show();
1135
-
1136
- // Event functions -------------------------------------------------------------------------------------
1137
- // It can be redefined by receiving event object as parameter.
1138
- // It is not called in exceptional cases and is called after the default event function has before finished.
1139
- // e: event object, core: Core object
1140
- editor.onScroll = function (e, core) { console.log('onScroll', e) }
1141
-
1142
- editor.onMouseDown = function (e, core) { console.log('onMouseDown', e) }
1143
-
1144
- editor.onClick = function (e, core) { console.log('onClick', e) }
1145
-
1146
- editor.onInput = function (e, core) { console.log('onInput', e) }
1147
-
1148
- editor.onKeyDown = function (e, core) { console.log('onKeyDown', e) }
1149
-
1150
- editor.onKeyUp = function (e, core) { console.log('onKeyUp', e) }
1151
-
1152
- editor.onFocus = function (e, core) { console.log('onFocus', e) }
1153
-
1154
- editor.onBlur = function (e, core) { console.log('onBlur', e) }
1155
-
1156
- // onchange event
1157
- // contents: core.getContents(), Core object
1158
- editor.onChange = function (contents, core) { console.log('onChange', contents) }
1159
-
1160
- // onload event
1161
- // When reloaded with the "setOptions" method, the value of the "reload" argument is true.
1162
- editor.onload = function (core, reload) {
1163
- console.log('onload-core', core)
1164
- console.log('onload-reload', reload)
1165
- }
1166
-
1167
- // Clipboard event.
1168
- // Called before the editor's default event action.
1169
- // If it returns false, it stops without executing the rest of the action.
1170
- /**
1171
- * paste event
1172
- * e: Event object
1173
- * cleanData: HTML string modified for editor format
1174
- * maxCharCount: maxChartCount option (true if max character is exceeded)
1175
- * core: Core object
1176
- */
1177
- editor.onPaste = function (e, cleanData, maxCharCount, core) { console.log('onPaste', e) }
1178
-
1179
- // Copy event.
1180
- // Called before the editor's default event action.
1181
- // If it returns false, it stops without executing the rest of the action.
1182
- /**
1183
- * copy event
1184
- * e: Event object
1185
- * clipboardData: event.clipboardData
1186
- * core: Core object
1187
- */
1188
- editor.onCopy = function (e, clipboardData, core) { console.log('onCopy', e) }
1189
-
1190
- // Cut event.
1191
- // Called before the editor's default event action.
1192
- // If it returns false, it stops without executing the rest of the action.
1193
- /**
1194
- * cut event
1195
- * e: Event object
1196
- * clipboardData: event.clipboardData
1197
- * core: Core object
1198
- */
1199
- editor.onCut = function (e, clipboardData, core) { console.log('onCut', e) }
1200
-
1201
- // Drop event.
1202
- // Called before the editor's default event action.
1203
- // If it returns false, it stops without executing the rest of the action.
1204
- /**
1205
- * e: Event object
1206
- * cleanData: HTML string modified for editor format
1207
- * maxCharCount: maxChartCount option (true if max character is exceeded)
1208
- * core: Core object
1209
- */
1210
- editor.onDrop = function (e, cleanData, maxCharCount, core) { console.log('onDrop', e) }
1211
-
1212
- // Save event
1213
- // Called just after the save was executed.
1214
- /**
1215
- * contents Editor content
1216
- * core: Core object
1217
- */
1218
- editor.onSave = function (contents, core) {console.log(contents) };
1219
-
1220
- // Called before the image is uploaded
1221
- // If true is returned, the internal upload process runs normally.
1222
- // If false is returned, no image upload is performed.
1223
- // If new fileList are returned, replaced the previous fileList
1224
- // If undefined is returned, it waits until "uploadHandler" is executed.
1225
- /**
1226
- * files: Files array
1227
- * info: {
1228
- * - linkValue: Link url value
1229
- * - linkNewWindow: Open in new window Check Value
1230
- * - inputWidth: Value of width input
1231
- * - inputHeight: Value of height input
1232
- * - align: Align Check Value
1233
- * - isUpdate: Update image if true, create image if false
1234
- * - element: If isUpdate is true, the currently selected image.
1235
- * }
1236
- * core: Core object,
1237
- * uploadHandler: If undefined is returned, it waits until "uploadHandler" is executed.
1238
- * "uploadHandler" is an upload function with "core" and "info" bound. (plugin.upload.bind(core, info))
1239
- * [upload files] : uploadHandler(files or [new File(...),])
1240
- * [error] : uploadHandler("Error message")
1241
- * [Just finish] : uploadHandler()
1242
- * [directly register] : uploadHandler(response) // Same format as "imageUploadUrl" response
1243
- * ex) {
1244
- * // "errorMessage": "insert error message",
1245
- * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
1246
- * }
1247
- * return {Boolean|Array|undefined}
1248
- */
1249
- editor.onImageUploadBefore: function (files, info, core, uploadHandler) {
1250
- return Boolean || return (new FileList) || return undefined;
1251
- }
1252
- // Called before the video is uploaded
1253
- // If true is returned, the internal upload process runs normally.
1254
- // If false is returned, no video(iframe, video) upload is performed.
1255
- // If new fileList are returned, replaced the previous fileList
1256
- // If undefined is returned, it waits until "uploadHandler" is executed.
1257
- /**
1258
- * files: Files array
1259
- * info: {
1260
- * - inputWidth: Value of width input
1261
- * - inputHeight: Value of height input
1262
- * - align: Align Check Value
1263
- * - isUpdate: Update video if true, create video if false
1264
- * - element: If isUpdate is true, the currently selected video.
1265
- * }
1266
- * core: Core object,
1267
- * uploadHandler: If undefined is returned, it waits until "uploadHandler" is executed.
1268
- * "uploadHandler" is an upload function with "core" and "info" bound. (plugin.upload.bind(core, info))
1269
- * [upload files] : uploadHandler(files or [new File(...),])
1270
- * [error] : uploadHandler("Error message")
1271
- * [Just finish] : uploadHandler()
1272
- * [directly register] : uploadHandler(response) // Same format as "videoUploadUrl" response
1273
- * ex) {
1274
- * // "errorMessage": "insert error message",
1275
- * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
1276
- * }
1277
- * return {Boolean|Array|undefined}
1278
- */
1279
- editor.onVideoUploadBefore: function (files, info, core, uploadHandler) {
1280
- return Boolean || return (new FileList) || return undefined;
1281
- }
1282
- // Called before the audio is uploaded
1283
- // If true is returned, the internal upload process runs normally.
1284
- // If false is returned, no audio upload is performed.
1285
- // If new fileList are returned, replaced the previous fileList
1286
- // If undefined is returned, it waits until "uploadHandler" is executed.
1287
- /**
1288
- * files: Files array
1289
- * info: {
1290
- * - isUpdate: Update audio if true, create audio if false
1291
- * - currentaudio: If isUpdate is true, the currently selected audio.
1292
- * }
1293
- * core: Core object,
1294
- * uploadHandler: If undefined is returned, it waits until "uploadHandler" is executed.
1295
- * "uploadHandler" is an upload function with "core" and "info" bound. (plugin.upload.bind(core, info))
1296
- * [upload files] : uploadHandler(files or [new File(...),])
1297
- * [error] : uploadHandler("Error message")
1298
- * [Just finish] : uploadHandler()
1299
- * [directly register] : uploadHandler(response) // Same format as "audioUploadUrl" response
1300
- * ex) {
1301
- * // "errorMessage": "insert error message",
1302
- * "result": [ { "url": "...", "name": "...", "size": "999" }, ]
1303
- * }
1304
- * return {Boolean|Array|undefined}
1305
- */
1306
- editor.onAudioUploadBefore: function (files, info, core, uploadHandler) {
1307
- return Boolean || return (new FileList) || return undefined;
1308
- }
1309
-
1310
- // Called when the image is uploaded, updated, deleted.
1311
- /**
1312
- * targetElement: Target element
1313
- * index: Uploaded index (key value)
1314
- * state: Upload status ('create', 'update', 'delete')
1315
- * info: {
1316
- * - index: data index
1317
- * - name: file name
1318
- * - size: file size
1319
- * - select: select function
1320
- * - delete: delete function
1321
- * - element: Target element
1322
- * - src: src attribute of tag
1323
- * }
1324
- * remainingFilesCount: Count of remaining files to upload (0 when added as a url)
1325
- * core: Core object
1326
- */
1327
- editor.onImageUpload = function (targetElement, index, state, info, remainingFilesCount, core) {
1328
- console.log(`targetElement:${targetElement}, index:${index}, state('create', 'update', 'delete'):${state}`)
1329
- console.log(`info:${info}, remainingFilesCount:${remainingFilesCount}`)
1330
- }
1331
- // Called when the video(iframe, video) is is uploaded, updated, deleted
1332
- // -- arguments is same "onImageUpload" --
1333
- editor.onVideoUpload = function (targetElement, index, state, info, remainingFilesCount, core) {
1334
- console.log(`targetElement:${targetElement}, index:${index}, state('create', 'update', 'delete'):${state}`)
1335
- console.log(`info:${info}, remainingFilesCount:${remainingFilesCount}`)
1336
- }
1337
- // Called when the audio is is uploaded, updated, deleted
1338
- // -- arguments is same "onImageUpload" --
1339
- editor.onAudioUpload = function (targetElement, index, state, info, remainingFilesCount, core) {
1340
- console.log(`targetElement:${targetElement}, index:${index}, state('create', 'update', 'delete'):${state}`)
1341
- console.log(`info:${info}, remainingFilesCount:${remainingFilesCount}`)
1342
- }
1343
-
1344
- // Called when the image is upload failed.
1345
- // If you return false, the default notices are not called.
1346
- /**
1347
- * errorMessage: Error message
1348
- * result: Response Object
1349
- * core: Core object
1350
- * return {Boolean}
1351
- */
1352
- editor.onImageUploadError = function (errorMessage, result, core) {
1353
- alert(errorMessage)
1354
- return Boolean
1355
- }
1356
- // Called when the video(iframe, video) upload failed
1357
- // -- arguments is same "onImageUploadError" --
1358
- editor.onVideoUploadError = function (errorMessage, result, core) {
1359
- alert(errorMessage)
1360
- return Boolean
1361
- }
1362
- // Called when the audio upload failed
1363
- // -- arguments is same "onImageUploadError" --
1364
- editor.onAudioUploadError = function (errorMessage, result, core) {
1365
- alert(errorMessage)
1366
- return Boolean
1367
- }
1368
-
1369
- // Called when the editor is resized using the bottom bar
1370
- // height, prevHeight are number
1371
- editor.onResizeEditor = function (height, prevHeight, core, resizeObserverEntry) {
1372
- console.log(`height: ${height}, prevHeight: ${prevHeight}`, resizeObserverEntry)
1373
- // "resizeObserverEntry" is not provided in IE Browser.
1374
- }
1375
-
1376
- // Called after the "setToolbarButtons" invocation
1377
- // Can be used to tweak buttons properties (useful for custom buttons)
1378
- /**
1379
- * buttonList: buttonList array
1380
- * core: Core object
1381
- */
1382
- editor.onSetToolbarButtons = function (buttonList, core) {
1383
- console.log(`buttonList: ${buttonList}`)
1384
- }
1385
-
1386
- // It replaces the default callback function of the image upload
1387
- /**
1388
- * xmlHttp: xmlHttpRequest object
1389
- * info: Input information
1390
- * - linkValue: Link url value
1391
- * - linkNewWindow: Open in new window Check Value
1392
- * - inputWidth: Value of width input
1393
- * - inputHeight: Value of height input
1394
- * - align: Align Check Value
1395
- * - isUpdate: Update image if true, create image if false
1396
- * - element: If isUpdate is true, the currently selected image.
1397
- * core: Core object
1398
- */
1399
- editor.imageUploadHandler = function (xmlHttp, info, core) {
1400
- // Editor code
1401
- const response = JSON.parse(xmlHttp.responseText);
1402
- if (response.errorMessage) {
1403
- this.plugins.image.error.call(this, response.errorMessage, response);
1404
- } else {
1405
- this.plugins.image.register.call(this, info, response);
1406
- }
1407
- }
1408
- /**
1409
- * @description It replaces the default callback function of the video upload
1410
- * xmlHttp: xmlHttpRequest object
1411
- * info: Input information
1412
- * - inputWidth: Value of width input
1413
- * - inputHeight: Value of height input
1414
- * - align: Align Check Value
1415
- * - isUpdate: Update video if true, create video if false
1416
- * - element: If isUpdate is true, the currently selected video.
1417
- * core: Core object
1418
- */
1419
- editor.videoUploadHandler = function (xmlHttp, info, core) {
1420
- // Editor code
1421
- const response = JSON.parse(xmlHttp.responseText);
1422
- if (response.errorMessage) {
1423
- this.plugins.video.error.call(this, response.errorMessage, response);
1424
- } else {
1425
- this.plugins.video.register.call(this, info, response);
1426
- }
1427
- }
1428
-
1429
- /**
1430
- * @description It replaces the default callback function of the audio upload
1431
- * xmlHttp xmlHttpRequest object
1432
- * info Input information
1433
- * - isUpdate: Update audio if true, create audio if false
1434
- * - element: If isUpdate is true, the currently selected audio.
1435
- * core Core object
1436
- */
1437
- editor.audioUploadHandler = function (xmlHttp, info, core) {
1438
- // Editor code
1439
- const response = JSON.parse(xmlHttp.responseText);
1440
- if (response.errorMessage) {
1441
- this.plugins.audio.error.call(this, response.errorMessage, response);
1442
- } else {
1443
- this.plugins.audio.register.call(this, info, response);
1444
- }
1445
- }
1446
-
1447
- // An event when toggling between code view and wysiwyg view.
1448
- /**
1449
- * isCodeView: Whether the current code view mode
1450
- * core: Core object
1451
- */
1452
- editor.toggleCodeView = function (isCodeView, core) {
1453
- console.log('isCodeView', isCodeView);
1454
- }
1455
-
1456
- // An event when toggling full screen.
1457
- /**
1458
- * isFullScreen: Whether the current full screen mode
1459
- * core: Core object
1460
- */
1461
- editor.toggleFullScreen = function (isFullScreen, core) {
1462
- console.log('isFullScreen', isFullScreen);
1463
- }
1464
-
1465
- // Called just before the inline toolbar is positioned and displayed on the screen.
1466
- /**
1467
- * toolbar: Toolbar Element
1468
- * context: The editor's context object (editor.getContext()|core.context)
1469
- * core Core object
1470
- */
1471
- editor.showInline = function (toolbar, context, core) {
1472
- console.log('toolbar', toolbar);
1473
- console.log('context', context);
1474
- }
1475
-
1476
- // Called just after the controller is positioned and displayed on the screen.
1477
- // controller - editing elements displayed on the screen [image resizing, table editor, link editor..]]
1478
- /**
1479
- * name: The name of the plugin that called the controller
1480
- * controllers: Array of Controller elements
1481
- * core: Core object
1482
- */
1483
- editor.showController = function (name, controllers, core) {
1484
- console.log('plugin name', name);
1485
- console.log('controller elements', controllers);
1486
- }
1487
- ```
1488
-
1489
- ## Plugins list
1490
- > The plugin and the button have the same name.
1491
-
1492
- <table>
1493
- <thead>
1494
- <tr>
1495
- <th align="left">Name</th>
1496
- <th align="left">Type</th>
1497
- </tr>
1498
- </thead>
1499
- <tbody>
1500
- <tr>
1501
- <td align="left">blockquote</td>
1502
- <td align="left"><strong>command</strong></td>
1503
- </tr>
1504
- <tr>
1505
- <td align="left">image</td>
1506
- <td align="left" rowspan="5"><strong>dialog</strong></td>
1507
- </tr>
1508
- <tr>
1509
- <td align="left">link</td>
1510
- </tr>
1511
- <tr>
1512
- <td align="left">video</td>
1513
- </tr>
1514
- <tr>
1515
- <td align="left">audio</td>
1516
- </tr>
1517
- <tr>
1518
- <td align="left">math</td>
1519
- </tr>
1520
- <tr>
1521
- <td align="left">align</td>
1522
- <td align="left" rowspan="13"><strong>submenu</strong></td>
1523
- </tr>
1524
- <tr>
1525
- <td align="left">font</td>
1526
- </tr>
1527
- <tr>
1528
- <td align="left">fontColor</td>
1529
- </tr>
1530
- <tr>
1531
- <td align="left">fontSize</td>
1532
- </tr>
1533
- <tr>
1534
- <td align="left">formatBlock</td>
1535
- </tr>
1536
- <tr>
1537
- <td align="left">hiliteColor</td>
1538
- </tr>
1539
- <tr>
1540
- <td align="left">horizontalRule</td>
1541
- </tr>
1542
- <tr>
1543
- <td align="left">lineHeight</td>
1544
- </tr>
1545
- <tr>
1546
- <td align="left">list</td>
1547
- </tr>
1548
- <tr>
1549
- <td align="left">paragraphStyle</td>
1550
- </tr>
1551
- <tr>
1552
- <td align="left">table</td>
1553
- </tr>
1554
- <tr>
1555
- <td align="left">template</td>
1556
- </tr>
1557
- <tr>
1558
- <td align="left">textStyle</td>
1559
- </tr>
1560
- <tr>
1561
- <td align="left">imageGallery</td>
1562
- <td align="left"><strong>fileBrowser</strong></td>
1563
- </tr>
1564
- </tbody>
1565
- </table>
1566
-
1567
- ## Examples
1568
- [Examples](http://suneditor.com/sample/html/examples.html)
1569
-
1570
- ## Options template
1571
- [Options template](http://suneditor.com/sample/html/options.html)
1572
-
1573
- ## Custom plugins
1574
- [Custom plugins](http://suneditor.com/sample/html/customPlugins.html)
1575
-
1576
- ## Document
1577
- [Document](http://suneditor.com/sample/html/document.html)
1578
-
1579
- ## Other libraries using SunEditor
1580
- <a id="lib-suneditor-react"></a>[suneditor-react](https://github.com/mkhstar/suneditor-react) ([@mkhstar](https://github.com/mkhstar)) - Pure React Component for SunEditor.
1581
-
1582
- <a id="lib-angular-suneditor"></a>[angular-suneditor](https://github.com/BauViso/angular-suneditor) ([@BauViso](https://github.com/BauViso)) - Angular module for the SunEditor WYSIWYG Editor.
1583
-
1584
- <a id="lib-livewire-alpine"></a>[Livewire & Alpine.JS](https://github.com/JiHong88/SunEditor/issues/789#issuecomment-1121317703) ([@kaju74](https://github.com/kaju74)) - Using SunEditor with Livewire & Alpine.JS
1585
-
1586
- <a id="lib-pluxml"></a>[Plugin for Pluxml](https://forum.pluxml.org/discussion/comment/59339) ([@sudwebdesign](https://github.com/sudwebdesign)) - Plugin for Pluxml.
1587
-
1588
- <a id="lib-aem-suneditor"></a>[AEM-SunEditor](https://blogs.perficientdigital.com/2019/08/13/suneditor-an-alternative-to-the-aem-rte) ([@ahmed-musallam](https://github.com/ahmed-musallam/AEM-SunEditor)) - Enables using SunEditor in AEM dialogs as an RTE replacement.
1589
-
1590
959
  ## License
1591
960
  Suneditor may be freely distributed under the MIT license.